am 654314ee: Merge "Camera2: return device list with the only supported device" into klp-dev
* commit '654314eedf642c01ea034a16d452272d9e4aab24': Camera2: return device list with the only supported device
This commit is contained in:
@@ -369,10 +369,30 @@ 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
|
||||
mDeviceIdList.add(String.valueOf(i));
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user