一、环境
高通865 Android 10
二、相关代码位置和实现
1、隐藏导航栏
device/mediatek/system/common/system.prop
-qemu.hw.mainkeys=0+qemu.hw.mainkeys=10就是开启,1就是关闭
注:frameworks/base/core/res/res/values/dimens.xml中 navigation_bar_height和navigation_bar_height_landscape都改成0dp也可以实现,只是布局看不出来了,如果换个布局还是有的!不推荐!!
原理是在frameworks下调用这个宏的值做的逻辑执行
frameworks/base/services/core/java/com/android/server/wm/DisplayPolicy.java
String navBarOverride = SystemProperties.get("qemu.hw.mainkeys");
if ("1".equals(navBarOverride)) {
mHasNavigationBar = false;
} else if ("0".equals(navBarOverride)) {
2、默认手势导航
frameworks/base/core/res/res/values/config.xml下改配置
<!-- Controls the navigation bar interaction mode:
0: 3 button mode (back, home, overview buttons)
1: 2 button mode (back, home buttons + swipe up for overview)
2: gestures only for back, home and overview -->
<integer name="config_navBarInteractionMode">2</integer>
3、删除关于底部三个按键的包
在frameworks//base/packages/overlays/Android.mk中
LOCAL_REQUIRED_MODULES里面删掉NavigationBarMode3ButtonOverlay \
不让编译就行
原理是在packages/apps/Settings/src/com/android/settings/gestures/SystemNavigationGestureSettings.java是根据这个包名来添加的
if (SystemNavigationPreferenceController.isOverlayPackageAvailable(c,
NAV_BAR_MODE_3BUTTON_OVERLAY)) {
candidates.add(new CandidateInfoExtra(
c.getText(R.string.legacy_navigation_title),
c.getText(R.string.legacy_navigation_summary),
KEY_SYSTEM_NAV_3BUTTONS, true /* enabled */));
}
4、去除底部横线
frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
在updateNavButtonIcons方法里有
getHomeHandle().setVisibility(disableHomeHandle ? View.INVISIBLE : View.VISIBLE);
这个就是底部横线的布局,直接让他不显示就行,两个都是INVISIBLE那三个虚拟按键getBackButton().setVisibility(disableBack ? View.INVISIBLE : View.VISIBLE);getHomeButton().setVisibility(disableHome ? View.INVISIBLE : View.VISIBLE);getRecentsButton().setVisibility(disableRecent ? View.INVISIBLE : View.VISIBLE);