react-native icon indicating copy to clipboard operation
react-native copied to clipboard

fix detection of android emulator

Open deecewan opened this issue 2 years ago • 5 comments

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

Test Plan

When running on a modern emulator, ensure that the packager attempts to load from 10.0.2.2.

deecewan avatar Oct 28 '22 03:10 deecewan

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 7,003,414 +258
android hermes armeabi-v7a 6,379,746 +253
android hermes x86 7,416,244 +255
android hermes x86_64 7,280,146 +251
android jsc arm64-v8a 8,868,429 +151
android jsc armeabi-v7a 7,606,752 +159
android jsc x86 8,926,325 +137
android jsc x86_64 9,409,569 +146

Base commit: 6a43fafd78d581f63c664b9af6d10828ac7f77fa Branch: main

analysis-bot avatar Oct 28 '22 03:10 analysis-bot

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: 76f70849578c664e9b14d96475e30e179edd7222 Branch: main

analysis-bot avatar Oct 28 '22 04:10 analysis-bot

PR build artifact for 53fd80a5f209df28e125020eb442d698dec30a54 is ready. To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball> in your React Native project.

pull-bot avatar Oct 28 '22 04:10 pull-bot

Thanks for sending this @deecewan Was this tested? Could you provide a screenshot of your emulator where to local host is properly shown to 10.0.2.2?

cortinico avatar Oct 28 '22 15:10 cortinico

Hey @cortinico - I tested this using the debugger to ensure that the isRunningOnStockEmulator method returns true for the Build.FINGERPRINT of the simulator I was running. It didn't before the change, it does afterwards.

Here's a screenshot of the getServerIpAddress running in the debugger with the changes.

Screenshot 2022-10-29 at 1 31 49 pm

I ran this by patching the file in my node_modules, then switching out the maven dependency on react-native for the ReactAndroid implementation containing the patch.

deecewan avatar Oct 29 '22 02:10 deecewan

@GijsWeterings has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot avatar Nov 14 '22 13:11 facebook-github-bot