Rename setApplicationBlocked to setApplicationHidden
This corrects the expected behavior of the app state. Hidden apps
can be installed by the store to be brought out of hidden state.
Bug: 16191518
Change-Id: Id128ce971ceee99ba1dea14ba07ce03bd8d77335
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 77fd409..6de8a8b 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -7882,7 +7882,7 @@
}
@Override
- public boolean setApplicationBlockedSettingAsUser(String packageName, boolean blocked,
+ public boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden,
int userId) {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_USERS, null);
PackageSetting pkgSetting;
@@ -7890,11 +7890,11 @@
if (UserHandle.getUserId(uid) != userId) {
mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.INTERACT_ACROSS_USERS_FULL,
- "setApplicationBlockedSetting for user " + userId);
+ "setApplicationHiddenSetting for user " + userId);
}
- if (blocked && isPackageDeviceAdmin(packageName, userId)) {
- Slog.w(TAG, "Not blocking package " + packageName + ": has active device admin");
+ if (hidden && isPackageDeviceAdmin(packageName, userId)) {
+ Slog.w(TAG, "Not hiding package " + packageName + ": has active device admin");
return false;
}
@@ -7908,10 +7908,10 @@
if (pkgSetting == null) {
return false;
}
- if (pkgSetting.getBlocked(userId) != blocked) {
- pkgSetting.setBlocked(blocked, userId);
+ if (pkgSetting.getHidden(userId) != hidden) {
+ pkgSetting.setHidden(hidden, userId);
mSettings.writePackageRestrictionsLPr(userId);
- if (blocked) {
+ if (hidden) {
sendRemoved = true;
} else {
sendAdded = true;
@@ -7924,8 +7924,8 @@
}
if (sendRemoved) {
killApplication(packageName, UserHandle.getUid(userId, pkgSetting.appId),
- "blocking pkg");
- sendPackageBlockedForUser(packageName, pkgSetting, userId);
+ "hiding pkg");
+ sendApplicationHiddenForUser(packageName, pkgSetting, userId);
}
} finally {
Binder.restoreCallingIdentity(callingId);
@@ -7933,7 +7933,7 @@
return false;
}
- private void sendPackageBlockedForUser(String packageName, PackageSetting pkgSetting,
+ private void sendApplicationHiddenForUser(String packageName, PackageSetting pkgSetting,
int userId) {
final PackageRemovedInfo info = new PackageRemovedInfo();
info.removedPackage = packageName;
@@ -7944,13 +7944,13 @@
/**
* Returns true if application is not found or there was an error. Otherwise it returns
- * the blocked state of the package for the given user.
+ * the hidden state of the package for the given user.
*/
@Override
- public boolean getApplicationBlockedSettingAsUser(String packageName, int userId) {
+ public boolean getApplicationHiddenSettingAsUser(String packageName, int userId) {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_USERS, null);
enforceCrossUserPermission(Binder.getCallingUid(), userId, true,
- "getApplicationBlocked for user " + userId);
+ "getApplicationHidden for user " + userId);
PackageSetting pkgSetting;
long callingId = Binder.clearCallingIdentity();
try {
@@ -7960,7 +7960,7 @@
if (pkgSetting == null) {
return true;
}
- return pkgSetting.getBlocked(userId);
+ return pkgSetting.getHidden(userId);
}
} finally {
Binder.restoreCallingIdentity(callingId);
@@ -7994,7 +7994,7 @@
}
if (!pkgSetting.getInstalled(userId)) {
pkgSetting.setInstalled(true, userId);
- pkgSetting.setBlocked(false, userId);
+ pkgSetting.setHidden(false, userId);
mSettings.writePackageRestrictionsLPr(userId);
sendAdded = true;
}
@@ -10593,19 +10593,19 @@
return;
}
- boolean blocked = false;
+ boolean uninstallBlocked = false;
if ((flags & PackageManager.DELETE_ALL_USERS) != 0) {
int[] users = sUserManager.getUserIds();
for (int i = 0; i < users.length; ++i) {
if (getBlockUninstallForUser(packageName, users[i])) {
- blocked = true;
+ uninstallBlocked = true;
break;
}
}
} else {
- blocked = getBlockUninstallForUser(packageName, userId);
+ uninstallBlocked = getBlockUninstallForUser(packageName, userId);
}
- if (blocked) {
+ if (uninstallBlocked) {
try {
observer.packageDeleted(packageName, PackageManager.DELETE_FAILED_OWNER_BLOCKED);
} catch (RemoteException re) {
@@ -10613,7 +10613,9 @@
return;
}
- if (DEBUG_REMOVE) Slog.d(TAG, "deletePackageAsUser: pkg=" + packageName + " user=" + userId);
+ if (DEBUG_REMOVE) {
+ Slog.d(TAG, "deletePackageAsUser: pkg=" + packageName + " user=" + userId);
+ }
// Queue up an async operation since the package deletion may take a little while.
mHandler.post(new Runnable() {
public void run() {
@@ -11032,7 +11034,7 @@
false, //installed
true, //stopped
true, //notLaunched
- false, //blocked
+ false, //hidden
null, null, null,
false // blockUninstall
);
diff --git a/services/core/java/com/android/server/pm/PackageSettingBase.java b/services/core/java/com/android/server/pm/PackageSettingBase.java
index e164f5f..e29332c 100644
--- a/services/core/java/com/android/server/pm/PackageSettingBase.java
+++ b/services/core/java/com/android/server/pm/PackageSettingBase.java
@@ -281,12 +281,12 @@
modifyUserState(userId).notLaunched = stop;
}
- boolean getBlocked(int userId) {
- return readUserState(userId).blocked;
+ boolean getHidden(int userId) {
+ return readUserState(userId).hidden;
}
- void setBlocked(boolean blocked, int userId) {
- modifyUserState(userId).blocked = blocked;
+ void setHidden(boolean hidden, int userId) {
+ modifyUserState(userId).hidden = hidden;
}
boolean getBlockUninstall(int userId) {
@@ -298,7 +298,7 @@
}
void setUserState(int userId, int enabled, boolean installed, boolean stopped,
- boolean notLaunched, boolean blocked,
+ boolean notLaunched, boolean hidden,
String lastDisableAppCaller, HashSet<String> enabledComponents,
HashSet<String> disabledComponents, boolean blockUninstall) {
PackageUserState state = modifyUserState(userId);
@@ -306,7 +306,7 @@
state.installed = installed;
state.stopped = stopped;
state.notLaunched = notLaunched;
- state.blocked = blocked;
+ state.hidden = hidden;
state.lastDisableAppCaller = lastDisableAppCaller;
state.enabledComponents = enabledComponents;
state.disabledComponents = disabledComponents;
diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java
index e16894e..d1ea3e1 100644
--- a/services/core/java/com/android/server/pm/Settings.java
+++ b/services/core/java/com/android/server/pm/Settings.java
@@ -153,7 +153,10 @@
private static final String ATTR_ENABLED = "enabled";
private static final String ATTR_ENABLED_CALLER = "enabledCaller";
private static final String ATTR_STOPPED = "stopped";
+ // Legacy, here for reading older versions of the package-restrictions.
private static final String ATTR_BLOCKED = "blocked";
+ // New name for the above attribute.
+ private static final String ATTR_HIDDEN = "hidden";
private static final String ATTR_INSTALLED = "inst";
private static final String ATTR_BLOCK_UNINSTALL = "blockUninstall";
@@ -606,7 +609,7 @@
installed,
true, // stopped,
true, // notLaunched
- false, // blocked
+ false, // hidden
null, null, null,
false // blockUninstall
);
@@ -1177,7 +1180,7 @@
true, // installed
false, // stopped
false, // notLaunched
- false, // blocked
+ false, // hidden
null, null, null,
false // blockUninstall
);
@@ -1233,9 +1236,14 @@
final String stoppedStr = parser.getAttributeValue(null, ATTR_STOPPED);
final boolean stopped = stoppedStr == null
? false : Boolean.parseBoolean(stoppedStr);
+ // For backwards compatibility with the previous name of "blocked", which
+ // now means hidden, read the old attribute as well.
final String blockedStr = parser.getAttributeValue(null, ATTR_BLOCKED);
- final boolean blocked = blockedStr == null
+ boolean hidden = blockedStr == null
? false : Boolean.parseBoolean(blockedStr);
+ final String hiddenStr = parser.getAttributeValue(null, ATTR_HIDDEN);
+ hidden = hiddenStr == null
+ ? hidden : Boolean.parseBoolean(hiddenStr);
final String notLaunchedStr = parser.getAttributeValue(null, ATTR_NOT_LAUNCHED);
final boolean notLaunched = stoppedStr == null
? false : Boolean.parseBoolean(notLaunchedStr);
@@ -1263,7 +1271,7 @@
}
}
- ps.setUserState(userId, enabled, installed, stopped, notLaunched, blocked,
+ ps.setUserState(userId, enabled, installed, stopped, notLaunched, hidden,
enabledCaller, enabledComponents, disabledComponents, blockUninstall);
} else if (tagName.equals("preferred-activities")) {
readPreferredActivitiesLPw(parser, userId);
@@ -1432,7 +1440,7 @@
PackageUserState ustate = pkg.readUserState(userId);
if (ustate.stopped || ustate.notLaunched || !ustate.installed
|| ustate.enabled != COMPONENT_ENABLED_STATE_DEFAULT
- || ustate.blocked
+ || ustate.hidden
|| (ustate.enabledComponents != null
&& ustate.enabledComponents.size() > 0)
|| (ustate.disabledComponents != null
@@ -1451,8 +1459,8 @@
if (ustate.notLaunched) {
serializer.attribute(null, ATTR_NOT_LAUNCHED, "true");
}
- if (ustate.blocked) {
- serializer.attribute(null, ATTR_BLOCKED, "true");
+ if (ustate.hidden) {
+ serializer.attribute(null, ATTR_HIDDEN, "true");
}
if (ustate.blockUninstall) {
serializer.attribute(null, ATTR_BLOCK_UNINSTALL, "true");
@@ -3443,7 +3451,7 @@
pw.print(user.id);
pw.print(",");
pw.print(ps.getInstalled(user.id) ? "I" : "i");
- pw.print(ps.getBlocked(user.id) ? "B" : "b");
+ pw.print(ps.getHidden(user.id) ? "B" : "b");
pw.print(ps.getStopped(user.id) ? "S" : "s");
pw.print(ps.getNotLaunched(user.id) ? "l" : "L");
pw.print(",");
@@ -3583,8 +3591,8 @@
pw.print(prefix); pw.print(" User "); pw.print(user.id); pw.print(": ");
pw.print(" installed=");
pw.print(ps.getInstalled(user.id));
- pw.print(" blocked=");
- pw.print(ps.getBlocked(user.id));
+ pw.print(" hidden=");
+ pw.print(ps.getHidden(user.id));
pw.print(" stopped=");
pw.print(ps.getStopped(user.id));
pw.print(" notLaunched=");
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index b4cc252..33ecc4d 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -1428,7 +1428,7 @@
removeRestrictionsForUser(userHandle, true);
}
- private void removeRestrictionsForUser(final int userHandle, boolean unblockApps) {
+ private void removeRestrictionsForUser(final int userHandle, boolean unhideApps) {
synchronized (mPackagesLock) {
// Remove all user restrictions
setUserRestrictions(new Bundle(), userHandle);
@@ -1437,12 +1437,12 @@
// Remove any app restrictions
cleanAppRestrictions(userHandle);
}
- if (unblockApps) {
- unblockAllAppsForUser(userHandle);
+ if (unhideApps) {
+ unhideAllInstalledAppsForUser(userHandle);
}
}
- private void unblockAllAppsForUser(final int userHandle) {
+ private void unhideAllInstalledAppsForUser(final int userHandle) {
mHandler.post(new Runnable() {
@Override
public void run() {
@@ -1453,8 +1453,8 @@
try {
for (ApplicationInfo appInfo : apps) {
if ((appInfo.flags & ApplicationInfo.FLAG_INSTALLED) != 0
- && (appInfo.flags & ApplicationInfo.FLAG_BLOCKED) != 0) {
- mPm.setApplicationBlockedSettingAsUser(appInfo.packageName, false,
+ && (appInfo.flags & ApplicationInfo.FLAG_HIDDEN) != 0) {
+ mPm.setApplicationHiddenSettingAsUser(appInfo.packageName, false,
userHandle);
}
}
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 12ed920..c218d38 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -3708,8 +3708,8 @@
}
@Override
- public boolean setApplicationBlocked(ComponentName who, String packageName,
- boolean blocked) {
+ public boolean setApplicationHidden(ComponentName who, String packageName,
+ boolean hidden) {
int callingUserId = UserHandle.getCallingUserId();
synchronized (this) {
if (who == null) {
@@ -3720,10 +3720,10 @@
long id = Binder.clearCallingIdentity();
try {
IPackageManager pm = AppGlobals.getPackageManager();
- return pm.setApplicationBlockedSettingAsUser(packageName, blocked, callingUserId);
+ return pm.setApplicationHiddenSettingAsUser(packageName, hidden, callingUserId);
} catch (RemoteException re) {
// shouldn't happen
- Slog.e(LOG_TAG, "Failed to setApplicationBlockedSetting", re);
+ Slog.e(LOG_TAG, "Failed to setApplicationHiddenSetting", re);
} finally {
restoreCallingIdentity(id);
}
@@ -3732,7 +3732,7 @@
}
@Override
- public int setApplicationsBlocked(ComponentName who, Intent intent, boolean blocked) {
+ public int setApplicationsHidden(ComponentName who, Intent intent, boolean hidden) {
int callingUserId = UserHandle.getCallingUserId();
synchronized (this) {
if (who == null) {
@@ -3750,20 +3750,20 @@
callingUserId);
if (DBG) Slog.d(LOG_TAG, "Enabling activities: " + activitiesToEnable);
- int numberOfAppsUnblocked = 0;
+ int numberOfAppsUnhidden = 0;
if (activitiesToEnable != null) {
for (ResolveInfo info : activitiesToEnable) {
if (info.activityInfo != null) {
- numberOfAppsUnblocked++;
- pm.setApplicationBlockedSettingAsUser(info.activityInfo.packageName,
- blocked, callingUserId);
+ numberOfAppsUnhidden++;
+ pm.setApplicationHiddenSettingAsUser(info.activityInfo.packageName,
+ hidden, callingUserId);
}
}
}
- return numberOfAppsUnblocked;
+ return numberOfAppsUnhidden;
} catch (RemoteException re) {
// shouldn't happen
- Slog.e(LOG_TAG, "Failed to setApplicationsBlockedSettingsWithIntent", re);
+ Slog.e(LOG_TAG, "Failed to setApplicationsHiddenSettingsWithIntent", re);
} finally {
restoreCallingIdentity(id);
}
@@ -3772,7 +3772,7 @@
}
@Override
- public boolean isApplicationBlocked(ComponentName who, String packageName) {
+ public boolean isApplicationHidden(ComponentName who, String packageName) {
int callingUserId = UserHandle.getCallingUserId();
synchronized (this) {
if (who == null) {
@@ -3783,10 +3783,10 @@
long id = Binder.clearCallingIdentity();
try {
IPackageManager pm = AppGlobals.getPackageManager();
- return pm.getApplicationBlockedSettingAsUser(packageName, callingUserId);
+ return pm.getApplicationHiddenSettingAsUser(packageName, callingUserId);
} catch (RemoteException re) {
// shouldn't happen
- Slog.e(LOG_TAG, "Failed to getApplicationBlockedSettingAsUser", re);
+ Slog.e(LOG_TAG, "Failed to getApplicationHiddenSettingAsUser", re);
} finally {
restoreCallingIdentity(id);
}