• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import Log from '../../../../../../../../common/src/main/ets/default/Log'
17import {ScreenLockStatus} from '../../../../../../../../common/src/main/ets/default/ScreenLockCommon'
18import screenLockService from '../model/screenLockService'
19
20const TAG = 'ScreenLock-LockIconViewModel'
21
22export default class LockIconViewModel {
23    cutMessage: any= {}
24    iconPath: any= {}
25
26    ViewModelInit(): void{
27        Log.showDebug(TAG, `ViewModelInit`);
28        this.iconPath = $r('app.media.ic_public_lock_filled');
29        this.cutMessage = $r('app.string.lock_prompt')
30    }
31
32    onStatusChange(lockStatus: ScreenLockStatus): void {
33        Log.showInfo(TAG, `onStatusChange lockStatus:${lockStatus}`);
34        switch (lockStatus) {
35            case ScreenLockStatus.Locking:
36                this.iconPath = $r('app.media.ic_public_lock_filled');
37                this.cutMessage = $r('app.string.lock_prompt')
38                break;
39            case ScreenLockStatus.Unlock:
40                this.iconPath = $r('app.media.ic_public_unlock_filled');
41                this.cutMessage = $r('app.string.unlock_prompt')
42                break;
43            case ScreenLockStatus.RecognizingFace:
44                this.iconPath = $r('app.media.ic_public_unlock_filled');
45                this.cutMessage = $r('app.string.recognizing_face')
46                break;
47            case ScreenLockStatus.FaceNotRecognized:
48                this.iconPath = $r('app.media.ic_public_unlock_filled');
49                this.cutMessage = $r('app.string.face_not_recognized')
50                break;
51            default:
52                this.iconPath = $r('app.media.ic_public_lock_filled');
53                this.cutMessage = $r('app.string.lock_prompt')
54                break;
55        }
56    }
57
58    onRecognizeFace(lockStatus: ScreenLockStatus) {
59        Log.showInfo(TAG, `onRecognizeFace lockStatus: ${lockStatus}`);
60        if (lockStatus == ScreenLockStatus.FaceNotRecognized) {
61            screenLockService.authUserByFace()
62        }
63    }
64}