Merge "Fixing shortcut intent getting cleared during backup/restore" into sc-dev
This commit is contained in:
commit
40ff7e4e41
|
@ -605,7 +605,6 @@ public final class Utilities {
|
|||
outObj[0] = activityInfo;
|
||||
return activityInfo.getFullResIcon(appState.getIconCache());
|
||||
}
|
||||
if (info.getIntent() == null || info.getIntent().getPackage() == null) return null;
|
||||
List<ShortcutInfo> si = ShortcutKey.fromItemInfo(info)
|
||||
.buildRequest(launcher)
|
||||
.query(ShortcutRequest.ALL);
|
||||
|
|
|
@ -22,7 +22,6 @@ import static com.android.launcher3.model.data.AppInfo.EMPTY_ARRAY;
|
|||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.LauncherActivityInfo;
|
||||
import android.content.pm.LauncherApps;
|
||||
import android.os.LocaleList;
|
||||
|
@ -145,10 +144,9 @@ public class AllAppsList {
|
|||
}
|
||||
|
||||
public void addPromiseApp(Context context, PackageInstallInfo installInfo) {
|
||||
ApplicationInfo applicationInfo = new PackageManagerHelper(context)
|
||||
.getApplicationInfo(installInfo.packageName, installInfo.user, 0);
|
||||
// only if not yet installed
|
||||
if (applicationInfo == null) {
|
||||
if (!new PackageManagerHelper(context)
|
||||
.isAppInstalled(installInfo.packageName, installInfo.user)) {
|
||||
AppInfo info = new AppInfo(installInfo);
|
||||
mIconCache.getTitleAndIcon(info, info.usingLowResIcon());
|
||||
info.sectionName = mIndex.computeSectionName(info.title);
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package com.android.launcher3.model;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
|
@ -66,8 +66,8 @@ public class PackageIncrementalDownloadUpdatedTask extends BaseModelUpdateTask {
|
|||
final ArrayList<WorkspaceItemInfo> updatedWorkspaceItems = new ArrayList<>();
|
||||
synchronized (dataModel) {
|
||||
dataModel.forAllWorkspaceItemInfos(mUser, si -> {
|
||||
ComponentName cn = si.getTargetComponent();
|
||||
if ((cn != null) && cn.getPackageName().equals(mPackageName)) {
|
||||
Intent intent = si.getIntent();
|
||||
if ((intent != null) && mPackageName.equals(intent.getPackage())) {
|
||||
si.runtimeStatusFlags &= ~ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE;
|
||||
si.setProgressLevel(downloadInfo);
|
||||
updatedWorkspaceItems.add(si);
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package com.android.launcher3.model;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
|
||||
|
@ -72,9 +72,9 @@ public class PackageInstallStateChangedTask extends BaseModelUpdateTask {
|
|||
synchronized (dataModel) {
|
||||
final HashSet<ItemInfo> updates = new HashSet<>();
|
||||
dataModel.forAllWorkspaceItemInfos(mInstallInfo.user, si -> {
|
||||
ComponentName cn = si.getTargetComponent();
|
||||
if (si.hasPromiseIconUi() && (cn != null)
|
||||
&& cn.getPackageName().equals(mInstallInfo.packageName)) {
|
||||
Intent intent = si.getIntent();
|
||||
if (si.hasPromiseIconUi() && (intent != null)
|
||||
&& mInstallInfo.packageName.equals(intent.getPackage())) {
|
||||
int installProgress = mInstallInfo.progress;
|
||||
|
||||
si.setProgressLevel(installProgress, PackageInstallInfo.STATUS_INSTALLING);
|
||||
|
|
|
@ -30,6 +30,7 @@ import android.os.UserManager;
|
|||
import android.util.Log;
|
||||
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.LauncherSettings;
|
||||
import com.android.launcher3.LauncherSettings.Favorites;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.icons.BitmapInfo;
|
||||
|
@ -228,7 +229,8 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
|
|||
isTargetValid = context.getSystemService(LauncherApps.class)
|
||||
.isActivityEnabled(cn, mUser);
|
||||
}
|
||||
if (si.hasStatusFlag(FLAG_RESTORED_ICON | FLAG_AUTOINSTALL_ICON)) {
|
||||
if (!isTargetValid && si.hasStatusFlag(
|
||||
FLAG_RESTORED_ICON | FLAG_AUTOINSTALL_ICON)) {
|
||||
if (updateWorkspaceItemIntent(context, si, packageName)) {
|
||||
infoUpdated = true;
|
||||
} else if (si.hasPromiseIconUi()) {
|
||||
|
@ -250,8 +252,7 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
|
|||
}
|
||||
}
|
||||
|
||||
if (isNewApkAvailable
|
||||
&& si.itemType == Favorites.ITEM_TYPE_APPLICATION) {
|
||||
if (isNewApkAvailable) {
|
||||
List<LauncherActivityInfo> activities = activitiesLists.get(
|
||||
packageName);
|
||||
si.setProgressLevel(
|
||||
|
@ -260,9 +261,11 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
|
|||
: PackageManagerHelper.getLoadingProgress(
|
||||
activities.get(0)),
|
||||
PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING);
|
||||
if (si.itemType == Favorites.ITEM_TYPE_APPLICATION) {
|
||||
iconCache.getTitleAndIcon(si, si.usingLowResIcon());
|
||||
infoUpdated = true;
|
||||
}
|
||||
}
|
||||
|
||||
int oldRuntimeFlags = si.runtimeStatusFlags;
|
||||
si.runtimeStatusFlags = flagOp.apply(si.runtimeStatusFlags);
|
||||
|
@ -353,6 +356,11 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
|
|||
*/
|
||||
private boolean updateWorkspaceItemIntent(Context context,
|
||||
WorkspaceItemInfo si, String packageName) {
|
||||
if (si.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
|
||||
// Do not update intent for deep shortcuts as they contain additional information
|
||||
// about the shortcut.
|
||||
return false;
|
||||
}
|
||||
// Try to find the best match activity.
|
||||
Intent intent = new PackageManagerHelper(context).getAppLaunchIntent(packageName, mUser);
|
||||
if (intent != null) {
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.android.launcher3.model.data.WorkspaceItemInfo;
|
|||
import com.android.launcher3.shortcuts.ShortcutKey;
|
||||
import com.android.launcher3.shortcuts.ShortcutRequest;
|
||||
import com.android.launcher3.util.ItemInfoMatcher;
|
||||
import com.android.launcher3.util.PackageManagerHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
@ -66,6 +67,14 @@ public class ShortcutsChangedTask extends BaseModelUpdateTask {
|
|||
}
|
||||
|
||||
if (!matchingWorkspaceItems.isEmpty()) {
|
||||
if (mShortcuts.isEmpty()) {
|
||||
// Verify that the app is indeed installed.
|
||||
if (!new PackageManagerHelper(app.getContext())
|
||||
.isAppInstalled(mPackageName, mUser)) {
|
||||
// App is not installed, ignoring package events
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Update the workspace to reflect the changes to updated shortcuts residing on it.
|
||||
List<String> allLauncherKnownIds = matchingWorkspaceItems.stream()
|
||||
.map(WorkspaceItemInfo::getDeepShortcutId)
|
||||
|
|
|
@ -217,8 +217,8 @@ public class InstallSessionHelper {
|
|||
&& sessionInfo.getAppIcon() != null
|
||||
&& !TextUtils.isEmpty(sessionInfo.getAppLabel())
|
||||
&& !promiseIconAddedForId(sessionInfo.getSessionId())
|
||||
&& new PackageManagerHelper(mAppContext).getApplicationInfo(
|
||||
sessionInfo.getAppPackageName(), getUserHandle(sessionInfo), 0) == null) {
|
||||
&& !new PackageManagerHelper(mAppContext).isAppInstalled(
|
||||
sessionInfo.getAppPackageName(), getUserHandle(sessionInfo))) {
|
||||
ItemInstallQueue.INSTANCE.get(mAppContext)
|
||||
.queueItem(sessionInfo.getAppPackageName(), getUserHandle(sessionInfo));
|
||||
|
||||
|
|
|
@ -91,6 +91,14 @@ public class PackageManagerHelper {
|
|||
return info != null && isAppSuspended(info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the target app is installed for a given user
|
||||
*/
|
||||
public boolean isAppInstalled(String packageName, UserHandle user) {
|
||||
ApplicationInfo info = getApplicationInfo(packageName, user, 0);
|
||||
return info != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the application info for the provided package or null
|
||||
*/
|
||||
|
@ -105,7 +113,7 @@ public class PackageManagerHelper {
|
|||
}
|
||||
|
||||
public boolean isSafeMode() {
|
||||
return mContext.getPackageManager().isSafeMode();
|
||||
return mPm.isSafeMode();
|
||||
}
|
||||
|
||||
public Intent getAppLaunchIntent(String pkg, UserHandle user) {
|
||||
|
|
Loading…
Reference in New Issue