Merge "Bugfix: Remove widgets and deep shortcuts of app which gets archived." into main
This commit is contained in:
@@ -78,10 +78,12 @@ public class ShortcutsChangedTask extends BaseModelUpdateTask {
|
||||
|
||||
if (!matchingWorkspaceItems.isEmpty()) {
|
||||
if (mShortcuts.isEmpty()) {
|
||||
PackageManagerHelper packageManagerHelper = new PackageManagerHelper(
|
||||
app.getContext());
|
||||
// Verify that the app is indeed installed.
|
||||
if (!new PackageManagerHelper(app.getContext())
|
||||
.isAppInstalled(mPackageName, mUser)) {
|
||||
// App is not installed, ignoring package events
|
||||
if (!packageManagerHelper.isAppInstalled(mPackageName, mUser)
|
||||
&& !packageManagerHelper.isAppArchivedForUser(mPackageName, mUser)) {
|
||||
// App is not installed or archived, ignoring package events
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +104,21 @@ public class PackageManagerHelper {
|
||||
return info != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the target app is archived for a given user
|
||||
*/
|
||||
public boolean isAppArchivedForUser(@NonNull final String packageName,
|
||||
@NonNull final UserHandle user) {
|
||||
if (!Utilities.enableSupportForArchiving()) {
|
||||
return false;
|
||||
}
|
||||
final ApplicationInfo info = getApplicationInfo(
|
||||
// LauncherApps does not support long flags currently. Since archived apps are
|
||||
// subset of uninstalled apps, this filter also includes archived apps.
|
||||
packageName, user, PackageManager.MATCH_UNINSTALLED_PACKAGES);
|
||||
return info != null && info.isArchived;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the target app is in archived state
|
||||
*/
|
||||
@@ -172,7 +187,7 @@ public class PackageManagerHelper {
|
||||
public void startDetailsActivityForInfo(ItemInfo info, Rect sourceBounds, Bundle opts) {
|
||||
if (info instanceof ItemInfoWithIcon
|
||||
&& (((ItemInfoWithIcon) info).runtimeStatusFlags
|
||||
& ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0) {
|
||||
& ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0) {
|
||||
ItemInfoWithIcon appInfo = (ItemInfoWithIcon) info;
|
||||
mContext.startActivity(ApiWrapper.getAppMarketActivityIntent(mContext,
|
||||
appInfo.getTargetComponent().getPackageName(), Process.myUserHandle()));
|
||||
@@ -251,6 +266,7 @@ public class PackageManagerHelper {
|
||||
|
||||
/**
|
||||
* Returns true if Launcher has the permission to access shortcuts.
|
||||
*
|
||||
* @see LauncherApps#hasShortcutHostPermission()
|
||||
*/
|
||||
public static boolean hasShortcutsPermission(Context context) {
|
||||
|
||||
Reference in New Issue
Block a user