Android11系统桌面隐藏指定APP图标

做项目时有时会遇到这样的需求,客户要求隐藏Launcher3桌面的某个app图标,但是又不能删除去掉这个app,具体修改如下:

diff --git a/src/com/android/launcher3/model/LoaderTask.java b/src/com/android/launcher3/model/LoaderTask.java
old mode 100644
new mode 100755
index 4756edc..eb737de
--- a/src/com/android/launcher3/model/LoaderTask.java
+++ b/src/com/android/launcher3/model/LoaderTask.java
@@ -817,6 +817,9 @@ public class LoaderTask implements Runnable {
             for (int i = 0; i < apps.size(); i++) {
                 LauncherActivityInfo app = apps.get(i);
                 // This builds the icon bitmaps.
+                 if (app.getComponentName().getPackageName().equals("org.chromium.webview_shell")) {
+                       continue;
+                 }
                 mBgAllAppsList.add(new AppInfo(app, user, quietMode), app);
             }
 
diff --git a/src/com/android/launcher3/model/PackageUpdatedTask.java b/src/com/android/launcher3/model/PackageUpdatedTask.java
old mode 100644
new mode 100755
index 78ecbc6..d928383
--- a/src/com/android/launcher3/model/PackageUpdatedTask.java
+++ b/src/com/android/launcher3/model/PackageUpdatedTask.java
@@ -94,6 +94,9 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
             case OP_ADD: {
                 for (int i = 0; i < N; i++) {
                     if (DEBUG) Log.d(TAG, "mAllAppsList.addPackage " + packages[i]);
+					if ("org.chromium.webview_shell".equals(packages[i])) {
+                          continue;
+					}
                     iconCache.updateIconsForPkg(packages[i], mUser);
                     if (FeatureFlags.LAUNCHER3_PROMISE_APPS_IN_ALL_APPS) {
                         appsList.removePackage(packages[i], Process.myUserHandle());
@@ -111,6 +114,9 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
             case OP_UPDATE:
                 for (int i = 0; i < N; i++) {
                     if (DEBUG) Log.d(TAG, "mAllAppsList.updatePackage " + packages[i]);
+					if ("org.chromium.webview_shell".equals(packages[i])) {
+                          continue;
+					}
                     iconCache.updateIconsForPkg(packages[i], mUser);
                     appsList.updatePackage(context, packages[i], mUser);
                     app.getWidgetCache().removePackage(packages[i], mUser);

你可能感兴趣的:(Android,安卓,平板,android,java,平板)