mirror of
https://gitee.com/openharmony/applications_screenlock
synced 2025-02-17 04:59:28 +00:00
add bytrace log for ScrrenLock
add English date Signed-off-by: yangpeng85 <yangpeng85@huawei.com>
This commit is contained in:
parent
c41660bd1d
commit
54170ef2be
74
common/src/main/ets/default/Trace.ts
Normal file
74
common/src/main/ets/default/Trace.ts
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import byTrace from "@ohos.bytrace";
|
||||
import Log from "./Log";
|
||||
|
||||
export default class Trace {
|
||||
static readonly CORE_METHOD_CALL_ACCOUNT_SYSTEM = "startToCallAccountSubsystem";
|
||||
static readonly CORE_METHOD_PASS_ACCOUNT_SYSTEM_RESULT = "passingAccountSubsystemResult";
|
||||
static readonly CORE_METHOD_CALL_PAGE_HIDE = "startToHidePage";
|
||||
|
||||
private static readonly TRACE_TAG = 'ScreenLock:Trace';
|
||||
private static readonly RECORD_TRACE = true;
|
||||
private static readonly TRACE_LIMIT = 2000;
|
||||
|
||||
private static readonly TRACE_BASE_INDEX = 10020;
|
||||
|
||||
private static init() {
|
||||
Log.showInfo(this.TRACE_TAG, 'init trace parameters');
|
||||
globalThis.taskIdMap = new Map<string, number>();
|
||||
globalThis.traceIndex = Trace.TRACE_BASE_INDEX;
|
||||
}
|
||||
|
||||
/**
|
||||
* start trace method
|
||||
*
|
||||
* @param {string} methodName - methodName for tracing
|
||||
*/
|
||||
static start(methodName: string) {
|
||||
if (!Trace.RECORD_TRACE) return;
|
||||
if (typeof globalThis.taskIdMap === 'undefined' || typeof globalThis.traceIndex === 'undefined') {
|
||||
Trace.init();
|
||||
}
|
||||
let taskId = globalThis.taskIdMap.get(methodName);
|
||||
if (taskId == undefined) {
|
||||
taskId = globalThis.traceIndex;
|
||||
globalThis.traceIndex++;
|
||||
globalThis.taskIdMap.set(methodName, taskId);
|
||||
}
|
||||
Log.showInfo(this.TRACE_TAG, `start trace ${taskId} for ${methodName}`);
|
||||
byTrace.startTrace(this.TRACE_TAG + methodName, taskId, Trace.TRACE_LIMIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* stop trace method
|
||||
*
|
||||
* @param {string} methodName - methodName for tracing
|
||||
*/
|
||||
static end(methodName: string) {
|
||||
if (!Trace.RECORD_TRACE) return;
|
||||
if (typeof globalThis.taskIdMap === 'undefined') {
|
||||
return;
|
||||
}
|
||||
const taskId = globalThis.taskIdMap.get(methodName);
|
||||
if (taskId == undefined) {
|
||||
Log.showError(this.TRACE_TAG, `fail to end trace name ${methodName}`);
|
||||
return;
|
||||
}
|
||||
Log.showInfo(this.TRACE_TAG, `end trace ${taskId} for ${methodName}`);
|
||||
byTrace.finishTrace(this.TRACE_TAG + methodName, taskId);
|
||||
}
|
||||
}
|
40
common/src/main/resources/en_US/element/string.json
Normal file
40
common/src/main/resources/en_US/element/string.json
Normal file
@ -0,0 +1,40 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "app_name",
|
||||
"value": "ScreenLock"
|
||||
},
|
||||
{
|
||||
"name": "mainability_description",
|
||||
"value": "JS_Phone_Empty Feature Ability"
|
||||
},
|
||||
{
|
||||
"name": "monday",
|
||||
"value": "Monday"
|
||||
},
|
||||
{
|
||||
"name": "tuesday",
|
||||
"value": "Tuesday"
|
||||
},
|
||||
{
|
||||
"name": "wednesday",
|
||||
"value": "Wednesday"
|
||||
},
|
||||
{
|
||||
"name": "thursday",
|
||||
"value": "Thursday"
|
||||
},
|
||||
{
|
||||
"name": "friday",
|
||||
"value": "Friday"
|
||||
},
|
||||
{
|
||||
"name": "saturday",
|
||||
"value": "Saturday"
|
||||
},
|
||||
{
|
||||
"name": "sunday",
|
||||
"value": "Sunday"
|
||||
}
|
||||
]
|
||||
}
|
40
common/src/main/resources/zh_CN/element/string.json
Normal file
40
common/src/main/resources/zh_CN/element/string.json
Normal file
@ -0,0 +1,40 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "app_name",
|
||||
"value": "ScreenLock"
|
||||
},
|
||||
{
|
||||
"name": "mainability_description",
|
||||
"value": "JS_Phone_Empty Feature Ability"
|
||||
},
|
||||
{
|
||||
"name": "monday",
|
||||
"value": "星期一"
|
||||
},
|
||||
{
|
||||
"name": "tuesday",
|
||||
"value": "星期二"
|
||||
},
|
||||
{
|
||||
"name": "wednesday",
|
||||
"value": "星期三"
|
||||
},
|
||||
{
|
||||
"name": "thursday",
|
||||
"value": "星期四"
|
||||
},
|
||||
{
|
||||
"name": "friday",
|
||||
"value": "星期五"
|
||||
},
|
||||
{
|
||||
"name": "saturday",
|
||||
"value": "星期六"
|
||||
},
|
||||
{
|
||||
"name": "sunday",
|
||||
"value": "星期日"
|
||||
}
|
||||
]
|
||||
}
|
@ -17,6 +17,7 @@ import osAccount from '@ohos.account.osAccount'
|
||||
import commonEvent from '@ohos.commonEvent';
|
||||
import util from '@ohos.util';
|
||||
import {Callback} from 'basic';
|
||||
import Trace from '../../../../../../../../common/src/main/ets/default/Trace'
|
||||
import Log from '../../../../../../../../common/src/main/ets/default/Log'
|
||||
import {UserData} from '../data/userData'
|
||||
|
||||
@ -157,9 +158,11 @@ export default class AccountsModel {
|
||||
|
||||
authUser(challenge, authType: AuthType, authLevel: number, callback) {
|
||||
Log.showDebug(TAG, `authUser param: userId ${mCurrentUserId} challenge ${challenge}`);
|
||||
Trace.end(Trace.CORE_METHOD_CALL_ACCOUNT_SYSTEM);
|
||||
this.userAuthManager.authUser(mCurrentUserId, challenge, authType, authLevel, {
|
||||
onResult: (result, extraInfo) => {
|
||||
Log.showInfo(TAG, `authUser UserAuthManager.authUser onResult`);
|
||||
Trace.start(Trace.CORE_METHOD_PASS_ACCOUNT_SYSTEM_RESULT);
|
||||
callback(result, extraInfo);
|
||||
},
|
||||
onAcquireInfo: (moduleId, acquire, extraInfo) => {
|
||||
|
@ -12,6 +12,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import Trace from '../../../../../../../../common/src/main/ets/default/Trace'
|
||||
import Log from '../../../../../../../../common/src/main/ets/default/Log'
|
||||
import ScreenLockMar from '@ohos.screenlock';
|
||||
import windowManager from '@ohos.window'
|
||||
@ -64,7 +65,9 @@ export default class ScreenLockModel {
|
||||
}
|
||||
|
||||
hiddenScreenLockWindow(callback: Callback<void>) {
|
||||
Trace.end(Trace.CORE_METHOD_PASS_ACCOUNT_SYSTEM_RESULT);
|
||||
windowManager.find(Constants.WIN_NAME).then((win) => {
|
||||
Trace.start(Trace.CORE_METHOD_CALL_PAGE_HIDE);
|
||||
win.hide().then(() => {
|
||||
Log.showInfo(TAG, `window hide`);
|
||||
callback();
|
||||
|
@ -13,6 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import Trace from '../../../../../../../../../common/src/main/ets/default/Trace'
|
||||
import Log from '../../../../../../../../../common/src/main/ets/default/Log'
|
||||
import Constants from '../../common/constants'
|
||||
import NumkeyBoard from './numkeyBoard'
|
||||
@ -35,6 +36,7 @@ export default struct CustomPSD {
|
||||
|
||||
aboutToDisappear() {
|
||||
Log.showInfo(TAG, `aboutToDisappear`)
|
||||
Trace.end(Trace.CORE_METHOD_CALL_PAGE_HIDE);
|
||||
this.mViewModel.clearPassword()
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import Trace from '../../../../../../../../../common/src/main/ets/default/Trace'
|
||||
import Log from '../../../../../../../../../common/src/main/ets/default/Log'
|
||||
import Constants from '../../common/constants'
|
||||
import NumkeyBoard from './numkeyBoard'
|
||||
@ -34,6 +35,7 @@ export default struct DigitalPSD {
|
||||
|
||||
aboutToDisappear() {
|
||||
Log.showInfo(TAG, `aboutToDisappear`)
|
||||
Trace.end(Trace.CORE_METHOD_CALL_PAGE_HIDE);
|
||||
this.mViewModel.clearPassword()
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import Trace from '../../../../../../../../../common/src/main/ets/default/Trace'
|
||||
import Log from '../../../../../../../../../common/src/main/ets/default/Log'
|
||||
import Constants from '../../common/constants'
|
||||
import ViewModel from '../../vm/mixedPSDViewModel'
|
||||
@ -34,6 +35,7 @@ export default struct MixedPSD {
|
||||
|
||||
aboutToDisappear() {
|
||||
Log.showInfo(TAG, `aboutToDisappear`)
|
||||
Trace.end(Trace.CORE_METHOD_CALL_PAGE_HIDE);
|
||||
this.mViewModel.clearPassword()
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import Trace from '../../../../../../../../common/src/main/ets/default/Trace'
|
||||
import Log from '../../../../../../../../common/src/main/ets/default/Log'
|
||||
import Constants from '../common/constants'
|
||||
import BaseViewModel, {service, AuthType, AuthSubType} from './baseViewModel'
|
||||
@ -66,6 +67,7 @@ export default class CustomPSDViewModel extends BaseViewModel {
|
||||
this.updateStorage(callback);
|
||||
return;
|
||||
}
|
||||
Trace.start(Trace.CORE_METHOD_CALL_ACCOUNT_SYSTEM);
|
||||
service.authUser(AuthSubType.PIN_MIXED, this.passwordArr, (result, extraInfo) => {
|
||||
this.clearPassword();
|
||||
if (result == 0) {
|
||||
|
@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
import Log from '../../../../../../../../common/src/main/ets/default/Log'
|
||||
import Trace from '../../../../../../../../common/src/main/ets/default/Trace'
|
||||
import Constants from '../common/constants'
|
||||
import BaseViewModel, {service, AuthType, AuthSubType} from './baseViewModel'
|
||||
import {Callback} from 'basic';
|
||||
@ -49,6 +50,7 @@ export default class DigitalPSDViewModel extends BaseViewModel {
|
||||
this.updateStorage(callback);
|
||||
}
|
||||
if (this.password.length >= PW_LEN) {
|
||||
Trace.start(Trace.CORE_METHOD_CALL_ACCOUNT_SYSTEM);
|
||||
service.authUser(AuthSubType.PIN_SIX, this.password, (result, extraInfo) => {
|
||||
this.clearPassword()
|
||||
if (result == 0) {
|
||||
|
@ -13,6 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import Trace from '../../../../../../../../common/src/main/ets/default/Trace'
|
||||
import Log from '../../../../../../../../common/src/main/ets/default/Log'
|
||||
import BaseViewModel, {service, AuthType, AuthSubType} from './baseViewModel'
|
||||
import {Callback} from 'basic';
|
||||
@ -46,6 +47,7 @@ export default class MixedPSDViewModel extends BaseViewModel {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
Trace.start(Trace.CORE_METHOD_CALL_ACCOUNT_SYSTEM);
|
||||
service.authUser(AuthSubType.PIN_MIXED, this.password, (result, extraInfo) => {
|
||||
this.clearPassword();
|
||||
if (result == 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user