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