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

Commit 546b62bf 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 60770752
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
@@ -101,6 +101,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
@@ -170,7 +171,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;
@@ -181,7 +183,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;
@@ -204,6 +207,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