Android 13接大屏时底下显示任务栏以及虚拟按键靠右问题

Android 13大屏显示时,界面底下显示任务栏,返回、home,recent按键显示会靠右。和Android12类似,但跟以往的Android系统不一样。之前Android12上面修改过这个显示:

Android 12 大屏时底下显示任务栏以及虚拟按键靠右问题_android taskbar_HH同学的博客-CSDN博客

但是,Android13上面又不一样了。 

Android12上面修改Luacher3里面的ENABLE_TASKBAR 值就可以去掉任务栏的显示,但是Android13上面没有ENABLE_TASKBAR这个属性。于是,找了一下ENABLE_TASKBAR在Android12上面调用的地方packages\apps\Launcher3\quickstep\src\com\android\launcher3\taskbar\TaskbarManager.java中recreateTaskbar()函数里面:

    private void recreateTaskbar() {
        destroyExistingTaskbar();
 
        DeviceProfile dp =
                mUserUnlocked ? LauncherAppState.getIDP(mContext).getDeviceProfile(mContext) : null;
 
        boolean isTaskBarEnabled =
                FeatureFlags.ENABLE_TASKBAR.get() && dp != null && dp.isTaskbarPresent;
 
        if (!isTaskBarEnabled) {
            SystemUiProxy.INSTANCE.get(mContext)
                    .notifyTaskbarStatus(/* visible */ false, /* stashed */ false);
            return;
        }

 

然后,在Android13上面的Launcher3找了一下recreateTaskbar(),还是存在的,内容如下:

  1.     @VisibleForTesting
        public void recreateTaskbar() {
            DeviceProfile dp = mUserUnlocked ?
                    LauncherAppState.getIDP(mContext).getDeviceProfile(mContext) : null;
     
            destroyExistingTaskbar();
     
            boolean isTaskBarEnabled = dp != null && isTaskbarPresent(dp);
            if (!isTaskBarEnabled) {
                SystemUiProxy.INSTANCE.get(mContext)
                        .notifyTaskbarStatus(/* visible */ false, /* stashed */ false);
                return;
            }
     
            if (mTaskbarActivityContext == null) {
                mTaskbarActivityContext = new TaskbarActivityContext(mContext, dp, mNavButtonController,
                        mUnfoldProgressProvider);
            } else {
                mTaskbarActivityContext.updateDeviceProfile(dp, mNavMode);
            }
            mTaskbarActivityContext.init(mSharedState);
     
            if (mActivity != null) {
                mTaskbarActivityContext.setUIController(
                        createTaskbarUIControllerForActivity(mActivity));
            }
        }

     

 发现都有一个控制任务栏显示的参数boolean isTaskBarEnabled,这个参数在由 isTaskbarPresent(dp)决定,这个函数实现如下:

  1.     private boolean isTaskbarPresent(DeviceProfile deviceProfile) {
            return FLAG_HIDE_NAVBAR_WINDOW || deviceProfile.isTaskbarPresent;
        }

     

上面函数中的返回值由packages\apps\Launcher3\src\com\android\launcher3\DeviceProfile.java中的isTaskbarPresent决定。isTaskbarPresent值又是packages\apps\Launcher3\src\com\android\launcher3\util\DisplayController.java中的isTablet函数决定。

  1.     DeviceProfile(Context context, InvariantDeviceProfile inv, Info info, WindowBounds windowBounds,
                SparseArray<DotRenderer> dotRendererCache, boolean isMultiWindowMode,
                boolean transposeLayoutWithOrientation, boolean isMultiDisplay, boolean isGestureMode,
                @NonNull final ViewScaleProvider viewScaleProvider) {
     
            this.inv = inv;
            this.isLandscape = windowBounds.isLandscape();
            this.isMultiWindowMode = isMultiWindowMode;
            this.transposeLayoutWithOrientation = transposeLayoutWithOrientation;
            this.isMultiDisplay = isMultiDisplay;
            this.isGestureMode = isGestureMode;
            windowX = windowBounds.bounds.left;
            windowY = windowBounds.bounds.top;
            this.rotationHint = windowBounds.rotationHint;
            mInsets.set(windowBounds.insets);
     
            isScalableGrid = inv.isScalable && !isVerticalBarLayout() && !isMultiWindowMode;
            // Determine device posture.
            mInfo = info;
            isTablet = info.isTablet(windowBounds);
            isPhone = !isTablet;
            isTwoPanels = isTablet && isMultiDisplay;
            isTaskbarPresent = isTablet && ApiWrapper.TASKBAR_DRAWN_IN_PROCESS;

     

 isTablet函数实现如下:

  1.         public boolean isTablet(WindowBounds bounds) {
                return smallestSizeDp(bounds) >= MIN_TABLET_WIDTH;
            }

     

MIN_TABLET_WIDTH值为600,上面的意思是最小边dp值大于600就返回true,判断为平板设备。

要让taskbar任务栏不显示,把所有判断该值的地方,都改成返回false。 

  1. @@ -3764,7 +3764,7 @@
    diff --git a/frameworks/base/core/res/res/values/config.xml b/frameworks/base/core/res/res/values/config.xml
    index 5558d4adc1..22d1f36f47 100644
    --- a/frameworks/base/core/res/res/values/config.xml
    +++ b/frameworks/base/core/res/res/values/config.xml
    @@ -3764,7 +3764,7 @@
     
         <!-- Controls whether the nav bar can move from the bottom to the side in landscape.
              Only applies if the device display is not square. -->
    -    <bool name="config_navBarCanMove">true</bool>
    +    <bool name="config_navBarCanMove">false</bool>
     
         <!-- Controls whether the navigation bar lets through taps. -->
         <bool name="config_navBarTapThrough">false</bool>
    diff --git a/frameworks/base/packages/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/Utilities.java b/frameworks/base/packages/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/Utilities.java
    index 77a13bd91b..6f9b8e0d61 100644
    --- a/frameworks/base/packages/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/Utilities.java
    +++ b/frameworks/base/packages/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/Utilities.java
    @@ -143,7 +143,7 @@ public class Utilities {
     
             float smallestWidth = dpiFromPx(Math.min(bounds.width(), bounds.height()),
                     context.getResources().getConfiguration().densityDpi);
    -        return smallestWidth >= TABLET_MIN_DPS;
    +        return false;//smallestWidth >= TABLET_MIN_DPS;
         }
     
         public static float dpiFromPx(float size, int densityDpi) {
    diff --git a/packages/apps/Launcher3/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/packages/apps/Launcher3/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
    index 86e191151a..f873425698 100644
    --- a/packages/apps/Launcher3/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
    +++ b/packages/apps/Launcher3/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
    @@ -292,7 +292,8 @@ public class TaskbarManager {
     
             destroyExistingTaskbar();
     
    -        boolean isTaskBarEnabled = dp != null && isTaskbarPresent(dp);
    +        boolean isTaskBarEnabled = false;//dp != null && isTaskbarPresent(dp);
    +               System.out.println("==hh isTaskBarEnabled:"+isTaskBarEnabled);
             if (!isTaskBarEnabled) {
                 SystemUiProxy.INSTANCE.get(mContext)
                         .notifyTaskbarStatus(/* visible */ false, /* stashed */ false);
    diff --git a/packages/apps/Launcher3/src/com/android/launcher3/states/RotationHelper.java b/packages/apps/Launcher3/src/com/android/launcher3/states/RotationHelper.java
    index e5b4ebae1d..b9dcc698e9 100644
    --- a/packages/apps/Launcher3/src/com/android/launcher3/states/RotationHelper.java
    +++ b/packages/apps/Launcher3/src/com/android/launcher3/states/RotationHelper.java
    @@ -54,7 +54,7 @@ public class RotationHelper implements OnSharedPreferenceChangeListener,
             // original dimensions to determine if rotation is allowed of not.
             float originalSmallestWidth = dpiFromPx(Math.min(info.currentSize.x, info.currentSize.y),
                     DENSITY_DEVICE_STABLE);
    -        return originalSmallestWidth >= MIN_TABLET_WIDTH;
    +        return false;//originalSmallestWidth >= MIN_TABLET_WIDTH;
         }
     
         public static final int REQUEST_NONE = 0;
    diff --git a/packages/apps/Launcher3/src/com/android/launcher3/util/DisplayController.java b/packages/apps/Launcher3/src/com/android/launcher3/util/DisplayController.java
    index c52890fd18..80b8e8354a 100644
    --- a/packages/apps/Launcher3/src/com/android/launcher3/util/DisplayController.java
    +++ b/packages/apps/Launcher3/src/com/android/launcher3/util/DisplayController.java
    @@ -378,7 +378,7 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
              * Returns {@code true} if the bounds represent a tablet.
              */
             public boolean isTablet(WindowBounds bounds) {
    -            return smallestSizeDp(bounds) >= MIN_TABLET_WIDTH;
    +            return false;//smallestSizeDp(bounds) >= MIN_TABLET_WIDTH;
             }
     
             /**
    diff --git a/packages/apps/Launcher3/src/com/android/launcher3/util/window/WindowManagerProxy.java b/packages/apps/Launcher3/src/com/android/launcher3/util/window/WindowManagerProxy.java
    index fb2ae732b7..5af6596e99 100644
    --- a/packages/apps/Launcher3/src/com/android/launcher3/util/window/WindowManagerProxy.java
    +++ b/packages/apps/Launcher3/src/com/android/launcher3/util/window/WindowManagerProxy.java
    @@ -145,7 +145,7 @@ public class WindowManagerProxy implements ResourceBasedOverride {
             Resources systemRes = context.getResources();
             Configuration config = systemRes.getConfiguration();
     
    -        boolean isTablet = config.smallestScreenWidthDp > MIN_TABLET_WIDTH;
    +        boolean isTablet = false;//config.smallestScreenWidthDp > MIN_TABLET_WIDTH;
             boolean isGesture = isGestureNav(context);
             boolean isPortrait = config.screenHeightDp > config.screenWidthDp;
     
    @@ -208,7 +208,7 @@ public class WindowManagerProxy implements ResourceBasedOverride {
                 systemRes = context.createConfigurationContext(conf).getResources();
             }
     
    -        boolean isTablet = swDp >= MIN_TABLET_WIDTH;
    +        boolean isTablet = false;//swDp >= MIN_TABLET_WIDTH;
             boolean isTabletOrGesture = isTablet
                     || (Utilities.ATLEAST_R && isGestureNav(context));

    Android 13接大屏时底下显示任务栏以及虚拟按键靠右问题_安卓 13 底部导航栏跟launcher有关系?-CSDN博客

posted @ 2024-03-01 13:50  xiaowang_lj  阅读(508)  评论(0编辑  收藏  举报