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

Commit d7ccae9b authored by Sai Kumar Sanagavarapu's avatar Sai Kumar Sanagavarapu Committed by Jan Altensen
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 599b3c15
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -20,15 +20,20 @@ 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.content.res.Resources;
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;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
@@ -241,6 +246,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());
@@ -293,6 +303,19 @@ public class SurfaceUtils {
        }
    }

    private static boolean isPrivilegedApp() {
        String packageName = ActivityThread.currentOpPackageName();
        List<String> packageList = new ArrayList<>(Arrays.asList(
                SystemProperties.get("persist.vendor.camera.privapp.list", ",").split(",")));

        // Append packages from lineage-sdk resources
        Resources res = ActivityThread.currentApplication().getResources();
        packageList.addAll(Arrays.asList(res.getStringArray(
                org.lineageos.platform.internal.R.array.config_cameraHFRPrivAppList)));

        return packageList.contains(packageName);
    }

    private static native int nativeDetectSurfaceType(Surface surface);

    private static native int nativeDetectSurfaceDataspace(Surface surface);