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
This commit is contained in:
Ram N 2018-11-10 08:52:14 -08:00 committed by Facebook Github Bot
parent 188cbb04ad
commit 9f9390ddfc
1 changed files with 6 additions and 1 deletions

View File

@ -15,6 +15,7 @@ import android.provider.Settings.Secure;
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 class AndroidInfoModule extends ReactContextBaseJavaModule {
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);
}
}