Commit 88e6ba64 authored by Kesha Antonov's avatar Kesha Antonov

fix: Error: The WIFI_SERVICE must be looked up on the Application context or…

fix:  Error: The WIFI_SERVICE must be looked up on the Application context or memory will leak on devices < Android N. Try changing reactContext to reactContext.getApplicationContext()  [WifiManagerLeak] WifiManager manager = (WifiManager) reactContext.getSystemService(Context.WIFI_SERVICE);
parent a2eefc11
......@@ -49,7 +49,7 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
private WifiInfo getWifiInfo() {
if ( this.wifiInfo == null ) {
WifiManager manager = (WifiManager) reactContext.getSystemService(Context.WIFI_SERVICE);
WifiManager manager = (WifiManager) reactContext.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
this.wifiInfo = manager.getConnectionInfo();
}
return this.wifiInfo;
......@@ -93,7 +93,7 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
@ReactMethod
public void isPinOrFingerprintSet(Callback callback) {
KeyguardManager keyguardManager = (KeyguardManager) this.reactContext.getSystemService(Context.KEYGUARD_SERVICE); //api 16+
KeyguardManager keyguardManager = (KeyguardManager) this.reactContext.getApplicationContext().getSystemService(Context.KEYGUARD_SERVICE); //api 16+
callback.invoke(keyguardManager.isKeyguardSecure());
}
......@@ -165,7 +165,7 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
(getCurrentActivity().checkCallingOrSelfPermission(Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED ||
getCurrentActivity().checkCallingOrSelfPermission(Manifest.permission.READ_SMS) == PackageManager.PERMISSION_GRANTED ||
getCurrentActivity().checkCallingOrSelfPermission("android.permission.READ_PHONE_NUMBERS") == PackageManager.PERMISSION_GRANTED)) {
TelephonyManager telMgr = (TelephonyManager) this.reactContext.getSystemService(Context.TELEPHONY_SERVICE);
TelephonyManager telMgr = (TelephonyManager) this.reactContext.getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
constants.put("phoneNumber", telMgr.getLine1Number());
}
return constants;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment