fix(mobile): passcode timing options (#1744)

This commit is contained in:
Mo
2022-10-05 10:08:54 -05:00
committed by GitHub
parent a4de9a05a9
commit 6c26b96cdc
14 changed files with 151 additions and 130 deletions

View File

@@ -483,7 +483,7 @@ export class ApplicationState extends ApplicationService {
return
}
const hasBiometrics = this.application.hasBiometrics()
const hasBiometrics = this.application.protections.hasBiometricsEnabled()
const hasPasscode = this.application.hasPasscode()
const passcodeLockImmediately = hasPasscode && this.passcodeTiming === MobileUnlockTiming.Immediately
const biometricsLockImmediately =
@@ -571,19 +571,19 @@ export class ApplicationState extends ApplicationService {
}
private async getScreenshotPrivacyEnabled(): Promise<boolean> {
return this.application.getMobileScreenshotPrivacyEnabled()
return this.application.protections.getMobileScreenshotPrivacyEnabled()
}
private async getPasscodeTiming(): Promise<MobileUnlockTiming | undefined> {
return this.application.getMobilePasscodeTiming()
return this.application.protections.getMobilePasscodeTiming()
}
private async getBiometricsTiming(): Promise<MobileUnlockTiming | undefined> {
return this.application.getMobileBiometricsTiming()
return this.application.protections.getMobileBiometricsTiming()
}
public async setScreenshotPrivacyEnabled(enabled: boolean) {
await this.application.setMobileScreenshotPrivacyEnabled(enabled)
await this.application.protections.setMobileScreenshotPrivacyEnabled(enabled)
this.screenshotPrivacyEnabled = enabled
await (this.application.deviceInterface as MobileDevice).setAndroidScreenshotPrivacy(enabled)
}

View File

@@ -197,7 +197,7 @@ export const Authenticate = ({
state: AuthenticationValueStateType.Pending,
})
if (await application?.getMobileScreenshotPrivacyEnabled()) {
if (application?.protections.getMobileScreenshotPrivacyEnabled()) {
hide()
}

View File

@@ -31,21 +31,23 @@ export const SecuritySection = (props: Props) => {
const [hasBiometrics, setHasBiometrics] = useState(false)
const [supportsBiometrics, setSupportsBiometrics] = useState(false)
const [biometricsTimingOptions, setBiometricsTimingOptions] = useState(() =>
application!.getBiometricsTimingOptions(),
application!.protections.getMobileBiometricsTimingOptions(),
)
const [passcodeTimingOptions, setPasscodeTimingOptions] = useState(() =>
application!.protections.getMobilePasscodeTimingOptions(),
)
const [passcodeTimingOptions, setPasscodeTimingOptions] = useState(() => application!.getPasscodeTimingOptions())
useEffect(() => {
let mounted = true
const getHasScreenshotPrivacy = async () => {
const hasScreenshotPrivacyEnabled = application?.getMobileScreenshotPrivacyEnabled()
const hasScreenshotPrivacyEnabled = application?.protections.getMobileScreenshotPrivacyEnabled()
if (mounted) {
setHasScreenshotPrivacy(hasScreenshotPrivacyEnabled)
}
}
void getHasScreenshotPrivacy()
const getHasBiometrics = async () => {
const appHasBiometrics = application!.hasBiometrics()
const appHasBiometrics = application!.protections.hasBiometricsEnabled()
if (mounted) {
setHasBiometrics(appHasBiometrics)
}
@@ -68,7 +70,7 @@ export const SecuritySection = (props: Props) => {
useFocusEffect(
useCallback(() => {
if (props.hasPasscode) {
setPasscodeTimingOptions(() => application!.getPasscodeTimingOptions())
setPasscodeTimingOptions(() => application!.protections.getMobilePasscodeTimingOptions())
}
}, [application, props.hasPasscode]),
)
@@ -126,12 +128,12 @@ export const SecuritySection = (props: Props) => {
const setBiometricsTiming = async (timing: MobileUnlockTiming) => {
await application?.getAppState().setBiometricsTiming(timing)
setBiometricsTimingOptions(() => application!.getBiometricsTimingOptions())
setBiometricsTimingOptions(() => application!.protections.getMobileBiometricsTimingOptions())
}
const setPasscodeTiming = async (timing: MobileUnlockTiming) => {
await application?.getAppState().setPasscodeTiming(timing)
setPasscodeTimingOptions(() => application!.getPasscodeTimingOptions())
setPasscodeTimingOptions(() => application!.protections.getMobilePasscodeTimingOptions())
}
const onScreenshotPrivacyPress = async () => {
@@ -153,14 +155,14 @@ export const SecuritySection = (props: Props) => {
void disableAuthentication('biometrics')
} else {
setHasBiometrics(true)
await application?.enableBiometrics()
await application?.protections.enableBiometrics()
await setBiometricsTiming(MobileUnlockTiming.OnQuit)
props.updateProtectionsAvailable()
}
}
const disableBiometrics = useCallback(async () => {
if (await application?.disableBiometrics()) {
if (await application?.protections.disableBiometrics()) {
setHasBiometrics(false)
props.updateProtectionsAvailable()
}