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

Commit 03aac47f authored by Danny Baumann's avatar Danny Baumann Committed by Michael Bestas
Browse files

CameraServiceProxy: Loosen UID check conditionally

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

Change-Id: I34e9ddb49adc78ba0589e3d64918eca7d675ec98
parent d4f2369d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -18,4 +18,7 @@
    <!-- Button backlight -->
    <integer name="config_buttonBrightnessSettingDefault">255</integer>
    <bool name="config_deviceHasVariableButtonBrightness">false</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
@@ -23,4 +23,7 @@
    <!-- Button backlight -->
    <java-symbol type="integer" name="config_buttonBrightnessSettingDefault" />
    <java-symbol type="bool" name="config_deviceHasVariableButtonBrightness" />

    <!-- 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
@@ -123,6 +123,7 @@ public class CameraServiceProxy extends SystemService

    private final @NfcNotifyState int mNotifyNfc;
    private boolean mLastNfcPollState = true;
    private final boolean mAllowMediaUid;

    /**
     * Structure to track camera usage
@@ -192,7 +193,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;
@@ -203,7 +205,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;
@@ -230,6 +233,8 @@ public class CameraServiceProxy extends SystemService
        }
        mNotifyNfc = notifyNfc;
        if (DEBUG) Slog.v(TAG, "Notify NFC state is " + nfcNotifyToString(mNotifyNfc));
        mAllowMediaUid = mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_allowMediaUidForCameraServiceProxy);
    }

    @Override