Commit 22b4e52b authored by Kacyn Fujii's avatar Kacyn Fujii

add check if security is enabled

parent c843144e
...@@ -162,6 +162,12 @@ RCT_EXPORT_MODULE() ...@@ -162,6 +162,12 @@ RCT_EXPORT_MODULE()
return [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad; return [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad;
} }
- (bool) isSecurityEnabled
{
LAContext *context = [[LAContext alloc] init];
return ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:nil]);
}
- (NSDictionary *)constantsToExport - (NSDictionary *)constantsToExport
{ {
UIDevice *currentDevice = [UIDevice currentDevice]; UIDevice *currentDevice = [UIDevice currentDevice];
...@@ -186,6 +192,7 @@ RCT_EXPORT_MODULE() ...@@ -186,6 +192,7 @@ RCT_EXPORT_MODULE()
@"timezone": self.timezone, @"timezone": self.timezone,
@"isEmulator": @(self.isEmulator), @"isEmulator": @(self.isEmulator),
@"isTablet": @(self.isTablet), @"isTablet": @(self.isTablet),
@"isSecurityEnabled": @(self.isSecurityEnabled),
}; };
} }
......
...@@ -69,6 +69,11 @@ public class RNDeviceModule extends ReactContextBaseJavaModule { ...@@ -69,6 +69,11 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
return layout == Configuration.SCREENLAYOUT_SIZE_LARGE || layout == Configuration.SCREENLAYOUT_SIZE_XLARGE; return layout == Configuration.SCREENLAYOUT_SIZE_LARGE || layout == Configuration.SCREENLAYOUT_SIZE_XLARGE;
} }
private Boolean isSecurityEnabled() {
KeyguardManager keyguardManager = (KeyguardManager) this.reactContext.getSystemService(Context.KEYGUARD_SERVICE); //api 16+
return keyguardManager.isKeyguardSecure();
}
@Override @Override
public @Nullable Map<String, Object> getConstants() { public @Nullable Map<String, Object> getConstants() {
HashMap<String, Object> constants = new HashMap<String, Object>(); HashMap<String, Object> constants = new HashMap<String, Object>();
...@@ -113,6 +118,7 @@ public class RNDeviceModule extends ReactContextBaseJavaModule { ...@@ -113,6 +118,7 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
constants.put("timezone", TimeZone.getDefault().getID()); constants.put("timezone", TimeZone.getDefault().getID());
constants.put("isEmulator", this.isEmulator()); constants.put("isEmulator", this.isEmulator());
constants.put("isTablet", this.isTablet()); constants.put("isTablet", this.isTablet());
constants.put("isSecurityEnabled", this.isSecurityEnabled());
return constants; return constants;
} }
} }
...@@ -62,4 +62,7 @@ module.exports = { ...@@ -62,4 +62,7 @@ module.exports = {
isTablet: function() { isTablet: function() {
return RNDeviceInfo.isTablet; return RNDeviceInfo.isTablet;
}, },
isSecurityEnabled: function () {
return RNDeviceInfo.isSecurityEnabled;
},
}; };
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