From 40ba49150c032fee5e34d80edc1fbc1a7ad27b4e Mon Sep 17 00:00:00 2001 From: chen Date: Mon, 5 Sep 2022 22:30:43 +0800 Subject: [PATCH] change Signed-off-by: chen --- .../systemplugin/napi/ohos_privacyManager.js | 55 ++++++++++++++++++- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_privacyManager.js b/runtime/main/extend/systemplugin/napi/ohos_privacyManager.js index a8100a52..efb30df0 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_privacyManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_privacyManager.js @@ -53,11 +53,22 @@ export function mockPrivacyManager() { endTime: '[PC preview] unknow endTime', bundleRecords: [BundleUsedRecordMock], }; + const ActiveChangeResponse = { + tokenId: "[PC Preview] unknown tokenId", + permissionName: "[PC Preview] unknown permissionName", + deviceId: "[PC Preview] unknown deviceId", + activeStatus: "[PC Preview] unknown activeStatus", + }; const privacyManager = { PermissionUsageFlag : { FLAG_PERMISSION_USAGE_SUMMARY: 0, FLAG_PERMISSION_USAGE_DETAIL: 1, - }, + }, + PermissionActiveStatus : { + PERM_INACTIVE: 0, + PERM_ACTIVE_IN_FOREGROUND: 1, + PERM_ACTIVE_IN_BACKGROUND: 2, + }, addPermissionUsedRecord: function (...args) { console.warn("privacyManager.addPermissionUsedRecord interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") @@ -82,6 +93,46 @@ export function mockPrivacyManager() { }) } }, + startUsingPermission: function (...args) { + console.warn("privacyManager.startUsingPermission 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 (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramNumberMock); + }); + } + }, + stopUsingPermission: function (...args) { + console.warn("privacyManager.stopUsingPermission 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 (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramNumberMock); + }); + } + }, + on: function (...args) { + console.warn("privacyManager.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 (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, ActiveChangeResponse); + } + }, + off: function (...args) { + console.warn("privacyManager.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 (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, ActiveChangeResponse); + } + }, }; return privacyManager; -} +} \ No newline at end of file