am 94fb2024: Merge "Rename functions that disable status bar and keyguard" into mnc-dev

* commit '94fb2024b013522e95a880e02b73886fa7d01222':
  Rename functions that disable status bar and keyguard
This commit is contained in:
Benjamin Franz
2015-05-06 15:27:47 +00:00
committed by Android Git Automerger
5 changed files with 43 additions and 34 deletions

View File

@@ -5791,8 +5791,8 @@ package android.app.admin {
method public void setCrossProfileCallerIdDisabled(android.content.ComponentName, boolean); method public void setCrossProfileCallerIdDisabled(android.content.ComponentName, boolean);
method public boolean setDeviceInitializer(android.content.ComponentName, android.content.ComponentName, java.lang.String) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException; method public boolean setDeviceInitializer(android.content.ComponentName, android.content.ComponentName, java.lang.String) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException;
method public void setGlobalSetting(android.content.ComponentName, java.lang.String, java.lang.String); method public void setGlobalSetting(android.content.ComponentName, java.lang.String, java.lang.String);
method public boolean setKeyguardDisabled(android.content.ComponentName, boolean);
method public void setKeyguardDisabledFeatures(android.content.ComponentName, int); method public void setKeyguardDisabledFeatures(android.content.ComponentName, int);
method public boolean setKeyguardEnabledState(android.content.ComponentName, boolean);
method public void setLockTaskPackages(android.content.ComponentName, java.lang.String[]) throws java.lang.SecurityException; method public void setLockTaskPackages(android.content.ComponentName, java.lang.String[]) throws java.lang.SecurityException;
method public void setMasterVolumeMuted(android.content.ComponentName, boolean); method public void setMasterVolumeMuted(android.content.ComponentName, boolean);
method public void setMaximumFailedPasswordsForWipe(android.content.ComponentName, int); method public void setMaximumFailedPasswordsForWipe(android.content.ComponentName, int);
@@ -5818,7 +5818,7 @@ package android.app.admin {
method public void setRestrictionsProvider(android.content.ComponentName, android.content.ComponentName); method public void setRestrictionsProvider(android.content.ComponentName, android.content.ComponentName);
method public void setScreenCaptureDisabled(android.content.ComponentName, boolean); method public void setScreenCaptureDisabled(android.content.ComponentName, boolean);
method public void setSecureSetting(android.content.ComponentName, java.lang.String, java.lang.String); method public void setSecureSetting(android.content.ComponentName, java.lang.String, java.lang.String);
method public void setStatusBarEnabledState(android.content.ComponentName, boolean); method public boolean setStatusBarDisabled(android.content.ComponentName, boolean);
method public int setStorageEncryption(android.content.ComponentName, boolean); method public int setStorageEncryption(android.content.ComponentName, boolean);
method public void setSystemUpdatePolicy(android.content.ComponentName, android.app.admin.SystemUpdatePolicy); method public void setSystemUpdatePolicy(android.content.ComponentName, android.app.admin.SystemUpdatePolicy);
method public void setTrustAgentConfiguration(android.content.ComponentName, android.content.ComponentName, android.os.PersistableBundle); method public void setTrustAgentConfiguration(android.content.ComponentName, android.content.ComponentName, android.os.PersistableBundle);

View File

@@ -5897,8 +5897,8 @@ package android.app.admin {
method public void setCrossProfileCallerIdDisabled(android.content.ComponentName, boolean); method public void setCrossProfileCallerIdDisabled(android.content.ComponentName, boolean);
method public boolean setDeviceInitializer(android.content.ComponentName, android.content.ComponentName, java.lang.String) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException; method public boolean setDeviceInitializer(android.content.ComponentName, android.content.ComponentName, java.lang.String) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException;
method public void setGlobalSetting(android.content.ComponentName, java.lang.String, java.lang.String); method public void setGlobalSetting(android.content.ComponentName, java.lang.String, java.lang.String);
method public boolean setKeyguardDisabled(android.content.ComponentName, boolean);
method public void setKeyguardDisabledFeatures(android.content.ComponentName, int); method public void setKeyguardDisabledFeatures(android.content.ComponentName, int);
method public boolean setKeyguardEnabledState(android.content.ComponentName, boolean);
method public void setLockTaskPackages(android.content.ComponentName, java.lang.String[]) throws java.lang.SecurityException; method public void setLockTaskPackages(android.content.ComponentName, java.lang.String[]) throws java.lang.SecurityException;
method public void setMasterVolumeMuted(android.content.ComponentName, boolean); method public void setMasterVolumeMuted(android.content.ComponentName, boolean);
method public void setMaximumFailedPasswordsForWipe(android.content.ComponentName, int); method public void setMaximumFailedPasswordsForWipe(android.content.ComponentName, int);
@@ -5924,7 +5924,7 @@ package android.app.admin {
method public void setRestrictionsProvider(android.content.ComponentName, android.content.ComponentName); method public void setRestrictionsProvider(android.content.ComponentName, android.content.ComponentName);
method public void setScreenCaptureDisabled(android.content.ComponentName, boolean); method public void setScreenCaptureDisabled(android.content.ComponentName, boolean);
method public void setSecureSetting(android.content.ComponentName, java.lang.String, java.lang.String); method public void setSecureSetting(android.content.ComponentName, java.lang.String, java.lang.String);
method public void setStatusBarEnabledState(android.content.ComponentName, boolean); method public boolean setStatusBarDisabled(android.content.ComponentName, boolean);
method public int setStorageEncryption(android.content.ComponentName, boolean); method public int setStorageEncryption(android.content.ComponentName, boolean);
method public void setSystemUpdatePolicy(android.content.ComponentName, android.app.admin.SystemUpdatePolicy); method public void setSystemUpdatePolicy(android.content.ComponentName, android.app.admin.SystemUpdatePolicy);
method public void setTrustAgentConfiguration(android.content.ComponentName, android.content.ComponentName, android.os.PersistableBundle); method public void setTrustAgentConfiguration(android.content.ComponentName, android.content.ComponentName, android.os.PersistableBundle);

View File

@@ -4294,14 +4294,14 @@ public class DevicePolicyManager {
* being disabled. * being disabled.
* *
* @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
* @param enabled New state of the keyguard. * @param disabled {@code true} disables the keyguard, {@code false} reenables it.
* *
* @return {@code false} if attempting to disable the keyguard while a lock password was in * @return {@code false} if attempting to disable the keyguard while a lock password was in
* place. {@code true} otherwise." * place. {@code true} otherwise.
*/ */
public boolean setKeyguardEnabledState(ComponentName admin, boolean enabled) { public boolean setKeyguardDisabled(ComponentName admin, boolean disabled) {
try { try {
return mService.setKeyguardEnabledState(admin, enabled); return mService.setKeyguardDisabled(admin, disabled);
} catch (RemoteException re) { } catch (RemoteException re) {
Log.w(TAG, "Failed talking with device policy service", re); Log.w(TAG, "Failed talking with device policy service", re);
return false; return false;
@@ -4309,18 +4309,22 @@ public class DevicePolicyManager {
} }
/** /**
* Called by device owner to set the enabled state of the status bar. Disabling the status * Called by device owner to disable the status bar. Disabling the status bar blocks
* bar blocks notifications, quick settings and other screen overlays that allow escaping from * notifications, quick settings and other screen overlays that allow escaping from
* a single use device. * a single use device.
* *
* @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
* @param enabled New state of the status bar. * @param disabled {@code true} disables the status bar, {@code false} reenables it.
*
* @return {@code false} if attempting to disable the status bar failed.
* {@code true} otherwise.
*/ */
public void setStatusBarEnabledState(ComponentName admin, boolean enabled) { public boolean setStatusBarDisabled(ComponentName admin, boolean disabled) {
try { try {
mService.setStatusBarEnabledState(admin, enabled); return mService.setStatusBarDisabled(admin, disabled);
} catch (RemoteException re) { } catch (RemoteException re) {
Log.w(TAG, "Failed talking with device policy service", re); Log.w(TAG, "Failed talking with device policy service", re);
return false;
} }
} }

View File

@@ -224,8 +224,8 @@ interface IDevicePolicyManager {
void setSystemUpdatePolicy(in ComponentName who, in PersistableBundle policy); void setSystemUpdatePolicy(in ComponentName who, in PersistableBundle policy);
PersistableBundle getSystemUpdatePolicy(); PersistableBundle getSystemUpdatePolicy();
boolean setKeyguardEnabledState(in ComponentName admin, boolean enabled); boolean setKeyguardDisabled(in ComponentName admin, boolean disabled);
void setStatusBarEnabledState(in ComponentName who, boolean enabled); boolean setStatusBarDisabled(in ComponentName who, boolean disabled);
boolean getDoNotAskCredentialsOnBoot(); boolean getDoNotAskCredentialsOnBoot();
void notifyPendingSystemUpdate(in long updateReceivedTime); void notifyPendingSystemUpdate(in long updateReceivedTime);

View File

@@ -161,7 +161,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
private static final String TAG_STATUS_BAR = "statusbar"; private static final String TAG_STATUS_BAR = "statusbar";
private static final String ATTR_ENABLED = "enabled"; private static final String ATTR_DISABLED = "disabled";
private static final String DO_NOT_ASK_CREDENTIALS_ON_BOOT_XML = private static final String DO_NOT_ASK_CREDENTIALS_ON_BOOT_XML =
"do-not-ask-credentials-on-boot"; "do-not-ask-credentials-on-boot";
@@ -313,7 +313,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
// This is the list of component allowed to start lock task mode. // This is the list of component allowed to start lock task mode.
List<String> mLockTaskPackages = new ArrayList<>(); List<String> mLockTaskPackages = new ArrayList<>();
boolean mStatusBarEnabledState = true; boolean mStatusBarDisabled = false;
ComponentName mRestrictionsProvider; ComponentName mRestrictionsProvider;
@@ -1476,9 +1476,9 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
out.endTag(null, TAG_LOCK_TASK_COMPONENTS); out.endTag(null, TAG_LOCK_TASK_COMPONENTS);
} }
if (!policy.mStatusBarEnabledState) { if (policy.mStatusBarDisabled) {
out.startTag(null, TAG_STATUS_BAR); out.startTag(null, TAG_STATUS_BAR);
out.attribute(null, ATTR_ENABLED, Boolean.toString(policy.mStatusBarEnabledState)); out.attribute(null, ATTR_DISABLED, Boolean.toString(policy.mStatusBarDisabled));
out.endTag(null, TAG_STATUS_BAR); out.endTag(null, TAG_STATUS_BAR);
} }
@@ -1615,8 +1615,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
} else if (TAG_LOCK_TASK_COMPONENTS.equals(tag)) { } else if (TAG_LOCK_TASK_COMPONENTS.equals(tag)) {
policy.mLockTaskPackages.add(parser.getAttributeValue(null, "name")); policy.mLockTaskPackages.add(parser.getAttributeValue(null, "name"));
} else if (TAG_STATUS_BAR.equals(tag)) { } else if (TAG_STATUS_BAR.equals(tag)) {
policy.mStatusBarEnabledState = Boolean.parseBoolean( policy.mStatusBarDisabled = Boolean.parseBoolean(
parser.getAttributeValue(null, ATTR_ENABLED)); parser.getAttributeValue(null, ATTR_DISABLED));
} else if (DO_NOT_ASK_CREDENTIALS_ON_BOOT_XML.equals(tag)) { } else if (DO_NOT_ASK_CREDENTIALS_ON_BOOT_XML.equals(tag)) {
policy.doNotAskCredentialsOnBoot = true; policy.doNotAskCredentialsOnBoot = true;
} else { } else {
@@ -1678,8 +1678,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
updateMaximumTimeToLockLocked(policy); updateMaximumTimeToLockLocked(policy);
addDeviceInitializerToLockTaskPackagesLocked(userHandle); addDeviceInitializerToLockTaskPackagesLocked(userHandle);
updateLockTaskPackagesLocked(policy.mLockTaskPackages, userHandle); updateLockTaskPackagesLocked(policy.mLockTaskPackages, userHandle);
if (!policy.mStatusBarEnabledState) { if (policy.mStatusBarDisabled) {
setStatusBarEnabledStateInternal(policy.mStatusBarEnabledState, userHandle); setStatusBarDisabledInternal(policy.mStatusBarDisabled, userHandle);
} }
updatePreferredSetupActivityLocked(userHandle); updatePreferredSetupActivityLocked(userHandle);
} }
@@ -4275,7 +4275,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
DevicePolicyData policy = getUserData(userId); DevicePolicyData policy = getUserData(userId);
policy.mPermissionPolicy = DevicePolicyManager.PERMISSION_POLICY_PROMPT; policy.mPermissionPolicy = DevicePolicyManager.PERMISSION_POLICY_PROMPT;
policy.mDelegatedCertInstallerPackage = null; policy.mDelegatedCertInstallerPackage = null;
policy.mStatusBarEnabledState = true; policy.mStatusBarDisabled = false;
saveSettingsLocked(userId); saveSettingsLocked(userId);
long ident = Binder.clearCallingIdentity(); long ident = Binder.clearCallingIdentity();
@@ -6026,7 +6026,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
} }
@Override @Override
public boolean setKeyguardEnabledState(ComponentName who, boolean enabled) { public boolean setKeyguardDisabled(ComponentName who, boolean disabled) {
Preconditions.checkNotNull(who, "ComponentName is null"); Preconditions.checkNotNull(who, "ComponentName is null");
synchronized (this) { synchronized (this) {
getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER); getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
@@ -6037,10 +6037,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
long ident = Binder.clearCallingIdentity(); long ident = Binder.clearCallingIdentity();
try { try {
// disallow disabling the keyguard if a password is currently set // disallow disabling the keyguard if a password is currently set
if (!enabled && utils.isSecure(userId)) { if (disabled && utils.isSecure(userId)) {
return false; return false;
} }
utils.setLockScreenDisabled(!enabled, userId); utils.setLockScreenDisabled(disabled, userId);
} finally { } finally {
Binder.restoreCallingIdentity(ident); Binder.restoreCallingIdentity(ident);
} }
@@ -6048,35 +6048,40 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
} }
@Override @Override
public void setStatusBarEnabledState(ComponentName who, boolean enabled) { public boolean setStatusBarDisabled(ComponentName who, boolean disabled) {
int userId = UserHandle.getCallingUserId(); int userId = UserHandle.getCallingUserId();
synchronized (this) { synchronized (this) {
getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER); getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
DevicePolicyData policy = getUserData(userId); DevicePolicyData policy = getUserData(userId);
if (policy.mStatusBarEnabledState != enabled) { if (policy.mStatusBarDisabled != disabled) {
policy.mStatusBarEnabledState = enabled; if (!setStatusBarDisabledInternal(disabled, userId)) {
setStatusBarEnabledStateInternal(enabled, userId); return false;
}
policy.mStatusBarDisabled = disabled;
saveSettingsLocked(userId); saveSettingsLocked(userId);
} }
} }
return true;
} }
private void setStatusBarEnabledStateInternal(boolean enabled, int userId) { private boolean setStatusBarDisabledInternal(boolean disabled, int userId) {
long ident = Binder.clearCallingIdentity(); long ident = Binder.clearCallingIdentity();
try { try {
IStatusBarService statusBarService = IStatusBarService.Stub.asInterface( IStatusBarService statusBarService = IStatusBarService.Stub.asInterface(
ServiceManager.checkService(Context.STATUS_BAR_SERVICE)); ServiceManager.checkService(Context.STATUS_BAR_SERVICE));
if (statusBarService != null) { if (statusBarService != null) {
int flags1 = enabled ? StatusBarManager.DISABLE_NONE : STATUS_BAR_DISABLE_MASK; int flags1 = disabled ? STATUS_BAR_DISABLE_MASK : StatusBarManager.DISABLE_NONE;
int flags2 = enabled ? StatusBarManager.DISABLE2_NONE : STATUS_BAR_DISABLE2_MASK; int flags2 = disabled ? STATUS_BAR_DISABLE2_MASK : StatusBarManager.DISABLE2_NONE;
statusBarService.disableForUser(flags1, mToken, mContext.getPackageName(), userId); statusBarService.disableForUser(flags1, mToken, mContext.getPackageName(), userId);
statusBarService.disable2ForUser(flags2, mToken, mContext.getPackageName(), userId); statusBarService.disable2ForUser(flags2, mToken, mContext.getPackageName(), userId);
return true;
} }
} catch (RemoteException e) { } catch (RemoteException e) {
Slog.e(LOG_TAG, "Failed to disable the status bar", e); Slog.e(LOG_TAG, "Failed to disable the status bar", e);
} finally { } finally {
Binder.restoreCallingIdentity(ident); Binder.restoreCallingIdentity(ident);
} }
return false;
} }
/** /**