Camera: Handle ISE when device state manager is absent
The device state manager doesn't seem to be present on all devices. Catch any ISEs and handle this corner case appropriately. Bug: 202597641 Test: atest CtsGraphicsTestCases:android.graphics.cts.CameraVulkanGpuTest#testCameraImportAndRendering -- --module-parameter instant_app Change-Id: I6e6c7266b268835f3138cbb22a6f2df606742300
This commit is contained in:
@@ -110,8 +110,16 @@ public final class CameraManager {
|
||||
mHandlerThread.start();
|
||||
mHandler = new Handler(mHandlerThread.getLooper());
|
||||
mFoldStateListener = new FoldStateListener(context);
|
||||
context.getSystemService(DeviceStateManager.class)
|
||||
.registerCallback(new HandlerExecutor(mHandler), mFoldStateListener);
|
||||
try {
|
||||
context.getSystemService(DeviceStateManager.class)
|
||||
.registerCallback(new HandlerExecutor(mHandler), mFoldStateListener);
|
||||
} catch (IllegalStateException e) {
|
||||
Log.v(TAG, "Failed to register device state listener!");
|
||||
Log.v(TAG, "Device state dependent characteristics updates will not be functional!");
|
||||
mHandlerThread.quitSafely();
|
||||
mHandler = null;
|
||||
mFoldStateListener = null;
|
||||
}
|
||||
}
|
||||
|
||||
private HandlerThread mHandlerThread;
|
||||
@@ -177,7 +185,9 @@ public final class CameraManager {
|
||||
synchronized (mLock) {
|
||||
DeviceStateListener listener = chars.getDeviceStateListener();
|
||||
listener.onDeviceStateChanged(mFoldedDeviceState);
|
||||
mDeviceStateListeners.add(new WeakReference<>(listener));
|
||||
if (mFoldStateListener != null) {
|
||||
mDeviceStateListeners.add(new WeakReference<>(listener));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user