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

Commit 92add565 authored by Gaoxiang Chen's avatar Gaoxiang Chen Committed by Arne Coucheron
Browse files

Camera: ignore torch status update for aux or compsite camera

Issue:
  we only expose aux and composite camera ids to whitelist app,
  but don't check the whitelist in torch status update.
  So for apps not in whitelist like CTS,
  they might receive extra unexpected torch status update,
  from aux and composite camera, which could cause CTS failure.

Fix:
  Also ignore torch status update, if app not in whitelist.
  It can fixe CTS issues in FlashlightTest.java.

CRs-Fixed: 2033688
Change-Id: I308bccfc027017b590f9f91089d644f7d8a206ff
parent 5b410f05
Loading
Loading
Loading
Loading
+45 −0
Original line number Diff line number Diff line
@@ -958,6 +958,26 @@ public final class CameraManager {
                    throw new IllegalArgumentException("cameraId was null");
                }

                /* Force to expose only two cameras
                 * if the package name does not falls in this bucket
                 */
                boolean exposeAuxCamera = false;
                String packageName = ActivityThread.currentOpPackageName();
                String packageList = SystemProperties.get("camera.aux.packagelist");
                if (packageList.length() > 0) {
                    TextUtils.StringSplitter splitter = new TextUtils.SimpleStringSplitter(',');
                    splitter.setString(packageList);
                    for (String str : splitter) {
                        if (packageName.equals(str)) {
                            exposeAuxCamera = true;
                            break;
                        }
                    }
                }
                if (exposeAuxCamera == false && (Integer.parseInt(cameraId) >= 2)) {
                    throw new IllegalArgumentException("invalid cameraId");
                }

                ICameraService cameraService = getCameraService();
                if (cameraService == null) {
                    throw new CameraAccessException(CameraAccessException.CAMERA_DISCONNECTED,
@@ -1171,6 +1191,31 @@ public final class CameraManager {
                        String.format("Camera id %s has torch status changed to 0x%x", id, status));
            }

            /* Force to ignore the aux or composite camera torch status update
             * if the package name does not falls in this bucket
             */
            boolean exposeMonoCamera = false;
            String packageName = ActivityThread.currentOpPackageName();
            String packageList = SystemProperties.get("camera.aux.packagelist");
            if (packageList.length() > 0) {
                TextUtils.StringSplitter splitter = new TextUtils.SimpleStringSplitter(',');
                splitter.setString(packageList);
                for (String str : splitter) {
                    if (packageName.equals(str)) {
                        exposeMonoCamera = true;
                        break;
                    }
                }
            }

            if (exposeMonoCamera == false) {
                if (Integer.parseInt(id) >= 2) {
                    Log.w(TAG, "ignore the torch status update of camera: " + id);
                    return;
                }
            }


            if (!validTorchStatus(status)) {
                Log.e(TAG, String.format("Ignoring invalid device %s torch status 0x%x", id,
                                status));