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

Commit 47cae0f0 authored by Emilian Peev's avatar Emilian Peev
Browse files

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
parent af816a74
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -110,8 +110,16 @@ public final class CameraManager {
        mHandlerThread.start();
        mHandler = new Handler(mHandlerThread.getLooper());
        mFoldStateListener = new FoldStateListener(context);
        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,9 +185,11 @@ public final class CameraManager {
        synchronized (mLock) {
            DeviceStateListener listener = chars.getDeviceStateListener();
            listener.onDeviceStateChanged(mFoldedDeviceState);
            if (mFoldStateListener != null) {
                mDeviceStateListeners.add(new WeakReference<>(listener));
            }
        }
    }

    /**
     * Return the list of currently connected camera devices by identifier, including