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

Commit 107f96c0 authored by Sam Dubey's avatar Sam Dubey Committed by Android (Google) Code Review
Browse files

Merge "[conflict] Merge "Use current user Context to generate NavBar layout"...

Merge "[conflict] Merge "Use current user Context to generate NavBar layout" into tm-dev am: a7abdb12 am: fb21f9ae"
parents 7615e236 b372cc72
Loading
Loading
Loading
Loading
+15 −10
Original line number Diff line number Diff line
@@ -129,6 +129,7 @@ import com.android.systemui.navigationbar.gestural.QuickswitchOrientedNavHandle;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.recents.OverviewProxyService;
import com.android.systemui.recents.Recents;
import com.android.systemui.settings.UserContextProvider;
import com.android.systemui.shared.recents.utilities.Utilities;
import com.android.systemui.shared.rotation.RotationButton;
import com.android.systemui.shared.rotation.RotationButtonController;
@@ -210,6 +211,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
    private final NavBarHelper mNavBarHelper;
    private final NotificationShadeDepthController mNotificationShadeDepthController;
    private final OnComputeInternalInsetsListener mOnComputeInternalInsetsListener;
    private final UserContextProvider mUserContextProvider;
    private NavigationBarFrame mFrame;

    private @WindowVisibleState int mNavigationBarWindowState = WINDOW_STATE_SHOWING;
@@ -522,7 +524,8 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
            DeviceConfigProxy deviceConfigProxy,
            NavigationBarTransitions navigationBarTransitions,
            EdgeBackGestureHandler edgeBackGestureHandler,
            Optional<BackAnimation> backAnimation) {
            Optional<BackAnimation> backAnimation,
            UserContextProvider userContextProvider) {
        super(navigationBarView);
        mFrame = navigationBarFrame;
        mContext = context;
@@ -559,6 +562,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
        mAutoHideControllerFactory = autoHideControllerFactory;
        mTelecomManagerOptional = telecomManagerOptional;
        mInputMethodManager = inputMethodManager;
        mUserContextProvider = userContextProvider;

        mOnComputeInternalInsetsListener = info -> {
            // When the nav bar is in 2-button or 3-button mode, or when IME is visible in fully
@@ -1550,35 +1554,36 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
        int insetsHeight = -1;
        int gravity = Gravity.BOTTOM;
        boolean navBarCanMove = true;
        final Context userContext = mUserContextProvider.createCurrentUserContext(mContext);
        if (mWindowManager != null && mWindowManager.getCurrentWindowMetrics() != null) {
            Rect displaySize = mWindowManager.getCurrentWindowMetrics().getBounds();
            navBarCanMove = displaySize.width() != displaySize.height()
                    && mContext.getResources().getBoolean(
                    && userContext.getResources().getBoolean(
                    com.android.internal.R.bool.config_navBarCanMove);
        }
        if (!navBarCanMove) {
            height = mContext.getResources().getDimensionPixelSize(
            height = userContext.getResources().getDimensionPixelSize(
                    com.android.internal.R.dimen.navigation_bar_frame_height);
            insetsHeight = mContext.getResources().getDimensionPixelSize(
            insetsHeight = userContext.getResources().getDimensionPixelSize(
                    com.android.internal.R.dimen.navigation_bar_height);
        } else {
            switch (rotation) {
                case ROTATION_UNDEFINED:
                case Surface.ROTATION_0:
                case Surface.ROTATION_180:
                    height = mContext.getResources().getDimensionPixelSize(
                    height = userContext.getResources().getDimensionPixelSize(
                            com.android.internal.R.dimen.navigation_bar_frame_height);
                    insetsHeight = mContext.getResources().getDimensionPixelSize(
                    insetsHeight = userContext.getResources().getDimensionPixelSize(
                            com.android.internal.R.dimen.navigation_bar_height);
                    break;
                case Surface.ROTATION_90:
                    gravity = Gravity.RIGHT;
                    width = mContext.getResources().getDimensionPixelSize(
                    width = userContext.getResources().getDimensionPixelSize(
                            com.android.internal.R.dimen.navigation_bar_width);
                    break;
                case Surface.ROTATION_270:
                    gravity = Gravity.LEFT;
                    width = mContext.getResources().getDimensionPixelSize(
                    width = userContext.getResources().getDimensionPixelSize(
                            com.android.internal.R.dimen.navigation_bar_width);
                    break;
            }
@@ -1603,12 +1608,12 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
            lp.providedInternalInsets[ITYPE_NAVIGATION_BAR] = null;
        }
        lp.token = new Binder();
        lp.accessibilityTitle = mContext.getString(R.string.nav_bar);
        lp.accessibilityTitle = userContext.getString(R.string.nav_bar);
        lp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC
                | WindowManager.LayoutParams.PRIVATE_FLAG_LAYOUT_SIZE_EXTENDED_BY_CUTOUT;
        lp.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
        lp.windowAnimations = 0;
        lp.setTitle("NavigationBar" + mContext.getDisplayId());
        lp.setTitle("NavigationBar" + userContext.getDisplayId());
        lp.setFitInsetsTypes(0 /* types */);
        lp.setTrustedOverlay();
        return lp;
+6 −0
Original line number Diff line number Diff line
@@ -23,4 +23,10 @@ import android.content.Context
 */
interface UserContextProvider {
    val userContext: Context

    /**
     * Creates the {@code context} with the current user.
     * @see Context#createContextAsUser(UserHandle, int)
     */
    fun createCurrentUserContext(context: Context): Context
}
 No newline at end of file
+6 −0
Original line number Diff line number Diff line
@@ -127,6 +127,12 @@ class UserTrackerImpl internal constructor(
        }
    }

    override fun createCurrentUserContext(context: Context): Context {
        synchronized(mutex) {
            return context.createContextAsUser(userHandle, 0)
        }
    }

    private fun setUserIdInternal(user: Int): Pair<Context, List<UserInfo>> {
        val profiles = userManager.getProfiles(user)
        val handle = UserHandle(user)
+7 −1
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ import com.android.systemui.navigationbar.gestural.EdgeBackGestureHandler;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.recents.OverviewProxyService;
import com.android.systemui.recents.Recents;
import com.android.systemui.settings.UserContextProvider;
import com.android.systemui.settings.UserTracker;
import com.android.systemui.shared.rotation.RotationButtonController;
import com.android.systemui.statusbar.CommandQueue;
@@ -188,6 +189,8 @@ public class NavigationBarTest extends SysuiTestCase {
    private DeadZone mDeadZone;
    @Mock
    private CentralSurfaces mCentralSurfaces;
    @Mock
    private UserContextProvider mUserContextProvider;
    private DeviceConfigProxyFake mDeviceConfigProxyFake = new DeviceConfigProxyFake();

    @Rule
@@ -210,6 +213,8 @@ public class NavigationBarTest extends SysuiTestCase {
                .thenReturn(mLightBarTransitionsController);
        when(mStatusBarKeyguardViewManager.isNavBarVisible()).thenReturn(true);
        when(mNavigationBarView.getViewTreeObserver()).thenReturn(mViewTreeObserver);
        when(mUserContextProvider.createCurrentUserContext(any(Context.class)))
                .thenReturn(mContext);
        setupSysuiDependency();
        // This class inflates views that call Dependency.get, thus these injections are still
        // necessary.
@@ -457,7 +462,8 @@ public class NavigationBarTest extends SysuiTestCase {
                mDeviceConfigProxyFake,
                mNavigationBarTransitions,
                mEdgeBackGestureHandler,
                Optional.of(mock(BackAnimation.class))));
                Optional.of(mock(BackAnimation.class)),
                mUserContextProvider));
    }

    private void processAllMessages() {
+0 −1
Original line number Diff line number Diff line
@@ -53,7 +53,6 @@ import org.mockito.Mock
import org.mockito.Mockito
import org.mockito.MockitoAnnotations
import org.mockito.Mockito.never
import org.mockito.Mockito.times
import org.mockito.Mockito.verify
import org.mockito.Mockito.`when`
import org.mockito.ArgumentMatchers.anyInt