diff options
author | Dianne Hackborn <hackbod@google.com> | 2011-06-17 14:49:23 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2011-06-17 14:49:45 -0700 |
commit | 0ac3031c159a0904e73eb4439cdc724d8df4a6e6 (patch) | |
tree | 27d80b0cb1d37b10c898340348ae863014c4a6e0 | |
parent | 3a3efe756389cbda3ddf74c0c55d7a3ce68f3780 (diff) | |
download | frameworks_base-0ac3031c159a0904e73eb4439cdc724d8df4a6e6.zip frameworks_base-0ac3031c159a0904e73eb4439cdc724d8df4a6e6.tar.gz frameworks_base-0ac3031c159a0904e73eb4439cdc724d8df4a6e6.tar.bz2 |
Implement remaining infrastructure for user disabling apps.
Change-Id: If8135eb0e27ec36f8f159eb7b6397add7acd0299
-rw-r--r-- | api/current.txt | 1 | ||||
-rw-r--r-- | cmds/pm/src/com/android/commands/pm/Pm.java | 7 | ||||
-rw-r--r-- | core/java/android/content/pm/ApplicationInfo.java | 9 | ||||
-rw-r--r-- | core/java/android/content/pm/PackageManager.java | 30 | ||||
-rw-r--r-- | core/java/android/content/pm/PackageParser.java | 4 | ||||
-rw-r--r-- | services/java/com/android/server/pm/PackageManagerService.java | 4 | ||||
-rw-r--r-- | services/java/com/android/server/pm/Settings.java | 2 |
7 files changed, 55 insertions, 2 deletions
diff --git a/api/current.txt b/api/current.txt index 1e2120c..7c656af 100644 --- a/api/current.txt +++ b/api/current.txt @@ -5804,6 +5804,7 @@ package android.content.pm { method public abstract void setInstallerPackageName(java.lang.String, java.lang.String); field public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0; // 0x0 field public static final int COMPONENT_ENABLED_STATE_DISABLED = 2; // 0x2 + field public static final int COMPONENT_ENABLED_STATE_DISABLED_USER = 3; // 0x3 field public static final int COMPONENT_ENABLED_STATE_ENABLED = 1; // 0x1 field public static final int DONT_KILL_APP = 1; // 0x1 field public static final java.lang.String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency"; diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java index b0e4a86..e433079 100644 --- a/cmds/pm/src/com/android/commands/pm/Pm.java +++ b/cmds/pm/src/com/android/commands/pm/Pm.java @@ -120,6 +120,11 @@ public final class Pm { return; } + if ("disable-user".equals(op)) { + runSetEnabledSetting(PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER); + return; + } + if ("setInstallLocation".equals(op)) { runSetInstallLocation(); return; @@ -970,6 +975,8 @@ public final class Pm { return "enabled"; case PackageManager.COMPONENT_ENABLED_STATE_DISABLED: return "disabled"; + case PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER: + return "disabled-user"; } return "unknown"; } diff --git a/core/java/android/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java index c0a1d8e..454cb31 100644 --- a/core/java/android/content/pm/ApplicationInfo.java +++ b/core/java/android/content/pm/ApplicationInfo.java @@ -417,6 +417,12 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable { public boolean enabled = true; /** + * For convenient access to the current enabled setting of this app. + * @hide + */ + public int enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT; + + /** * For convenient access to package's install location. * @hide */ @@ -508,6 +514,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable { uid = orig.uid; targetSdkVersion = orig.targetSdkVersion; enabled = orig.enabled; + enabledSetting = orig.enabledSetting; installLocation = orig.installLocation; manageSpaceActivityName = orig.manageSpaceActivityName; descriptionRes = orig.descriptionRes; @@ -544,6 +551,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable { dest.writeInt(uid); dest.writeInt(targetSdkVersion); dest.writeInt(enabled ? 1 : 0); + dest.writeInt(enabledSetting); dest.writeInt(installLocation); dest.writeString(manageSpaceActivityName); dest.writeString(backupAgentName); @@ -581,6 +589,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable { uid = source.readInt(); targetSdkVersion = source.readInt(); enabled = source.readInt() != 0; + enabledSetting = source.readInt(); installLocation = source.readInt(); manageSpaceActivityName = source.readString(); backupAgentName = source.readString(); diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index 1cd8ec0..dd684cd 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -224,11 +224,41 @@ public abstract class PackageManager { */ public static final int SIGNATURE_UNKNOWN_PACKAGE = -4; + /** + * Flag for {@link #setApplicationEnabledSetting(String, int, int)} + * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This + * component or application is in its default enabled state (as specified + * in its manifest). + */ public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0; + + /** + * Flag for {@link #setApplicationEnabledSetting(String, int, int)} + * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This + * component or application has been explictily enabled, regardless of + * what it has specified in its manifest. + */ public static final int COMPONENT_ENABLED_STATE_ENABLED = 1; + + /** + * Flag for {@link #setApplicationEnabledSetting(String, int, int)} + * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This + * component or application has been explicitly disabled, regardless of + * what it has specified in its manifest. + */ public static final int COMPONENT_ENABLED_STATE_DISABLED = 2; /** + * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: The + * user has explicitly disabled the application, regardless of what it has + * specified in its manifest. Because this is due to the user's request, + * they may re-enable it if desired through the appropriate system UI. This + * option currently <strong>can not</strong> be used with + * {@link #setComponentEnabledSetting(ComponentName, int, int)}. + */ + public static final int COMPONENT_ENABLED_STATE_DISABLED_USER = 3; + + /** * Flag parameter for {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} to * indicate that this package should be installed as forward locked, i.e. only the app itself * should have access to its code and non-resource assets. diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index 31ad6e9..e927f6c 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -3128,9 +3128,11 @@ public class PackageParser { } if (p.mSetEnabled == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) { ai.enabled = true; - } else if (p.mSetEnabled == PackageManager.COMPONENT_ENABLED_STATE_DISABLED) { + } else if (p.mSetEnabled == PackageManager.COMPONENT_ENABLED_STATE_DISABLED + || p.mSetEnabled == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER) { ai.enabled = false; } + ai.enabledSetting = p.mSetEnabled; return ai; } diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java index e1fbe1c..5a9dae9 100644 --- a/services/java/com/android/server/pm/PackageManagerService.java +++ b/services/java/com/android/server/pm/PackageManagerService.java @@ -18,6 +18,7 @@ package com.android.server.pm; import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DEFAULT; import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED; +import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER; import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED; import com.android.internal.app.IMediaContainerService; @@ -7048,7 +7049,8 @@ public class PackageManagerService extends IPackageManager.Stub { final String packageName, String className, int newState, final int flags) { if (!(newState == COMPONENT_ENABLED_STATE_DEFAULT || newState == COMPONENT_ENABLED_STATE_ENABLED - || newState == COMPONENT_ENABLED_STATE_DISABLED)) { + || newState == COMPONENT_ENABLED_STATE_DISABLED + || newState == COMPONENT_ENABLED_STATE_DISABLED_USER)) { throw new IllegalArgumentException("Invalid new component state: " + newState); } diff --git a/services/java/com/android/server/pm/Settings.java b/services/java/com/android/server/pm/Settings.java index 2720bf8..5ed7988 100644 --- a/services/java/com/android/server/pm/Settings.java +++ b/services/java/com/android/server/pm/Settings.java @@ -18,6 +18,7 @@ package com.android.server.pm; import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DEFAULT; import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED; +import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER; import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED; import com.android.internal.util.FastXmlSerializer; @@ -1912,6 +1913,7 @@ final class Settings { return false; } if (packageSettings.enabled == COMPONENT_ENABLED_STATE_DISABLED + || packageSettings.enabled == COMPONENT_ENABLED_STATE_DISABLED_USER || (packageSettings.pkg != null && !packageSettings.pkg.applicationInfo.enabled && packageSettings.enabled == COMPONENT_ENABLED_STATE_DEFAULT)) { return false; |