Fix fetching sourcemap in genymotion. Fixes #5338

Summary:Source maps are broken on Genymotion right now as they aren't being loaded from the correct URL. refer - https://github.com/facebook/react-native/issues/5338#issuecomment-188232402

**Test plan**

Build and install UIExplorer from master branch in genymotion and enable hot reload. When you change a file and save it, you'll see a Yellow box due to source map fetching failed, as per the referenced comment.

Doing the same for this branch doesn't produce any yellow boxes.
Closes https://github.com/facebook/react-native/pull/6594

Differential Revision: D3088218

Pulled By: martinbigio

fb-gh-sync-id: 0d1c19cc263de5c6c62061c399eef33fa4ac4a7b
shipit-source-id: 0d1c19cc263de5c6c62061c399eef33fa4ac4a7b
This commit is contained in:
Satyajit Sahoo
2016-03-24 12:05:48 -07:00
committed by Facebook Github Bot 6
parent c4699d8b73
commit 6c22a2174e
6 changed files with 68 additions and 40 deletions

View File

@@ -0,0 +1,33 @@
package com.facebook.react.modules.systeminfo;
import android.os.Build;
public class AndroidInfoHelpers {
public static final String EMULATOR_LOCALHOST = "10.0.2.2:8081";
public static final String GENYMOTION_LOCALHOST = "10.0.3.2:8081";
public static final String DEVICE_LOCALHOST = "localhost:8081";
private static boolean isRunningOnGenymotion() {
return Build.FINGERPRINT.contains("vbox");
}
private static boolean isRunningOnStockEmulator() {
return Build.FINGERPRINT.contains("generic");
}
public static String getServerHost() {
// Since genymotion runs in vbox it use different hostname to refer to adb host.
// We detect whether app runs on genymotion and replace js bundle server hostname accordingly
if (isRunningOnGenymotion()) {
return GENYMOTION_LOCALHOST;
}
if (isRunningOnStockEmulator()) {
return EMULATOR_LOCALHOST;
}
return DEVICE_LOCALHOST;
}
}

View File

@@ -9,14 +9,14 @@
package com.facebook.react.modules.systeminfo;
import javax.annotation.Nullable;
import android.os.Build;
import com.facebook.react.bridge.BaseJavaModule;
import java.util.HashMap;
import java.util.Map;
import android.os.Build;
import com.facebook.react.bridge.BaseJavaModule;
import javax.annotation.Nullable;
/**
* Module that exposes Android Constants to JS.
@@ -32,6 +32,7 @@ public class AndroidInfoModule extends BaseJavaModule {
public @Nullable Map<String, Object> getConstants() {
HashMap<String, Object> constants = new HashMap<String, Object>();
constants.put("Version", Build.VERSION.SDK_INT);
constants.put("ServerHost", AndroidInfoHelpers.getServerHost());
return constants;
}
}