mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add appDisplayName to inspector host metadata (#45250)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45250 Adds and implements a new `appDisplayName` field as part of `HostTargetMetadata` and the `ReactNativeApplication.metadataUpdated` CDP event. This will be used to display the app display name in the debugger frontend. Changelog: [Internal] Reviewed By: robhogan Differential Revision: D59273360 fbshipit-source-id: d770cccadb520b9c13c7288cd690df21683d2cc1
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9da07d70dc
commit
09bfb68a39
@@ -191,6 +191,7 @@ class RCTBridgeHostTargetDelegate : public facebook::react::jsinspector_modern::
|
||||
auto metadata = [RCTInspectorUtils getHostMetadata];
|
||||
|
||||
return {
|
||||
.appDisplayName = [metadata.appDisplayName UTF8String],
|
||||
.appIdentifier = [metadata.appIdentifier UTF8String],
|
||||
.deviceName = [metadata.deviceName UTF8String],
|
||||
.integrationName = "iOS Bridge (RCTBridge)",
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
// containing the nonnull members implemented by getHostMetadata.
|
||||
@interface CommonHostMetadata : NSObject
|
||||
|
||||
@property (nonatomic, strong) NSString *appDisplayName;
|
||||
@property (nonatomic, strong) NSString *appIdentifier;
|
||||
@property (nonatomic, strong) NSString *deviceName;
|
||||
@property (nonatomic, strong) NSString *platform;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
CommonHostMetadata *metadata = [[CommonHostMetadata alloc] init];
|
||||
|
||||
metadata.appDisplayName = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleNameKey];
|
||||
metadata.appIdentifier = [[NSBundle mainBundle] bundleIdentifier];
|
||||
metadata.platform = RCTPlatformName;
|
||||
metadata.deviceName = [device name];
|
||||
|
||||
+18
-1
@@ -8,6 +8,7 @@
|
||||
package com.facebook.react.modules.systeminfo;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import com.facebook.common.logging.FLog;
|
||||
@@ -72,9 +73,25 @@ public class AndroidInfoHelpers {
|
||||
* jsinspector_modern::HostTargetMetadata}.
|
||||
*/
|
||||
public static Map<String, String> getInspectorHostMetadata(@Nullable Context applicationContext) {
|
||||
String appIdentifier = null;
|
||||
String appDisplayName = null;
|
||||
|
||||
if (applicationContext != null) {
|
||||
ApplicationInfo applicationInfo = applicationContext.getApplicationInfo();
|
||||
int labelResourceId = applicationInfo.labelRes;
|
||||
|
||||
appIdentifier = applicationContext.getPackageName();
|
||||
appDisplayName =
|
||||
labelResourceId == 0
|
||||
? applicationInfo.nonLocalizedLabel.toString()
|
||||
: applicationContext.getString(labelResourceId);
|
||||
}
|
||||
|
||||
return MapBuilder.<String, String>of(
|
||||
"appDisplayName",
|
||||
appDisplayName,
|
||||
"appIdentifier",
|
||||
applicationContext != null ? applicationContext.getPackageName() : null,
|
||||
appIdentifier,
|
||||
"platform",
|
||||
"android",
|
||||
"deviceName",
|
||||
|
||||
+1
@@ -125,6 +125,7 @@ ReactInstanceManagerInspectorTarget::getMetadata() {
|
||||
};
|
||||
|
||||
return {
|
||||
.appDisplayName = getStringOptional("appDisplayName"),
|
||||
.appIdentifier = getStringOptional("appIdentifier"),
|
||||
.deviceName = getStringOptional("deviceName"),
|
||||
.integrationName = "Android Bridge (ReactInstanceManagerInspectorTarget)",
|
||||
|
||||
+1
@@ -103,6 +103,7 @@ JReactHostInspectorTarget::getMetadata() {
|
||||
: std::nullopt;
|
||||
};
|
||||
|
||||
metadata.appDisplayName = getStringOptional("appDisplayName");
|
||||
metadata.appIdentifier = getStringOptional("appIdentifier");
|
||||
metadata.deviceName = getStringOptional("deviceName");
|
||||
metadata.platform = getStringOptional("platform");
|
||||
|
||||
@@ -223,6 +223,9 @@ bool HostTargetController::decrementPauseOverlayCounter() {
|
||||
folly::dynamic hostMetadataToDynamic(const HostTargetMetadata& metadata) {
|
||||
folly::dynamic result = folly::dynamic::object;
|
||||
|
||||
if (metadata.appDisplayName) {
|
||||
result["appDisplayName"] = metadata.appDisplayName.value();
|
||||
}
|
||||
if (metadata.appIdentifier) {
|
||||
result["appIdentifier"] = metadata.appIdentifier.value();
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ class HostCommandSender;
|
||||
class HostTarget;
|
||||
|
||||
struct HostTargetMetadata {
|
||||
std::optional<std::string> appDisplayName;
|
||||
std::optional<std::string> appIdentifier;
|
||||
std::optional<std::string> deviceName;
|
||||
std::optional<std::string> integrationName;
|
||||
|
||||
@@ -46,6 +46,7 @@ class RCTHostHostTargetDelegate : public facebook::react::jsinspector_modern::Ho
|
||||
auto metadata = [RCTInspectorUtils getHostMetadata];
|
||||
|
||||
return {
|
||||
.appDisplayName = [metadata.appDisplayName UTF8String],
|
||||
.appIdentifier = [metadata.appIdentifier UTF8String],
|
||||
.deviceName = [metadata.deviceName UTF8String],
|
||||
.integrationName = "iOS Bridgeless (RCTHost)",
|
||||
|
||||
Reference in New Issue
Block a user