OSDN Git Service

Protect TrustManager.setDeviceLockedForUser with permission
authorClara Bayarri <clarabayarri@google.com>
Wed, 13 Jan 2016 16:17:09 +0000 (16:17 +0000)
committerClara Bayarri <clarabayarri@google.com>
Fri, 15 Jan 2016 15:19:36 +0000 (15:19 +0000)
Bug: 26535793
Change-Id: I172f1ec7d9285213ecd70564728c7328a3a675ff

core/java/android/app/trust/TrustManager.java
services/core/java/com/android/server/trust/TrustManagerService.java

index ee591d3..88ba874 100644 (file)
@@ -16,7 +16,9 @@
 
 package android.app.trust;
 
+import android.Manifest;
 import android.annotation.IntDef;
+import android.annotation.RequiresPermission;
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.Looper;
@@ -54,9 +56,12 @@ public class TrustManager {
      * Changes the lock status for the given user. This is only applicable to Managed Profiles,
      * other users should be handled by Keyguard.
      *
+     * Requires the {@link android.Manifest.permission#ACCESS_KEYGUARD_SECURE_STORAGE} permission.
+     *
      * @param userId The id for the user to be locked/unlocked.
      * @param locked The value for that user's locked state.
      */
+    @RequiresPermission(Manifest.permission.ACCESS_KEYGUARD_SECURE_STORAGE)
     public void setDeviceLockedForUser(int userId, boolean locked) {
         try {
             mService.setDeviceLockedForUser(userId, locked);
index 42b8721..8cdff11 100644 (file)
@@ -778,6 +778,7 @@ public class TrustManagerService extends SystemService {
 
         @Override
         public void setDeviceLockedForUser(int userId, boolean value) {
+            enforceReportPermission();
             mHandler.obtainMessage(MSG_SET_DEVICE_LOCKED, value ? 1 : 0, userId)
                     .sendToTarget();
         }