[ScreenLock]日志整改

Signed-off-by: zhangyimin <zhangyimin12@huawei.com>
This commit is contained in:
zhangyimin 2022-09-01 17:15:11 +08:00
parent 2c20556ee1
commit 436f4bc985
6 changed files with 37 additions and 48 deletions

View File

@ -7,8 +7,6 @@
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"singleton": true,
"keepAlive": true,
"minAPIVersion": 8,
"targetAPIVersion": 9
}

View File

@ -18,8 +18,8 @@ import Log from "./Log";
import hiSysEvent from '@ohos.hiSysEvent'
const TAG = 'SystemFaultLogger';
const APP_DOMAIN: string = "CoreApp";
const APP_LOG_NAME: string = "ScreenLockFault";
const APP_DOMAIN: string = "SYSTEMUI_APP";
const APP_LOG_NAME: string = "SCREENLOCK_FAULT";
interface LogParam {
FAULT_ID: string,

View File

@ -86,29 +86,28 @@ export class NotificationService {
return this.mSubscriber;
}
handleNotificationAddAndSortMap(data) {
Log.showInfo(TAG, 'handleNotificationAddAndSortMap, sortingMap' + JSON.stringify(data.sortingMap || {}));
handleNotificationAddAndSortMap(data): void {
Log.showInfo(TAG, 'handleNotificationAddAndSortMap');
this.mSortingMap = { ...this.mSortingMap, ...data?.sortingMap };
this.handleNotificationAdd(data?.request);
}
handleNotificationAdd(request) {
handleNotificationAdd(request): void {
ParseDataUtil.parseData(request, this.mSortingMap).then((intermediateData) => {
Log.showInfo(TAG, `parseData after = ${JSON.stringify(intermediateData)}`);
Log.showInfo(TAG, `parseData id=${intermediateData?.id}, timestamp=${intermediateData?.timestamp}, bundleName=${intermediateData?.bundleName}`);
RuleController.getNotificationData(intermediateData, (finalItemData) => {
Log.showInfo(TAG, `RuleController.getNotificationData after = ${JSON.stringify(finalItemData)}`);
this.mListeners.forEach((listener) => {
Log.showInfo(TAG, `notifcationUserId: ${finalItemData.userId}, listener.userId: ${listener.userId}`);
Log.showInfo(TAG, `notifcationUserId: ${finalItemData?.userId}, listener.userId: ${listener?.userId}`);
if (CommonUtil.checkVisibilityByUser(finalItemData.userId, listener.userId)) {
listener.onNotificationConsume(finalItemData);
}
})
});
});
}).catch(errorInfo => Log.showError(TAG, errorInfo));
}
handleNotificationCancel(data) {
Log.showInfo(TAG, `handleNotificationCancel hashCode: ${JSON.stringify(data?.request?.hashCode)}`);
Log.showDebug(TAG, `handleNotificationCancel hashCode: ${JSON.stringify(data?.request?.hashCode)}`);
this.mSortingMap = { ...this.mSortingMap, ...data?.sortingMap };
const hashCode = data?.request?.hashCode;
if (!hashCode) {
@ -140,10 +139,10 @@ export class NotificationService {
return pluginTempLate;
}
enableNotification(bundleOption, data) {
Log.showInfo(TAG, `enableNotification bundleOption:${JSON.stringify(bundleOption)} data:${JSON.stringify(data)} `);
NotificationManager.enableNotification(TAG, bundleOption, data, (result) => {
Log.showInfo(TAG, `enableNotification ==> result: ${JSON.stringify(result)}`);
enableNotification(bundleOption, data: boolean): void {
Log.showDebug(TAG, `enableNotification bundleOption:${JSON.stringify(bundleOption)} data:${JSON.stringify(data)} `);
NotificationManager.enableNotification(TAG, bundleOption, data, () => {
Log.showInfo(TAG, 'enableNotification succeed');
});
}

View File

@ -82,7 +82,6 @@ export default class ParseDataUtil {
deviceId: request.deviceId,
groupName: request.groupName??request.hashcode
};
Log.showDebug(TAG, `notificationItem construct over`);
notificationItem = {
...notificationItem, ...ParseDataUtil.getContentByType(request?.content?.contentType, request)
}

View File

@ -30,19 +30,15 @@ export class RuleController {
* @param {notificationItemData} Data of the notification
* @param {callback} Data of the type to show the notification
*/
getNotificationData(notificationItemData: NotificationItemData, callback) {
Log.showDebug(TAG, "getNotificationData start")
getNotificationData(notificationItemData: NotificationItemData, callback): void {
this.isAllowSendNotification(notificationItemData, (isSuccess) => {
if (!isSuccess) {
Log.showDebug(TAG, "user is not allow this to send notification");
Log.showWarn(TAG, 'user is not allow this to send notification');
callback(undefined);
return;
}
this.getNotificationDataByApp(notificationItemData, (originalData) => {
Log.showDebug(TAG, `originalData = ${JSON.stringify(originalData)}`);
this.updateNotificationDataBySense(originalData, (finalData) => {
Log.showDebug(TAG, `finalData = ${JSON.stringify(finalData)}`);
callback(finalData);
});
});
@ -55,11 +51,10 @@ export class RuleController {
* @param {notificationItemData} The origin notification data
* @param {callback} The user allow the app send notification or not
*/
isAllowSendNotification(notificationItemData, callback) {
Log.showDebug(TAG, "isAllowSendNotification start");
isAllowSendNotification(notificationItemData, callback): void {
Notification.isNotificationEnabled({ bundle: notificationItemData.bundleName, uid: notificationItemData.uid })
.then((flag) => {
Log.showInfo(TAG, `Notification.isNotificationEnabled:` + flag)
Log.showInfo(TAG, `Notification.isNotificationEnabled: ${flag}`);
callback(flag);
});
}
@ -93,8 +88,7 @@ export class RuleController {
* @param {notificationItemData} The origin notification data
* @param {callback} The type to show notification
*/
getNotificationDataByApp(notificationItemData, callback) {
Log.showDebug(TAG, "getNotificationDataByApp start")
getNotificationDataByApp(notificationItemData, callback): void {
let mNotificationItemData : NotificationItemData = notificationItemData;
mNotificationItemData.ruleData = {
isAllowBanner: false,
@ -103,7 +97,7 @@ export class RuleController {
isAllowStatusBarShow : false,
isAllowNotificationListShow : false
};
Log.showDebug(TAG, `notificationItemData.slotLevel = ${notificationItemData.slotLevel}`);
Log.showInfo(TAG, `notificationItemData.slotLevel = ${notificationItemData.slotLevel}`);
if (notificationItemData.slotLevel === SlotLevel.LEVEL_HIGH) {
mNotificationItemData.ruleData.isAllowBanner = true;
this.SoundOrVibrate(notificationItemData, (sound, vibrationValues) => {
@ -126,7 +120,7 @@ export class RuleController {
} else {
mNotificationItemData.ruleData.isAllowNotificationListShow = false;
}
Log.showDebug(TAG, `mNotificationItemData.ruleData = ${JSON.stringify(mNotificationItemData.ruleData)}`);
Log.showInfo(TAG, `mNotificationItemData.ruleData = ${JSON.stringify(mNotificationItemData.ruleData)}`);
callback(mNotificationItemData);
}
@ -138,9 +132,9 @@ export class RuleController {
* @param {notificationItemData} The origin notification data
* @param {callback} The final notification data
*/
updateNotificationDataBySense(notificationItemData, callback) {
Log.showDebug(TAG, "updateNotificationDataBySense start")
updateNotificationDataBySense(notificationItemData, callback): void {
let mNotificationItemData = notificationItemData;
// TODO Scenario Management
callback(mNotificationItemData);
}

View File

@ -82,10 +82,10 @@ export class ViewModel {
*/
onNotificationConsume(notificationItemData) {
if (notificationItemData === undefined) {
Log.showDebug(TAG, `onNotificationConsume notificationItemData is undefined`);
Log.showError(TAG, 'onNotificationConsume notificationItemData is undefined');
return;
}
this.onNotificationCancel(notificationItemData.hashcode)
this.onNotificationCancel(notificationItemData.hashcode);
Log.showDebug(TAG, `onNotificationConsume ${JSON.stringify(notificationItemData)}`);
//Verify the notifications can be displayed
if (!this.isCanShow(notificationItemData.bundleName)) {
@ -94,6 +94,7 @@ export class ViewModel {
}
if (notificationItemData.ruleData.isAllowStatusBarShow) {
//TODO statusbar show
}
if (notificationItemData.ruleData.isAllowNotificationListShow) {
this.mNotificationList.unshift(notificationItemData);
@ -108,15 +109,15 @@ export class ViewModel {
/**
* notification CancelCallback
*/
onNotificationCancel(hashCode: string) {
Log.showDebug(TAG, `onNotificationCancel hashCode: ${hashCode}`);
onNotificationCancel(hashCode: string): void {
Log.showInfo(TAG, `onNotificationCancel hashCode: ` + hashCode);
// Common Notification Deletion Logic Processing
for (let i = 0, len = this.mNotificationList.length; i < len; i++) {
if (this.mNotificationList[i].hashcode == hashCode) {
let removeItemArr = this.mNotificationList.splice(i, 1);
Log.showDebug(TAG, `onNotificationCancel removeItemArr= ${JSON.stringify(removeItemArr)}`);
if (!CheckEmptyUtils.isEmpty(removeItemArr)) {
this.updateFlowControlInfos(removeItemArr[0].bundleName, false)
this.updateFlowControlInfos(removeItemArr[0].bundleName, false);
}
this.updateNotification();
break;
@ -124,30 +125,29 @@ export class ViewModel {
}
}
updateNotification() {
Log.showDebug(TAG, `updateNotification length: ${this.mNotificationList.length}`);
this.sortNotification()
updateNotification(): void {
this.sortNotification();
let notificationList = this.groupByGroupName();
Log.showInfo(TAG, `updateNotification length: ${notificationList.length}`);
AppStorage.SetOrCreate('notificationListSc', notificationList);
}
groupByGroupName(): any[]{
Log.showDebug(TAG, `groupByGroupName`);
if (!this.mNotificationList || this.mNotificationList.length < 1) {
Log.showWarn(TAG, 'groupByGroupName, list is empty.');
return [];
}
let groupArr: any[] = [];
let groups = {};
this.mNotificationList.forEach((item) => {
const groupName = `${item.bundleName}_${item.groupName}`;
Log.showDebug(TAG, `groupByGroupName groupName:${groupName}`);
Log.showDebug(TAG, `groupByGroupName, groupName:${groupName}`);
if (!groups[groupName] || groups[groupName].length < 1) {
groups[groupName] = [];
groupArr.push(groups[groupName]);
}
groups[groupName].push(item)
})
Log.showDebug(TAG, `groupByGroupName groupArr:${JSON.stringify(groupArr)}`);
groups[groupName].push(item);
});
return groupArr;
}
@ -232,7 +232,7 @@ export class ViewModel {
Log.showDebug(TAG, `removeGroupNotification, groupName: ${itemData.groupName}`);
let groupName = itemData.groupName
for (let i = 0, len = this.mNotificationList.length; i < len; i++) {
if (this.mNotificationList[i].groupName == groupName) {
if (this.mNotificationList[i]?.groupName == groupName) {
Log.showDebug(TAG, `removeGroupNotification i = ${i}`);
let id = this.mNotificationList[i].id
let hashcode = this.mNotificationList[i].hashcode
@ -318,7 +318,6 @@ export class ViewModel {
}
updateFlowControlInfos(bundleName: string, plusOrMinus: boolean): void {
Log.showDebug(TAG, `updateFlowControlInfos`);
if (!CheckEmptyUtils.isEmpty(this.mNotificationCtrl)) {
if (this.mNotificationCtrl['app'].has(bundleName)) {
let tmp = this.mNotificationCtrl['app'].get(bundleName)