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

Commit 1672e8a3 authored by Winson Chung's avatar Winson Chung Committed by Android Build Coastguard Worker
Browse files

Fix an issue with nav bar translations not being updated



- There are flows where the shared taskbar state is updated prior
  to being destroyed, and not updated to the latest values when
  the taskbar is recreated.

  ie.
    unfolded -> lock screen -> LauncherTaskbarUiController's
      mTaskbarInAppDisplayProgress[SYSUI_SURFACE_PROGRESS_INDEX]
      is set to 1 due to the notif shade (lockscreen) showing.
      This is written into TaskbarSharedState's sysuiStateFlags
      and inAppDisplayProgressMultiPropValues.
    fold -> TaskbarActivityContext is destroyed
    unlock -> TaskbarManager and TaskbarSharedState's
      sysuiStateFlags are updated while the device is folded
    unfold -> TaskbarActivityContext is recreated and initialized
      which restores from the shared state's
      inAppDisplayProgressMultiPropValues. It also tries to reapply
      the shared state's sysuiStateFlags, but this doesn't update
      inAppDisplayProgressMultiPropValues because the state's
      "enabled" state is not updated (default is no flag set, and
      lockscreen sysui state is not set anymore).
    -> The restored inAppDisplayProgressMultiPropValues value
       results in the wrong translation.

- Note that after the above, the NavbarButtonsViewController state
  is actually correct and reflects the SysUI state, but the
  LauncherTaskbarUiController state is wrong.  This CL tries to
  manually update the ui controller to the correct state when it
  is recreated.
- CL also fixes a separate issue where LauncherTaskbarUIController
  could potentially overwrite the saved state progresses while
  restoring them due to the state callback being called

Bug: 283346744
Test: Unfold -> Lockscreen -> Fold -> Unlock -> Unfold and ensure
      the buttons are translated correctly



Signed-off-by: default avatarWinson Chung <winsonc@google.com>
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:ccd359d76c7f42d4fc799f19d54a66c7c2fa462a)
Merged-In: I43e473faf4fa2a493b9705506e3755df8f6264e7
Change-Id: I43e473faf4fa2a493b9705506e3755df8f6264e7
parent 1f6a5f50
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -50,6 +50,7 @@ import com.android.quickstep.util.GroupTask;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.RecentsView;


import java.io.PrintWriter;
import java.io.PrintWriter;
import java.util.Arrays;


/**
/**
 * A data source which integrates with a Launcher instance
 * A data source which integrates with a Launcher instance
@@ -105,6 +106,10 @@ public class LauncherTaskbarUIController extends TaskbarUIController {


        // Restore the in-app display progress from before Taskbar was recreated.
        // Restore the in-app display progress from before Taskbar was recreated.
        float[] prevProgresses = mControllers.getSharedState().inAppDisplayProgressMultiPropValues;
        float[] prevProgresses = mControllers.getSharedState().inAppDisplayProgressMultiPropValues;
        // Make a copy of the previous progress to set since updating the multiprop will update
        // the property which also calls onInAppDisplayProgressChanged() which writes the current
        // values into the shared state
        prevProgresses = Arrays.copyOf(prevProgresses, prevProgresses.length);
        for (int i = 0; i < prevProgresses.length; i++) {
        for (int i = 0; i < prevProgresses.length; i++) {
            mTaskbarInAppDisplayProgressMultiProp.get(i).setValue(prevProgresses[i]);
            mTaskbarInAppDisplayProgressMultiProp.get(i).setValue(prevProgresses[i]);
        }
        }
+9 −0
Original line number Original line Diff line number Diff line
@@ -923,6 +923,15 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
        insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION);
        insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION);
    }
    }


    /**
     * Called whenever a new ui controller is set, and should update anything that depends on the
     * ui controller.
     */
    public void onUiControllerChanged() {
        updateNavButtonInAppDisplayProgressForSysui();
        updateNavButtonTranslationY();
    }

    @Override
    @Override
    public void dumpLogs(String prefix, PrintWriter pw) {
    public void dumpLogs(String prefix, PrintWriter pw) {
        pw.println(prefix + "NavbarButtonsViewController:");
        pw.println(prefix + "NavbarButtonsViewController:");
+1 −3
Original line number Original line Diff line number Diff line
@@ -591,9 +591,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
     * Sets a new data-source for this taskbar instance
     * Sets a new data-source for this taskbar instance
     */
     */
    public void setUIController(@NonNull TaskbarUIController uiController) {
    public void setUIController(@NonNull TaskbarUIController uiController) {
        mControllers.uiController.onDestroy();
        mControllers.setUiController(uiController);
        mControllers.uiController = uiController;
        mControllers.uiController.init(mControllers);
    }
    }


    /**
    /**
+13 −0
Original line number Original line Diff line number Diff line
@@ -196,6 +196,19 @@ public class TaskbarControllers {
        mPostInitCallbacks.clear();
        mPostInitCallbacks.clear();
    }
    }


    /**
     * Sets the ui controller.
     */
    public void setUiController(@NonNull TaskbarUIController newUiController) {
        uiController.onDestroy();
        uiController = newUiController;
        uiController.init(this);
        uiController.updateStateForSysuiFlags(mSharedState.sysuiStateFlags);

        // Notify that the ui controller has changed
        navbarButtonsViewController.onUiControllerChanged();
    }

    @Nullable
    @Nullable
    public TaskbarSharedState getSharedState() {
    public TaskbarSharedState getSharedState() {
        // This should only be null if called before init() and after destroy().
        // This should only be null if called before init() and after destroy().