Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 00a9b890 authored by Clara Bayarri's avatar Clara Bayarri
Browse files

Protect TrustManager.setDeviceLockedForUser with permission

Bug: 26535793
Change-Id: I172f1ec7d9285213ecd70564728c7328a3a675ff
parent 206747d9
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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);
+1 −0
Original line number Diff line number Diff line
@@ -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();
        }