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

Commit 3166593f authored by Dan Sandler's avatar Dan Sandler
Browse files

Fix NPE when the vr manager isn't around at first.

There's a race condition when grabbing the VR service during
ImmersiveModeConfirmation's constructor since the window
manager allocates the ImmersiveModeConfirmation in its own
init(); vr may still be starting up at that time.

Change-Id: Ic0aa0fbf8fd087f01f4690c14e1c68f0670b0bc0
Fixes: 28159168
parent a6dea121
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -80,8 +80,6 @@ public class ImmersiveModeConfirmation {
                .getInteger(R.integer.config_immersive_mode_confirmation_panic);
        mWindowManager = (WindowManager)
                mContext.getSystemService(Context.WINDOW_SERVICE);
        mVrManager = (IVrManager) IVrManager.Stub.asInterface(
                ServiceManager.getService(VrManagerService.VR_MANAGER_BINDER_SERVICE));
    }

    private long getNavBarExitDuration() {
@@ -121,9 +119,16 @@ public class ImmersiveModeConfirmation {

    private boolean getVrMode() {
        boolean vrMode = false;
        if (mVrManager == null) {
            // lazily grab this service since it may not be available at construction time
            mVrManager = (IVrManager) IVrManager.Stub.asInterface(
                ServiceManager.getService(VrManagerService.VR_MANAGER_BINDER_SERVICE));
        }
        if (mVrManager != null) {
            try {
                vrMode = mVrManager.getVrModeState();
            } catch (RemoteException ex) { }
        }
        return vrMode;
    }