You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-16 00:14:34 +02:00
Mobile: Add log info for biometrics feature
This commit is contained in:
@ -5,6 +5,9 @@ import { View, Dimensions, Alert, Button } from 'react-native';
|
|||||||
import FingerprintScanner from 'react-native-fingerprint-scanner';
|
import FingerprintScanner from 'react-native-fingerprint-scanner';
|
||||||
import { SensorInfo } from './sensorInfo';
|
import { SensorInfo } from './sensorInfo';
|
||||||
import { _ } from '@joplin/lib/locale';
|
import { _ } from '@joplin/lib/locale';
|
||||||
|
import Logger from '@joplin/lib/Logger';
|
||||||
|
|
||||||
|
const logger = Logger.create('BiometricPopup');
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
themeId: number;
|
themeId: number;
|
||||||
@ -21,12 +24,22 @@ export default (props: Props) => {
|
|||||||
const [display, setDisplay] = useState(!!props.sensorInfo.supportedSensors && (props.sensorInfo.enabled || !initialPromptDone));
|
const [display, setDisplay] = useState(!!props.sensorInfo.supportedSensors && (props.sensorInfo.enabled || !initialPromptDone));
|
||||||
const [tryBiometricsCheck, setTryBiometricsCheck] = useState(initialPromptDone);
|
const [tryBiometricsCheck, setTryBiometricsCheck] = useState(initialPromptDone);
|
||||||
|
|
||||||
|
logger.info('Render start');
|
||||||
|
logger.info('initialPromptDone', initialPromptDone);
|
||||||
|
logger.info('display', display);
|
||||||
|
logger.info('tryBiometricsCheck', tryBiometricsCheck);
|
||||||
|
logger.info('props.sensorInfo', props.sensorInfo);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!display || !tryBiometricsCheck) return;
|
if (!display || !tryBiometricsCheck) return;
|
||||||
|
|
||||||
const biometricsCheck = async () => {
|
const biometricsCheck = async () => {
|
||||||
|
logger.info('biometricsCheck: start');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
logger.info('biometricsCheck: authenticate...');
|
||||||
await FingerprintScanner.authenticate({ description: _('Verify your identity') });
|
await FingerprintScanner.authenticate({ description: _('Verify your identity') });
|
||||||
|
logger.info('biometricsCheck: authenticate done');
|
||||||
setTryBiometricsCheck(false);
|
setTryBiometricsCheck(false);
|
||||||
setDisplay(false);
|
setDisplay(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -35,6 +48,8 @@ export default (props: Props) => {
|
|||||||
} finally {
|
} finally {
|
||||||
FingerprintScanner.release();
|
FingerprintScanner.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.info('biometricsCheck: end');
|
||||||
};
|
};
|
||||||
|
|
||||||
void biometricsCheck();
|
void biometricsCheck();
|
||||||
@ -45,6 +60,9 @@ export default (props: Props) => {
|
|||||||
if (!display) return;
|
if (!display) return;
|
||||||
|
|
||||||
const complete = (enableBiometrics: boolean) => {
|
const complete = (enableBiometrics: boolean) => {
|
||||||
|
logger.info('complete: start');
|
||||||
|
logger.info('complete: enableBiometrics:', enableBiometrics);
|
||||||
|
|
||||||
setInitialPromptDone(true);
|
setInitialPromptDone(true);
|
||||||
Setting.setValue('security.biometricsInitialPromptDone', true);
|
Setting.setValue('security.biometricsInitialPromptDone', true);
|
||||||
Setting.setValue('security.biometricsEnabled', enableBiometrics);
|
Setting.setValue('security.biometricsEnabled', enableBiometrics);
|
||||||
@ -59,6 +77,8 @@ export default (props: Props) => {
|
|||||||
type: 'BIOMETRICS_DONE_SET',
|
type: 'BIOMETRICS_DONE_SET',
|
||||||
value: true,
|
value: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
logger.info('complete: end');
|
||||||
};
|
};
|
||||||
|
|
||||||
Alert.alert(
|
Alert.alert(
|
||||||
@ -87,12 +107,18 @@ export default (props: Props) => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
logger.info('effect 1: start');
|
||||||
|
|
||||||
if (!display) {
|
if (!display) {
|
||||||
|
logger.info('effect 1: display', display);
|
||||||
|
|
||||||
props.dispatch({
|
props.dispatch({
|
||||||
type: 'BIOMETRICS_DONE_SET',
|
type: 'BIOMETRICS_DONE_SET',
|
||||||
value: true,
|
value: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.info('effect 1: end');
|
||||||
}, [display, props.dispatch]);
|
}, [display, props.dispatch]);
|
||||||
|
|
||||||
const renderTryAgainButton = () => {
|
const renderTryAgainButton = () => {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
|
import Logger from '@joplin/lib/Logger';
|
||||||
import Setting from '@joplin/lib/models/Setting';
|
import Setting from '@joplin/lib/models/Setting';
|
||||||
import FingerprintScanner from 'react-native-fingerprint-scanner';
|
import FingerprintScanner from 'react-native-fingerprint-scanner';
|
||||||
|
const logger = Logger.create('sensorInfo');
|
||||||
|
|
||||||
export interface SensorInfo {
|
export interface SensorInfo {
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
@ -12,6 +14,9 @@ export default async (): Promise<SensorInfo> => {
|
|||||||
// FingerprintScanner scanner calls, since it seems they can fail and freeze
|
// FingerprintScanner scanner calls, since it seems they can fail and freeze
|
||||||
// the app.
|
// the app.
|
||||||
|
|
||||||
|
logger.info('Start');
|
||||||
|
logger.info('security.biometricsEnabled', Setting.value('security.biometricsEnabled'));
|
||||||
|
|
||||||
if (!Setting.value('security.biometricsEnabled')) {
|
if (!Setting.value('security.biometricsEnabled')) {
|
||||||
return {
|
return {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
@ -24,7 +29,9 @@ export default async (): Promise<SensorInfo> => {
|
|||||||
let supportedSensors = '';
|
let supportedSensors = '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
logger.info('Getting isSensorAvailable...');
|
||||||
const result = await FingerprintScanner.isSensorAvailable();
|
const result = await FingerprintScanner.isSensorAvailable();
|
||||||
|
logger.info('isSensorAvailable result', result);
|
||||||
supportedSensors = result;
|
supportedSensors = result;
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
@ -34,7 +41,7 @@ export default async (): Promise<SensorInfo> => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn('Could not check for biometrics sensor:', error);
|
logger.warn('Could not check for biometrics sensor:', error);
|
||||||
Setting.setValue('security.biometricsSupportedSensors', '');
|
Setting.setValue('security.biometricsSupportedSensors', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -984,6 +984,10 @@ class AppComponent extends React.Component {
|
|||||||
const biometricIsEnabled = !!this.state.sensorInfo && this.state.sensorInfo.enabled;
|
const biometricIsEnabled = !!this.state.sensorInfo && this.state.sensorInfo.enabled;
|
||||||
const shouldShowMainContent = !biometricIsEnabled || this.props.biometricsDone;
|
const shouldShowMainContent = !biometricIsEnabled || this.props.biometricsDone;
|
||||||
|
|
||||||
|
logger.info('root.biometrics: biometricIsEnabled', biometricIsEnabled);
|
||||||
|
logger.info('root.biometrics: shouldShowMainContent', shouldShowMainContent);
|
||||||
|
logger.info('root.biometrics: this.state.sensorInfo', this.state.sensorInfo);
|
||||||
|
|
||||||
const mainContent = (
|
const mainContent = (
|
||||||
<View style={{ flex: 1, backgroundColor: theme.backgroundColor }}>
|
<View style={{ flex: 1, backgroundColor: theme.backgroundColor }}>
|
||||||
<SideMenu
|
<SideMenu
|
||||||
|
Reference in New Issue
Block a user