Protect TrustManager.setDeviceLockedForUser with permission

Bug: 26535793
Change-Id: I172f1ec7d9285213ecd70564728c7328a3a675ff
This commit is contained in:
Clara Bayarri
2016-01-13 16:17:09 +00:00
parent 206747d9f6
commit 00a9b89085
2 changed files with 6 additions and 0 deletions

View 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);

View 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();
}