Loading src/com/android/launcher3/AllAppsList.java +1 −1 Original line number Diff line number Diff line Loading @@ -186,7 +186,7 @@ public class AllAppsList { if (user.equals(applicationInfo.user) && packageName.equals(applicationInfo.componentName.getPackageName())) { if (!findActivity(matches, applicationInfo.componentName)) { Log.w(TAG, "Shortcut will be removed due to app component name change."); Log.w(TAG, "Changing shortcut target due to app component name change."); removed.add(applicationInfo); data.remove(i); } Loading src/com/android/launcher3/AppInfo.java +0 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ import android.os.Process; import android.os.UserHandle; import com.android.launcher3.compat.UserManagerCompat; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.PackageManagerHelper; Loading src/com/android/launcher3/model/LoaderTask.java +9 −17 Original line number Diff line number Diff line Loading @@ -381,9 +381,7 @@ public class LoaderTask implements Runnable { // no special handling necessary for this item c.markRestored(); } else { if (c.hasRestoreFlag(ShortcutInfo.FLAG_AUTOINSTALL_ICON)) { // We allow auto install apps to have their intent // updated after an install. // Gracefully try to find a fallback activity. intent = pmHelper.getAppLaunchIntent(targetPkg, c.user); if (intent != null) { c.restoreFlag = 0; Loading @@ -395,12 +393,6 @@ public class LoaderTask implements Runnable { c.markDeleted("Unable to find a launch target"); continue; } } else { // The app is installed but the component is no // longer available. c.markDeleted("Invalid component removed: " + cn); continue; } } } // else if cn == null => can't infer much, leave it Loading src/com/android/launcher3/model/PackageUpdatedTask.java +28 −25 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import android.content.Context; import android.content.Intent; import android.os.Process; import android.os.UserHandle; import android.util.ArrayMap; import android.util.Log; import com.android.launcher3.AllAppsList; Loading Loading @@ -159,15 +158,16 @@ public class PackageUpdatedTask extends BaseModelUpdateTask { appsList.added.clear(); addedOrModified.addAll(appsList.modified); appsList.modified.clear(); if (!addedOrModified.isEmpty()) { scheduleCallbackTask((callbacks) -> callbacks.bindAppsAddedOrUpdated(addedOrModified)); } final ArrayList<AppInfo> removedApps = new ArrayList<>(appsList.removed); appsList.removed.clear(); final ArrayMap<ComponentName, AppInfo> addedOrUpdatedApps = new ArrayMap<>(); if (!addedOrModified.isEmpty()) { scheduleCallbackTask((callbacks) -> callbacks.bindAppsAddedOrUpdated(addedOrModified)); for (AppInfo ai : addedOrModified) { addedOrUpdatedApps.put(ai.componentName, ai); final HashSet<ComponentName> removedComponents = new HashSet<>(); if (mOp == OP_UPDATE) { for (AppInfo ai : removedApps) { removedComponents.add(ai.componentName); } } Loading Loading @@ -201,7 +201,7 @@ public class PackageUpdatedTask extends BaseModelUpdateTask { ComponentName cn = si.getTargetComponent(); if (cn != null && matcher.matches(si, cn)) { AppInfo appInfo = addedOrUpdatedApps.get(cn); String packageName = cn.getPackageName(); if (si.hasStatusFlag(ShortcutInfo.FLAG_SUPPORTS_WEB_UI)) { removedShortcuts.put(si.id, false); Loading Loading @@ -231,17 +231,7 @@ public class PackageUpdatedTask extends BaseModelUpdateTask { if (si.hasStatusFlag(ShortcutInfo.FLAG_AUTOINSTALL_ICON)) { // Auto install icon if (!isTargetValid) { // Try to find the best match activity. Intent intent = new PackageManagerHelper(context) .getAppLaunchIntent(cn.getPackageName(), mUser); if (intent != null) { cn = intent.getComponent(); appInfo = addedOrUpdatedApps.get(cn); } if (intent != null && appInfo != null) { si.intent = intent; si.status = ShortcutInfo.DEFAULT; if (updateShortcutIntent(context, si, packageName)) { infoUpdated = true; } else if (si.hasPromiseIconUi()) { removedShortcuts.put(si.id, true); Loading @@ -257,6 +247,10 @@ public class PackageUpdatedTask extends BaseModelUpdateTask { si.status = ShortcutInfo.DEFAULT; infoUpdated = true; } } else if (isNewApkAvailable && removedComponents.contains(cn)) { if (updateShortcutIntent(context, si, packageName)) { infoUpdated = true; } } if (isNewApkAvailable && Loading Loading @@ -315,7 +309,6 @@ public class PackageUpdatedTask extends BaseModelUpdateTask { } final HashSet<String> removedPackages = new HashSet<>(); final HashSet<ComponentName> removedComponents = new HashSet<>(); if (mOp == OP_REMOVE) { // Mark all packages in the broadcast to be removed Collections.addAll(removedPackages, packages); Loading @@ -330,11 +323,6 @@ public class PackageUpdatedTask extends BaseModelUpdateTask { removedPackages.add(packages[i]); } } // Update removedComponents as some components can get removed during package update for (AppInfo info : removedApps) { removedComponents.add(info.componentName); } } if (!removedPackages.isEmpty() || !removedComponents.isEmpty()) { Loading Loading @@ -366,4 +354,19 @@ public class PackageUpdatedTask extends BaseModelUpdateTask { bindUpdatedWidgets(dataModel); } } /** * Updates {@param si}'s intent to point to a new ComponentName. * @return Whether the shortcut intent was changed. */ private boolean updateShortcutIntent(Context context, ShortcutInfo si, String packageName) { // Try to find the best match activity. Intent intent = new PackageManagerHelper(context).getAppLaunchIntent(packageName, mUser); if (intent != null) { si.intent = intent; si.status = ShortcutInfo.DEFAULT; return true; } return false; } } Loading
src/com/android/launcher3/AllAppsList.java +1 −1 Original line number Diff line number Diff line Loading @@ -186,7 +186,7 @@ public class AllAppsList { if (user.equals(applicationInfo.user) && packageName.equals(applicationInfo.componentName.getPackageName())) { if (!findActivity(matches, applicationInfo.componentName)) { Log.w(TAG, "Shortcut will be removed due to app component name change."); Log.w(TAG, "Changing shortcut target due to app component name change."); removed.add(applicationInfo); data.remove(i); } Loading
src/com/android/launcher3/AppInfo.java +0 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ import android.os.Process; import android.os.UserHandle; import com.android.launcher3.compat.UserManagerCompat; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.PackageManagerHelper; Loading
src/com/android/launcher3/model/LoaderTask.java +9 −17 Original line number Diff line number Diff line Loading @@ -381,9 +381,7 @@ public class LoaderTask implements Runnable { // no special handling necessary for this item c.markRestored(); } else { if (c.hasRestoreFlag(ShortcutInfo.FLAG_AUTOINSTALL_ICON)) { // We allow auto install apps to have their intent // updated after an install. // Gracefully try to find a fallback activity. intent = pmHelper.getAppLaunchIntent(targetPkg, c.user); if (intent != null) { c.restoreFlag = 0; Loading @@ -395,12 +393,6 @@ public class LoaderTask implements Runnable { c.markDeleted("Unable to find a launch target"); continue; } } else { // The app is installed but the component is no // longer available. c.markDeleted("Invalid component removed: " + cn); continue; } } } // else if cn == null => can't infer much, leave it Loading
src/com/android/launcher3/model/PackageUpdatedTask.java +28 −25 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import android.content.Context; import android.content.Intent; import android.os.Process; import android.os.UserHandle; import android.util.ArrayMap; import android.util.Log; import com.android.launcher3.AllAppsList; Loading Loading @@ -159,15 +158,16 @@ public class PackageUpdatedTask extends BaseModelUpdateTask { appsList.added.clear(); addedOrModified.addAll(appsList.modified); appsList.modified.clear(); if (!addedOrModified.isEmpty()) { scheduleCallbackTask((callbacks) -> callbacks.bindAppsAddedOrUpdated(addedOrModified)); } final ArrayList<AppInfo> removedApps = new ArrayList<>(appsList.removed); appsList.removed.clear(); final ArrayMap<ComponentName, AppInfo> addedOrUpdatedApps = new ArrayMap<>(); if (!addedOrModified.isEmpty()) { scheduleCallbackTask((callbacks) -> callbacks.bindAppsAddedOrUpdated(addedOrModified)); for (AppInfo ai : addedOrModified) { addedOrUpdatedApps.put(ai.componentName, ai); final HashSet<ComponentName> removedComponents = new HashSet<>(); if (mOp == OP_UPDATE) { for (AppInfo ai : removedApps) { removedComponents.add(ai.componentName); } } Loading Loading @@ -201,7 +201,7 @@ public class PackageUpdatedTask extends BaseModelUpdateTask { ComponentName cn = si.getTargetComponent(); if (cn != null && matcher.matches(si, cn)) { AppInfo appInfo = addedOrUpdatedApps.get(cn); String packageName = cn.getPackageName(); if (si.hasStatusFlag(ShortcutInfo.FLAG_SUPPORTS_WEB_UI)) { removedShortcuts.put(si.id, false); Loading Loading @@ -231,17 +231,7 @@ public class PackageUpdatedTask extends BaseModelUpdateTask { if (si.hasStatusFlag(ShortcutInfo.FLAG_AUTOINSTALL_ICON)) { // Auto install icon if (!isTargetValid) { // Try to find the best match activity. Intent intent = new PackageManagerHelper(context) .getAppLaunchIntent(cn.getPackageName(), mUser); if (intent != null) { cn = intent.getComponent(); appInfo = addedOrUpdatedApps.get(cn); } if (intent != null && appInfo != null) { si.intent = intent; si.status = ShortcutInfo.DEFAULT; if (updateShortcutIntent(context, si, packageName)) { infoUpdated = true; } else if (si.hasPromiseIconUi()) { removedShortcuts.put(si.id, true); Loading @@ -257,6 +247,10 @@ public class PackageUpdatedTask extends BaseModelUpdateTask { si.status = ShortcutInfo.DEFAULT; infoUpdated = true; } } else if (isNewApkAvailable && removedComponents.contains(cn)) { if (updateShortcutIntent(context, si, packageName)) { infoUpdated = true; } } if (isNewApkAvailable && Loading Loading @@ -315,7 +309,6 @@ public class PackageUpdatedTask extends BaseModelUpdateTask { } final HashSet<String> removedPackages = new HashSet<>(); final HashSet<ComponentName> removedComponents = new HashSet<>(); if (mOp == OP_REMOVE) { // Mark all packages in the broadcast to be removed Collections.addAll(removedPackages, packages); Loading @@ -330,11 +323,6 @@ public class PackageUpdatedTask extends BaseModelUpdateTask { removedPackages.add(packages[i]); } } // Update removedComponents as some components can get removed during package update for (AppInfo info : removedApps) { removedComponents.add(info.componentName); } } if (!removedPackages.isEmpty() || !removedComponents.isEmpty()) { Loading Loading @@ -366,4 +354,19 @@ public class PackageUpdatedTask extends BaseModelUpdateTask { bindUpdatedWidgets(dataModel); } } /** * Updates {@param si}'s intent to point to a new ComponentName. * @return Whether the shortcut intent was changed. */ private boolean updateShortcutIntent(Context context, ShortcutInfo si, String packageName) { // Try to find the best match activity. Intent intent = new PackageManagerHelper(context).getAppLaunchIntent(packageName, mUser); if (intent != null) { si.intent = intent; si.status = ShortcutInfo.DEFAULT; return true; } return false; } }