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

Unverified Commit a25a614c authored by Sai Kumar Sanagavarapu's avatar Sai Kumar Sanagavarapu Committed by Michael Bestas
Browse files

camera: Skip HFR checks for privileged apps.

Issue: HAL3 supports HFR only if its greater than or equal
       to 120fps.

Fix: Skip the checks to allow HFR 60 and 90 fps in HAL3 for
     specific apps.
     The following property need to be set to allow these
     HFR configurations :
     adb shell setprop persist.camera.privapp.list <pack1,pack2,etc>

Additionally allows extension of the privapp list via sdk resources

Change-Id: I5f3bc94bea60dbe03284de39cd4280f67df8b015
CRs-Fixed: 2258892
parent ea6d28e1
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -20,11 +20,14 @@ import static android.system.OsConstants.EINVAL;

import static com.android.internal.util.Preconditions.checkNotNull;

import android.app.ActivityThread;
import android.compat.annotation.UnsupportedAppUsage;
import android.graphics.ImageFormat;
import android.graphics.PixelFormat;
import android.hardware.HardwareBuffer;
import android.hardware.camera2.params.StreamConfigurationMap;
import android.os.SystemProperties;
import android.text.TextUtils;
import android.util.Range;
import android.util.Size;
import android.view.Surface;
@@ -263,6 +266,11 @@ public class SurfaceUtils {
                    + " the size must be 1 or 2");
        }

        if (isPrivilegedApp()) {
            //skip checks for privileged apps
            return;
        }

        List<Size> highSpeedSizes = null;
        if (fpsRange == null) {
            highSpeedSizes = Arrays.asList(config.getHighSpeedVideoSizes());
@@ -325,4 +333,21 @@ public class SurfaceUtils {
            /*out*/int[/*2*/] dimens);

    private static native long nativeGetSurfaceId(Surface surface);

    private static boolean isPrivilegedApp() {
        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;
    }
}