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	 
相关推荐
长亭外的少年7 小时前
Kotlin 编译失败问题及解决方案:从守护进程到 Gradle 配置
android·开发语言·kotlin
建群新人小猿9 小时前
会员等级经验问题
android·开发语言·前端·javascript·php
1024小神10 小时前
tauri2.0版本开发苹果ios和安卓android应用,环境搭建和最后编译为apk
android·ios·tauri
兰琛10 小时前
20241121 android中树结构列表(使用recyclerView实现)
android·gitee
Y多了个想法11 小时前
RK3568 android11 适配敦泰触摸屏 FocalTech-ft5526
android·rk3568·触摸屏·tp·敦泰·focaltech·ft5526
NotesChapter12 小时前
Android吸顶效果,并有着ViewPager左右切换
android
_祝你今天愉快13 小时前
分析android :The binary version of its metadata is 1.8.0, expected version is 1.5.
android
暮志未晚Webgl13 小时前
109. UE5 GAS RPG 实现检查点的存档功能
android·java·ue5
麦田里的守望者江14 小时前
KMP 中的 expect 和 actual 声明
android·ios·kotlin
Dnelic-14 小时前
解决 Android 单元测试 No tests found for given includes:
android·junit·单元测试·问题记录·自学笔记