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

Commit 202d3959 authored by Austin Borger's avatar Austin Borger Committed by Android (Google) Code Review
Browse files

Merge "CameraService: Check if the camera is disabled via device policy by user."

parents 807626ae d2fb6ce7
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -582,13 +582,18 @@ public class CameraServiceProxy extends SystemService
        }

        @Override
        public boolean isCameraDisabled() {
        public boolean isCameraDisabled(int userId) {
            DevicePolicyManager dpm = mContext.getSystemService(DevicePolicyManager.class);
            if (dpm == null) {
                Slog.e(TAG, "Failed to get the device policy manager service");
                return false;
            }
            return dpm.getCameraDisabled(null);
            try {
                return dpm.getCameraDisabled(null, userId);
            } catch (Exception e) {
                e.printStackTrace();
                return false;
            }
        }
    };

+6 −1
Original line number Diff line number Diff line
@@ -8144,7 +8144,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        }
        final CallerIdentity caller = getCallerIdentity(who);
        Preconditions.checkCallAuthorization(hasFullCrossUsersPermission(caller, userHandle));
        Preconditions.checkCallAuthorization(hasFullCrossUsersPermission(caller, userHandle)
                || isCameraServerUid(caller));
        if (parent) {
            Preconditions.checkCallAuthorization(
@@ -9666,6 +9667,10 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        return UserHandle.isSameApp(caller.getUid(), Process.SHELL_UID);
    }
    private boolean isCameraServerUid(CallerIdentity caller) {
        return UserHandle.isSameApp(caller.getUid(), Process.CAMERASERVER_UID);
    }
    private @UserIdInt int getCurrentForegroundUserId() {
        try {
            UserInfo currentUser = mInjector.getIActivityManager().getCurrentUser();