Android13 大屏设备底部显示TaskBar并NavagatonBar居右

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

当前需求是去掉底部任务栏的显示,并把虚拟按键导航栏居中显示。

修改前的效果:

修改后的效果:

通过查看源码逻辑,可以发现只需把isTablet相关的逻辑和配置修改为false即可。

涉及修改的文件目录如下:

java 复制代码
	modified:   vendor/mediatek/proprietary/packages/apps/Launcher3/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
	modified:   vendor/mediatek/proprietary/packages/apps/Launcher3/res/layout/launcher.xml
	modified:   vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/states/RotationHelper.java
	modified:   vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/util/DisplayController.java
	modified:   vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/util/window/WindowManagerProxy.java
	modified:   vendor/mediatek/proprietary/packages/apps/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/Utilities.java

具体修改如下:

1.把TaskbarManager.java中isTaskBarEnabled直接修改为false

java 复制代码
--- a/mtk/vendor/mediatek/proprietary/packages/apps/Launcher3/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
+++ b/mtk/vendor/mediatek/proprietary/packages/apps/Launcher3/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
@@ -266,7 +266,7 @@ public class TaskbarManager {
         DeviceProfile dp =
                 mUserUnlocked ? LauncherAppState.getIDP(mContext).getDeviceProfile(mContext) : null;
 
-        boolean isTaskBarEnabled = dp != null && dp.isTaskbarPresent;
+        boolean isTaskBarEnabled = false;//dp != null && dp.isTaskbarPresent;
 
         if (!isTaskBarEnabled) {
             SystemUiProxy.INSTANCE.get(mContext)

2.把RotationHelper.java中的getAllowRotationDefaultValue方法直接返回false

java 复制代码
--- a/mtk/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/states/RotationHelper.java
+++ b/mtk/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/states/RotationHelper.java
@@ -49,7 +49,7 @@ public class RotationHelper implements OnSharedPreferenceChangeListener,
         // original dimensions to determine if rotation is allowed of not.
         float originalSmallestWidth = dpiFromPx(
                 Math.min(deviceProfile.widthPx, deviceProfile.heightPx), DENSITY_DEVICE_STABLE);
-        return originalSmallestWidth >= MIN_TABLET_WIDTH;
+        return false;//originalSmallestWidth >= MIN_TABLET_WIDTH;
     }

3.把DisplayController.java中isTablet方法直接返回false

java 复制代码
--- a/mtk/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/util/DisplayController.java
+++ b/mtk/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/util/DisplayController.java
@@ -348,7 +348,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;
         }
 
         /**

4.把WindowManagerProxy.java中isTablet直接修改为false

java 复制代码
--- a/mtk/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/util/window/WindowManagerProxy.java
+++ b/mtk/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/util/window/WindowManagerProxy.java
@@ -153,7 +153,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;
 
@@ -226,7 +226,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));

5.把Utilities.java中的isTablet方法直接false

java 复制代码
--- a/mtk/vendor/mediatek/proprietary/packages/apps/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/Utilities.java
+++ b/mtk/vendor/mediatek/proprietary/packages/apps/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/Utilities.java
@@ -133,7 +133,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;
     }

6.修复Launcher3界面与导航栏重叠的问题

java 复制代码
--- a/mtk/vendor/mediatek/proprietary/packages/apps/Launcher3/res/layout/launcher.xml
+++ b/mtk/vendor/mediatek/proprietary/packages/apps/Launcher3/res/layout/launcher.xml
@@ -25,7 +25,8 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:clipChildren="false"
         android:clipToPadding="false"
+       android:layout_marginBottom="@*android:dimen/navigation_bar_height"
         android:importantForAccessibility="no">
 
         <com.android.launcher3.views.AccessibilityActionsView	 
相关推荐
m0_548514772 小时前
2024.12.10——攻防世界Web_php_include
android·前端·php
凤邪摩羯3 小时前
Android-性能优化-03-启动优化-启动耗时
android
凤邪摩羯3 小时前
Android-性能优化-02-内存优化-LeakCanary原理解析
android
喀什酱豆腐3 小时前
Handle
android
m0_748232925 小时前
Android Https和WebView
android·网络协议·https
m0_748251725 小时前
Android webview 打开本地H5项目(Cocos游戏以及Unity游戏)
android·游戏·unity
m0_748254667 小时前
go官方日志库带色彩格式化
android·开发语言·golang
zhangphil7 小时前
Android使用PorterDuffXfermode模式PorterDuff.Mode.SRC_OUT橡皮擦实现“刮刮乐”效果,Kotlin(2)
android·kotlin
爱学测试的李木子7 小时前
从0到1搭建 Android 自动化 python+appium 环境
android·软件测试·python·测试工具·自动化
咸芝麻鱼7 小时前
Android Studio | 连接手机设备后,启动App时出现:Waiting For DebuggerApplication (App名)...
android·adb·智能手机·android studio