@@ -2825,8 +2825,36 @@ public String getAppArg() {
2825
2825
}
2826
2826
return null ;
2827
2827
}
2828
-
2829
-
2828
+
2829
+ // taken from https://stackoverflow.com/a/70380413/756809
2830
+ private boolean isRunningOnAndroidStudioEmulator () {
2831
+ return Build .FINGERPRINT .startsWith ("google/sdk_gphone" )
2832
+ && Build .FINGERPRINT .endsWith (":user/release-keys" )
2833
+ && Build .MANUFACTURER == "Google" && Build .PRODUCT .startsWith ("sdk_gphone" ) && Build .BRAND == "google"
2834
+ && Build .MODEL .startsWith ("sdk_gphone" );
2835
+ }
2836
+
2837
+ // taken from https://stackoverflow.com/a/57960169/756809
2838
+ private boolean isEmulator () {
2839
+ return isRunningOnAndroidStudioEmulator () ||
2840
+ ((Build .BRAND .startsWith ("generic" ) && Build .DEVICE .startsWith ("generic" ))
2841
+ || Build .FINGERPRINT .startsWith ("generic" )
2842
+ || Build .FINGERPRINT .startsWith ("unknown" )
2843
+ || Build .HARDWARE .contains ("goldfish" )
2844
+ || Build .HARDWARE .contains ("ranchu" )
2845
+ || Build .MODEL .contains ("google_sdk" )
2846
+ || Build .MODEL .contains ("Emulator" )
2847
+ || Build .MODEL .contains ("Android SDK built for x86" )
2848
+ || Build .MODEL .contains ("VirtualBox" )
2849
+ || Build .MANUFACTURER .contains ("Genymotion" )
2850
+ || Build .PRODUCT .contains ("sdk_google" )
2851
+ || Build .PRODUCT .contains ("google_sdk" )
2852
+ || Build .PRODUCT .contains ("sdk" )
2853
+ || Build .PRODUCT .contains ("sdk_x86" )
2854
+ || Build .PRODUCT .contains ("vbox86p" )
2855
+ || Build .PRODUCT .contains ("emulator" )
2856
+ || Build .PRODUCT .contains ("simulator" ));
2857
+ }
2830
2858
2831
2859
2832
2860
/**
@@ -2907,6 +2935,9 @@ public String getProperty(String key, String defaultValue) {
2907
2935
if ("DeviceName" .equals (key )) {
2908
2936
return "" + android .os .Build .MODEL ;
2909
2937
}
2938
+ if ("Emulator" .equals (key )) {
2939
+ return "" + isEmulator ();
2940
+ }
2910
2941
/*try {
2911
2942
if ("IMEI".equals(key) || "UDID".equals(key)) {
2912
2943
if(!checkForPermission(Manifest.permission.READ_PHONE_STATE, "This is required to get the device ID")){
0 commit comments