diff options
| author | Dianne Hackborn <hackbod@google.com> | 2013-01-22 17:10:23 -0800 |
|---|---|---|
| committer | Dianne Hackborn <hackbod@google.com> | 2013-01-22 17:10:23 -0800 |
| commit | fd7adedebf88427162a3ce27fcc9cfd3893c869d (patch) | |
| tree | d9dfb04e5d0972a6ae7bf92431b0d48925e97b48 /services/java/com/android/server/pm | |
| parent | cc7433470f00fac3bbe7835de3ded4b9bf121244 (diff) | |
Add new disabled state for "optional" built-in apps.
The disabled state allows you to make an app disabled
except for whatever parts of the system still want to
provide access to them and automatically enable them
if the user want to use it.
Currently the input method manager service is the only
part of the system that supports this, so you can put
an IME in this state and it will generally look disabled
but still be available in the IME list and once selected
switched to the enabled state.
Change-Id: I77f01c70610d82ce9070d4aabbadec8ae2cff2a3
Diffstat (limited to 'services/java/com/android/server/pm')
| -rw-r--r-- | services/java/com/android/server/pm/PackageManagerService.java | 6 | ||||
| -rw-r--r-- | services/java/com/android/server/pm/Settings.java | 7 |
2 files changed, 11 insertions, 2 deletions
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java index 47987f167eb1..5462ecce3193 100644 --- a/services/java/com/android/server/pm/PackageManagerService.java +++ b/services/java/com/android/server/pm/PackageManagerService.java @@ -20,6 +20,7 @@ import static android.Manifest.permission.GRANT_REVOKE_PERMISSIONS; import static android.Manifest.permission.READ_EXTERNAL_STORAGE; 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_UNTIL_USED; import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER; import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED; import static com.android.internal.util.ArrayUtils.appendInt; @@ -8906,13 +8907,14 @@ public class PackageManagerService extends IPackageManager.Stub { if (!(newState == COMPONENT_ENABLED_STATE_DEFAULT || newState == COMPONENT_ENABLED_STATE_ENABLED || newState == COMPONENT_ENABLED_STATE_DISABLED - || newState == COMPONENT_ENABLED_STATE_DISABLED_USER)) { + || newState == COMPONENT_ENABLED_STATE_DISABLED_USER + || newState == COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED)) { throw new IllegalArgumentException("Invalid new component state: " + newState); } PackageSetting pkgSetting; final int uid = Binder.getCallingUid(); - final int permission = mContext.checkCallingPermission( + final int permission = mContext.checkCallingOrSelfPermission( android.Manifest.permission.CHANGE_COMPONENT_ENABLED_STATE); enforceCrossUserPermission(uid, userId, false, "set enabled"); final boolean allowedByPermission = (permission == PackageManager.PERMISSION_GRANTED); diff --git a/services/java/com/android/server/pm/Settings.java b/services/java/com/android/server/pm/Settings.java index 06f11bc9a4da..e33652442c27 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_UNTIL_USED; import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER; import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED; import static android.Manifest.permission.READ_EXTERNAL_STORAGE; @@ -2412,8 +2413,14 @@ final class Settings { return false; } PackageUserState ustate = packageSettings.readUserState(userId); + if ((flags&PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS) != 0) { + if (ustate.enabled == COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED) { + return true; + } + } if (ustate.enabled == COMPONENT_ENABLED_STATE_DISABLED || ustate.enabled == COMPONENT_ENABLED_STATE_DISABLED_USER + || ustate.enabled == COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED || (packageSettings.pkg != null && !packageSettings.pkg.applicationInfo.enabled && ustate.enabled == COMPONENT_ENABLED_STATE_DEFAULT)) { return false; |
