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

Commit 276b3436 authored by Danny Baumann's avatar Danny Baumann Committed by Bruno Martins
Browse files

CameraServiceProxy: Loosen UID check conditionally

Also allow media UID for camera-in-mediaserver devices.

Change-Id: I34e9ddb49adc78ba0589e3d64918eca7d675ec98
parent 3cb28e02
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -36,4 +36,7 @@

    <!-- Whether to cleanup fingerprints upon connection to the daemon and when user switches -->
    <bool name="config_cleanupUnusedFingerprints">true</bool>

    <!-- Whether to allow process with media UID to access CameraServiceProxy -->
    <bool name="config_allowMediaUidForCameraServiceProxy">false</bool>
</resources>
+3 −0
Original line number Diff line number Diff line
@@ -36,4 +36,7 @@

    <!-- Whether to cleanup fingerprints upon connection to the daemon and when user switches -->
    <java-symbol type="bool" name="config_cleanupUnusedFingerprints" />

    <!-- Whether to allow process with media UID to access CameraServiceProxy -->
    <java-symbol type="bool" name="config_allowMediaUidForCameraServiceProxy" />
</resources>
+7 −2
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ public class CameraServiceProxy extends SystemService
    private static final IBinder nfcInterfaceToken = new Binder();

    private final boolean mNotifyNfc;
    private final boolean mAllowMediaUid;

    /**
     * Structure to track camera usage
@@ -165,7 +166,8 @@ public class CameraServiceProxy extends SystemService
    private final ICameraServiceProxy.Stub mCameraServiceProxy = new ICameraServiceProxy.Stub() {
        @Override
        public void pingForUserUpdate() {
            if (Binder.getCallingUid() != Process.CAMERASERVER_UID) {
            if (Binder.getCallingUid() != Process.CAMERASERVER_UID
                    && (!mAllowMediaUid || Binder.getCallingUid() != Process.MEDIA_UID)) {
                Slog.e(TAG, "Calling UID: " + Binder.getCallingUid() + " doesn't match expected " +
                        " camera service UID!");
                return;
@@ -176,7 +178,8 @@ public class CameraServiceProxy extends SystemService
        @Override
        public void notifyCameraState(String cameraId, int newCameraState, int facing,
                String clientName, int apiLevel) {
            if (Binder.getCallingUid() != Process.CAMERASERVER_UID) {
            if (Binder.getCallingUid() != Process.CAMERASERVER_UID
                    && (!mAllowMediaUid || Binder.getCallingUid() != Process.MEDIA_UID)) {
                Slog.e(TAG, "Calling UID: " + Binder.getCallingUid() + " doesn't match expected " +
                        " camera service UID!");
                return;
@@ -199,6 +202,8 @@ public class CameraServiceProxy extends SystemService

        mNotifyNfc = SystemProperties.getInt(NFC_NOTIFICATION_PROP, 0) > 0;
        if (DEBUG) Slog.v(TAG, "Notify NFC behavior is " + (mNotifyNfc ? "active" : "disabled"));
        mAllowMediaUid = mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_allowMediaUidForCameraServiceProxy);
    }

    @Override