Make Android connect to the inspector proxy

Summary: Maintains a single persistent connection to the packager for the inspector. It supports getting the available pages and connecting to them.

Reviewed By: foghina

Differential Revision: D4088690

fbshipit-source-id: 0c445225f5a3de573b199e7868c8693b78f45729
This commit is contained in:
Alexander Blom
2016-11-15 08:55:38 -08:00
committed by Facebook Github Bot
parent 655fe2796a
commit 18184a83f1
5 changed files with 362 additions and 3 deletions

View File

@@ -3,10 +3,13 @@
package com.facebook.react.bridge;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import com.facebook.common.logging.FLog;
import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.common.ReactConstants;
@DoNotStrip
public class Inspector {
@@ -17,11 +20,21 @@ public class Inspector {
private final HybridData mHybridData;
public static List<Page> getPages() {
return Arrays.asList(instance().getPagesNative());
try {
return Arrays.asList(instance().getPagesNative());
} catch (UnsatisfiedLinkError e) {
FLog.e(ReactConstants.TAG, "Inspector doesn't work in open source yet", e);
return Collections.emptyList();
}
}
public static LocalConnection connect(int pageId, RemoteConnection remote) {
return instance().connectNative(pageId, remote);
try {
return instance().connectNative(pageId, remote);
} catch (UnsatisfiedLinkError e) {
FLog.e(ReactConstants.TAG, "Inspector doesn't work in open source yet", e);
throw new RuntimeException(e);
}
}
private static native Inspector instance();