support launch screenlock by SystemUI

Signed-off-by: yangpeng85 <yangpeng85@huawei.com>
This commit is contained in:
yangpeng85 2022-08-05 15:19:38 +08:00
parent 409058131b
commit d1642b0e43
41 changed files with 80 additions and 74 deletions

3
.gitignore vendored
View File

@ -2,4 +2,5 @@
/local.properties
/.idea
**/build
/features/**/build
/features/**/build
/.hvigor

View File

@ -1,15 +1,15 @@
{
"app": {
"bundleName": "com.ohos.screenlock",
"vendor": "example",
"bundleName": "com.ohos.systemui",
"vendor": "ohos",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"singleton": true,
"keepAlive":true,
"minAPIVersion": 9,
"keepAlive": true,
"minAPIVersion": 8,
"targetAPIVersion": 9
}
}

View File

@ -1,3 +1,4 @@
// @ts-nocheck
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
@ -30,7 +31,7 @@ export type TimeEventArgs = {
timeFormat: boolean;
};
const TAG = "TimeManager";
const TAG = "TimeManagerSc";
const URI_VAR = "dataability:///com.ohos.settingsdata.DataAbility";
const TIME_FORMAT_KEY = settings.date.TIME_FORMAT;
const TIME_SUBSCRIBE_INFO = {

View File

@ -1,3 +1,4 @@
// @ts-nocheck
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
@ -38,7 +39,7 @@ export const WINDOW_SHOW_HIDE_EVENT = "WindowShowHideEvent";
export const WINDOW_RESIZE_EVENT = "WindowResizeEvent";
type WindowHandle = typeof Window.Window;
const TAG = "WindowManager";
const TAG = "WindowManagerSc";
const SYSTEM_WINDOW_TYPE_MAP: { [key in WindowType]: number } = {
SystemUi_StatusBar: 2108,
SystemUi_NavigationBar: 2112,

View File

@ -22,7 +22,7 @@ import { Callback, createEventBus, EventBus } from "./EventBus";
export type unsubscribe = () => void;
export type Events = string | string[];
const TAG = "EventManager";
const TAG = "EventManagerSc";
class EventManager {
mEventBus: EventBus<string>;

View File

@ -3,7 +3,7 @@
"name": "common",
"type": "har",
"deviceTypes": [
"phone",
"default",
"tablet"
],
"uiSyntax": "ets"

View File

@ -6,7 +6,7 @@
"description": "$string:entry_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone",
"default",
"tablet"
],
"deliveryWithInstall": true,
@ -21,6 +21,8 @@
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"visible": true,
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:startWindowBackground",
"skills": [
{
"entities": [

View File

@ -0,0 +1,8 @@
{
"color": [
{
"name": "startWindowBackground",
"value": "#ffffff"
}
]
}

View File

@ -1,3 +1,4 @@
// @ts-nocheck
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
@ -25,7 +26,7 @@ import {
POLICY,
} from "../../../../../../common/src/main/ets/default/commonEvent/CommonEventManager";
const TAG = "BatteryComponent-batteryModel";
const TAG = "BatteryComponent-batteryModelSc";
const DEFAULT_PROGRESS = 100;
const SUBSCRIBE_INFO = {
events: [commonEvent.Support.COMMON_EVENT_BATTERY_CHANGED],

View File

@ -3,7 +3,7 @@
"name": "batterycomponent",
"type": "har",
"deviceTypes": [
"phone",
"default",
"tablet"
],
"uiSyntax": "ets"

View File

@ -3,7 +3,7 @@
"name": "clockcomponent",
"type": "har",
"deviceTypes": [
"phone",
"default",
"tablet"
],
"uiSyntax": "ets"

View File

@ -3,7 +3,7 @@
"name": "datetimecomponent",
"type": "har",
"deviceTypes": [
"phone",
"default",
"tablet"
],
"uiSyntax": "ets"

View File

@ -28,8 +28,8 @@ export default class CommonUtil {
static startWant(want, triggerInfo?: any) {
let info = (triggerInfo) ? triggerInfo : DEFAULT_INFO;
Log.showDebug(TAG, `startWant ${JSON.stringify(want)}, info ${JSON.stringify(info)}`);
WantAgent.trigger(want, info, ((err, data) => {
Log.showDebug(TAG, `wantAgent trigger err ${JSON.stringify(err)} data ${JSON.stringify(data)}`);
WantAgent.trigger(want, info, ((data) => {
Log.showDebug(TAG, `wantAgent trigger data ${JSON.stringify(data)}`);
}));
}

View File

@ -13,8 +13,6 @@
* limitations under the License.
*/
import notification from '@ohos.notification';
import NotificationSubscriber from '@ohos.notificationSubscriber';
import Log from '../../../../../../../../../common/src/main/ets/default/Log';
import NotificationManager from './NotificationManager';
import ParseDataUtil from './ParseDataUtil';
@ -23,7 +21,7 @@ import CommonUtil from '../common/CommonUtil';
import createOrGet from "../../../../../../../../../common/src/main/ets/default/SingleInstanceHelper";
import DistributionManager from './NotificationDistributionManager';
const TAG = 'NotificationService';
const TAG = 'NotificationServiceSc';
interface NotificationListener {
userId: number;

View File

@ -13,14 +13,12 @@
* limitations under the License.
*/
import Notification from '@ohos.notification';
import AccountManager from '@ohos.account.osAccount';
import Log from '../../../../../../../../../common/src/main/ets/default/Log';
import BundleManager from '../../../../../../../../../common/src/main/ets/default/abilitymanager/bundleManager';
import AbilityManager from '../../../../../../../../../common/src/main/ets/default/abilitymanager/abilityManager';
import DistributionManager from './NotificationDistributionManager';
import NotificationManager from './NotificationManager';
import Constants, {NotificationItemData} from '../common/constants';
import {NotificationItemData} from '../common/constants';
import {NotificationConfig} from './NotificationConfig';
const TAG = 'Notification_ParseDataUtil';
@ -39,11 +37,8 @@ type NotificationContent = {
}
async function getUserId(uid) {
let userId = await AccountManager.getAccountManager().getOsAccountLocalIdFromUid(uid)
.catch((err)=>{
Log.showError(TAG, `getOsAccountLocalIdFromUid error error: ${JSON.stringify(err)}`);
})
Log.showDebug(TAG, `getOsAccountLocalIdFromUid uid = ${uid}, userId = ${userId}`);
let userId = await AccountManager.getAccountManager().getOsAccountLocalIdFromUid(uid);
Log.showInfo(TAG, `getOsAccountLocalIdFromUid uid = ${uid}, userId = ${userId}`);
return userId;
}
@ -112,8 +107,8 @@ export default class ParseDataUtil {
let context = AbilityManager.getContext()??AbilityManager.getContext(AbilityManager.ABILITY_NAME_SCREEN_LOCK);
let item = await BundleManager.getResourceManager(TAG, context, bundleName);
let appMessage = {
appName: labelId > 0 ? await item.getString(labelId) : '',
icon: iconId > 0 ? await item.getMediaBase64(iconId) : null
appName: parseInt(labelId) > 0 ? await item.getString(parseInt(labelId)) : '',
icon: parseInt(iconId) > 0 ? await item.getMediaBase64(parseInt(iconId)) : null
};
if (appMessage.icon != null && appMessage.appName) {
appDataMap.set(bundleName, appMessage);

View File

@ -1,3 +1,4 @@
// @ts-nocheck
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -27,8 +27,8 @@ type NotificationLayoutConfig = {
@Component
export default struct NotificationListComponent {
@Provide('notificationUpdate') update: number = 0;
@StorageLink('notificationList') notificationList: any[] = []
@Provide('notificationUpdateSc') update: number = 0;
@StorageLink('notificationListSc') notificationList: any[] = []
private config: NotificationLayoutConfig = {
itemMargin: Layout.ITEM_MARGIN
}

View File

@ -28,7 +28,7 @@ const TAG = 'NoticeItem-GeneralItem';
@Component
export default struct GeneralItem {
@Consume('notificationUpdate') updateFlag: number;
@Consume('notificationUpdateSc') updateFlag: number;
@State hasPicture: boolean = false
@State @Watch('expandChange') isExpand: boolean = false
@State needExpand: boolean = true

View File

@ -24,7 +24,7 @@ const TAG = 'NoticeItem-GroupItem';
@Component
export default struct GroupItem {
@Consume('notificationUpdate') updateFlag: number;
@Consume('notificationUpdateSc') updateFlag: number;
@State distributedDeviceName: string = ''
@State @Watch('expandChange') toExpand: boolean = false;
private groupData: any[] = []

View File

@ -1,3 +1,4 @@
// @ts-nocheck
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
@ -16,8 +17,6 @@
import Log from '../../../../../../../../../common/src/main/ets/default/Log';
import SwitchUserManager from '../../../../../../../../../common/src/main/ets/default/SwitchUserManager';
import media from '@ohos.multimedia.media';
import vibrator from '@ohos.vibrator';
import wantAgent from '@ohos.wantAgent';
import SourceType from '@ohos.notification'
import NotificationService from '../model/NotificationService'
import NotificationWindowManager from '../model/NotificationWindowManager';
@ -129,7 +128,7 @@ export class ViewModel {
Log.showDebug(TAG, `updateNotification length: ${this.mNotificationList.length}`);
this.sortNotification()
let notificationList = this.groupByGroupName();
AppStorage.SetOrCreate('notificationList', notificationList);
AppStorage.SetOrCreate('notificationListSc', notificationList);
}
groupByGroupName(): any[]{

View File

@ -3,7 +3,7 @@
"name": "noticeitem",
"type": "har",
"deviceTypes": [
"phone",
"default",
"tablet"
],
"uiSyntax": "ets"

View File

@ -1,3 +1,4 @@
// @ts-nocheck
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -150,9 +150,9 @@ export class ScreenLockService {
lockScreen() {
Trace.start(Trace.CORE_METHOD_SHOW_LOCK_SCREEN);
Log.showDebug(TAG, `lockScreen`);
let length = Router.getLength()
let length = parseInt(Router.getLength())
Log.showDebug(TAG, `Router.getLength: ${length}`)
for (let index = 1;index < length; index++) {
for (let index = 1; index < length; index++) {
Log.showInfo(TAG, `back to index`);
Router.back();
}

View File

@ -3,7 +3,7 @@
"name": "screenlock",
"type": "har",
"deviceTypes": [
"phone",
"default",
"tablet"
],
"uiSyntax": "ets"

View File

@ -3,7 +3,7 @@
"name": "shortcutcomponent",
"type": "har",
"deviceTypes": [
"phone",
"default",
"tablet"
],
"uiSyntax": "ets"

View File

@ -3,7 +3,7 @@
"name": "signalcomponent",
"type": "har",
"deviceTypes": [
"phone",
"default",
"tablet"
],
"uiSyntax": "ets"

View File

@ -3,7 +3,7 @@
"name": "wallpapercomponent",
"type": "har",
"deviceTypes": [
"phone",
"default",
"tablet"
],
"uiSyntax": "ets"

View File

@ -3,7 +3,7 @@
"name": "wificomponent",
"type": "har",
"deviceTypes": [
"phone",
"default",
"tablet"
],
"uiSyntax": "ets"

View File

@ -1,18 +1,19 @@
{
"license":"ISC",
"devDependencies":{},
"name":"screenlock",
"ohos":{
"org":"huawei",
"directoryLevel":"project",
"buildTool":"hvigor"
},
"description":"example description",
"repository":{},
"version":"1.0.0",
"dependencies":{
"@ohos/hvigor-ohos-plugin":"1.0.6",
"hypium":"^1.0.0",
"@ohos/hvigor":"1.0.6"
}
}
"license": "ISC",
"devDependencies": {},
"name": "systemui",
"ohos": {
"org": "huawei",
"directoryLevel": "project",
"buildTool": "hvigor"
},
"description": "example description",
"repository": {},
"version": "1.0.0",
"dependencies": {
"@ohos/hvigor-ohos-plugin": "1.1.6",
"hypium": "^1.0.0",
"@ohos/hvigor": "1.1.6",
"@ohos/hypium": "1.0.1"
}
}

View File

@ -31,7 +31,6 @@ export default struct CustomPassword {
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear`)
setAppBgColor('#00000000')
CommonStyleManager.setAbilityPageName(TAG)
let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_STATUS_BAR, 'rect')
this.mHeightPx = configInfo.height

View File

@ -31,7 +31,6 @@ export default struct DigitalPassword {
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear`)
setAppBgColor('#00000000')
CommonStyleManager.setAbilityPageName(TAG)
let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_STATUS_BAR, 'rect')
Log.showInfo(TAG, `configMaxWidth${JSON.stringify(configInfo.height)}`)

View File

@ -71,7 +71,7 @@ struct Index {
}
onBackPress(): boolean {
let length = Router.getLength()
let length = parseInt(Router.getLength())
Log.showInfo(TAG, `onBackPress length: ${length}`)
if (length > 1) {
Router.back()

View File

@ -31,7 +31,6 @@ export default struct MixedPassword {
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear`)
setAppBgColor('#00000000')
CommonStyleManager.setAbilityPageName(TAG)
let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_STATUS_BAR, 'rect')
Log.showDebug(TAG, `configMaxWidth${JSON.stringify(configInfo.height)}`)

View File

@ -4,7 +4,7 @@
"type": "feature",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:pc_desc",
"mainElement": "ServiceExtAbility",
"mainElement": "com.ohos.systemui.screenlock.ServiceExtAbility",
"deviceTypes": [
"tablet"
],
@ -73,7 +73,7 @@
],
"extensionAbilities": [
{
"name": "ServiceExtAbility",
"name": "com.ohos.systemui.screenlock.ServiceExtAbility",
"srcEntrance": "./ets/ServiceExtAbility/ServiceExtAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",

View File

@ -31,7 +31,6 @@ export default struct CustomPassword {
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear`)
setAppBgColor('#00000000')
CommonStyleManager.setAbilityPageName(TAG)
let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_STATUS_BAR, 'rect')
Log.showDebug(TAG, `configMaxWidth${JSON.stringify(configInfo.height)}`)

View File

@ -31,7 +31,6 @@ export default struct DigitalPassword {
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear`)
setAppBgColor('#00000000')
CommonStyleManager.setAbilityPageName(TAG)
let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_STATUS_BAR, 'rect')
Log.showDebug(TAG, `configMaxWidth${JSON.stringify(configInfo.height)}`)

View File

@ -72,7 +72,7 @@ struct Index {
}
onBackPress(): boolean {
let length = Router.getLength()
let length = parseInt(Router.getLength())
Log.showDebug(TAG, `onBackPress length: ${length}`)
if (length > 1) {
Router.back()

View File

@ -31,7 +31,6 @@ export default struct MixedPassword {
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear`)
setAppBgColor('#00000000')
CommonStyleManager.setAbilityPageName(TAG)
let configInfo = AbilityManager.getAbilityData(AbilityManager.ABILITY_NAME_STATUS_BAR, 'rect')
Log.showDebug(TAG, `configMaxWidth${JSON.stringify(configInfo.height)}`)

View File

@ -111,6 +111,8 @@ export default struct SlideScreenlock {
}
.alignItems(HorizontalAlign.Center)
.width(Constants.NOTIFICATION_AREA_WIDTH)
.borderWidth("4vp")
.borderColor(Color.Green)
}
.width(Constants.FULL_CONTAINER_WIDTH)
.height(Constants.FULL_CONTAINER_HEIGHT)

View File

@ -4,9 +4,9 @@
"type": "feature",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_desc",
"mainElement": "ServiceExtAbility",
"mainElement": "com.ohos.systemui.screenlock.ServiceExtAbility",
"deviceTypes": [
"phone"
"default"
],
"deliveryWithInstall": true,
"installationFree": false,
@ -70,7 +70,7 @@
],
"extensionAbilities": [
{
"name": "ServiceExtAbility",
"name": "com.ohos.systemui.screenlock.ServiceExtAbility",
"srcEntrance": "./ets/ServiceExtAbility/ServiceExtAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",