From c4a47726cd0b632a892b37580e00a00d26da908b Mon Sep 17 00:00:00 2001 From: LVB8189 Date: Thu, 22 Sep 2022 14:19:55 +0800 Subject: [PATCH] Signed-off-by: LVB8189 Changes to be committed: --- .../systemplugin/napi/ohos_screenLock.js | 28 +++++-------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_screenLock.js b/runtime/main/extend/systemplugin/napi/ohos_screenLock.js index dc10e303..4e7a78cf 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_screenLock.js +++ b/runtime/main/extend/systemplugin/napi/ohos_screenLock.js @@ -65,32 +65,18 @@ export function mockScreenLock() { }) } }, - on: function (...args) { - console.warn("screenLock.on interface mocked in the Previewer. How this interface works on the" + + onSystemEvent: function (...args) { + console.warn("screenLock.onSystemEvent interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") const len = args.length if (typeof args[len - 1] === 'function') { - if (args[0] == 'beginWakeUp' || args[0] == 'endWakeUp' || args[0] == 'beginScreenOn' || args[0] == 'endScreenOn' - || args[0] == 'beginScreenOff' || args[0] == 'endScreenOff' || args[0] == 'unlockScreen' || args[0] == 'beginExitAnimation') { - args[len - 1].call(this); - } else if (args[0] == 'beginSleep' || args[0] == 'endSleep' || args[0] == 'changeUser') { - args[len - 1].call(this, paramMock.paramNumberMock); - } else if (args[0] == 'screenlockEnabled') { - args[len - 1].call(this, paramMock.paramBooleanMock); - } + args[len - 1].call(this, screenLock.SystemEvent) } + return paramMock.paramBooleanMock }, - off: function (...args) { - console.warn("screenLock.off interface mocked in the Previewer. How this interface works on the" + - " Previewer may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - if (args[0] == 'beginWakeUp' || args[0] == 'endWakeUp' || args[0] == 'beginScreenOn' || args[0] == 'endScreenOn' - || args[0] == 'beginScreenOff' || args[0] == 'endScreenOff' || args[0] == 'unlockScreen' || args[0] == 'beginExitAnimation' - || args[0] == 'screenlockEnabled' || args[0] == 'beginSleep' || args[0] == 'endSleep' || args[0] == 'changeUser') { - args[len - 1].call(this); - } - } + SystemEvent: { + eventType: '[PC Preview] unknow eventType', + params: paramMock.paramStringMock }, sendScreenLockEvent: function (...args) { console.warn("screenLock.sendScreenLockEvent interface mocked in the Previewer. How this interface works on the" +