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

Unverified Commit ea6d28e1 authored by Gaoxiang Chen's avatar Gaoxiang Chen Committed by Michael Bestas
Browse files

Camera: Skip stream size check for whitelisted apps.

Issue:
For quadracfa capture, Blob/YUV output streams need to be
configured with custom dimensions which will not be
available in advertised stream configurations map.

Fix:
Skip the stream size check for whitelisted apps to allow
configuration of streams with custom dimensions.

Also, additionally, remove session id check so that
buffers from one session can be passed on to another
session for reprocess.

Setprop to be used:
adb shell setprop persist.vendor.camera.privapp.list <pack1,pack2>

CRs-Fixed: 2075934
Change-Id: Ie9c950fdc4e1675d19c38630d7063ac9d7c9d5b1
parent 3d96e789
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
@@ -21,6 +21,7 @@ import static com.android.internal.util.function.pooled.PooledLambda.obtainRunna
import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityThread;
import android.app.compat.CompatChanges;
import android.compat.annotation.ChangeId;
import android.compat.annotation.EnabledSince;
@@ -65,6 +66,8 @@ import android.os.Parcelable;
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;
@@ -194,6 +197,7 @@ public class CameraDeviceImpl extends CameraDevice
    private int mNextSessionId = 0;

    private final int mAppTargetSdkVersion;
    private boolean mIsPrivilegedApp = false;

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

    /**
@@ -1873,6 +1878,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 boolean checkSurfaceSizesCompatible(List<OutputConfiguration> outputConfigs) {
        for (OutputConfiguration outputConfig : outputConfigs) {
            Size configuredSize = outputConfig.getConfiguredSize();
@@ -1931,6 +1957,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 " +