From 50ee75482d2105cefa7d26d8130346c8ac4ae3b5 Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Mon, 18 Jul 2022 16:51:25 +0800 Subject: [PATCH] Signed-off-by: lovechinamo Changes to be committed: --- .../systemplugin/napi/ohos_screenLock.js | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/runtime/main/extend/systemplugin/napi/ohos_screenLock.js b/runtime/main/extend/systemplugin/napi/ohos_screenLock.js index 893f232c..edf5f1d1 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_screenLock.js +++ b/runtime/main/extend/systemplugin/napi/ohos_screenLock.js @@ -52,6 +52,45 @@ export function mockScreenLock() { resolve(); }) } + }, + on: function (...args) { + console.warn("screenLock.on 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); + } + } + }, + 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); + } + } + }, + sendScreenLockEvent: function (...args) { + console.warn("screenLock.sendScreenLockEvent 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') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock); + } else { + return new Promise((resolve) => { + resolve(paramMock.paramBooleanMock); + }) + } } } return screenLock