final List<LauncherActivityInfo> apps = mLauncherApps.getActivityList(null, user);for(int i =0; i < apps.size(); i++){
LauncherActivityInfo app = apps.get(i);
mBgAllAppsList.add(newAppInfo(app, user, quietMode), app);}
4. LoadWidgets
mBgDataModel.widgetsModel.update(mApp, null);
Context context = app.getContext();final ArrayList<WidgetItem> widgetsAndShortcuts =newArrayList<>();try{
PackageManager pm = context.getPackageManager();
InvariantDeviceProfile idp = app.getInvariantDeviceProfile();// Widgets
AppWidgetManagerCompat widgetManager = AppWidgetManagerCompat.getInstance(context);for(AppWidgetProviderInfo widgetInfo : widgetManager.getAllProviders(packageUser)){
widgetsAndShortcuts.add(newWidgetItem(LauncherAppWidgetProviderInfo
.fromProviderInfo(context, widgetInfo), pm, idp));}// Shortcutsfor(ShortcutConfigActivityInfo info : LauncherAppsCompat.getInstance(context).getCustomShortcutActivityList(packageUser)){
widgetsAndShortcuts.add(newWidgetItem(info));}setWidgetsAndShortcuts(widgetsAndShortcuts, app, packageUser);}catch(Exception e){if(!FeatureFlags.IS_DOGFOOD_BUILD && Utilities.isBinderSizeError(e)){// the returned value may be incomplete and will not be refreshed until the next// time Launcher starts.// TODO: after figuring out a repro step, introduce a dirty bit to check when// onResume is called to refresh the widget provider list.}else{throw e;}}