From 64ff077a6640f9eaed695287469735cb03478927 Mon Sep 17 00:00:00 2001 From: David Buchan-Swanson Date: Tue, 15 Nov 2022 07:20:36 -0800 Subject: [PATCH] fix detection of android emulator (#35111) Summary: at some point, the `Build.FINGERPRINT` of the emulator has changed and no longer includes `generic` as an option. It apparently now, on all platforms, includes `google/sdk_gphone` at the beginning. Older emulators may still include `generic` in the `Build.FINGERPRINT` so we should maintain that check too. ## Changelog [Android] [Fixed] - Fix android emulator detection for packager host Pull Request resolved: https://github.com/facebook/react-native/pull/35111 Test Plan: When running on a modern emulator, ensure that the packager attempts to load from `10.0.2.2`. Reviewed By: cipolleschi Differential Revision: D41266071 Pulled By: GijsWeterings fbshipit-source-id: 43115dbde6a411fe2ebde23e720dff4812a4309f --- .../facebook/react/modules/systeminfo/AndroidInfoHelpers.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/AndroidInfoHelpers.java b/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/AndroidInfoHelpers.java index 6f86abb28b7e94..e9c9c54c820132 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/AndroidInfoHelpers.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/AndroidInfoHelpers.java @@ -32,7 +32,8 @@ private static boolean isRunningOnGenymotion() { } private static boolean isRunningOnStockEmulator() { - return Build.FINGERPRINT.contains("generic"); + return Build.FINGERPRINT.contains("generic") + || Build.FINGERPRINT.startsWith("google/sdk_gphone"); } public static String getServerHost(Integer port) {