summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/compat
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2014-10-02 15:58:31 -0700
committerSunny Goyal <sunnygoyal@google.com>2014-10-08 11:07:11 -0700
commit1a745e8f18e54aff152ff51743ae7595adde6927 (patch)
tree5c178bfb3a51c96f4c036dc4eaa05625fd59cccb /src/com/android/launcher3/compat
parentb50cc8c5d6125715b139d978887830a5341971aa (diff)
downloadandroid_packages_apps_Trebuchet-1a745e8f18e54aff152ff51743ae7595adde6927.tar.gz
android_packages_apps_Trebuchet-1a745e8f18e54aff152ff51743ae7595adde6927.tar.bz2
android_packages_apps_Trebuchet-1a745e8f18e54aff152ff51743ae7595adde6927.zip
Keeping icons in disabled state when SD-card is unmounted
> changing shortcutInfo.isDisabled to be a flag based variable > on received OnPackageUnavailable, icons are disabled from desktop instead of being removed. Icons in all apps are removed Bug: 15852084 Bug: 16238283 Change-Id: I126d23c709682a917d4bbb84de71032593dce8f9
Diffstat (limited to 'src/com/android/launcher3/compat')
-rw-r--r--src/com/android/launcher3/compat/LauncherAppsCompat.java13
-rw-r--r--src/com/android/launcher3/compat/LauncherAppsCompatV16.java17
2 files changed, 20 insertions, 10 deletions
diff --git a/src/com/android/launcher3/compat/LauncherAppsCompat.java b/src/com/android/launcher3/compat/LauncherAppsCompat.java
index 6efcc00fd..5858bc8b9 100644
--- a/src/com/android/launcher3/compat/LauncherAppsCompat.java
+++ b/src/com/android/launcher3/compat/LauncherAppsCompat.java
@@ -19,8 +19,10 @@ package com.android.launcher3.compat;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.Rect;
-import android.os.Build;
import android.os.Bundle;
import com.android.launcher3.Utilities;
@@ -73,4 +75,13 @@ public abstract class LauncherAppsCompat {
public abstract boolean isPackageEnabledForProfile(String packageName, UserHandleCompat user);
public abstract boolean isActivityEnabledForProfile(ComponentName component,
UserHandleCompat user);
+
+ public boolean isAppEnabled(PackageManager pm, String packageName, int flags) {
+ try {
+ ApplicationInfo info = pm.getApplicationInfo(packageName, flags);
+ return info != null && info.enabled;
+ } catch (NameNotFoundException e) {
+ return false;
+ }
+ }
} \ No newline at end of file
diff --git a/src/com/android/launcher3/compat/LauncherAppsCompatV16.java b/src/com/android/launcher3/compat/LauncherAppsCompatV16.java
index 7e5e6bf2c..e47b9a58d 100644
--- a/src/com/android/launcher3/compat/LauncherAppsCompatV16.java
+++ b/src/com/android/launcher3/compat/LauncherAppsCompatV16.java
@@ -22,7 +22,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
-import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
@@ -112,12 +111,7 @@ public class LauncherAppsCompatV16 extends LauncherAppsCompat {
}
public boolean isPackageEnabledForProfile(String packageName, UserHandleCompat user) {
- try {
- PackageInfo info = mPm.getPackageInfo(packageName, 0);
- return info != null && info.applicationInfo.enabled;
- } catch (NameNotFoundException e) {
- return false;
- }
+ return isAppEnabled(mPm, packageName, 0);
}
public boolean isActivityEnabledForProfile(ComponentName component, UserHandleCompat user) {
@@ -198,8 +192,13 @@ public class LauncherAppsCompatV16 extends LauncherAppsCompat {
callback.onPackagesAvailable(packages, user, replacing);
}
} else if (Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE.equals(action)) {
- final boolean replacing = intent.getBooleanExtra(Intent.EXTRA_REPLACING,
- Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT);
+ // This intent is broadcasted when moving a package or mounting/un-mounting
+ // external storage.
+ // However on Kitkat this is also sent when a package is being updated, and
+ // contains an extra Intent.EXTRA_REPLACING=true for that case.
+ // Using false as default for Intent.EXTRA_REPLACING gives correct value on
+ // lower devices as the intent is not sent when the app is updating/replacing.
+ final boolean replacing = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false);
String[] packages = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);
for (OnAppsChangedCallbackCompat callback : getCallbacks()) {
callback.onPackagesUnavailable(packages, user, replacing);