1010import android .graphics .drawable .Drawable ;
1111import android .os .Build ;
1212import android .os .Bundle ;
13+ import android .os .SystemProperties ;
1314import android .util .Log ;
1415import android .util .TypedValue ;
1516import android .view .KeyCharacterMap ;
@@ -88,8 +89,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
8889 if (!this .onCreateCalled ) {
8990 this .getLayoutInflater ().setFactory2 (new LayoutInflaterFactory (this .getDelegate ())
9091 .addOnViewCreatedListener (WindowInsetsHelper .Companion .getLISTENER ()));
91- this .hasHardwareNavBar = ViewConfiguration .get (this ).hasPermanentMenuKey () ||
92- KeyCharacterMap .deviceHasKey (KeyEvent .KEYCODE_BACK );
92+ this .hasHardwareNavBar = this .hasHardwareNavBar0 ();
9393 this .onCreateCalledOnce = true ;
9494 }
9595 Application application = this .getApplication ();
@@ -104,6 +104,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
104104
105105 @ Override
106106 protected void onResume () {
107+ this .hasHardwareNavBar = this .hasHardwareNavBar0 ();
107108 super .onResume ();
108109 this .refreshUI ();
109110 }
@@ -287,9 +288,13 @@ public int getNavigationBarHeight() {
287288
288289 public boolean hasHardwareNavBar () {
289290 // If onCreate has not been called yet, cached value is not valid
290- return this .onCreateCalledOnce ? this .hasHardwareNavBar :
291- ViewConfiguration .get (this ).hasPermanentMenuKey () ||
292- KeyCharacterMap .deviceHasKey (KeyEvent .KEYCODE_BACK );
291+ return this .onCreateCalledOnce ? this .hasHardwareNavBar : this .hasHardwareNavBar0 ();
292+ }
293+
294+ private boolean hasHardwareNavBar0 () {
295+ return (ViewConfiguration .get (this ).hasPermanentMenuKey () ||
296+ KeyCharacterMap .deviceHasKey (KeyEvent .KEYCODE_BACK )) &&
297+ !"0" .equals (SystemProperties .get ("qemu.hw.mainkeys" ));
293298 }
294299
295300 public void setActionBarExtraMenuButton (@ DrawableRes int drawableResId ,
0 commit comments