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

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

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

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


            mDeviceIdList = new ArrayList<String>();
            mDeviceIdList = new ArrayList<String>();
            CameraMetadataNative info = new CameraMetadataNative();
            for (int i = 0; i < numCameras; ++i) {
            for (int i = 0; i < numCameras; ++i) {
                // Non-removable cameras use integers starting at 0 for their
                // Non-removable cameras use integers starting at 0 for their
                // identifiers
                // 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));
                    mDeviceIdList.add(String.valueOf(i));
                }
                }
            }


        }
        }
        return mDeviceIdList;
        return mDeviceIdList;