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

Commit 54f0c655 authored by Winson Chung's avatar Winson Chung
Browse files

Fixing NPE when updating controller state.

- Since registering the pinned stack listener is not synchronous,
  defer updating the controller state until the the listener is
  registered and we have the controller set.

Bug: 33271221
Test: Run on car_emulator_x86_64-userdebug

Change-Id: Ie122b475122bfd2c4ca6f8e439fefc2443a18a37
parent 803abe73
Loading
Loading
Loading
Loading
+18 −8
Original line number Diff line number Diff line
@@ -156,6 +156,10 @@ public class PipTouchHandler implements TunerService.Tunable {
        @Override
        public void onListenerRegistered(IPinnedStackController controller) {
            mPinnedStackController = controller;

            // Update the controller with the current tuner state
            setMinimizedState(mIsMinimized);
            setSnapToEdge(mEnableSnapToEdge);
        }

        @Override
@@ -353,24 +357,30 @@ public class PipTouchHandler implements TunerService.Tunable {
     */
    private void setSnapToEdge(boolean snapToEdge) {
        mSnapAlgorithm.setSnapToEdge(snapToEdge);

        if (mPinnedStackController != null) {
            try {
                mPinnedStackController.setSnapToEdge(snapToEdge);
            } catch (RemoteException e) {
                Log.e(TAG, "Could not set snap mode to edge", e);
            }
        }
    }

    /**
     * Sets the minimized state and notifies the controller.
     */
    private void setMinimizedState(boolean isMinimized) {
        mIsMinimized = isMinimized;

        if (mPinnedStackController != null) {
            try {
                mPinnedStackController.setIsMinimized(isMinimized);
            } catch (RemoteException e) {
                Log.e(TAG, "Could not set minimized state", e);
            }
        }
    }

    /**
     * @return whether the given {@param pinnedStackBounds} indicates the PIP should be minimized.