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

Commit 4115df37 authored by Youngjun Kwak's avatar Youngjun Kwak Committed by Automerger Merge Worker
Browse files

Merge "Allow SystemBar configuration via XML." into rvc-qpr-dev am: 4dbcd829 am: 36b52fee

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12181454

Change-Id: I6ef84cef8f71763baba5f130f16c36b4aaf427a6
parents 23a649d1 36b52fee
Loading
Loading
Loading
Loading
+24 −1
Original line number Original line Diff line number Diff line
@@ -24,12 +24,35 @@


    <bool name="config_enableFullscreenUserSwitcher">true</bool>
    <bool name="config_enableFullscreenUserSwitcher">true</bool>


    <!-- configure which system ui bars should be displayed -->
    <!-- Configure which system bars should be displayed. -->
    <bool name="config_enableTopNavigationBar">true</bool>
    <bool name="config_enableTopNavigationBar">true</bool>
    <bool name="config_enableLeftNavigationBar">false</bool>
    <bool name="config_enableLeftNavigationBar">false</bool>
    <bool name="config_enableRightNavigationBar">false</bool>
    <bool name="config_enableRightNavigationBar">false</bool>
    <bool name="config_enableBottomNavigationBar">true</bool>
    <bool name="config_enableBottomNavigationBar">true</bool>


    <!-- Configure the type of each system bar. Each system bar must have a unique type. -->
    <!--    STATUS_BAR = 0-->
    <!--    NAVIGATION_BAR = 1-->
    <!--    STATUS_BAR_EXTRA = 2-->
    <!--    NAVIGATION_BAR_EXTRA = 3-->
    <integer name="config_topSystemBarType">0</integer>
    <integer name="config_leftSystemBarType">2</integer>
    <integer name="config_rightSystemBarType">3</integer>
    <integer name="config_bottomSystemBarType">1</integer>

    <!-- Configure the relative z-order among the system bars. When two system bars overlap (e.g.
         if both top bar and left bar are enabled, it creates an overlapping space in the upper left
         corner), the system bar with the higher z-order takes the overlapping space and padding is
         applied to the other bar.-->
    <!-- NOTE: If two overlapping system bars have the same z-order, SystemBarConfigs will throw a
         RuntimeException, since their placing order cannot be determined. Bars that do not overlap
         are allowed to have the same z-order. -->
    <!-- NOTE: If the z-order of a bar is 10 or above, it will also appear on top of HUN's.    -->
    <integer name="config_topSystemBarZOrder">1</integer>
    <integer name="config_leftSystemBarZOrder">0</integer>
    <integer name="config_rightSystemBarZOrder">0</integer>
    <integer name="config_bottomSystemBarZOrder">10</integer>

    <!-- Disable normal notification rendering; we handle that ourselves -->
    <!-- Disable normal notification rendering; we handle that ourselves -->
    <bool name="config_renderNotifications">false</bool>
    <bool name="config_renderNotifications">false</bool>


+40 −85
Original line number Original line Diff line number Diff line
@@ -16,12 +16,8 @@


package com.android.systemui.car.navigationbar;
package com.android.systemui.car.navigationbar;


import static android.view.InsetsState.ITYPE_BOTTOM_GESTURES;
import static android.view.InsetsState.ITYPE_CLIMATE_BAR;
import static android.view.InsetsState.ITYPE_EXTRA_NAVIGATION_BAR;
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
import static android.view.InsetsState.ITYPE_STATUS_BAR;
import static android.view.InsetsState.ITYPE_STATUS_BAR;
import static android.view.InsetsState.ITYPE_TOP_GESTURES;
import static android.view.InsetsState.containsType;
import static android.view.InsetsState.containsType;
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;


@@ -30,13 +26,11 @@ import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSPARE


import android.content.Context;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.Resources;
import android.graphics.PixelFormat;
import android.inputmethodservice.InputMethodService;
import android.inputmethodservice.InputMethodService;
import android.os.Handler;
import android.os.Handler;
import android.os.IBinder;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.RemoteException;
import android.view.Display;
import android.view.Display;
import android.view.Gravity;
import android.view.View;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup;
import android.view.WindowInsetsController;
import android.view.WindowInsetsController;
@@ -47,7 +41,6 @@ import androidx.annotation.VisibleForTesting;
import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.statusbar.RegisterStatusBarResult;
import com.android.internal.statusbar.RegisterStatusBarResult;
import com.android.internal.view.AppearanceRegion;
import com.android.internal.view.AppearanceRegion;
import com.android.systemui.R;
import com.android.systemui.SystemUI;
import com.android.systemui.SystemUI;
import com.android.systemui.car.CarDeviceProvisionedController;
import com.android.systemui.car.CarDeviceProvisionedController;
import com.android.systemui.car.CarDeviceProvisionedListener;
import com.android.systemui.car.CarDeviceProvisionedListener;
@@ -76,7 +69,6 @@ import dagger.Lazy;


/** Navigation bars customized for the automotive use case. */
/** Navigation bars customized for the automotive use case. */
public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks {
public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks {

    private final Resources mResources;
    private final Resources mResources;
    private final CarNavigationBarController mCarNavigationBarController;
    private final CarNavigationBarController mCarNavigationBarController;
    private final SysuiDarkIconDispatcher mStatusBarIconController;
    private final SysuiDarkIconDispatcher mStatusBarIconController;
@@ -93,6 +85,7 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
    private final Lazy<StatusBarIconController> mIconControllerLazy;
    private final Lazy<StatusBarIconController> mIconControllerLazy;


    private final int mDisplayId;
    private final int mDisplayId;
    private final SystemBarConfigs mSystemBarConfigs;


    private StatusBarSignalPolicy mSignalPolicy;
    private StatusBarSignalPolicy mSignalPolicy;
    private ActivityManagerWrapper mActivityManagerWrapper;
    private ActivityManagerWrapper mActivityManagerWrapper;
@@ -141,7 +134,8 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
            IStatusBarService barService,
            IStatusBarService barService,
            Lazy<KeyguardStateController> keyguardStateControllerLazy,
            Lazy<KeyguardStateController> keyguardStateControllerLazy,
            Lazy<PhoneStatusBarPolicy> iconPolicyLazy,
            Lazy<PhoneStatusBarPolicy> iconPolicyLazy,
            Lazy<StatusBarIconController> iconControllerLazy
            Lazy<StatusBarIconController> iconControllerLazy,
            SystemBarConfigs systemBarConfigs
    ) {
    ) {
        super(context);
        super(context);
        mResources = resources;
        mResources = resources;
@@ -158,6 +152,7 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
        mKeyguardStateControllerLazy = keyguardStateControllerLazy;
        mKeyguardStateControllerLazy = keyguardStateControllerLazy;
        mIconPolicyLazy = iconPolicyLazy;
        mIconPolicyLazy = iconPolicyLazy;
        mIconControllerLazy = iconControllerLazy;
        mIconControllerLazy = iconControllerLazy;
        mSystemBarConfigs = systemBarConfigs;


        mDisplayId = context.getDisplayId();
        mDisplayId = context.getDisplayId();
    }
    }
@@ -344,103 +339,63 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks
    private void buildNavBarContent() {
    private void buildNavBarContent() {
        mTopNavigationBarView = mCarNavigationBarController.getTopBar(isDeviceSetupForUser());
        mTopNavigationBarView = mCarNavigationBarController.getTopBar(isDeviceSetupForUser());
        if (mTopNavigationBarView != null) {
        if (mTopNavigationBarView != null) {
            mSystemBarConfigs.insetSystemBar(SystemBarConfigs.TOP, mTopNavigationBarView);
            mTopNavigationBarWindow.addView(mTopNavigationBarView);
            mTopNavigationBarWindow.addView(mTopNavigationBarView);
        }
        }


        mBottomNavigationBarView = mCarNavigationBarController.getBottomBar(isDeviceSetupForUser());
        mBottomNavigationBarView = mCarNavigationBarController.getBottomBar(isDeviceSetupForUser());
        if (mBottomNavigationBarView != null) {
        if (mBottomNavigationBarView != null) {
            mSystemBarConfigs.insetSystemBar(SystemBarConfigs.BOTTOM, mBottomNavigationBarView);
            mBottomNavigationBarWindow.addView(mBottomNavigationBarView);
            mBottomNavigationBarWindow.addView(mBottomNavigationBarView);
        }
        }


        mLeftNavigationBarView = mCarNavigationBarController.getLeftBar(isDeviceSetupForUser());
        mLeftNavigationBarView = mCarNavigationBarController.getLeftBar(isDeviceSetupForUser());
        if (mLeftNavigationBarView != null) {
        if (mLeftNavigationBarView != null) {
            mSystemBarConfigs.insetSystemBar(SystemBarConfigs.LEFT, mLeftNavigationBarView);
            mLeftNavigationBarWindow.addView(mLeftNavigationBarView);
            mLeftNavigationBarWindow.addView(mLeftNavigationBarView);
        }
        }


        mRightNavigationBarView = mCarNavigationBarController.getRightBar(isDeviceSetupForUser());
        mRightNavigationBarView = mCarNavigationBarController.getRightBar(isDeviceSetupForUser());
        if (mRightNavigationBarView != null) {
        if (mRightNavigationBarView != null) {
            mSystemBarConfigs.insetSystemBar(SystemBarConfigs.RIGHT, mRightNavigationBarView);
            mRightNavigationBarWindow.addView(mRightNavigationBarView);
            mRightNavigationBarWindow.addView(mRightNavigationBarView);
        }
        }
    }
    }


    private void attachNavBarWindows() {
    private void attachNavBarWindows() {
        if (mTopNavigationBarWindow != null) {
        mSystemBarConfigs.getSystemBarSidesByZOrder().forEach(this::attachNavBarBySide);
            int height = mResources.getDimensionPixelSize(
                    com.android.internal.R.dimen.status_bar_height);
            WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT,
                    height,
                    WindowManager.LayoutParams.TYPE_STATUS_BAR_ADDITIONAL,
                    WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                            | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                            | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
                            | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH,
                    PixelFormat.TRANSLUCENT);
            lp.setTitle("TopCarNavigationBar");
            lp.providesInsetsTypes = new int[]{ITYPE_STATUS_BAR, ITYPE_TOP_GESTURES};
            lp.setFitInsetsTypes(0);
            lp.windowAnimations = 0;
            lp.gravity = Gravity.TOP;
            mWindowManager.addView(mTopNavigationBarWindow, lp);
    }
    }


    private void attachNavBarBySide(int side) {
        switch(side) {
            case SystemBarConfigs.TOP:
                if (mTopNavigationBarWindow != null) {
                    mWindowManager.addView(mTopNavigationBarWindow,
                            mSystemBarConfigs.getLayoutParamsBySide(SystemBarConfigs.TOP));
                }
                break;
            case SystemBarConfigs.BOTTOM:
                if (mBottomNavigationBarWindow != null && !mBottomNavBarVisible) {
                if (mBottomNavigationBarWindow != null && !mBottomNavBarVisible) {
                    mBottomNavBarVisible = true;
                    mBottomNavBarVisible = true;
            int height = mResources.getDimensionPixelSize(
                    com.android.internal.R.dimen.navigation_bar_height);

            WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT,
                    height,
                    WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL,
                    WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                            | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                            | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
                            | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH,
                    PixelFormat.TRANSLUCENT);
            lp.setTitle("BottomCarNavigationBar");
            lp.providesInsetsTypes = new int[]{ITYPE_NAVIGATION_BAR, ITYPE_BOTTOM_GESTURES};
            lp.windowAnimations = 0;
            lp.gravity = Gravity.BOTTOM;
            mWindowManager.addView(mBottomNavigationBarWindow, lp);
        }


                    mWindowManager.addView(mBottomNavigationBarWindow,
                            mSystemBarConfigs.getLayoutParamsBySide(SystemBarConfigs.BOTTOM));
                }
                break;
            case SystemBarConfigs.LEFT:
                if (mLeftNavigationBarWindow != null) {
                if (mLeftNavigationBarWindow != null) {
            int width = mResources.getDimensionPixelSize(
                    mWindowManager.addView(mLeftNavigationBarWindow,
                    R.dimen.car_left_navigation_bar_width);
                            mSystemBarConfigs.getLayoutParamsBySide(SystemBarConfigs.LEFT));
            WindowManager.LayoutParams leftlp = new WindowManager.LayoutParams(
                    width, ViewGroup.LayoutParams.MATCH_PARENT,
                    WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL,
                    WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                            | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                            | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
                            | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH,
                    PixelFormat.TRANSLUCENT);
            leftlp.setTitle("LeftCarNavigationBar");
            leftlp.providesInsetsTypes = new int[]{ITYPE_CLIMATE_BAR};
            leftlp.setFitInsetsTypes(0);
            leftlp.windowAnimations = 0;
            leftlp.gravity = Gravity.LEFT;
            mWindowManager.addView(mLeftNavigationBarWindow, leftlp);
                }
                }

                break;
            case SystemBarConfigs.RIGHT:
                if (mRightNavigationBarWindow != null) {
                if (mRightNavigationBarWindow != null) {
            int width = mResources.getDimensionPixelSize(
                    mWindowManager.addView(mRightNavigationBarWindow,
                    R.dimen.car_right_navigation_bar_width);
                            mSystemBarConfigs.getLayoutParamsBySide(SystemBarConfigs.RIGHT));
            WindowManager.LayoutParams rightlp = new WindowManager.LayoutParams(
                }
                    width, ViewGroup.LayoutParams.MATCH_PARENT,
                break;
                    WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL,
            default:
                    WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                return;
                            | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                            | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
                            | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH,
                    PixelFormat.TRANSLUCENT);
            rightlp.setTitle("RightCarNavigationBar");
            rightlp.providesInsetsTypes = new int[]{ITYPE_EXTRA_NAVIGATION_BAR};
            rightlp.setFitInsetsTypes(0);
            rightlp.windowAnimations = 0;
            rightlp.gravity = Gravity.RIGHT;
            mWindowManager.addView(mRightNavigationBarWindow, rightlp);
        }
        }
    }
    }


+6 −6
Original line number Original line Diff line number Diff line
@@ -22,7 +22,6 @@ import android.view.ViewGroup;


import androidx.annotation.Nullable;
import androidx.annotation.Nullable;


import com.android.systemui.R;
import com.android.systemui.car.hvac.HvacController;
import com.android.systemui.car.hvac.HvacController;


import javax.inject.Inject;
import javax.inject.Inject;
@@ -61,7 +60,8 @@ public class CarNavigationBarController {
            NavigationBarViewFactory navigationBarViewFactory,
            NavigationBarViewFactory navigationBarViewFactory,
            ButtonSelectionStateController buttonSelectionStateController,
            ButtonSelectionStateController buttonSelectionStateController,
            Lazy<HvacController> hvacControllerLazy,
            Lazy<HvacController> hvacControllerLazy,
            ButtonRoleHolderController buttonRoleHolderController) {
            ButtonRoleHolderController buttonRoleHolderController,
            SystemBarConfigs systemBarConfigs) {
        mContext = context;
        mContext = context;
        mNavigationBarViewFactory = navigationBarViewFactory;
        mNavigationBarViewFactory = navigationBarViewFactory;
        mButtonSelectionStateController = buttonSelectionStateController;
        mButtonSelectionStateController = buttonSelectionStateController;
@@ -69,10 +69,10 @@ public class CarNavigationBarController {
        mButtonRoleHolderController = buttonRoleHolderController;
        mButtonRoleHolderController = buttonRoleHolderController;


        // Read configuration.
        // Read configuration.
        mShowTop = mContext.getResources().getBoolean(R.bool.config_enableTopNavigationBar);
        mShowTop = systemBarConfigs.getEnabledStatusBySide(SystemBarConfigs.TOP);
        mShowBottom = mContext.getResources().getBoolean(R.bool.config_enableBottomNavigationBar);
        mShowBottom = systemBarConfigs.getEnabledStatusBySide(SystemBarConfigs.BOTTOM);
        mShowLeft = mContext.getResources().getBoolean(R.bool.config_enableLeftNavigationBar);
        mShowLeft = systemBarConfigs.getEnabledStatusBySide(SystemBarConfigs.LEFT);
        mShowRight = mContext.getResources().getBoolean(R.bool.config_enableRightNavigationBar);
        mShowRight = systemBarConfigs.getEnabledStatusBySide(SystemBarConfigs.RIGHT);
    }
    }


    /**
    /**
+0 −28
Original line number Original line Diff line number Diff line
@@ -16,14 +16,10 @@


package com.android.systemui.car.navigationbar;
package com.android.systemui.car.navigationbar;


import static android.view.WindowInsets.Type.systemBars;

import android.content.Context;
import android.content.Context;
import android.graphics.Insets;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View;
import android.view.WindowInsets;
import android.widget.LinearLayout;
import android.widget.LinearLayout;


import com.android.systemui.Dependency;
import com.android.systemui.Dependency;
@@ -80,30 +76,6 @@ public class CarNavigationBarView extends LinearLayout {
        setFocusable(false);
        setFocusable(false);
    }
    }


    @Override
    public WindowInsets onApplyWindowInsets(WindowInsets windowInsets) {
        applyMargins(windowInsets.getInsets(systemBars()));
        return windowInsets;
    }

    private void applyMargins(Insets insets) {
        final int count = getChildCount();
        for (int i = 0; i < count; i++) {
            View child = getChildAt(i);
            if (child.getLayoutParams() instanceof LayoutParams) {
                LayoutParams lp = (LayoutParams) child.getLayoutParams();
                if (lp.rightMargin != insets.right || lp.leftMargin != insets.left
                        || lp.topMargin != insets.top || lp.bottomMargin != insets.bottom) {
                    lp.rightMargin = insets.right;
                    lp.leftMargin = insets.left;
                    lp.topMargin = insets.top;
                    lp.bottomMargin = insets.bottom;
                    child.requestLayout();
                }
            }
        }
    }

    // Used to forward touch events even if the touch was initiated from a child component
    // Used to forward touch events even if the touch was initiated from a child component
    @Override
    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
    public boolean onInterceptTouchEvent(MotionEvent ev) {
+380 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading