From 614e3bf2a77a4d2d3f1ab18b3be718bf7458bdee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=BF=E6=96=87=E5=B9=BF?= Date: Thu, 24 Feb 2022 11:41:17 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0d.td=E4=B8=AD=E6=9C=AA?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=9A=84api-mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 耿文广 --- .../extend/systemplugin/ohos/bundleManager.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/runtime/main/extend/systemplugin/ohos/bundleManager.js b/runtime/main/extend/systemplugin/ohos/bundleManager.js index 6c07ee18..0ed9584d 100644 --- a/runtime/main/extend/systemplugin/ohos/bundleManager.js +++ b/runtime/main/extend/systemplugin/ohos/bundleManager.js @@ -1509,5 +1509,29 @@ export function mockBundleManager() { }); } }, + getAllShortcutInfo: function (...args) { + console.warn("bundle.getAllShortcutInfo 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, ShortcutInfosMock) + } else { + return new Promise((resolve) => { + resolve(ShortcutInfosMock) + }); + } + }, + getModuleUsageRecords: function (...args) { + console.warn("bundle.getModuleUsageRecords 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,ModeleUsageRecordsMock) + } else { + return new Promise((resolve) => { + resolve(ModeleUsageRecordsMock) + }); + } + } } } From 3f89825f52ab384a5e039a57f962db696fb7ff29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=BF=E6=96=87=E5=B9=BF?= Date: Thu, 24 Feb 2022 16:13:25 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0bundle.d.ts=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=AD=E6=9C=AA=E6=B7=BB=E5=8A=A0=E7=9A=84api-mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 耿文广 --- .../extend/systemplugin/ohos/bundleManager.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/runtime/main/extend/systemplugin/ohos/bundleManager.js b/runtime/main/extend/systemplugin/ohos/bundleManager.js index 0ed9584d..7cc70a6c 100644 --- a/runtime/main/extend/systemplugin/ohos/bundleManager.js +++ b/runtime/main/extend/systemplugin/ohos/bundleManager.js @@ -886,6 +886,25 @@ export function mockBundleManager() { installTime: "[PC preview] unknown install time", } +const ExtensionAbilityInfoMock = [ + { + bundleName: "[PC preview] unknown bundle name", + moduleName: "[PC preview] unknown module name", + name: "[PC preview] unknown name", + labelId: "[PC preview] unknown label id", + descriptionId: "[PC preview] unknown description id", + iconId: "[PC preview] unknown icon id", + isVisible: "[PC preview] unknown is visible", + extensionAbilityType: "[PC preview] unknown extension abilityType", + permissions: "[PC preview] unknown permissions", + applicationInfo: "[PC preview] unknown application info", + metadata: "[PC preview] unknown metadata", + enabled: "[PC preview] unknown enabled", + readPermission: "[PC preview] unknown read permission", + writePermission: "[PC preview] unknown write permission", + } +] + const ModuleUpdateFlagMock = { FLAG_MODULE_UPGRADE_CHECK: 0, FLAG_MODULE_UPGRADE_INSTALL: 1, @@ -1532,6 +1551,18 @@ export function mockBundleManager() { resolve(ModeleUsageRecordsMock) }); } + }, + queryExtensionAbilityInfosByWant: function (...args) { + console.warn("bundle.queryExtensionAbilityInfosByWant 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,ExtensionAbilityInfoMock) + } else { + return new Promise((resolve) => { + resolve(ExtensionAbilityInfoMock) + }); + } } } }