From 048f88a33a53ebd4e45865b319c42291f1d6c7f2 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Wed, 18 Dec 2019 08:18:40 -0800 Subject: [PATCH] Fix NativePlatformConstants Summary: When in debug mode, PlatformConstants doesn't have a `ServerHost` constant. This wasn't captured by `NativePlatformConstants`. Changelog: [Android][Fixed] - Make sure ServerHost is optional in NativePlatformConstants.js Reviewed By: rickhanlonii Differential Revision: D19091270 fbshipit-source-id: 4b3ac73a4ab6111b3e433ecca01cc769e8cdec6b --- .../FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h | 4 ++-- Libraries/Utilities/NativePlatformConstantsAndroid.js | 2 +- Libraries/Utilities/Platform.android.js | 2 +- .../fbreact/specs/NativePlatformConstantsAndroidSpec.java | 5 +++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h b/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h index 4e361e2bef4..6bf1ef4a993 100644 --- a/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h +++ b/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h @@ -1976,7 +1976,7 @@ namespace JS { RCTRequired Serial; RCTRequired Fingerprint; RCTRequired Model; - RCTRequired ServerHost; + NSString *ServerHost; RCTRequired uiMode; }; @@ -3633,7 +3633,7 @@ inline JS::NativePlatformConstantsAndroid::Constants::Builder::Builder(const Inp d[@"Fingerprint"] = Fingerprint; auto Model = i.Model.get(); d[@"Model"] = Model; - auto ServerHost = i.ServerHost.get(); + auto ServerHost = i.ServerHost; d[@"ServerHost"] = ServerHost; auto uiMode = i.uiMode.get(); d[@"uiMode"] = uiMode; diff --git a/Libraries/Utilities/NativePlatformConstantsAndroid.js b/Libraries/Utilities/NativePlatformConstantsAndroid.js index dcf276ae2ac..39aa25d8c49 100644 --- a/Libraries/Utilities/NativePlatformConstantsAndroid.js +++ b/Libraries/Utilities/NativePlatformConstantsAndroid.js @@ -27,7 +27,7 @@ export interface Spec extends TurboModule { Serial: string, Fingerprint: string, Model: string, - ServerHost: string, + ServerHost?: string, uiMode: string, |}; +getAndroidID: () => string; diff --git a/Libraries/Utilities/Platform.android.js b/Libraries/Utilities/Platform.android.js index 13b0586701e..3785bc8790a 100644 --- a/Libraries/Utilities/Platform.android.js +++ b/Libraries/Utilities/Platform.android.js @@ -38,7 +38,7 @@ const Platform = { Serial: string, Fingerprint: string, Model: string, - ServerHost: string, + ServerHost?: string, uiMode: string, |} { if (this.__constants == null) { diff --git a/ReactAndroid/src/main/java/com/facebook/fbreact/specs/NativePlatformConstantsAndroidSpec.java b/ReactAndroid/src/main/java/com/facebook/fbreact/specs/NativePlatformConstantsAndroidSpec.java index c39b6a03d53..c8340538348 100644 --- a/ReactAndroid/src/main/java/com/facebook/fbreact/specs/NativePlatformConstantsAndroidSpec.java +++ b/ReactAndroid/src/main/java/com/facebook/fbreact/specs/NativePlatformConstantsAndroidSpec.java @@ -47,11 +47,12 @@ public abstract class NativePlatformConstantsAndroidSpec extends ReactContextBas "Version", "reactNativeVersion", "Model", - "ServerHost", "isTesting", "Release" )); - Set optionalFlowConstants = new HashSet<>(); + Set optionalFlowConstants = new HashSet<>(Arrays.asList( + "ServerHost" + )); Set undeclaredConstants = new HashSet<>(constants.keySet()); undeclaredConstants.removeAll(obligatoryFlowConstants); undeclaredConstants.removeAll(optionalFlowConstants);