summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Alex Kershaw <alexkershaw@google.com> 2018-03-16 14:31:04 +0000
committer Alex Kershaw <alexkershaw@google.com> 2018-03-19 10:57:12 +0000
commit61ec825598261a5e1061e3eadb986bf3463a8443 (patch)
treecf4ce1b4907fb9bb1de8ca6202fed8d437dcfd00
parentd65bb202834d4e636b160feff28c8b86f63ff8e6 (diff)
Fix Javadoc of DevicePolicyManager#setStorageEncryption to reflect that
it's a no-op (and silent fail) when called from a non-system user. DevicePolicyManagerService#setStorageEncryption also has its Javadoc fixed. Bug: 74591983 Change-Id: Ie191ad255cbfcade921d172641f134d6c49a17b1 Fixes: 74591983 Test: N/A - just javadoc changed
-rw-r--r--core/java/android/app/admin/DevicePolicyManager.java13
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java9
2 files changed, 14 insertions, 8 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 6511f214f19d..02e77df7a1ba 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -3769,7 +3769,7 @@ public class DevicePolicyManager {
/**
* Called by an application that is administering the device to request that the storage system
- * be encrypted.
+ * be encrypted. Does nothing if the caller is on a secondary user or a managed profile.
* <p>
* When multiple device administrators attempt to control device encryption, the most secure,
* supported setting will always be used. If any device administrator requests device
@@ -3791,10 +3791,13 @@ public class DevicePolicyManager {
*
* @param admin Which {@link DeviceAdminReceiver} this request is associated with.
* @param encrypt true to request encryption, false to release any previous request
- * @return the new request status (for all active admins) - will be one of
- * {@link #ENCRYPTION_STATUS_UNSUPPORTED}, {@link #ENCRYPTION_STATUS_INACTIVE}, or
- * {@link #ENCRYPTION_STATUS_ACTIVE}. This is the value of the requests; Use
- * {@link #getStorageEncryptionStatus()} to query the actual device state.
+ * @return the new total request status (for all active admins), or {@link
+ * DevicePolicyManager#ENCRYPTION_STATUS_UNSUPPORTED} if called for a non-system user.
+ * Will be one of {@link #ENCRYPTION_STATUS_UNSUPPORTED}, {@link
+ * #ENCRYPTION_STATUS_INACTIVE}, or {@link #ENCRYPTION_STATUS_ACTIVE}. This is the value
+ * of the requests; use {@link #getStorageEncryptionStatus()} to query the actual device
+ * state.
+ *
* @throws SecurityException if {@code admin} is not an active administrator or does not use
* {@link DeviceAdminInfo#USES_ENCRYPTED_STORAGE}
*/
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index c7ae5704ae50..3dc9141325d3 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -6466,8 +6466,11 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
}
/**
- * Set the storage encryption request for a single admin. Returns the new total request
- * status (for all admins).
+ * Called by an application that is administering the device to request that the storage system
+ * be encrypted. Does nothing if the caller is on a secondary user or a managed profile.
+ *
+ * @return the new total request status (for all admins), or {@link
+ * DevicePolicyManager#ENCRYPTION_STATUS_UNSUPPORTED} if called for a non-system user
*/
@Override
public int setStorageEncryption(ComponentName who, boolean encrypt) {
@@ -6482,7 +6485,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
if (userHandle != UserHandle.USER_SYSTEM) {
Slog.w(LOG_TAG, "Only owner/system user is allowed to set storage encryption. User "
+ UserHandle.getCallingUserId() + " is not permitted.");
- return 0;
+ return DevicePolicyManager.ENCRYPTION_STATUS_UNSUPPORTED;
}
ActiveAdmin ap = getActiveAdminForCallerLocked(who,