遇到一个Android P相关的问题,和原来CTS/GTS 问题分析1的表现是一样的,但是将 这个修复cp过来,发现不生效,仍然报错,因此记录一下

问题初探

测试命令: run gts -m GtsGmscoreHostTestCases -t com.google.android.gts.devicepolicy.managedprovisioning.DeviceOwnerProvisioningHostsideTest#testRequiredAppsInManagedDevice

报错堆栈:

09-28 13:54:41 W/XtsHostTestBase: java.lang.AssertionError: Should have at least one packages to handle Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] }, found []
Expected: a value greater than <0>
but: <0> was equal to <0>
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18)
at com.google.android.gts.managedprovisioning.AfwRequiredAppsTest.assertAndGetPackagesHandleIntent(AfwRequiredAppsTest.java:450)
at com.google.android.gts.managedprovisioning.AfwRequiredAppsTest.assertRequiredAppsInDeviceOwnerOrManagedUser(AfwRequiredAppsTest.java:490)
at com.google.android.gts.managedprovisioning.AfwRequiredAppsTest.assertRequiredAppsInDeviceOwner(AfwRequiredAppsTest.java:474)
at com.google.android.gts.managedprovisioning.AfwRequiredAppsTest.testRequiredApps_DeviceOwner_withGms(AfwRequiredAppsTest.java:124)
at java.lang.reflect.Method.invoke(Native Method)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:52)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:148)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:142)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.lang.Thread.run(Thread.java:764)

上面还有:

09-28 01:54:32.486 18930 18956 D ManagedProvisioning: Deleting package [com.mi.android.globallauncher] as user 0

问题分析

可见,E10这个机器自定义的桌面被删掉了,导致case fail。在OverlayPackagesProvider.java中调试一下,结果如下:

 
OverlayPackage.png

可见我们得到的是vendor/google/products/gms_overlay下面的资源,那么首先怀疑的是不是和上面链接的一样,overlay顺序问题导致资源加载不正确?

那么我们在本地加log看一下:

在build/core/package_internal.mk中添加log

ifdef enforce_rro_enabled
ifneq ($(PRODUCT_ENFORCE_RRO_EXCLUDED_OVERLAYS),)
static_only_resource_overlays := $(filter $(addsuffix %,$(PRODUCT_ENFORCE_RRO_EXCLUDED_OVERLAYS)),$(package_resource_overlays))
ifneq ($(static_only_resource_overlays),)
package_resource_overlays := $(filter-out $(static_only_resource_overlays),$(package_resource_overlays))
LOCAL_RESOURCE_DIR := $(static_only_resource_overlays) $(LOCAL_RESOURCE_DIR)
ifeq ($(package_resource_overlays),)
enforce_rro_enabled :=
endif
endif
endif
else
LOCAL_RESOURCE_DIR := $(package_resource_overlays) $(LOCAL_RESOURCE_DIR)
$(warning ------>a1)
$(warning ------>$(LOCAL_RESOURCE_DIR))
$(warning ------>a2)
endif

注意这个log不是在lunch时出现的,而是在packages/apps/ManagedProvisioning这里编译时出现的

国内版log

build/make/core/package_internal.mk:136: warning: ------>a1
build/make/core/package_internal.mk:137: warning: ------>miui/config-overlay/v6/common/packages/apps/ManagedProvisioning/res packages/apps/ManagedProvisioning/res
build/make/core/package_internal.mk:138: warning: ------>a2

国际版

在根目录执行deploy

Deploy menu... pick a combo:
1. cn
2. cn_chinaunicom
3. cn_chinatelecom
4. cn_chinamobile
5. cn_cta
6. cn_chinamobile-cta
7. global Which would you like? [cn] 7
global ============================================
MIUI_CURRENT_CUST_VARIANT=global
============================================

重新回到packages/apps/ManagedProvisioning进行mm

build/make/core/package_internal.mk:136: warning: ------>a1
build/make/core/package_internal.mk:137: warning: ------>miui/config-overlay/v6/global/packages/apps/ManagedProvisioning/res miui/config-overlay/v6/common/packages/apps/ManagedProvisioning/res packages/apps/ManagedProvisioning/res
build/make/core/package_internal.mk:138: warning: ------>a2

看着overlay的顺序完全正确,为了再确定下,我们用Android Studio看一下ManagedProvisioning.apk的资源,发现:

 
ManagedProvisioning资源.png

果然,资源已经顺利被aapt打包到相应apk里面了,前面的怀疑是错的,和原来不是一个问题。

那么剩下的还有两个怀疑点,1. apk的逻辑有问题或改动 2.资源加载出错;我们调试的时候发现加载的资源id是

 
ManagedProvisioning资源id.png

和上面的id对不上,那么肯定是资源就没加载对。然后突然想到,我调试的时候attach的是system_process进程,那么会不会加载的是framework的资源呢,查看framework-res.apk,果然:

 
framework-res资源id.png

id对上了。那么可以肯定,是逻辑更改造成的问题

逻辑更改

http://cisys.pt.miui.com/opengrok/xref/v10-p-dipper-dev/packages/apps/ManagedProvisioning/src/com/android/managedprovisioning/task/nonrequiredapps/NonRequiredAppsLogic.java#120

99    public Set<String> getSystemAppsToRemove(int userId) {
100 if (!shouldDeleteSystemApps(userId)) {
101 return Collections.emptySet();
102 }
103
104 // Start with all system apps
105 Set<String> newSystemApps = mUtils.getCurrentSystemApps(mIPackageManager, userId);
106
107 // Remove the ones that were already present in the last snapshot only when OTA
108 if (!mNewProfile) {
109 newSystemApps.removeAll(mSnapshot.getSnapshot(userId));
110 }
111 ComponentName deviceAdminComponentName;
112 try {
113 deviceAdminComponentName = mParams.inferDeviceAdminComponentName(
114 mUtils, mContext, userId);
115 } catch (IllegalProvisioningArgumentException ex) {
116 // Should not happen
117 throw new RuntimeException("Failed to infer device admin component name", ex);
118 }
119 // Get the packages from the black/white lists
120 Set<String> packagesToDelete = mDevicePolicyManager.getDisallowedSystemApps(
121 deviceAdminComponentName, userId, mParams.provisioningAction);
122
123 // Retain only new system apps
124 packagesToDelete.retainAll(newSystemApps);
125
126 return packagesToDelete;
127 }
70 /**
71 * Computes non-required apps. All the system apps with a launcher that are not in
72 * the required set of packages will be considered as non-required apps.
73 *
74 * Note: If an app is mistakenly listed as both required and disallowed, it will be treated as
75 * disallowed.
76 *
77 * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
78 * @param userId The userId for which the non-required apps needs to be computed.
79 * @param provisioningAction action indicating type of provisioning, should be one of
80 * {@link ACTION_PROVISION_MANAGED_DEVICE}, {@link
81 * ACTION_PROVISION_MANAGED_PROFILE} or
82 * {@link ACTION_PROVISION_MANAGED_USER}.
83 * @return the set of non-required apps.
84 */
85 @NonNull
86 public Set<String> getNonRequiredApps(@NonNull ComponentName admin, int userId,
87 @NonNull String provisioningAction) {
88 final Set<String> nonRequiredApps = getLaunchableApps(userId);
89 // Newly installed system apps are uninstalled when they are not required and are either
90 // disallowed or have a launcher icon.
91 nonRequiredApps.removeAll(getRequiredApps(provisioningAction, admin.getPackageName()));
92 // Don't delete the system input method packages in case of Device owner provisioning.
93 if (ACTION_PROVISION_MANAGED_DEVICE.equals(provisioningAction)
94 || ACTION_PROVISION_MANAGED_USER.equals(provisioningAction)) {
95 nonRequiredApps.removeAll(getSystemInputMethods());
96 }
97 nonRequiredApps.addAll(getDisallowedApps(provisioningAction));
98 return nonRequiredApps;
99 }
195 private Set<String> getVendorRequiredAppsSet(String provisioningAction) {
196 final int resId;
197 switch (provisioningAction) {
198 case ACTION_PROVISION_MANAGED_USER:
199 resId = R.array.vendor_required_apps_managed_user;
200 break;
201 case ACTION_PROVISION_MANAGED_PROFILE:
202 resId = R.array.vendor_required_apps_managed_profile;
203 break;
204 case ACTION_PROVISION_MANAGED_DEVICE:
205 resId = R.array.vendor_required_apps_managed_device;
206 break;
207 default:
208 throw new IllegalArgumentException("Provisioning type "
209 + provisioningAction + " not supported.");
210 }
211 return new ArraySet<>(Arrays.asList(mContext.getResources().getStringArray(resId)));
212 }

可见,ManagedProvisioning将这部分逻辑放到了framework中,所以取的是framework的资源;

总结

ManagedProvisioning.apk也会随着大版本升级改动,我们进行CTS测试时需要注意这一点,尤其是其越来越与framework依赖时,我们要注意观察以往的overlay逻辑是否适用

作者:weiinter105 链接:https://www.jianshu.com/p/a6065587ce43 來源:简书 简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

CTS问题分析6的更多相关文章

  1. 基于Linux的tty架构及UART驱动详解

    更多嵌入式Linux原创,请关注公众号:一口Linux 一.模块硬件学习 1.1. Uart介绍 通用异步收发传输器(Universal Asynchronous Receiver/Transmitt ...

  2. 【转】Android兼容性测试CTS --环境搭建、测试执行、结果分析

    原文网址:http://www.cnblogs.com/zh-ya-jing/p/4396918.html 为了确保Android应用能够在所有兼容Android的设备上正确运行,并且保持相似的用户体 ...

  3. Android兼容性测试CTS --环境搭建、测试执行、结果分析

    为了确保Android应用能够在所有兼容Android的设备上正确运行,并且保持相似的用户体验,在每个版本发布之时,Android提供了一套兼容性测试用例集合(Compatibility Test S ...

  4. 【转】Android兼容性测试CTS Verifier-环境搭建、测试执行、结果分析

    原文网址:http://www.cnblogs.com/zh-ya-jing/p/4452675.html CTS Verifier算是CTS的一部分,需要手动进行,主要用于测试那些自动测试系统无法测 ...

  5. Android CTS 结果 testResult.xml 修改 fail 项 为 notExecuted 项 分析

    这两天一直在搞 Android 4.1 CTS ,每次完整跑完一遍后总有几百项 failed,用编辑器手动改为 notExecuted 项后重新跑,有很多项第二次都跑过了. 但是发现直接修改也带来很多 ...

  6. Cts分析框架(4)-添加任务

    Debug watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaXRmb290YmFsbA==/font/5a6L5L2T/fontsize/400/fill/ ...

  7. Android兼容性测试CTS Verifier-环境搭建、测试执行、结果分析

    CTS Verifier算是CTS的一部分,需要手动进行,主要用于测试那些自动测试系统无法测试的功能,比如相机.传感器等.由于硬件配置或其他原因,不同手机上部分测试项目被隐藏,也就是说CTS Veri ...

  8. NS2中trace文件分析

    ns中模拟出来的时间最终会以trace文件的形式告诉我们,虽然说一般都是用awk等工具分析trace文件,但是了解trace文件的格式也是必不可少的.下面就介绍一下无线网络模拟中trace文件的格式. ...

  9. 【转】Hostapd工作流程分析

    [转]Hostapd工作流程分析 转自:http://blog.chinaunix.net/uid-30081165-id-5290531.html Hostapd是一个运行在用户态的守护进程,可以通 ...

随机推荐

  1. [Swift]LeetCode142. 环形链表 II | Linked List Cycle II

    Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note ...

  2. [Swift]LeetCode567. 字符串的排列 | Permutation in String

    Given two strings s1 and s2, write a function to return true if s2 contains the permutation of s1. I ...

  3. [Swift]LeetCode922.按奇偶排序数组 II | Sort Array By Parity II

    Given an array A of non-negative integers, half of the integers in A are odd, and half of the intege ...

  4. 经典案例复盘——运维专家讲述如何实现K8S落地

    经典案例复盘——运维专家讲述如何实现K8S落地 背景介绍 运满满自开始微服务改造以来,线上线下已有数千个微服务的 Java 实例在运行中.这些 Java 实例部署在数百台云服务器或虚机上,除少数访问量 ...

  5. FloatingActionButton(悬浮按钮)使用学习<一>

      FloatingActionButton简称FAB.   一. 对于App或某个页面中是否要使用FloatingActionButton必要性:     FAB代表一个App或一个页面中最主要的操 ...

  6. ES 03 - 初探Elasticsearch的主要配置文件(以6.6.0版本为例)

    目录 1 elasticsearch.yml(ES服务配置) 1.1 Cluster集群配置 1.2 Node节点配置 1.3 Paths路径配置 1.4 Memory内存配置 1.5 Network ...

  7. 16-Flink-Redis-Sink

    戳更多文章: 1-Flink入门 2-本地环境搭建&构建第一个Flink应用 3-DataSet API 4-DataSteam API 5-集群部署 6-分布式缓存 7-重启策略 8-Fli ...

  8. Linux - CentOS 登陆密码找回解决方法

  9. JDK动态代理深入理解分析并手写简易JDK动态代理(下)

    原文同步发表至个人博客[夜月归途] 原文链接:http://www.guitu18.com/se/java/2019-01-05/27.html 作者:夜月归途 出处:http://www.guitu ...

  10. Smobiler 4.4已正式发布!(Smobiler能让你在Visual Studio上开发APP)

    Smobiler 4.4已经正式发布,还不快来看看?原文地址:https://www.smobiler.com/portal.php?mod=view&aid=53这次更新要感谢我们的用户,在 ...