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

Commit 528699bd authored by Nishith  Khanna's avatar Nishith Khanna
Browse files

Merge remote-tracking branch 'origin/lineage-19.1' into v1-s

parents e00dfff1 b24ae4fe
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -222,7 +222,8 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession
        } else if (request.isReprocess() && !isReprocessable()) {
            throw new IllegalArgumentException("this capture session cannot handle reprocess " +
                    "requests");
        } else if (request.isReprocess() && request.getReprocessableSessionId() != mId) {
        } else if (!mDeviceImpl.isPrivilegedApp() &&
                request.isReprocess() && request.getReprocessableSessionId() != mId) {
            throw new IllegalArgumentException("capture request was created for another session");
        }
    }
+35 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.annotation.NonNull;
import android.content.Context;
import android.graphics.ImageFormat;
import android.hardware.ICameraService;
import android.app.ActivityThread;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCaptureSession;
import android.hardware.camera2.CameraCharacteristics;
@@ -53,6 +54,8 @@ import android.os.Looper;
import android.os.RemoteException;
import android.os.ServiceSpecificException;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.text.TextUtils;
import android.util.Log;
import android.util.Range;
import android.util.Size;
@@ -151,6 +154,7 @@ public class CameraDeviceImpl extends CameraDevice
    private int mNextSessionId = 0;

    private final int mAppTargetSdkVersion;
    private boolean mIsPrivilegedApp = false;

    private ExecutorService mOfflineSwitchService;
    private CameraOfflineSessionImpl mOfflineSessionImpl;
@@ -301,6 +305,7 @@ public class CameraDeviceImpl extends CameraDevice
        } else {
            mTotalPartialCount = partialCount;
        }
        mIsPrivilegedApp = checkPrivilegedAppList();
    }

    public CameraDeviceCallbacks getCallbacks() {
@@ -1503,6 +1508,27 @@ public class CameraDeviceImpl extends CameraDevice
        return false;
    }

    private boolean checkPrivilegedAppList() {
        String packageName = ActivityThread.currentOpPackageName();
        String packageList = SystemProperties.get("persist.vendor.camera.privapp.list");

        if (packageList.length() > 0) {
            TextUtils.StringSplitter splitter = new TextUtils.SimpleStringSplitter(',');
            splitter.setString(packageList);
            for (String str : splitter) {
                if (packageName.equals(str)) {
                    return true;
                }
            }
        }

        return false;
    }

    public boolean isPrivilegedApp() {
        return mIsPrivilegedApp;
    }

    private void checkInputConfiguration(InputConfiguration inputConfig) {
        if (inputConfig == null) {
            return;
@@ -1540,6 +1566,15 @@ public class CameraDeviceImpl extends CameraDevice
                        inputConfig.getWidth() + "x" + inputConfig.getHeight() + " is not valid");
            }
        } else {
            /*
             * don't check input format and size,
             * if the package name is in the white list
             */
            if (isPrivilegedApp()) {
                Log.w(TAG, "ignore input format/size check for white listed app");
                return;
            }

            if (!checkInputConfigurationWithStreamConfigurations(inputConfig, /*maxRes*/false) &&
                    !checkInputConfigurationWithStreamConfigurations(inputConfig, /*maxRes*/true)) {
                throw new IllegalArgumentException("Input config with format " +