You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android 13 Google AOSP导航栏异常:手势/三键导航均不可见求助

针对Android 13 AOSP小屏设备导航栏异常的修复方案

一、System UI 核心修复(解决导航栏不可见/三键不显示问题)

1. 修正导航栏可见性触发逻辑

打开frameworks/base/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java,在updateVisibility方法中补充小屏设备的强制可见判断,避免逻辑错误拦截导航栏显示:

// 在updateVisibility方法内添加
boolean isSmallScreen = getResources().getConfiguration().smallestScreenWidthDp < 360;
if (isSmallScreen) {
    mWindowManagerLayoutParams.flags &= ~WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
    setBarVisibility(View.VISIBLE);
}

2. 修复三键导航UI加载逻辑

打开frameworks/base/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java,在onFinishInflate方法中针对小屏设备强制加载三键布局并绑定事件:

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    boolean isSmallScreen = getResources().getConfiguration().smallestScreenWidthDp < 360;
    if (isSmallScreen && mCurrentMode == MODE_3BUTTON) {
        inflate(getContext(), R.layout.navigation_bar_layout, this);
        mLeftButton = findViewById(R.id.back);
        mCenterButton = findViewById(R.id.home);
        mRightButton = findViewById(R.id.recent_apps);
        bindButtons();
    }
}

3. 提升导航栏窗口层级

打开frameworks/base/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarWindowController.java,调整窗口优先级避免被Launcher覆盖:

private void updateWindowLayoutParams() {
    mWindowLayoutParams.type = WindowManager.LayoutParams.TYPE_NAVIGATION_BAR;
    mWindowLayoutParams.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
    // 提升窗口优先级,确保导航栏显示在最上层
    mWindowLayoutParams.priority = WindowManager.LayoutParams.PRIORITY_HIGH;
}

二、Launcher3 适配(解决导航栏与Hotseat重叠问题)

1. 修正Hotseat底部边距计算逻辑

打开packages/apps/Launcher3/src/com/android/launcher3/hotseat/Hotseat.java,在onMeasure方法中强制读取系统导航栏高度并设置边距:

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    Resources res = getResources();
    int navBarHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height);
    boolean isSmallScreen = res.getConfiguration().smallestScreenWidthDp < 360;
    if (isSmallScreen) {
        MarginLayoutParams lp = (MarginLayoutParams) getLayoutParams();
        lp.bottomMargin = navBarHeight + res.getDimensionPixelSize(R.dimen.hotseat_bottom_extra_margin);
        setLayoutParams(lp);
    }
}

2. 更新Launcher窗口布局参数

打开packages/apps/Launcher3/src/com/android/launcher3/Launcher.java,在onCreate方法中设置窗口预留导航栏空间:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
}

三、Framework层补充调整

1. 统一小屏设备导航栏尺寸参数

打开frameworks/base/core/res/res/values/dimens.xml,添加小屏专属导航栏高度:

<dimen name="navigation_bar_height_small">24dp</dimen>

打开frameworks/base/core/res/res/values/config.xml,修改导航栏高度引用:

<dimen name="config_navigationBarHeight">@dimen/navigation_bar_height_small</dimen>

2. 修复导航栏布局空间分配逻辑

打开frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java,在computeScreenInsets方法中确保小屏设备导航栏空间正确分配:

private void computeScreenInsets(DisplayContent dc) {
    super.computeScreenInsets(dc);
    boolean isSmallScreen = dc.getDisplayInfo().smallestScreenWidthDp < 360;
    if (isSmallScreen) {
        dc.getInsetsState().setInsets(WindowInsets.Type.navigationBars(),
                new Insets(0, 0, 0, dc.getDisplayInfo().navigationBarHeight));
    }
}

验证步骤

  1. 重新编译对应模块并生成镜像:
mmm frameworks/base/packages/SystemUI/
mmm packages/apps/Launcher3/
mmm frameworks/base/
make snod
  1. 刷入新镜像后重启设备,测试手势导航与三键导航的显示及功能。

内容的提问来源于stack exchange,提问作者user25601509

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 08:35:57