20220414在MT6739的Android10系统下开启导航栏NavigationBar(虚拟按键)
2022/4/14 18:00
导航栏NavigationBar
1、源码部分:
frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
mHasNavigationBar = res.getBoolean(com.android.internal.R.bool.config_showNavigationBar);
// Allow a system property to override this. Used by the emulator.
// See also hasNavigationBar().
String navBarOverride = SystemProperties.get("qemu.hw.mainkeys");
if ("1".equals(navBarOverride)) {
mHasNavigationBar = false;
} else if ("0".equals(navBarOverride)) {
mHasNavigationBar = true;
}
Z:\mt6739_android10\frameworks\base\services\core\java\com\android\server\policy\PhoneWindowManager.java
// Use this instead of checking config_showNavigationBar so that it can be consistently
// overridden by qemu.hw.mainkeys in the emulator.
@Override
public boolean hasNavigationBar() {
return mDefaultDisplayPolicy.hasNavigationBar();
}
修改为:
// Use this instead of checking config_showNavigationBar so that it can be consistently
// overridden by qemu.hw.mainkeys in the emulator.
@Override
public boolean hasNavigationBar() {
//return mDefaultDisplayPolicy.hasNavigationBar();
return true;
}
2、显示方案:
[1]、使用adb命令开启Android手机虚拟按键(导航栏)
【如果如下操作可以打开导航栏,就有的搞!否则就是JAVA代码被拿掉了,就很麻烦了!】
adb root
adb remount
adb shell
$ getprop qemu.hw.mainkeys #查看值
$ setprop qemu.hw.mainkeys 0 #设置值为0,属性值为1 表示未打开虚拟按键,属性值为0表示一直打开虚拟按键
【杀掉当前的launcher】
$ stop
【重启launcher】
$ start
console:/ $ su
console:/ #
console:/ # cd /data
console:/data # ll
total 189
drwxrwx--x 55 system system 4096 2022-04-14 10:19 .
drwxr-xr-x 21 root root 4096 2022-04-11 12:31 ..
-rw------- 1 root root 2 2022-04-14 10:16 .layout_version
drwx------ 2 root root 3488 2022-04-14 10:16 adb
drwxrwxr-x 3 root root 3488 2022-04-14 10:16 aee_exp
drwxrwxr-x 2 system system 3488 2022-04-14 10:16 anr
drwxr-x--- 5 root system 3488 2022-04-14 10:16 apex
drwxrwx--x 2 system system 3488 2022-04-14 10:16 app
drwx------ 2 root root 3488 2022-04-14 10:16 app-asec
drwxrwx--x 2 system system 3488 2022-04-14 10:16 app-ephemeral
drwxrwx--x 2 system system 3488 2022-04-14 10:16 app-lib
drwxrwx--x 2 system system 3488 2022-04-14 10:16 app-private
drwxr-x--- 2 system system 3488 2022-04-14 10:16 app-staging
drwx------ 4 system system 3488 2022-04-14 10:19 backup
drwxr-xr-x 2 shell shell 3488 2022-04-14 10:16 bootchart
drwxrwx--- 5 system cache 3488 2022-04-14 10:16 cache
drwxrwxr-x 3 system system 3488 2022-04-14 10:16 connsyslog
drwxrwxr-x 2 system system 3488 2022-04-14 10:16 core
drwxrwx--x 3 root root 3488 2022-04-14 10:16 dalvik-cache
drwxrwx--x 156 system system 20480 2022-04-14 10:19 data
drwxrwx--- 3 shell log 3488 2022-04-14 10:16 debuglogger
drwxrwx--- 3 drm drm 3488 2022-04-14 10:19 drm
drwxrwxr-x 2 system system 3488 2022-04-14 10:19 dumpsys
drwx------ 3 system system 3488 2022-04-14 10:18 duraspeed
drwx------ 3 root root 3488 2022-04-14 10:16 gsi
drwxr-x--x 4 root root 3488 2022-04-14 10:16 local
drwxr-xr-x 2 system system 3488 2022-04-14 10:20 log_temp
drwxrwx--- 2 root root 3488 2022-04-14 10:16 lost+found
drwxrwxr-x 3 system system 3488 2022-04-14 10:17 mdlog
drwxrwx--- 3 media_rw media_rw 3488 2022-04-14 10:19 media
drwxrwx--- 2 mediadrm mediadrm 3488 2022-04-14 10:16 mediadrm
drwxrwx--t 47 system misc 3488 2022-04-14 10:16 misc
drwxrwx--t 3 system misc 3488 2022-04-14 10:19 misc_ce
drwxrwx--t 3 system misc 3488 2022-04-14 10:16 misc_de
drwxrwx--- 3 nfc nfc 3488 2022-04-14 10:16 nfc
drwxrwx--x 2 root root 3488 2022-04-14 10:16 ota
drwxrwx--- 2 system cache 3488 2022-04-14 10:16 ota_package
drwx------ 2 system system 3488 2022-04-14 10:19 per_boot
drwxrwxr-x 2 system system 3488 2022-04-14 10:16 preloads
drwx------ 2 root root 3488 2022-04-14 10:20 property
drwxrwxr-x 2 shell system 3488 2022-04-14 10:16 ramdump
drwxrwx--x 2 system system 8192 2022-04-14 10:17 resource-cache
drwx------ 2 system system 3488 2022-04-14 10:17 rollback
drwx------ 2 system system 3488 2022-04-14 10:17 rollback-observer
drwxrwxr-x 2 system system 3488 2022-04-14 10:16 server_configurable_flags
drwx------ 2 system system 3488 2022-04-14 10:16 ss
drwxrwxr-x 20 system system 3488 2022-04-14 10:20 system
drwxrwx--- 3 system system 3488 2022-04-14 10:19 system_ce
drwxrwx--- 4 system system 3488 2022-04-14 10:16 system_de
drwxrwx--x 2 system system 3488 2022-04-14 10:16 tombstones
drwx------ 3 root root 3488 2022-04-14 10:16 unencrypted
drwx--x--x 2 system system 3488 2022-04-14 10:16 user
drwx--x--x 3 system system 3488 2022-04-14 10:16 user_de
drwxrwx--x 25 root root 3488 2022-04-14 10:16 vendor
drwxrwx--x 3 root root 3488 2022-04-14 10:19 vendor_ce
drwxrwx--x 4 root root 3488 2022-04-14 10:16 vendor_de
console:/data #
console:/data #
console:/data # sc
schedtest screencap screenrecord
console:/data # scr
screencap screenrecord
console:/data # screencap 01.png
console:/data #
console:/data #
console:/data # getprop qemu.hw.mainkeys
1
console:/data #
console:/data # setprop qemu.hw.mainkeys 0
console:/data #
console:/data #
console:/data # getprop qemu.hw.mainkeys
0
console:/data #
console:/data # stop
console:/data #
console:/data # start
console:/data #
console:/data #
console:/data # input keyevent 82
console:/data #
console:/data # sc
schedtest screencap screenrecord
console:/data # scr
screencap screenrecord
console:/data # screencap 11-key.png
console:/data #
[2]、修改config.xml文件
设置config_showNavigationBar为true就可以打开系统的虚拟键
framework/base/core/res/res/values/config.xml
<!-- Whether a software navigation bar should be shown. NOTE: in the future this may be
autodetected from the Configuration. -->
<bool name="config_showNavigationBar">true</bool>
<!--<bool name="config_supportSystemNavigationKeys">false</bool>-->
Z:\mt6739_android10\frameworks\base\core\res\res\values\config.xml
<!-- Whether a software navigation bar should be shown. NOTE: in the future this may be
autodetected from the Configuration. -->
<bool name="config_showNavigationBar">false</bool>
修改为:
<!-- Whether a software navigation bar should be shown. NOTE: in the future this may be
autodetected from the Configuration. -->
<bool name="config_showNavigationBar">true</bool>
一般这种config 文件都会有overlay文件,所以也需要修改对应的device下的overlay文件
device\qcom\msm8953_64\overlay\frameworks\base\core\res\res\values\config.xml
<!-- Whether a software navigation bar should be shown. NOTE: in the future this may be
autodetected from the Configuration. -->
<bool name="config_showNavigationBar">true</bool>
<!--<bool name="config_supportSystemNavigationKeys">false</bool>-->
Z:\mt6739_android10\device\mediatek\common\overlay\navbar\frameworks\base\core\res\res\values\config.xml
方法一:
在Z:\mt6739_android10\device\mediatek\目录下:find . -name config.xml
之后在Ultraedit中先查找frameworks然后在查找overlay。
可以看见:config_showNavigationBar已经为真了!
<!-- These resources are around just to allow their values to be customized
for different hardware and product builds. Do not translate. -->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Whether a software navigation bar should be shown. NOTE: in the future this may be
autodetected from the Configuration. -->
<bool name="config_showNavigationBar">true</bool>
</resources>
方法二:
rootroot@rootroot-System-Product1:~/mt6739_android10/device$
rootroot@rootroot-System-Product1:~/mt6739_android10/device$ grep config_showNavigationBar . -R
./linaro/hikey/overlay/frameworks/base/core/res/res/values/config.xml: <bool name="config_showNavigationBar">true</bool>
./linaro/poplar/overlay/frameworks/base/core/res/res/values/config.xml: <bool name="config_showNavigationBar">true</bool>
grep: ./linaro/bootloader/edk2/EmulatorPkg/Unix/Host/X11IncludeHack: No such file or directory
./generic/armv7-a-neon/overlay/frameworks/base/core/res/res/values/config.xml: <bool name="config_showNavigationBar">true</bool>
./generic/x86/overlay/frameworks/base/core/res/res/values/config.xml: <bool name="config_showNavigationBar">true</bool>
./google/bonito/bonito/overlay/frameworks/base/core/res/res/values/config.xml: <bool name="config_showNavigationBar">true</bool>
./google/bonito/sargo/overlay/frameworks/base/core/res/res/values/config.xml: <bool name="config_showNavigationBar">true</bool>
./google/bonito/overlay/frameworks/base/core/res/res/values/config.xml: <bool name="config_showNavigationBar">true</bool>
./google/marlin/overlay/frameworks/base/core/res/res/values/config.xml: <bool name="config_showNavigationBar">true</bool>
./google/cuttlefish/vsoc_arm64/phone/overlay/frameworks/base/core/res/res/values/config.xml: <bool name="config_showNavigationBar">true</bool>
./google/cuttlefish/vsoc_x86_64/phone/overlay/frameworks/base/core/res/res/values/config.xml: <bool name="config_showNavigationBar">true</bool>
./google/cuttlefish/vsoc_x86/phone/overlay/frameworks/base/core/res/res/values/config.xml: <bool name="config_showNavigationBar">true</bool>
./google/crosshatch/blueline/overlay/frameworks/base/core/res/res/values/config.xml: <bool name="config_showNavigationBar">true</bool>
./google/crosshatch/crosshatch/overlay/frameworks/base/core/res/res/values/config.xml: <bool name="config_showNavigationBar">true</bool>
./google/crosshatch/overlay/frameworks/base/core/res/res/values/config.xml: <bool name="config_showNavigationBar">true</bool>
./google/wahoo/overlay/frameworks/base/core/res/res/values/config.xml: <bool name="config_showNavigationBar">true</bool>
grep: ./ti/beagle_x15/hostcc/ld: No such file or directory
grep: ./ti/beagle_x15/hostcc/strings: No such file or directory
grep: ./ti/beagle_x15/hostcc/gcc: No such file or directory
grep: ./ti/beagle_x15/hostcc/g++: No such file or directory
grep: ./ti/beagle_x15/hostcc/ar: No such file or directory
grep: ./ti/beagle_x15/hostcc/ld.bfd: No such file or directory
grep: ./ti/beagle_x15/hostcc/cc: No such file or directory
./ti/beagle_x15/overlay/frameworks/base/core/res/res/values/config.xml: <bool name="config_showNavigationBar">true</bool>
./mediatek/common/overlay/navbar/frameworks/base/core/res/res/values/config.xml: <bool name="config_showNavigationBar">true</bool>
./mediatek/build/mcs/Q0.basic_hiddenapi-stub-flags.txt:Lcom/android/internal/R$bool;->config_showNavigationBar:I
./mediatek/system/common/overlay/navbar/frameworks/base/core/res/res/values/config.xml: <bool name="config_showNavigationBar">true</bool>
rootroot@rootroot-System-Product1:~/mt6739_android10/device$
[3]、添加配置文件
添加qemu.hw.mainkeys=0,也就是修改 androdi系统的system/build.prop
device\qcom\msm8953_64\system.prop
qemu.hw.mainkeys=0
rootroot@rootroot-System-Product1:~/mt6739_android10/device$
rootroot@rootroot-System-Product1:~/mt6739_android10/device$ find . -name system.prop
./linaro/hikey/system.prop
./bird/bird_k39tv1_bsp_1g/system.prop
./google/marlin/system.prop
./google/wahoo/system.prop
./mediateksample/k50v1_64_bsp/system.prop
./mediateksample/k57pv1_1g_hdp_ago/system.prop
./mediateksample/k62v1_32_bsp_2g/system.prop
./mediateksample/k62mv1_32_bsp/system.prop
./mediateksample/k50sv1_64_bsp/system.prop
./mediateksample/k61v1_32_bsp_hdp/system.prop
./mediateksample/k39tv1_bsp_512/system.prop
./mediateksample/k61v1_hdp_ref_1g/system.prop
./mediateksample/k39tv1_bsp_1g/system.prop
./mediateksample/k63v2_64_bsp/system.prop
./mediateksample/k50sv1_bsp/system.prop
./mediateksample/k61v1_hdp_ref/system.prop
./mediateksample/k61v1_64_bsp/system.prop
./mediateksample/k62v1_64_bsp/system.prop
./mediateksample/k57pv1_dm_2g_hdp/system.prop
./mediateksample/k80_bsp/system.prop
./mediateksample/k57pv1_dm_64/system.prop
./mediateksample/k39tv1_64_bsp/system.prop
./mediateksample/k61v1_32_bsp_1g/system.prop
./mediateksample/k80hd_bsp_fwv_512m/system.prop
./mediateksample/k63v1us_64_bsp/system.prop
./mediateksample/k39tlc_bsp/system.prop
./mediateksample/k62v1_32_bsp/system.prop
./mediateksample/k39tv1_bsp/system.prop
./mediateksample/k50v1_bsp/system.prop
./agenew/AGN_8149D_S553E_E_MV3216_Q/system.prop
./agenew/AGN_7130D_S40285B_PEP_E_DS442_Q/system.prop
./agenew/AGN_9186D_S5080AE_E_DS883_Q/system.prop
./agenew/AGN_9186D_S40410_E_DS843_Q/system.prop
./agenew/AGN_7130D_S40411B_AM_DS883_V12_FTM/system.prop
./agenew/AGN_H180XO_D39_F_MV1616_Q/system.prop
./agenew/AGN_8149D_S553H_E_MV168_Q/system.prop
./agenew/AGN_7130D_S40411B_AM_DS883_V12/system.prop
./agenew/AGN_H180XO_FTM/system.prop
./agenew/AGN_H188XO_D33A_FTM_MV3224/system.prop
./agenew/AGN_9186D_I950K_E_MV88/system.prop
./agenew/AGN_7130D_S40411A_E_DS843_Q/system.prop
./agenew/AGN_H188XOA_D33_C3AX_MV1616_Q_V01/system.prop
./agenew/AGN_H188XO_D33_FTM_MV3224/system.prop
./agenew/AGN_H188XOA_D33Y_C3AX_MV1616_Q_V01/system.prop
./agenew/AGN_H152XO_NFT10_ALL_P1P2P3_Q/system.prop
./agenew/AGN_7130D_B25_DS883S_V12_FTM/system.prop
./agenew/AGN_7130D_B1258_DS883_V12_FTM/system.prop
./agenew/AGN_H199XO_H600_MV1616_Q/system.prop
./agenew/AGN_H185WOPA_FTM_MV88_Q/system.prop
./agenew/AGN_L30D_K4080D_E_MV88_V06_QGO/system.prop
./agenew/AGN_H213XO_C90_E4BX_FTM_Q/system.prop
./agenew/AGN_H188XO_FTM_MV1616/system.prop
./agenew/AGN_L30D_B25_MV88_V06_FTM/system.prop
./agenew/AGN_H185WOPA_D36_F_MV88_Q/system.prop
./agenew/AGN_H180XO_FTM_MV1616_Q/system.prop
./agenew/AGN_H192XO_D31_MV1616_Q/system.prop
./agenew/AGN_H205XOA_C6000_E3AX_P1_ALL/system.prop
./agenew/AGN_H170XO_W102_MV1616_HDPLUS_FTM/system.prop
./agenew/AGN_H192XO_MT6762_FTM/system.prop
./agenew/AGN_7130D_S40411C_Q_DS883_V12/system.prop
./agenew/AGN_7130D_L5015C_AM_DS883_Q/system.prop
./agenew/AGN_9186D_S5080AE_E_DS883_Q_HD/system.prop
./agenew/AGN_8149D_E01A_E_MV168_Q/system.prop
./agenew/AGN_H213XO_C90_E4BX_ALL_Q/system.prop
./agenew/AGN_7130D_B1258_DS883S_V12_FTM/system.prop
./agenew/AGN_H188XO_D33_G6_MV1616/system.prop
./agenew/AGN_8149D_E01A_E_MV88_Q/system.prop
./agenew/AGN_H196XO_M110/system.prop
./agenew/AGN_8149WOF_I960AC_E_MV1616/system.prop
./agenew/AGN_H180XO_D36_F_MV1616_Q/system.prop
./agenew/AGN_7130D_V12_FTM/system.prop
./agenew/H163XO_M103_G6_MV1616_CN/system.prop
./agenew/AGN_9186D_I940C_E_MV88/system.prop
./agenew/AGN_H185WOPA_D37_F_MV88_Q/system.prop
./mediatek/system/common/system.prop
rootroot@rootroot-System-Product1:~/mt6739_android10/device$
Z:\mt6739_android10\device\bird\bird_k39tv1_bsp_1g\system.prop
# temporary enables NAV bar (soft keys)
qemu.hw.mainkeys=0
我表示我已经【崩溃了】,参考资料走完了一遍,但是导航栏还是没有出现!
本帖是msm8953/骁龙625平台的,MT6739的android10只能用来参考!
baidu的时候,有帖子说android10下,google已经拿掉导航栏了!
不死心,死马当活马医!于是:
rootroot@rootroot-System-Product1:~/mt6739_android10$
rootroot@rootroot-System-Product1:~/mt6739_android10$ grep qemu.hw.mainkeys . -R
./bird/device/common.mk: PRODUCT_PROPERTY_OVERRIDES += qemu.hw.mainkeys=1
grep: ./external/e2fsprogs/config/ltmain.sh: No such file or directory
grep: ./external/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/bad_symlink: No such file or directory
grep: ./external/kmod/testsuite/rootfs-pristine/test-loaded/sys/module/btusb/drivers/usb:btusb: No such file or directory
grep: ./external/bcc/tests/lua/spec: No such file or directory
grep: ./external/python/mock/docs/changelog.txt: No such file or directory
grep: ./packages/apps/Calendar/libs/android-support-v4.jar: No such file or directory
./device/linaro/hikey/device-common.mk:PRODUCT_PROPERTY_OVERRIDES += qemu.hw.mainkeys=0
grep: ./device/linaro/bootloader/edk2/EmulatorPkg/Unix/Host/X11IncludeHack: No such file or directory
./device/generic/goldfish/qemu-props/qemu-props.c: } else if (strcmp(temp, "qemu.hw.mainkeys") == 0 ) {
./device/bird/bird_k39tv1_bsp_1g/system.prop:qemu.hw.mainkeys=0
./device/google/marlin/system.prop:qemu.hw.mainkeys=0
./device/common/common.mk: PRODUCT_PROPERTY_OVERRIDES += qemu.hw.mainkeys=1
grep: ./device/ti/beagle_x15/hostcc/ld: No such file or directory
grep: ./device/ti/beagle_x15/hostcc/strings: No such file or directory
grep: ./device/ti/beagle_x15/hostcc/gcc: No such file or directory
grep: ./device/ti/beagle_x15/hostcc/g++: No such file or directory
grep: ./device/ti/beagle_x15/hostcc/ar: No such file or directory
grep: ./device/ti/beagle_x15/hostcc/ld.bfd: No such file or directory
grep: ./device/ti/beagle_x15/hostcc/cc: No such file or directory
./device/mediateksample/k50v1_64_bsp/system.prop:qemu.hw.mainkeys=0
./device/mediateksample/k57pv1_1g_hdp_ago/system.prop:qemu.hw.mainkeys=0
Z:\mt6739_android10\bird\device\common.mk
#AGENEW add by nimengfei for removing virtual buttons @20200103 begin
ifeq ($(strip $(AGN_REMOVE_VIRTUAL_KEY)), yes)
PRODUCT_PROPERTY_OVERRIDES += qemu.hw.mainkeys=1
endif
#AGENEW add by nimengfei for removing virtual buttons @20200103 end
修改为:
#AGENEW add by nimengfei for removing virtual buttons @20200103 begin
ifeq ($(strip $(AGN_REMOVE_VIRTUAL_KEY)), yes)
PRODUCT_PROPERTY_OVERRIDES += qemu.hw.mainkeys=0
endif
#AGENEW add by nimengfei for removing virtual buttons @20200103 end
Z:\mt6739_android10\device\common\common.mk
#AGENEW add by nimengfei for removing virtual buttons @20200103 begin
ifeq ($(strip $(AGN_REMOVE_VIRTUAL_KEY)), yes)
PRODUCT_PROPERTY_OVERRIDES += qemu.hw.mainkeys=1
endif
#AGENEW add by nimengfei for removing virtual buttons @20200103 end
修改为:
#AGENEW add by nimengfei for removing virtual buttons @20200103 begin
ifeq ($(strip $(AGN_REMOVE_VIRTUAL_KEY)), yes)
PRODUCT_PROPERTY_OVERRIDES += qemu.hw.mainkeys=0
endif
#AGENEW add by nimengfei for removing virtual buttons @20200103 end
【解决问题了!】
参考资料:
https://blog.csdn.net/weixin_44008788/article/details/108404794
Android系统开启导航栏NavigationBar(虚拟按键)