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

Commit 46d10aad authored by Winson Chung's avatar Winson Chung
Browse files

Add workaround to handle overlay package changes for non-primary users

- Workaround for b/132825155, trigger the recreation of the sysui fragments
  as it would for normal users when overlays for secondary users change.

Bug: 132825155
Test: Enter secondary user, repeatedly try switching nav bar modes and
      ensure the buttons update correctly

Change-Id: Iec758014ed9941abcb270a12e84ec2db4ff23dd6
parent 1bb7455f
Loading
Loading
Loading
Loading
+8 −11
Original line number Diff line number Diff line
@@ -156,10 +156,7 @@ public class FragmentHostManager {
     */
    protected void onConfigurationChanged(Configuration newConfig) {
        if (mConfigChanges.applyNewConfig(mContext.getResources())) {
            // Save the old state.
            Parcelable p = destroyFragmentHost();
            // Generate a new fragment host and restore its state.
            createFragmentHost(p);
            reloadFragments();
        } else {
            mFragments.dispatchConfigurationChanged(newConfig);
        }
@@ -217,6 +214,13 @@ public class FragmentHostManager {
        Dependency.get(FragmentService.class).removeAndDestroy(view);
    }

    public void reloadFragments() {
        // Save the old state.
        Parcelable p = destroyFragmentHost();
        // Generate a new fragment host and restore its state.
        createFragmentHost(p);
    }

    class HostCallbacks extends FragmentHostCallback<FragmentHostManager> {
        public HostCallbacks() {
            super(mContext, FragmentHostManager.this.mHandler, 0);
@@ -293,13 +297,6 @@ public class FragmentHostManager {
            reloadFragments();
        }

        private void reloadFragments() {
            // Save the old state.
            Parcelable p = destroyFragmentHost();
            // Generate a new fragment host and restore its state.
            createFragmentHost(p);
        }

        Fragment instantiate(Context context, String className, Bundle arguments) {
            Context extensionContext = mExtensionLookup.get(className);
            if (extensionContext != null) {
+11 −0
Original line number Diff line number Diff line
@@ -979,6 +979,17 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
    public void onNavigationModeChanged(int mode) {
        mNavBarMode = mode;
        updateScreenPinningGestures();

        // Workaround for b/132825155, for secondary users, we currently don't receive configuration
        // changes on overlay package change since SystemUI runs for the system user. In this case,
        // trigger a new configuration change to ensure that the nav bar is updated in the same way.
        int userId = ActivityManagerWrapper.getInstance().getCurrentUserId();
        if (userId != UserHandle.USER_SYSTEM) {
            mHandler.post(() -> {
                FragmentHostManager fragmentHost = FragmentHostManager.get(mNavigationBarView);
                fragmentHost.reloadFragments();
            });
        }
    }

    public void disableAnimationsDuringHide(long delay) {