summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/LauncherModel.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-04-06 16:18:20 -0700
committerSunny Goyal <sunnygoyal@google.com>2016-04-07 11:38:10 -0700
commitd09c37052ef9a70d4dde53ece6619f04de5f97cb (patch)
tree2d5f9f6901d32a8424ab1a4014b72b1dec545494 /src/com/android/launcher3/LauncherModel.java
parentb8b070c2dfb27d9ba168c45dd5503e89035a1139 (diff)
downloadandroid_packages_apps_Trebuchet-d09c37052ef9a70d4dde53ece6619f04de5f97cb.tar.gz
android_packages_apps_Trebuchet-d09c37052ef9a70d4dde53ece6619f04de5f97cb.tar.bz2
android_packages_apps_Trebuchet-d09c37052ef9a70d4dde53ece6619f04de5f97cb.zip
Removing dependency on getApplicationInfo method added in N
This method is goiing away. We don't need this method anyway since LauncherActivityInfo already has the information Change-Id: Ic6afa1df14958b894925d730e01a2e2d2a6fb98c
Diffstat (limited to 'src/com/android/launcher3/LauncherModel.java')
-rw-r--r--src/com/android/launcher3/LauncherModel.java40
1 files changed, 23 insertions, 17 deletions
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index f2b307b12..884685c8a 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -33,7 +33,6 @@ import android.content.pm.ResolveInfo;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.net.Uri;
-import android.os.Environment;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
@@ -64,6 +63,7 @@ import com.android.launcher3.util.CursorIconInfo;
import com.android.launcher3.util.FlagOp;
import com.android.launcher3.util.LongArrayMap;
import com.android.launcher3.util.ManagedProfileHeuristic;
+import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.StringFilter;
import com.android.launcher3.util.Thunk;
import com.android.launcher3.util.ViewOnDrawExecutor;
@@ -1749,6 +1749,7 @@ public class LauncherModel extends BroadcastReceiver
long serialNumber;
Intent intent;
UserHandleCompat user;
+ String targetPackage;
while (!mStopped && c.moveToNext()) {
try {
@@ -1767,6 +1768,7 @@ public class LauncherModel extends BroadcastReceiver
int promiseType = c.getInt(restoredIndex);
int disabledState = 0;
boolean itemReplaced = false;
+ targetPackage = null;
if (user == null) {
// User has been deleted remove the item.
itemsToRemove.add(id);
@@ -1780,6 +1782,9 @@ public class LauncherModel extends BroadcastReceiver
cn.getPackageName(), user);
boolean validComponent = validPkg &&
launcherApps.isActivityEnabledForProfile(cn, user);
+ if (validPkg) {
+ targetPackage = cn.getPackageName();
+ }
if (validComponent) {
if (restored) {
@@ -1787,13 +1792,8 @@ public class LauncherModel extends BroadcastReceiver
restoredRows.add(id);
restored = false;
}
- boolean isSuspended = launcherApps.isPackageSuspendedForProfile(
- cn.getPackageName(), user);
- if (isSuspended) {
- disabledState = ShortcutInfo.FLAG_DISABLED_SUSPENDED;
- }
if (quietMode.get(serialNumber)) {
- disabledState |= ShortcutInfo.FLAG_DISABLED_QUIET_USER;
+ disabledState = ShortcutInfo.FLAG_DISABLED_QUIET_USER;
}
} else if (validPkg) {
intent = null;
@@ -1859,9 +1859,8 @@ public class LauncherModel extends BroadcastReceiver
itemsToRemove.add(id);
continue;
}
- } else if (launcherApps.isAppEnabled(
- manager, cn.getPackageName(),
- PackageManager.GET_UNINSTALLED_PACKAGES)) {
+ } else if (PackageManagerHelper.isAppOnSdcard(
+ manager, cn.getPackageName())) {
// Package is present but not available.
allowMissingTarget = true;
disabledState = ShortcutInfo.FLAG_DISABLED_NOT_AVAILABLE;
@@ -1901,7 +1900,7 @@ public class LauncherModel extends BroadcastReceiver
if (itemReplaced) {
if (user.equals(UserHandleCompat.myUserHandle())) {
- info = getAppShortcutInfo(manager, intent, user, context, null,
+ info = getAppShortcutInfo(intent, user, context, null,
cursorIconInfo.iconIndex, titleIndex,
false, useLowResIcon);
} else {
@@ -1921,12 +1920,17 @@ public class LauncherModel extends BroadcastReceiver
}
} else if (itemType ==
LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
- info = getAppShortcutInfo(manager, intent, user, context, c,
+ info = getAppShortcutInfo(intent, user, context, c,
cursorIconInfo.iconIndex, titleIndex,
allowMissingTarget, useLowResIcon);
} else {
info = getShortcutInfo(c, context, titleIndex, cursorIconInfo);
+ // Shortcuts are only available on the primary profile
+ if (PackageManagerHelper.isAppSuspended(manager, targetPackage)) {
+ disabledState |= ShortcutInfo.FLAG_DISABLED_SUSPENDED;
+ }
+
// App shortcuts that used to be automatically added to Launcher
// didn't always have the correct intent flags set, so do that
// here
@@ -1954,7 +1958,7 @@ public class LauncherModel extends BroadcastReceiver
if (info.promisedIntent != null) {
info.promisedIntent.putExtra(ItemInfo.EXTRA_PROFILE, serialNumber);
}
- info.isDisabled = disabledState;
+ info.isDisabled |= disabledState;
if (isSafeMode && !Utilities.isSystemApp(context, intent)) {
info.isDisabled |= ShortcutInfo.FLAG_DISABLED_SAFEMODE;
}
@@ -2822,9 +2826,7 @@ public class LauncherModel extends BroadcastReceiver
packagesUnavailable.clear();
for (String pkg : entry.getValue()) {
if (!launcherApps.isPackageEnabledForProfile(pkg, user)) {
- boolean packageOnSdcard = launcherApps.isAppEnabled(
- manager, pkg, PackageManager.GET_UNINSTALLED_PACKAGES);
- if (packageOnSdcard) {
+ if (PackageManagerHelper.isAppOnSdcard(manager, pkg)) {
packagesUnavailable.add(pkg);
} else {
packagesRemoved.add(pkg);
@@ -3310,7 +3312,7 @@ public class LauncherModel extends BroadcastReceiver
*
* If c is not null, then it will be used to fill in missing data like the title and icon.
*/
- public ShortcutInfo getAppShortcutInfo(PackageManager manager, Intent intent,
+ public ShortcutInfo getAppShortcutInfo(Intent intent,
UserHandleCompat user, Context context, Cursor c, int iconIndex, int titleIndex,
boolean allowMissingTarget, boolean useLowResIcon) {
if (user == null) {
@@ -3340,6 +3342,10 @@ public class LauncherModel extends BroadcastReceiver
info.setIcon(icon == null ? mIconCache.getDefaultIcon(user) : icon);
}
+ if (lai != null && PackageManagerHelper.isAppSuspended(lai.getApplicationInfo())) {
+ info.isDisabled = ShortcutInfo.FLAG_DISABLED_SUSPENDED;
+ }
+
// from the db
if (TextUtils.isEmpty(info.title) && c != null) {
info.title = Utilities.trim(c.getString(titleIndex));