Android 6.0 Launcher3隐藏小部件与APP icon

隐藏桌面应用icon:
packages/apps/Launcher3/src/com/android/launcher3/LauncherModel.java
在loadAllApps()方法拦截

for (int i = 0; i < apps.size(); i++) {
    LauncherActivityInfoCompat app = apps.get(i);
    // This builds the icon bitmaps.
    if("com.android.firewall".equals(apps.get(i).getApplicationInfo().packageName)) {
        continue;
    }
    mBgAllAppsList.add(new AppInfo(mContext, app, user, mIconCache));
}

移除小部件:在updateWidgetsModel()方法拦截

widgetsAndShortcuts.addAll(getWidgetProviders(mApp.getContext(), refresh));
Intent shortcutsIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
widgetsAndShortcuts.addAll(packageManager.queryIntentActivities(shortcutsIntent, 0));
 for(int i = 0;i < widgetsAndShortcuts.size();i++){
    Object o = widgetsAndShortcuts.get(i);
    if(o instanceof LauncherAppWidgetProviderInfo){
       LauncherAppWidgetProviderInfo info = (LauncherAppWidgetProviderInfo)o;
       if(info.provider.getPackageName().equals("com.android.mms")) {
          widgetsAndShortcuts.remove(i);
          i--;
       }else if(info.provider.getPackageName().equals("com.android.browser")) {
          widgetsAndShortcuts.remove(i);
          i--;
       }
    }
 }
mBgWidgetsModel.setWidgetsAndShortcuts(widgetsAndShortcuts);
}

 

你可能感兴趣的:(launcher)