TA的每日心情 | 奋斗 2021-8-6 16:14 |
---|
签到天数: 1 天 连续签到: 1 天 [LV.1]测试小兵
|
问题1、CTS Failed:release的apk版本为测试版本,非正式版本
Launcher通过eclipse编译Run As——AndroidApplication后,在项目bin目录生成的apk为测试版,可以通过以
下代码测试当前包名apk是否为测试版:
- private boolean isApkDebugable(Contextcontext, String packageName) {
- try{
- PackageInfopkginfo = context.getPackageManager().getPackageInfo(packageName, 1);
- if(pkginfo != null) {
- ApplicationInfoinfo = pkginfo.applicationInfo;
- return(info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
- }
-
- }catch (Exception e) {
-
- }
- returnfalse;
- }
-
复制代码
因此eclipse正确的release方式为,eclipse——Android Tools——Export SignedApplication Package…或者
Export UnSignedApplication Package…
问题2、CTS Failed:Launcher CTS测试项BYODManaged Provisionging——Badged work apps visible in
Launcher生成的work文件夹图标没有置灰
Work文件夹中图标置灰功能,在Android7.0Launcher CTS上才增加的一个测试项,Android6.0版本的L
auncher代码没有关于该属性的配置。所以将Android7.0 Launcher相关代码导入即可,涉及到主要Java类如下:
com.android.laucnher3.compat.LauncherAppsCompat.java
com.android.laucnher3.compat.UserHandleCompat.java
com.android.laucnher3.compat.UserManagerCompat.java
com.android.laucnher3.compat.UserManagerCompatV16.java
com.android.laucnher3.compat.UserManagerCompatVN.java
问题3、CTS Failed:Launcher CTS测试项BYODManaged Provisionging——Badged work apps visible in Laun
cher生成的work文件夹里面图标没有显示公文包图标,或者有些显示有些未显示
分析:CTS——BYOD Managed Provisioning——Badged work apps visible in Launcher测试项,是在当前系统
中添加不同用户work类型的APPS,在设置-系统应用列表中可看到(例如会生成两个Contacts应用,一个带
公文包图标,另一个没有),然后生成一个Work的文件夹,并把相关work信息的APPS放到work文件夹里。
生成文件夹的操作在Launcher代码中执行,具体流程如下:
——LauncherModel.loadAllApps(监听是否有生成work文件夹操作)
- finalManagedProfileHeuristic heuristic = ManagedProfileHeuristic.get(mContext,user);
- if (heuristic != null) {
- final Runnable r = newRunnable() {
- @Override
- public void run() {
- heuristic.processUserApps(apps);
- }
- };
- runOnMainThread(new Runnable() {
- @Override
- public void run() {
- // CheckisLoadingWorkspace on the UI thread, as it is updated on
- // the UI thread.
- if(mIsLoadingAndBindingWorkspace) {
- synchronized(mBindCompleteRunnables) {
- mBindCompleteRunnables.add(r);
- }
- } else {
- runOnWorkerThread(r);
- }
- }
- });
- }
- ——ManagedProfileHeuristic. processUserApps(判断work文件夹是否已创建)
- public voidprocessUserApps(List<LauncherActivityInfoCompat> apps) {
- initVars();
-
- HashSet<String> packageSet = newHashSet<>();
- final boolean userAppsExisted =getUserApps(packageSet);
-
- boolean newPackageAdded = false;
- for (LauncherActivityInfoCompat info :apps) {
- String packageName =info.getComponentName().getPackageName();
- if(!packageSet.contains(packageName)) {
- packageSet.add(packageName);
- newPackageAdded = true;
- markForAddition(info, info.getFirstInstallTime());
- }
- }
-
- if (newPackageAdded) {
- mPrefs.edit().putStringSet(mPackageSetKey, packageSet).apply();
- // Do not add shortcuts on thehomescreen for the first time. This prevents the launcher
- // getting filled with the manageduser apps, when it start with a fresh DB (or after
- // a very long time).
- finalizeAdditions(userAppsExisted);
- }
- }
- ——ManagedProfileHeuristic.finalizeWorkFolder(创建work文件夹)
- private void finalizeWorkFolder() {
- if (mWorkFolderApps.isEmpty()) {
- return;
- }
- sortList(mWorkFolderApps);
-
- // Try to get a work folder.
- String folderIdKey = USER_FOLDER_ID_PREFIX+ mUserSerial;
- if (mPrefs.contains(folderIdKey)) {
- long folderId =mPrefs.getLong(folderIdKey, 0);
- final FolderInfo workFolder =mModel.findFolderById(folderId);
-
- if (workFolder == null || !workFolder.hasOption(FolderInfo.FLAG_WORK_FOLDER)){
- // Could not get a work folder.Add all the icons to homescreen.
- mHomescreenApps.addAll(mWorkFolderApps);
- return;
- }
- saveWorkFolderShortcuts(folderId,workFolder.contents.size());
-
- final ArrayList<ShortcutInfo>shortcuts = mWorkFolderApps;
- // FolderInfo could already bebound. We need to add shortcuts on the UI thread.
- new MainThreadExecutor().execute(newRunnable() {
-
- @Override
- public void run() {
- for (ShortcutInfo info :shortcuts) {
- workFolder.add(info);
- }
- }
- });
- } else {
- // Create a new folder.
- final FolderInfo workFolder = newFolderInfo();
- workFolder.title =mContext.getText(R.string.work_folder_name);
- workFolder.setOption(FolderInfo.FLAG_WORK_FOLDER, true, null);
-
- // Add all shortcuts before adding it tothe UI, as an empty folder might get deleted.
- for (ShortcutInfo info :mWorkFolderApps) {
- workFolder.add(info);
- }
-
- // Add the item to home screen andDB. This also generates an item id synchronously.
- ArrayList<ItemInfo> itemList= new ArrayList<ItemInfo>(1);
- itemList.add(workFolder);
- mModel.addAndBindAddedWorkspaceItems(mContext, itemList);
- mPrefs.edit().putLong(USER_FOLDER_ID_PREFIX+ mUserSerial, workFolder.id).apply();
-
- saveWorkFolderShortcuts(workFolder.id, 0);
- }
- }
-
复制代码
在Work文件夹中的Apps没有生成公文包图标是因为Launcher将原生的All Apps放到桌面上,然后添加去重复
APP操作LauncherModel.verifyApplications。去重复APP操作,只是将当前重复数组遇到的第一位去除,导致
过滤数组将带公文包APP排在首位,过滤掉了带公文包图标的APP。而且由于Launcher在后台是多个线程去
操作,线程执行的先后顺序不同,造成添加的过滤数组排序不一样,导致在桌面上Apps有时带公文包有时
不带公文包。
修改方案是优化去重复APP条件,考虑多用户条件,使其符合CTS规范要求。
以上是近期Launcher在CTS测试中遇到的几个Failed的问题,供遇到同样情况的开发者参考。
|
|