android: allow registering custom packager command handlers

Summary:
@public
Apps may need to listen for custom commands via the packager connection. This allows registering such listeners.

Reviewed By: raluca-elena

Differential Revision: D8654477

fbshipit-source-id: 5f17298a88fec31b8939236fef48ee46c0ba2ee8
This commit is contained in:
Kevin Gozali authored and Facebook Github Bot committed 2018-06-27 15:34:54 -07:00
1 parent bc2f12c68c
commit b3ef1c3a56
6 files changed
+55 -9

No files matched your search

@@ -21,8 +21,10 @@ import com.facebook.react.devsupport.RedBoxHandler;
import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
import com.facebook.react.devsupport.interfaces.DevSupportManager;
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
import com.facebook.react.packagerconnection.RequestHandler;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
/**
@@ -50,6 +52,7 @@ public class ReactInstanceManagerBuilder {
private int mMinNumShakes = 1;
private int mMinTimeLeftInFrameForNonBatchedOperationMs = -1;
private @Nullable JSIModulePackage mJSIModulesPackage;
private @Nullable Map<String, RequestHandler> mCustomPackagerCommandHandlers;
/* package protected */ ReactInstanceManagerBuilder() {
}
@@ -216,6 +219,12 @@ public class ReactInstanceManagerBuilder {
return this;
}
public ReactInstanceManagerBuilder setCustomPackagerCommandHandlers(
Map<String, RequestHandler> customPackagerCommandHandlers) {
mCustomPackagerCommandHandlers = customPackagerCommandHandlers;
return this;
}
/**
* Instantiates a new {@link ReactInstanceManager}.
* Before calling {@code build}, the following must be called:
@@ -266,6 +275,7 @@ public class ReactInstanceManagerBuilder {
mDevBundleDownloadListener,
mMinNumShakes,
mMinTimeLeftInFrameForNonBatchedOperationMs,
mJSIModulesPackage);
mJSIModulesPackage,
mCustomPackagerCommandHandlers);
}
}