mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Implement new HostTargetMetadata fields (Android Bridgeless) (#45249)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45249 Follows D58288489, D58415181. Implements the remaining `HostTargetMetadata` fields, sent by the debugger on `ReactNativeApplication.metadataUpdated`, on **Android Bridgeless**. This will be used to display details such as the app name and React Native version in the debugger frontend. Changelog: [Internal] Reviewed By: javache Differential Revision: D59271755 fbshipit-source-id: a2488fed98df0800ec0a611d2317cd40cd809aac
This commit is contained in:
committed by
Facebook GitHub Bot
parent
297ccf325f
commit
9da07d70dc
+8
@@ -61,6 +61,7 @@ import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags;
|
||||
import com.facebook.react.modules.appearance.AppearanceModule;
|
||||
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
|
||||
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
||||
import com.facebook.react.modules.systeminfo.AndroidInfoHelpers;
|
||||
import com.facebook.react.runtime.internal.bolts.Task;
|
||||
import com.facebook.react.runtime.internal.bolts.TaskCompletionSource;
|
||||
import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder;
|
||||
@@ -73,6 +74,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
@@ -90,6 +92,7 @@ import kotlin.jvm.functions.Function0;
|
||||
*
|
||||
* @see <a href="https://github.com/BoltsFramework/Bolts-Android#tasks">Bolts Android</a>
|
||||
*/
|
||||
@DoNotStrip
|
||||
@ThreadSafe
|
||||
@Nullsafe(Nullsafe.Mode.LOCAL)
|
||||
public class ReactHostImpl implements ReactHost {
|
||||
@@ -498,6 +501,11 @@ public class ReactHostImpl implements ReactHost {
|
||||
}
|
||||
}
|
||||
|
||||
@DoNotStrip
|
||||
private Map<String, String> getHostMetadata() {
|
||||
return AndroidInfoHelpers.getInspectorHostMetadata(mContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Entrypoint to destroy the ReactInstance. If the ReactInstance is reloading, will wait until
|
||||
* reload is finished, before destroying.
|
||||
|
||||
+20
-1
@@ -88,9 +88,28 @@ void JReactHostInspectorTarget::registerNatives() {
|
||||
|
||||
jsinspector_modern::HostTargetMetadata
|
||||
JReactHostInspectorTarget::getMetadata() {
|
||||
return {
|
||||
jsinspector_modern::HostTargetMetadata metadata = {
|
||||
.integrationName = "Android Bridgeless (ReactHostImpl)",
|
||||
};
|
||||
|
||||
if (auto javaReactHostImplStrong = javaReactHostImpl_->get()) {
|
||||
auto javaMetadata = javaReactHostImplStrong->getHostMetadata();
|
||||
auto getMethod = jni::JMap<jstring, jstring>::javaClassLocal()
|
||||
->getMethod<jobject(jobject)>("get");
|
||||
|
||||
auto getStringOptional = [&](const std::string& key) {
|
||||
auto result = getMethod(javaMetadata, make_jstring(key).get());
|
||||
return result ? std::optional<std::string>(result->toString())
|
||||
: std::nullopt;
|
||||
};
|
||||
|
||||
metadata.appIdentifier = getStringOptional("appIdentifier");
|
||||
metadata.deviceName = getStringOptional("deviceName");
|
||||
metadata.platform = getStringOptional("platform");
|
||||
metadata.reactNativeVersion = getStringOptional("reactNativeVersion");
|
||||
}
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
||||
void JReactHostInspectorTarget::onReload(const PageReloadRequest& request) {
|
||||
|
||||
+8
@@ -36,6 +36,14 @@ struct JReactHostImpl : public jni::JavaClass<JReactHostImpl> {
|
||||
"setPausedInDebuggerMessage");
|
||||
method(self(), message ? jni::make_jstring(*message) : nullptr);
|
||||
}
|
||||
|
||||
jni::local_ref<jni::JMap<jstring, jstring>> getHostMetadata() const {
|
||||
static auto method =
|
||||
javaClassStatic()
|
||||
->getMethod<jni::local_ref<jni::JMap<jstring, jstring>>()>(
|
||||
"getHostMetadata");
|
||||
return method(self());
|
||||
}
|
||||
};
|
||||
|
||||
class JReactHostInspectorTarget
|
||||
|
||||
Reference in New Issue
Block a user