Skip to content

Commit

Permalink
use wifi info only for 2 funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
kesha-antonov committed Oct 16, 2017
1 parent 61cdeaa commit a2eefc1
Showing 1 changed file with 10 additions and 6 deletions.
Expand Up @@ -40,17 +40,21 @@ public RNDeviceModule(ReactApplicationContext reactContext) {
super(reactContext);

this.reactContext = reactContext;


WifiManager manager = (WifiManager) reactContext.getSystemService(Context.WIFI_SERVICE);
this.wifiInfo = manager.getConnectionInfo();
}

@Override
public String getName() {
return "RNDeviceInfo";
}

private WifiInfo getWifiInfo() {
if ( this.wifiInfo == null ) {
WifiManager manager = (WifiManager) reactContext.getSystemService(Context.WIFI_SERVICE);
this.wifiInfo = manager.getConnectionInfo();
}
return this.wifiInfo;
}

private String getCurrentLanguage() {
Locale current = getReactApplicationContext().getResources().getConfiguration().locale;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Expand Down Expand Up @@ -95,13 +99,13 @@ public void isPinOrFingerprintSet(Callback callback) {

@ReactMethod
public void getIpAddress(Promise p) {
String ipAddress = Formatter.formatIpAddress(wifiInfo.getIpAddress());
String ipAddress = Formatter.formatIpAddress(getWifiInfo().getIpAddress());
p.resolve(ipAddress);
}

@ReactMethod
public void getMacAddress(Promise p) {
String macAddress = wifiInfo.getMacAddress();
String macAddress = getWifiInfo().getMacAddress();
p.resolve(macAddress);
}

Expand Down

0 comments on commit a2eefc1

Please sign in to comment.