From 9f9390ddfccab706ff2d346fdbd408c1cfc1c312 Mon Sep 17 00:00:00 2001 From: Ram N Date: Sat, 10 Nov 2018 08:52:14 -0800 Subject: [PATCH] Moved androidID constant to a method Summary: androidID was a constant that was exposed as a Platform constant, but it seems to use slightly expensive methods when they need to be computed. Moving this to a method so that it is computed only when needed. Test Plan Reviewed By: ejanzer Differential Revision: D6563853 fbshipit-source-id: 3c5929fcbc947c13c3a25f2bf473e145ac4bf73e --- .../react/modules/systeminfo/AndroidInfoModule.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/AndroidInfoModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/AndroidInfoModule.java index ee9dfbc3d31b22..3860cb9671f4f9 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/AndroidInfoModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/AndroidInfoModule.java @@ -15,6 +15,7 @@ import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.common.build.ReactBuildConfig; +import com.facebook.react.bridge.ReactMethod; import com.facebook.react.module.annotations.ReactModule; import java.util.HashMap; @@ -76,7 +77,11 @@ public String getName() { constants.put("isTesting", "true".equals(System.getProperty(IS_TESTING))); constants.put("reactNativeVersion", ReactNativeVersion.VERSION); constants.put("uiMode", uiMode()); - constants.put("androidID", Secure.getString(getReactApplicationContext().getContentResolver(), Secure.ANDROID_ID)); return constants; } + + @ReactMethod(isBlockingSynchronousMethod = true) + public String getAndroidID(){ + return Secure.getString(getReactApplicationContext().getContentResolver(),Secure.ANDROID_ID); + } }