隐藏程序图标想要修改两处:
1.在首次加载时隐藏特定应用图标。
找到LoaderTask.java类,里面有个loadAllApps方法。
boolean quietMode = mUserManagerState.isUserQuiet(user);
// Create the ApplicationInfos
for (int i = 0; i < apps.size(); i++) {
LauncherActivityInfo app = apps.get(i);
// This builds the icon bitmaps.
mBgAllAppsList.add(new AppInfo(app, user, quietMode), app);
}
可以在这个for循环内过滤应用图标。(自己实现checkPackageName方法去判断是否需要显示图标)
boolean quietMode = mUserManagerState.isUserQuiet(user);
// Create the ApplicationInfos
for (int i = 0; i < apps.size(); i++) {
LauncherActivityInfo app = apps.get(i);
AppInfo appInfo = new AppInfo(app, user, quietMode);
if (checkPackageName(appInfo.componentName.getPackageName())){
mBgAllAppsList.add(appInfo,app);
}
// This builds the icon bitmaps.
//mBgAllAppsList.add(appInfo, app);
}
2.在页面刷新时隐藏应用图标。
找到PackageUpdatedTask.java,找到execute方法的OP_UPDATE条件。
case OP_UPDATE:
try (SafeCloseable t =
appsList.trackRemoves(a -> removedComponents.add(a.componentName))) {
for (int i = 0; i < N; i++) {
if (DEBUG) Log.d(TAG, "mAllAppsList.updatePackage " + packages[i]);
if(checkPackageName(packages[i])){
iconCache.updateIconsForPkg(packages[i], mUser);
appsList.updatePackage(context, packages[i], mUser);
app.getWidgetCache().removePackage(packages[i], mUser);
}
}
}
// Since package was just updated, the target must be available now.
flagOp = FlagOp.removeFlag(WorkspaceItemInfo.FLAG_DISABLED_NOT_AVAILABLE);
break;
自己实现checkPackageName方法。