Skip to content

For the fix of hasPermanentMenuKey on Emulator #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,15 @@ public Map<String, Object> getConstants() {

private boolean hasPermanentMenuKey() {
final Context ctx = getReactApplicationContext();
int id = ctx.getResources().getIdentifier("config_showNavigationBar", "bool", "android");
return !(id > 0 && ctx.getResources().getBoolean(id));

if(isEmulator()) {
boolean hasPermanentMenuKey = ViewConfiguration.get(ctx).hasPermanentMenuKey();
return hasPermanentMenuKey;
} else {
int id = ctx.getResources().getIdentifier("config_showNavigationBar", "bool", "android");

return !(id > 0 && ctx.getResources().getBoolean(id));
}
}

private float getStatusBarHeight(DisplayMetrics metrics) {
Expand Down Expand Up @@ -160,4 +167,15 @@ protected static float getNormalNavigationBarHeight(final Context ctx) {
}
return 0;
}
}

public static boolean isEmulator() {
return Build.FINGERPRINT.startsWith("generic")
|| Build.FINGERPRINT.startsWith("unknown")
|| Build.MODEL.contains("google_sdk")
|| Build.MODEL.contains("Emulator")
|| Build.MODEL.contains("Android SDK built for x86")
|| Build.MANUFACTURER.contains("Genymotion")
|| (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"))
|| "google_sdk".equals(Build.PRODUCT);
}
}