Skip to content

Commit

Permalink
Moved androidID constant to a method
Browse files Browse the repository at this point in the history
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
  • Loading branch information
axe-fb authored and facebook-github-bot committed Nov 10, 2018
1 parent 188cbb0 commit 9f9390d
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

0 comments on commit 9f9390d

Please sign in to comment.