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

Commit 5af55d7a authored by Zhijun He's avatar Zhijun He Committed by Android Git Automerger
Browse files

am 69c30a49: am a5761bd1: am 654314ee: Merge "Camera2: return device list with...

am 69c30a49: am a5761bd1: am 654314ee: Merge "Camera2: return device list with the only supported device" into klp-dev

* commit '69c30a49':
  Camera2: return device list with the only supported device
parents b3c7f0e5 69c30a49
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -369,11 +369,31 @@ public final class CameraManager {
            }

            mDeviceIdList = new ArrayList<String>();
            CameraMetadataNative info = new CameraMetadataNative();
            for (int i = 0; i < numCameras; ++i) {
                // Non-removable cameras use integers starting at 0 for their
                // identifiers
                boolean isDeviceSupported = false;
                try {
                    mCameraService.getCameraCharacteristics(i, info);
                    if (!info.isEmpty()) {
                        isDeviceSupported = true;
                    } else {
                        throw new AssertionError("Expected to get non-empty characteristics");
                    }
                } catch(IllegalArgumentException  e) {
                    // Got a BAD_VALUE from service, meaning that this
                    // device is not supported.
                } catch(CameraRuntimeException e) {
                    throw e.asChecked();
                } catch(RemoteException e) {
                    // impossible
                }

                if (isDeviceSupported) {
                    mDeviceIdList.add(String.valueOf(i));
                }
            }

        }
        return mDeviceIdList;