Merge "Enable Promise App Icon in All Apps." into ub-launcher3-master

This commit is contained in:
Mario Bertschler
2017-03-21 23:52:12 +00:00
committed by Android (Google) Code Review
5 changed files with 30 additions and 18 deletions
@@ -154,7 +154,7 @@ public class PackageInstallerCompatVL extends PackageInstallerCompat {
if (sessionInfo == null || sessionInfo.getInstallerPackageName() == null) {
return null;
}
String pkg = sessionInfo.getAppPackageName();
String pkg = sessionInfo.getInstallerPackageName();
synchronized (mSessionVerifiedMap) {
if (!mSessionVerifiedMap.containsKey(pkg)) {
LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(mAppContext);
@@ -33,6 +33,7 @@ import com.android.launcher3.LauncherModel.CallbackTask;
import com.android.launcher3.LauncherModel.Callbacks;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.util.GridOccupancy;
import com.android.launcher3.util.Provider;
@@ -140,7 +141,7 @@ public class AddWorkspaceItemsTask extends ExtendedModelTask {
* the workspace has been loaded. We identify a shortcut by its intent.
*/
protected boolean shortcutExists(BgDataModel dataModel, Intent intent, UserHandle user) {
final String intentWithPkg, intentWithoutPkg;
final String compPkgName, intentWithPkg, intentWithoutPkg;
if (intent == null) {
// Skip items with null intents
return true;
@@ -148,19 +149,21 @@ public class AddWorkspaceItemsTask extends ExtendedModelTask {
if (intent.getComponent() != null) {
// If component is not null, an intent with null package will produce
// the same result and should also be a match.
String packageName = intent.getComponent().getPackageName();
compPkgName = intent.getComponent().getPackageName();
if (intent.getPackage() != null) {
intentWithPkg = intent.toUri(0);
intentWithoutPkg = new Intent(intent).setPackage(null).toUri(0);
} else {
intentWithPkg = new Intent(intent).setPackage(packageName).toUri(0);
intentWithPkg = new Intent(intent).setPackage(compPkgName).toUri(0);
intentWithoutPkg = intent.toUri(0);
}
} else {
compPkgName = null;
intentWithPkg = intent.toUri(0);
intentWithoutPkg = intent.toUri(0);
}
boolean isLauncherAppTarget = Utilities.isLauncherAppTarget(intent);
synchronized (dataModel) {
for (ItemInfo item : dataModel.itemsIdMap) {
if (item instanceof ShortcutInfo) {
@@ -172,6 +175,16 @@ public class AddWorkspaceItemsTask extends ExtendedModelTask {
if (intentWithPkg.equals(s) || intentWithoutPkg.equals(s)) {
return true;
}
// checking for existing promise icon with same package name
if (isLauncherAppTarget
&& info.isPromise()
&& info.hasStatusFlag(ShortcutInfo.FLAG_AUTOINTALL_ICON)
&& info.getTargetComponent() != null
&& compPkgName != null
&& compPkgName.equals(info.getTargetComponent().getPackageName())) {
return true;
}
}
}
}
@@ -62,8 +62,7 @@ public class PackageInstallStateChangedTask extends ExtendedModelTask {
if (mInstallInfo.state == PackageInstallerCompat.STATUS_INSTALLING) {
promiseAppInfo.level = mInstallInfo.progress;
updated = promiseAppInfo;
} else if (mInstallInfo.state == PackageInstallerCompat.STATUS_FAILED
|| mInstallInfo.state == PackageInstallerCompat.STATUS_INSTALLED) {
} else if (mInstallInfo.state == PackageInstallerCompat.STATUS_FAILED) {
apps.removePromiseApp(appInfo);
removed.add(appInfo);
}
@@ -18,9 +18,8 @@ package com.android.launcher3.model;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.Bitmap;
import android.os.Process;
import android.os.UserHandle;
import android.util.Log;
@@ -31,7 +30,6 @@ import com.android.launcher3.InstallShortcutReceiver;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherAppWidgetInfo;
import com.android.launcher3.LauncherModel;
import com.android.launcher3.LauncherModel.CallbackTask;
import com.android.launcher3.LauncherModel.Callbacks;
import com.android.launcher3.LauncherSettings;
@@ -40,10 +38,12 @@ import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.graphics.LauncherIcons;
import com.android.launcher3.util.FlagOp;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.ManagedProfileHeuristic;
import com.android.launcher3.util.PackageManagerHelper;
import java.util.ArrayList;
import java.util.Arrays;
@@ -94,6 +94,9 @@ public class PackageUpdatedTask extends ExtendedModelTask {
for (int i = 0; i < N; i++) {
if (DEBUG) Log.d(TAG, "mAllAppsList.addPackage " + packages[i]);
iconCache.updateIconsForPkg(packages[i], mUser);
if (FeatureFlags.LAUNCHER3_PROMISE_APPS_IN_ALL_APPS) {
appsList.removePackage(packages[i], Process.myUserHandle());
}
appsList.addPackage(context, packages[i], mUser);
}
@@ -224,15 +227,12 @@ public class PackageUpdatedTask extends ExtendedModelTask {
if (si.isPromise() && mOp == OP_ADD) {
if (si.hasStatusFlag(ShortcutInfo.FLAG_AUTOINTALL_ICON)) {
// Auto install icon
PackageManager pm = context.getPackageManager();
ResolveInfo matched = pm.resolveActivity(
new Intent(Intent.ACTION_MAIN)
.setComponent(cn).addCategory(Intent.CATEGORY_LAUNCHER),
PackageManager.MATCH_DEFAULT_ONLY);
if (matched == null) {
LauncherAppsCompat launcherApps
= LauncherAppsCompat.getInstance(context);
if (!launcherApps.isActivityEnabledForProfile(cn, mUser)) {
// Try to find the best match activity.
Intent intent = pm.getLaunchIntentForPackage(
cn.getPackageName());
Intent intent = new PackageManagerHelper(context)
.getAppLaunchIntent(cn.getPackageName(), mUser);
if (intent != null) {
cn = intent.getComponent();
appInfo = addedOrUpdatedApps.get(cn);
@@ -37,7 +37,7 @@ public final class FeatureFlags {
// When enabled while all-apps open, the soft input will be set to adjust resize .
public static boolean LAUNCHER3_UPDATE_SOFT_INPUT_MODE = false;
// When enabled the promise icon is visible in all apps while installation an app.
public static boolean LAUNCHER3_PROMISE_APPS_IN_ALL_APPS = false;
public static boolean LAUNCHER3_PROMISE_APPS_IN_ALL_APPS = true;
// Feature flag to enable moving the QSB on the 0th screen of the workspace.
public static final boolean QSB_ON_FIRST_SCREEN = true;