From f4bc32ed6232da4705e1717f4cc8c57cc32f3652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=BF=E6=96=87=E5=B9=BF?= Date: Fri, 8 Jul 2022 16:24:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=85=E7=AE=A1=E7=90=86api-mock=E8=A1=A5?= =?UTF-8?q?=E9=BD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 耿文广 --- .../systemplugin/napi/bundle/abilityInfo.js | 18 +- .../napi/bundle/applicationInfo.js | 21 +- .../systemplugin/napi/bundle/bundleInfo.js | 163 ++++++------- .../napi/bundle/bundleInstaller.js | 67 ++++++ .../napi/bundle/bundleStatusCallback.js | 32 +++ .../systemplugin/napi/bundle/customizeData.js | 20 ++ .../napi/bundle/defaultAppManager.js | 2 +- .../systemplugin/napi/bundle/dispatchInfo.js | 19 ++ .../systemplugin/napi/bundle/elementName.js | 23 ++ .../napi/bundle/extensionAbilityInfo.js | 98 ++++++++ .../systemplugin/napi/bundle/hapModuleInfo.js | 101 ++++++++ .../napi/bundle/launcherAbilityInfo.js | 8 +- .../systemplugin/napi/bundle/metadata.js | 20 ++ .../systemplugin/napi/bundle/moduleInfo.js | 19 ++ .../systemplugin/napi/bundle/packInfo.js | 157 +++++++++++++ .../systemplugin/napi/bundle/permissionDef.js | 21 ++ .../napi/bundle/remoteAbilityInfo.js | 22 ++ .../systemplugin/napi/bundle/shortcutInfo.js | 41 ++++ .../extend/systemplugin/napi/ohos_bundle.js | 220 +++++++++++------- .../napi/ohos_bundle_defaultAppManager.js | 6 +- .../napi/ohos_bundle_innerBundleManager.js | 16 +- 21 files changed, 893 insertions(+), 201 deletions(-) create mode 100755 runtime/main/extend/systemplugin/napi/bundle/bundleInstaller.js create mode 100755 runtime/main/extend/systemplugin/napi/bundle/bundleStatusCallback.js create mode 100755 runtime/main/extend/systemplugin/napi/bundle/customizeData.js create mode 100755 runtime/main/extend/systemplugin/napi/bundle/dispatchInfo.js create mode 100755 runtime/main/extend/systemplugin/napi/bundle/elementName.js create mode 100755 runtime/main/extend/systemplugin/napi/bundle/extensionAbilityInfo.js create mode 100755 runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js create mode 100755 runtime/main/extend/systemplugin/napi/bundle/metadata.js create mode 100755 runtime/main/extend/systemplugin/napi/bundle/moduleInfo.js create mode 100755 runtime/main/extend/systemplugin/napi/bundle/packInfo.js create mode 100755 runtime/main/extend/systemplugin/napi/bundle/permissionDef.js create mode 100755 runtime/main/extend/systemplugin/napi/bundle/remoteAbilityInfo.js create mode 100755 runtime/main/extend/systemplugin/napi/bundle/shortcutInfo.js diff --git a/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js b/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js index ee690e17..9bc0920f 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/abilityInfo.js @@ -13,7 +13,9 @@ * limitations under the License. */ -export const AbilityInfoMock = { +import { paramMock } from "../../utils" + +export const AbilityInfo = { name: "[PC preview] unknown name", bundleName: "[PC preview] unknown bundleName", moduleName: "[PC preview] unknown moduleName", @@ -51,9 +53,9 @@ export const AbilityInfoMock = { SINGLETON: 0, STANDARD: 1, }, - permissions: ['[PC Preview] unknow permissions'], - deviceTypes: ['[PC Preview] unknow deviceTypes'], - deviceCapabilities: ['[PC Preview] unknow deviceCapabilities'], + permissions: [paramMock.paramStringMock], + deviceTypes: [paramMock.paramStringMock], + deviceCapabilities: [paramMock.paramNumberMock], readPermission: '[PC Preview] unknow readPermission', writePermission: '[PC Preview] unknow writePermission', appId: '[PC Preview] unknow appId', @@ -77,14 +79,14 @@ export const AbilityInfoMock = { iconId: "[PC preview] unknown iconId", process: "[PC preview] unknown process", sourceDir: "[PC preview] unknown sourceDir", - moduleSourceDirs: ["[PC preview] unknown moduleSourceDirs"], - permissions: ["[PC preview] unknown permissions"], + moduleSourceDirs: [paramMock.paramStringMock], + permissions: [paramMock.paramStringMock], moduleInfos: [{ moduleName: "[PC preview] unknown moduleName", moduleSourceDir: "[PC preview] unknown moduleSourceDir", }], - entryDir: ["[PC preview] unknown entryDir"], - codePath: ["[PC preview] unknown codePath"], + entryDir: "[PC preview] unknown entryDir", + codePath: "[PC preview] unknown codePath", metaData: [{ name: "[PC preview] unknown name", value: "[PC preview] unknown value", diff --git a/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js b/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js index cd6b17a1..953227c3 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/applicationInfo.js @@ -13,7 +13,9 @@ * limitations under the License. */ -export const ApplicationInfoMock = { +import { paramMock } from "../../utils" + +export const ApplicationInfo = { name: "[PC preview] unknown name", description: "[PC preview] unknown description", descriptionId: "[PC preview] unknown descriptionId", @@ -25,8 +27,8 @@ export const ApplicationInfoMock = { iconId: "[PC preview] unknown iconId", process: "[PC preview] unknown process", supportedModes: "[PC preview] unknown supportedModes", - moduleSourceDirs: ["[PC preview] unknown moduleSourceDirs"], - permissions: ["[PC preview] unknown permissions"], + moduleSourceDirs: [paramMock.paramNumberMock], + permissions: [paramMock.paramNumberMock], moduleInfos: [ { moduleName: "[PC preview] unknown moduleName", @@ -69,7 +71,7 @@ export const ApplicationInfoMock = { appProvisionType: "[PC preview] unknown appProvisionType", } -export const WantMock = { +export const Want = { deviceId: "[PC Preview] unknow deviceId", bundleName: "[PC Preview] unknow bundleName", abilityName: "[PC Preview] unknow abilityName", @@ -77,12 +79,12 @@ export const WantMock = { type: "[PC Preview] unknow type", flag: "[PC Preview] unknow flag", action: "[PC Preview] unknow action", - parameters: ["[PC Preview] unknow parameters"], - entities: ["[PC Preview] unknow entities"], + parameters: [paramMock.paramStringMock], + entities: [paramMock.paramStringMock], moduleName: "[PC Preview] unknow moduleName", } -export const ShortcutInfoMock = { +export const ShortcutInfo = { id: "[PC preview] unknown id", bundleName: "[PC preview] unknown bundleName", hostAbility: "[PC preview] unknown hostAbility", @@ -96,14 +98,15 @@ export const ShortcutInfoMock = { targetBundle: "[PC preview] unknown targetBundle", targetModule: "[PC preview] unknown targetModule", targetClass: "[PC preview] unknown targetClass", - }], + } + ], isStatic: "[PC preview] unknown isStatic", isHomeShortcut: "[PC preview] unknown isHomeShortcut", isEnabled: "[PC preview] unknown isEnabled", moduleName: "[PC preview] unknown moduleName", } -export const ModuleUsageRecordMock = { +export const ModuleUsageRecord = { bundleName: "[PC preview] unknown bundleName", appLabelId: "[PC preview] unknown appLabelId", name: "[PC preview] unknown name", diff --git a/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js b/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js index ab73c42a..97112a5c 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/bundleInfo.js @@ -13,7 +13,9 @@ * limitations under the License. */ -export const BundleInfoMock = { +import { paramMock } from "../../utils" + +export const BundleInfo = { name: "[PC preview] unknown name", type: "[PC preview] unknown type", appId: "[PC preview] unknown appId", @@ -34,8 +36,8 @@ export const BundleInfoMock = { iconId: "[PC preview] unknown iconId", process: "[PC preview] unknown process", supportedModes: "[PC preview] unknown supportedModes", - moduleSourceDirs: ["[PC preview] unknown moduleSourceDirs"], - permissions: ["[PC preview] unknown permissions"], + moduleSourceDirs: [paramMock.paramStringMock], + permissions: [paramMock.paramStringMock], sourceDir: "[PC preview] unknown sourceDir", moduleInfos: [{ moduleName: "[PC preview] unknown moduleName", @@ -125,9 +127,9 @@ export const BundleInfoMock = { SINGLETON: 0, STANDARD: 1, }, - permissions: ['[PC Preview] unknow permissions'], - deviceTypes: ['[PC Preview] unknow deviceTypes'], - deviceCapabilities: ['[PC Preview] unknow deviceCapabilities'], + permissions: [paramMock.paramStringMock], + deviceTypes: [paramMock.paramStringMock], + deviceCapabilities: [paramMock.paramStringMock], readPermission: '[PC Preview] unknow readPermission', writePermission: '[PC Preview] unknow writePermission', appId: '[PC Preview] unknow appId', @@ -151,14 +153,14 @@ export const BundleInfoMock = { iconId: "[PC preview] unknown iconId", process: "[PC preview] unknown process", sourceDir: "[PC preview] unknown sourceDir", - moduleSourceDirs: ["[PC preview] unknown moduleSourceDirs"], - permissions: ["[PC preview] unknown permissions"], + moduleSourceDirs: [paramMock.paramStringMock], + permissions: [paramMock.paramStringMock], moduleInfos: [{ moduleName: "[PC preview] unknown moduleName", moduleSourceDir: "[PC preview] unknown moduleSourceDir", }], - entryDir: ["[PC preview] unknown entryDir"], - codePath: ["[PC preview] unknown codePath"], + entryDir: [paramMock.paramStringMock], + codePath: [paramMock.paramStringMock], metaData: [{ name: "[PC preview] unknown name", value: "[PC preview] unknown value", @@ -238,14 +240,14 @@ export const BundleInfoMock = { }, } ], - reqPermissions: ["[PC preview] unknown repermission"], + reqPermissions: [paramMock.paramStringMock], reqPermissionDetails: [ { name: "[PC preview] unknown name", reason: "[PC preview] unknown reason", reasonId: "[PC preview] unknown reasonId", usedScene: { - abilities: ["[PC preview] unknown ability"], + abilities: [paramMock.paramStringMock], when: "[PC preview] unknown when", } } @@ -266,8 +268,8 @@ export const BundleInfoMock = { iconId: "[PC preview] unknown iconId", backgroundImg: "[PC preview] unknown backgroundImg", supportedModes: "[PC preview] unknown supportedModes", - reqCapabilities: ["[PC preview] unknown reqCapabilities"], - deviceTypes: ["[PC preview] unknown deviceTypes"], + reqCapabilities: [paramMock.paramStringMock], + deviceTypes: [paramMock.paramStringMock], abilityInfo: [ { name: "[PC preview] unknown name", @@ -307,9 +309,9 @@ export const BundleInfoMock = { SINGLETON: 0, STANDARD: 1, }, - permissions: ['[PC Preview] unknow permissions'], - deviceTypes: ['[PC Preview] unknow deviceTypes'], - deviceCapabilities: ['[PC Preview] unknow deviceCapabilities'], + permissions: [paramMock.paramNumberMock], + deviceTypes: [paramMock.paramNumberMock], + deviceCapabilities: [paramMock.paramNumberMock], readPermission: '[PC Preview] unknow readPermission', writePermission: '[PC Preview] unknow writePermission', appId: '[PC Preview] unknow appId', @@ -333,14 +335,14 @@ export const BundleInfoMock = { iconId: "[PC preview] unknown iconId", process: "[PC preview] unknown process", sourceDir: "[PC preview] unknown sourceDir", - moduleSourceDirs: ["[PC preview] unknown moduleSourceDirs"], - permissions: ["[PC preview] unknown permissions"], + moduleSourceDirs: [paramMock.paramStringMock], + permissions: [paramMock.paramStringMock], moduleInfos: [{ moduleName: "[PC preview] unknown moduleName", moduleSourceDir: "[PC preview] unknown moduleSourceDir", }], - entryDir: ["[PC preview] unknown entryDir"], - codePath: ["[PC preview] unknown codePath"], + entryDir: [paramMock.paramStringMock], + codePath: [paramMock.paramStringMock], metaData: [{ name: "[PC preview] unknown name", value: "[PC preview] unknown value", @@ -461,50 +463,50 @@ export const BundleInfoMock = { }], hapModuleInfo: [ { - name: "string", - description: "string", - descriptionId: 1, - icon: "string", - label: "string", - labelId: 2, - iconId: 3, - backgroundImg: "string", - supportedModes: 4, - reqCapabilities: ["1", "2"], - deviceTypes: ["1", "2"], + name: "[PC preview] unknown name", + description: "[PC preview] unknown description", + descriptionId: "[PC preview] unknown descriptionId", + icon: "[PC preview] unknown icon", + label: "[PC preview] unknown label", + labelId: "[PC preview] unknown labelId", + iconId: "[PC preview] unknown iconId", + backgroundImg: "[PC preview] unknown backgroundImg", + supportedModes: "[PC preview] unknown supportedModes", + reqCapabilities: [paramMock.paramStringMock], + deviceTypes: [paramMock.paramStringMock], abilityInfo: [ { - bundleName: "string", - name: "string", - label: "string", - description: "string", - icon: "string", - labelId: 1, - descriptionId: 2, - iconId: 3, - moduleName: "string", - process: "string", - targetAbility: "string", - backgroundModes: 4, - isVisible: true, - formEnabled: true, - type: "bundle.AbilityType", - subType: "bundle.AbilitySubType", - orientation: "bundle.DisplayOrientation", - launchMode: "bundle.LaunchMode", - permissions: ["1"], - deviceTypes: ["2"], - deviceCapabilities: ["3"], - readPermission: "string", - writePermission: "string", + bundleName: "[PC preview] unknown bundleName", + name: "[PC preview] unknown name", + label: "[PC preview] unknown label", + description: "[PC preview] unknown description", + icon: "[PC preview] unknown icon", + labelId: "[PC preview] unknown labelId", + descriptionId: "[PC preview] unknown descriptionId", + iconId: "[PC preview] unknown iconId", + moduleName: "[PC preview] unknown moduleName", + process: "[PC preview] unknown process", + targetAbility: "[PC preview] unknown targetAbility", + backgroundModes: "[PC preview] unknown backgroundModes", + isVisible: "[PC preview] unknown isVisible", + formEnabled: "[PC preview] unknown formEnabled", + type: "[PC preview] unknown type", + subType: "[PC preview] unknown subType", + orientation: "[PC preview] unknown orientation", + launchMode: "[PC preview] unknown launchMode", + permissions: [paramMock.paramStringMock], + deviceTypes: [paramMock.paramStringMock], + deviceCapabilities: [paramMock.paramStringMock], + readPermission: "[PC preview] unknown readPermission", + writePermission: "[PC preview] unknown writePermission", applicationInfo: { packageName: "[PC preview] unknown packageName", className: "[PC preview] unknown className", name: "[PC preview] unknown name", - labelId: 2, - iconId: 3, + labelId: "[PC preview] unknown labelId", + iconId: "[PC preview] unknown iconId", sourceDir: "[PC preview] unknown sourceDir", - flags: 1, + flags: "[PC preview] unknown flags", customizeData: { key: "[PC preview] unknown key", value: { @@ -515,12 +517,12 @@ export const BundleInfoMock = { } } }, - formEntity: 5, - minFormHeight: 6, - defaultFormHeight: 7, - minFormWidth: 8, - defaultFormWidth: 9, - uri: "string", + formEntity: "[PC preview] unknown formEntity", + minFormHeight: "[PC preview] unknown minFormHeight", + defaultFormHeight: "[PC preview] unknown defaultFormHeight", + minFormWidth: "[PC preview] unknown minFormWidth", + defaultFormWidth: "[PC preview] unknown defaultFormWidth", + uri: "[PC preview] unknown uri", customizeData: { key: "[PC preview] unknown key", value: [ @@ -540,9 +542,9 @@ export const BundleInfoMock = { }, } ], - moduleName: "string", - mainAbilityName: "string", - installationFree: true, + moduleName: "[PC preview] unknown moduleName", + mainAbilityName: "[PC preview] unknown mainAbilityName", + installationFree: "[PC preview] unknown installationFree", } ], entryModuleName: "string", @@ -550,7 +552,7 @@ export const BundleInfoMock = { isSilentInstallation: "string", minCompatibleVersionCode: 7, entryInstallationFree: true, - reqPermissionStates: ["[PC preview] unknown reqPermissionStates"], + reqPermissionStates: [paramMock.paramStringMock], extensionAbilityInfo: [{ bundleName: "[PC preview] unknown bundleName", moduleName: "[PC preview] unknown moduleName", @@ -579,7 +581,7 @@ export const BundleInfoMock = { value: "[PC preview] unknown value", resource: "[PC preview] unknown resource", }], - permissions: ["[PC preview] unknown hashValue"], + permissions: [paramMock.paramStringMock], applicationInfo: { packageName: "[PC preview] unknown packageName", description: "[PC preview] unknown description", @@ -593,14 +595,14 @@ export const BundleInfoMock = { icon: "[PC preview] unknown icon", iconId: "[PC preview] unknown iconId", process: "[PC preview] unknown process", - moduleSourceDirs: ["[PC preview] unknown moduleSourceDirs"], - permissions: ["[PC preview] unknown permissions"], + moduleSourceDirs: [paramMock.paramStringMock], + permissions: [paramMock.paramStringMock], moduleInfos: [{ moduleName: "[PC preview] unknown moduleName", moduleSourceDir: "[PC preview] unknown moduleSourceDir", }], - entryDir: ["[PC preview] unknown entryDir"], - codePath: ["[PC preview] unknown codePath"], + entryDir: [paramMock.paramStringMock], + codePath: [paramMock.paramStringMock], metaData: [{ name: "[PC preview] unknown name", value: "[PC preview] unknown value", @@ -636,7 +638,7 @@ export const BundleInfoMock = { export const BundlePackInfo = { packages: [{ - deviceType: ["[PC preview] unknown deviceType"], + deviceType: [paramMock.paramStringMock], name: "[PC preview] unknown name", moduleType: "[PC preview] unknown moduleType", deliveryWithInstall: "[PC preview] unknown deliveryWithInstall", @@ -657,7 +659,7 @@ export const BundlePackInfo = { compatible: "[PC preview] unknown compatible", target: "[PC preview] unknown target", }, - deviceType: ["[PC preview] unknown deviceType"], + deviceType: [paramMock.paramStringMock], distro: { mainAbility: "[PC preview] unknown mainAbility", deliveryWithInstall: "[PC preview] unknown deliveryWithInstall", @@ -677,7 +679,7 @@ export const BundlePackInfo = { updateEnabled: "[PC preview] unknown updateEnabled", scheduledUpdateTime: "[PC preview] unknown scheduledUpdateTime", updateDuration: "[PC preview] unknown updateDuration", - supportDimensions: ["[PC preview] unknown supportDimensions"], + supportDimensions: [paramMock.paramNumberMock], defaultDimension: "[PC preview] unknown defaultDimension", } ], @@ -694,7 +696,7 @@ export const BundlePackInfo = { updateEnabled: "[PC preview] unknown updateEnabled", scheduledUpdateTime: "[PC preview] unknown scheduledUpdateTime", updateDuration: "[PC preview] unknown updateDuration", - supportDimensions: ["[PC preview] unknown supportDimensions"], + supportDimensions: [paramMock.paramNumberMock], defaultDimension: "[PC preview] unknown defaultDimension", } ], @@ -705,7 +707,8 @@ export const BundlePackInfo = { } }; -export const DispatchInfoMock = { - verison: "[PC preview] unknown verison", - dispatchAPI: "[PC preview] unknown dispatchAPI", +export const PixelMapFormat = { + UNKNOWN: 0, + RGB_565: 2, + RGBA_8888: 3, } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/bundleInstaller.js b/runtime/main/extend/systemplugin/napi/bundle/bundleInstaller.js new file mode 100755 index 00000000..c7e5d512 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/bundleInstaller.js @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { paramMock } from "../../utils" +import { InstallErrorCode } from '../ohos_bundle.js' + +export const HashParam = { + moduleName: "[PC preview] unknown moduleName", + hashValue: "[PC preview] unknown hashValue", +} + +export const InstallParam = { + userId: "[PC preview] unknown userId", + installFlag: "[PC preview] unknown installFlag", + hashParams: [ + HashParam + ], + crowdtestDeadline: "[PC preview] unknown crowdtestDeadline", +} + +export const InstallStatus = { + status: { + InstallErrorCode + }, + statusMessage: "[PC preview] unknown statusMessage", +} + +export const BundleInstaller = { + moduleName: "[PC preview] unknown moduleName", + hashValue: "[PC preview] unknown hashValue", +} + +export function mockBundleInstaller() { + const bundleInstaller = { + install: function(...args){ + console.warn("bundleInstaller.install 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; + args[len - 1].call(this, paramMock.businessErrorMock, InstallStatus); + }, + uninstall: function(...args){ + console.warn("bundleInstaller.uninstall 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; + args[len - 1].call(this, paramMock.businessErrorMock, InstallStatus); + }, + recover: function(...args){ + console.warn("bundleInstaller.recover 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; + args[len - 1].call(this, paramMock.businessErrorMock, InstallStatus); + } + }; + return bundleInstaller; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/bundleStatusCallback.js b/runtime/main/extend/systemplugin/napi/bundle/bundleStatusCallback.js new file mode 100755 index 00000000..2215a05f --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/bundleStatusCallback.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export function mockBundleStatusCallback() { + const bundleStatusCallback = { + add: function(){ + console.warn("bundleStatusCallback.add interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + update: function(){ + console.warn("bundleStatusCallback.update interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + remove: function(){ + console.warn("bundleStatusCallback.remove interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + } + }; + return bundleStatusCallback; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/customizeData.js b/runtime/main/extend/systemplugin/napi/bundle/customizeData.js new file mode 100755 index 00000000..dce34591 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/customizeData.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const CustomizeData = { + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + extra: "[PC preview] unknown extra", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/defaultAppManager.js b/runtime/main/extend/systemplugin/napi/bundle/defaultAppManager.js index 0e47ba4b..f66db7aa 100755 --- a/runtime/main/extend/systemplugin/napi/bundle/defaultAppManager.js +++ b/runtime/main/extend/systemplugin/napi/bundle/defaultAppManager.js @@ -13,7 +13,7 @@ * limitations under the License. */ -export const DefaultAppManagerMock = { +export const DefaultAppManager = { BROWSER: "[PC preview] unknown BROWSER", IMAGE: "[PC preview] unknown IMAGE", AUDIO: "[PC preview] unknown AUDIO", diff --git a/runtime/main/extend/systemplugin/napi/bundle/dispatchInfo.js b/runtime/main/extend/systemplugin/napi/bundle/dispatchInfo.js new file mode 100755 index 00000000..36c5110d --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/dispatchInfo.js @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const DispatchInfo = { + verison: "[PC preview] unknown verison", + dispatchAPI: "[PC preview] unknown dispatchAPI", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/elementName.js b/runtime/main/extend/systemplugin/napi/bundle/elementName.js new file mode 100755 index 00000000..ffa0992a --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/elementName.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const ElementName = { + deviceId: "[PC preview] unknown deviceId", + bundleName: "[PC preview] unknown bundleName", + abilityName: "[PC preview] unknown abilityName", + uri: "[PC preview] unknown uri", + shortName: "[PC preview] unknown shortName", + moduleName: "[PC preview] unknown moduleName", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/extensionAbilityInfo.js b/runtime/main/extend/systemplugin/napi/bundle/extensionAbilityInfo.js new file mode 100755 index 00000000..ba8738ed --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/extensionAbilityInfo.js @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { paramMock } from "../../utils" + +export const ExtensionAbilityInfo = { + bundleName: "[PC preview] unknown bundleName", + moduleName: "[PC preview] unknown moduleName", + name: "[PC preview] unknown name", + labelId: "[PC preview] unknown labelId", + descriptionId: "[PC preview] unknown descriptionId", + iconId: "[PC preview] unknown iconId", + isVisible: "[PC preview] unknown isVisible", + extensionAbilityType: { + FORM: 0, + WORK_SCHEDULER: 1, + INPUT_METHOD: 2, + SERVICE: 3, + ACCESSIBILITY: 4, + DATA_SHARE: 5, + FILE_SHARE: 6, + STATIC_SUBSCRIBER: 7, + WALLPAPER: 8, + BACKUP: 9, + WINDOW: 10, + ENTERPRISE_ADMIN: 11, + UNSPECIFIED: 20, + }, + metadata: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + resource: "[PC preview] unknown resource", + }], + permissions: [paramMock.paramStringMock], + applicationInfo: { + packageName: "[PC preview] unknown packageName", + description: "[PC preview] unknown description", + descriptionId: "[PC preview] unknown descriptionId", + enabled: "[PC preview] unknown enabled", + systemApp: "[PC preview] unknown systemApp", + className: "[PC preview] unknown className", + name: "[PC preview] unknown name", + label: "[PC preview] unknown label", + labelId: "[PC preview] unknown labelId", + icon: "[PC preview] unknown icon", + iconId: "[PC preview] unknown iconId", + process: "[PC preview] unknown process", + moduleSourceDirs: [paramMock.paramStringMock], + permissions: [paramMock.paramStringMock], + moduleInfos: [{ + moduleName: "[PC preview] unknown moduleName", + moduleSourceDir: "[PC preview] unknown moduleSourceDir", + }], + entryDir: "[PC preview] unknown entryDir", + codePath: "[PC preview] unknown codePath", + metaData: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + extra: "[PC preview] unknown extra", + }], + metadata: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + resource: "[PC preview] unknown resource", + }], + removable: "[PC preview] unknown removable", + accessTokenId: "[PC preview] unknown accessTokenId", + uid: "[PC preview] unknown uid", + entityType: "[PC preview] unknown entityType", + fingerprint: "[PC preview] unknown fingerprint", + iconResource: "[PC preview] unknown iconResource", + labelResource: "[PC preview] unknown labelResource", + descriptionResource: "[PC preview] unknown descriptionResource", + appDistributionType: "[PC preview] unknown appDistributionType", + appProvisionType: "[PC preview] unknown appProvisionType", + supportedModes: "[PC preview] unknown supportedModes", + }, + metadata: [{ + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + resource: "[PC preview] unknown resource", + }], + enabled: "[PC preview] unknown enabled", + readPermission: "[PC preview] unknown readPermission", + writePermission: "[PC preview] unknown writePermission", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js b/runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js new file mode 100755 index 00000000..f7a699f8 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/hapModuleInfo.js @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { paramMock } from "../../utils" + +export const HapModuleInfo = { + name: "[PC preview] unknown name", + description: "[PC preview] unknown description", + descriptionId: "[PC preview] unknown descriptionId", + icon: "[PC preview] unknown icon", + label: "[PC preview] unknown label", + labelId: "[PC preview] unknown labelId", + iconId: "[PC preview] unknown iconId", + backgroundImg: "[PC preview] unknown backgroundImg", + supportedModes: "[PC preview] unknown supportedModes", + reqCapabilities: [paramMock.paramStringMock], + deviceTypes: [paramMock.paramStringMock], + abilityInfo: [ + { + bundleName: "[PC preview] unknown bundleName", + name: "[PC preview] unknown name", + label: "[PC preview] unknown label", + description: "[PC preview] unknown description", + icon: "[PC preview] unknown icon", + labelId: "[PC preview] unknown labelId", + descriptionId: "[PC preview] unknown descriptionId", + iconId: "[PC preview] unknown iconId", + moduleName: "[PC preview] unknown moduleName", + process: "[PC preview] unknown process", + targetAbility: "[PC preview] unknown targetAbility", + backgroundModes: "[PC preview] unknown backgroundModes", + isVisible: "[PC preview] unknown isVisible", + formEnabled: "[PC preview] unknown formEnabled", + type: "[PC preview] unknown type", + subType: "[PC preview] unknown subType", + orientation: "[PC preview] unknown orientation", + launchMode: "[PC preview] unknown launchMode", + permissions: [paramMock.paramStringMock], + deviceTypes: [paramMock.paramStringMock], + deviceCapabilities: [paramMock.paramStringMock], + readPermission: "[PC preview] unknown readPermission", + writePermission: "[PC preview] unknown writePermission", + applicationInfo: { + packageName: "[PC preview] unknown packageName", + className: "[PC preview] unknown className", + name: "[PC preview] unknown name", + labelId: "[PC preview] unknown name", + iconId: "[PC preview] unknown name", + sourceDir: "[PC preview] unknown sourceDir", + flags: "[PC preview] unknown name", + customizeData: { + key: "[PC preview] unknown key", + value: { + CustomizeData: { + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + } + } + } + }, + formEntity: "[PC preview] unknown formEntity", + minFormHeight: "[PC preview] unknown minFormHeight", + defaultFormHeight: "[PC preview] unknown defaultFormHeight", + minFormWidth: "[PC preview] unknown minFormWidth", + defaultFormWidth: "[PC preview] unknown defaultFormWidth", + uri: "[PC preview] unknown uri", + customizeData: { + key: "[PC preview] unknown key", + value: [ + { + CustomizeData: { + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + }, + }, + { + CustomizeData: { + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + }, + } + ] + }, + } + ], + moduleName: "[PC preview] unknown moduleName", + mainAbilityName: "[PC preview] unknown mainAbilityName", + installationFree: "[PC preview] unknown installationFree", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js b/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js index 720915a6..25564dda 100644 --- a/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js +++ b/runtime/main/extend/systemplugin/napi/bundle/launcherAbilityInfo.js @@ -13,7 +13,9 @@ * limitations under the License. */ -export const LauncherAbilityInfoMock = { +import { paramMock } from "../../utils" + +export const LauncherAbilityInfo = { applicationInfo: { packageName: "[PC preview] unknown packageName", description: "[PC preview] unknown description", @@ -28,8 +30,8 @@ export const LauncherAbilityInfoMock = { iconId: "[PC preview] unknown iconId", process: "[PC preview] unknown process", supportedModes: "[PC preview] unknown supportedModes", - moduleSourceDirs: ["[PC preview] unknown moduleSourceDirs"], - permissions: ["[PC preview] unknown permissions"], + moduleSourceDirs: [paramMock.paramStringMock], + permissions: [paramMock.paramStringMock], sourceDir: "[PC preview] unknown sourceDir", moduleInfos: [{ moduleName: "[PC preview] unknown moduleName", diff --git a/runtime/main/extend/systemplugin/napi/bundle/metadata.js b/runtime/main/extend/systemplugin/napi/bundle/metadata.js new file mode 100755 index 00000000..6157307c --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/metadata.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const Metadata = { + name: "[PC preview] unknown name", + value: "[PC preview] unknown value", + resource: "[PC preview] unknown resource", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/moduleInfo.js b/runtime/main/extend/systemplugin/napi/bundle/moduleInfo.js new file mode 100755 index 00000000..4b0193f6 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/moduleInfo.js @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const ModuleInfo = { + moduleName: "[PC preview] unknown moduleName", + moduleSourceDir: "[PC preview] unknown moduleSourceDir", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/packInfo.js b/runtime/main/extend/systemplugin/napi/bundle/packInfo.js new file mode 100755 index 00000000..aca7df89 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/packInfo.js @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { paramMock } from "../../utils" + +export const BundlePackInfo = { + packages: [{ + deviceType: [paramMock.paramStringMock], + name: "[PC preview] unknown name", + moduleType: "[PC preview] unknown moduleType", + deliveryWithInstall: "[PC preview] unknown deliveryWithInstall", + }], + summary: { + app: { + bundleName: "[PC preview] unknown bundleName", + version: { + minCompatibleVersionCode: "[PC preview] unknown minCompatibleVersionCode", + name: "[PC preview] unknown name", + code: "[PC preview] unknown code", + }, + }, + modules: [ + { + apiVersion: { + releaseType: "[PC preview] unknown releaseType", + compatible: "[PC preview] unknown compatible", + target: "[PC preview] unknown target", + }, + deviceType: [paramMock.paramStringMock], + distro: { + mainAbility: "[PC preview] unknown mainAbility", + deliveryWithInstall: "[PC preview] unknown deliveryWithInstall", + installationFree: "[PC preview] unknown installationFree", + moduleName: "[PC preview] unknown moduleName", + moduleType: "[PC preview] unknown moduleType", + }, + abilities: [ + { + name: "[PC preview] unknown name", + label: "[PC preview] unknown label", + visible: "[PC preview] unknown visible", + forms: [ + { + name: "[PC preview] unknown name", + type: "[PC preview] unknown type", + updateEnabled: "[PC preview] unknown updateEnabled", + scheduledUpdateTime: "[PC preview] unknown scheduledUpdateTime", + updateDuration: "[PC preview] unknown updateDuration", + supportDimensions: [paramMock.paramNumberMock], + defaultDimension: "[PC preview] unknown defaultDimension", + } + ], + + } + ], + extensionAbilities: [ + { + name: "[PC preview] unknown name", + forms: [ + { + name: "[PC preview] unknown name", + type: "[PC preview] unknown type", + updateEnabled: "[PC preview] unknown updateEnabled", + scheduledUpdateTime: "[PC preview] unknown scheduledUpdateTime", + updateDuration: "[PC preview] unknown updateDuration", + supportDimensions: [paramMock.paramNumberMock], + defaultDimension: "[PC preview] unknown defaultDimension", + } + ], + } + ] + } + ] + } +} + +export const PackageConfig = { + deviceType: [paramMock.paramStringMock], + name: "[PC preview] unknown name", + moduleType: "[PC preview] unknown moduleType", + deliveryWithInstall: "[PC preview] unknown deliveryWithInstall", +} + +export const PackageSummary = { + app: { + bundleName: "[PC preview] unknown bundleName", + version: { + minCompatibleVersionCode: "[PC preview] unknown minCompatibleVersionCode", + name: "[PC preview] unknown name", + code: "[PC preview] unknown code", + }, + }, + modules: [ + { + apiVersion: { + releaseType: "[PC preview] unknown releaseType", + compatible: "[PC preview] unknown compatible", + target: "[PC preview] unknown target", + }, + deviceType: [paramMock.paramStringMock], + distro: { + mainAbility: "[PC preview] unknown mainAbility", + deliveryWithInstall: "[PC preview] unknown deliveryWithInstall", + installationFree: "[PC preview] unknown installationFree", + moduleName: "[PC preview] unknown moduleName", + moduleType: "[PC preview] unknown moduleType", + }, + abilities: [ + { + name: "[PC preview] unknown name", + label: "[PC preview] unknown label", + visible: "[PC preview] unknown visible", + forms: [ + { + name: "[PC preview] unknown name", + type: "[PC preview] unknown type", + updateEnabled: "[PC preview] unknown updateEnabled", + scheduledUpdateTime: "[PC preview] unknown scheduledUpdateTime", + updateDuration: "[PC preview] unknown updateDuration", + supportDimensions: [paramMock.paramNumberMock], + defaultDimension: "[PC preview] unknown defaultDimension", + } + ], + + } + ], + extensionAbilities: [ + { + name: "[PC preview] unknown name", + forms: [ + { + name: "[PC preview] unknown name", + type: "[PC preview] unknown type", + updateEnabled: "[PC preview] unknown updateEnabled", + scheduledUpdateTime: "[PC preview] unknown scheduledUpdateTime", + updateDuration: "[PC preview] unknown updateDuration", + supportDimensions: [paramMock.paramNumberMock], + defaultDimension: "[PC preview] unknown defaultDimension", + } + ], + } + ] + } + ] +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/permissionDef.js b/runtime/main/extend/systemplugin/napi/bundle/permissionDef.js new file mode 100755 index 00000000..3caaf73d --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/permissionDef.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const PermissionDef = { + permissionName: "[PC preview] unknown permissionName", + grantMode: "[PC preview] unknown grantMode", + labelId: "[PC preview] unknown labelId", + descriptionId: "[PC preview] unknown descriptionId", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/remoteAbilityInfo.js b/runtime/main/extend/systemplugin/napi/bundle/remoteAbilityInfo.js new file mode 100755 index 00000000..ab31d377 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/remoteAbilityInfo.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ElementName } from './elementName'; + +export const RemoteAbilityInfo = { + elementName: ElementName, + label: "[PC preview] unknown IMAGE", + icon: "[PC preview] unknown AUDIO", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/bundle/shortcutInfo.js b/runtime/main/extend/systemplugin/napi/bundle/shortcutInfo.js new file mode 100755 index 00000000..934d65a2 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/bundle/shortcutInfo.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const ShortcutWant = { + targetBundle: "[PC preview] unknown targetBundle", + targetModule: "[PC preview] unknown targetModule", + targetClass: "[PC preview] unknown targetClass", +} + +export const ShortcutInfo = { + id: "[PC preview] unknown id", + bundleName: "[PC preview] unknown bundleName", + hostAbility: "[PC preview] unknown hostAbility", + icon: "[PC preview] unknown icon", + iconId: "[PC preview] unknown iconId", + label: "[PC preview] unknown label", + labelId: "[PC preview] unknown labelId", + disableMessage: "[PC preview] unknown disableMessage", + wants: [ + { + targetBundle: "[PC preview] unknown targetBundle", + targetModule: "[PC preview] unknown targetModule", + targetClass: "[PC preview] unknown targetClass", + }], + isStatic: "[PC preview] unknown isStatic", + isHomeShortcut: "[PC preview] unknown isHomeShortcut", + isEnabled: "[PC preview] unknown isEnabled", + moduleName: "[PC preview] unknown moduleName", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_bundle.js b/runtime/main/extend/systemplugin/napi/ohos_bundle.js index cba24dee..e07715c9 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_bundle.js +++ b/runtime/main/extend/systemplugin/napi/ohos_bundle.js @@ -14,89 +14,47 @@ */ import { paramMock } from "../utils" -import { BundleInfoMock, BundlePackInfo, DispatchInfoMock } from './bundle/bundleInfo' -import { ApplicationInfoMock } from './bundle/applicationInfo' -import { WantMock } from './bundle/applicationInfo' +import { BundleInfo, BundlePackInfo, PixelMapFormat} from './bundle/bundleInfo' +import { DispatchInfo } from './bundle/dispatchInfo' +import { ApplicationInfo, Want } from './bundle/applicationInfo' +import { AbilityInfo } from './bundle/abilityInfo' +import { PermissionDef } from './bundle/permissionDef' +import { ExtensionAbilityInfo } from './bundle/extensionAbilityInfo' + +export const InstallErrorCode = { + SUCCESS: 0, + STATUS_INSTALL_FAILURE: 1, + STATUS_INSTALL_FAILURE_ABORTED: 2, + STATUS_INSTALL_FAILURE_INVALID: 3, + STATUS_INSTALL_FAILURE_CONFLICT: 4, + STATUS_INSTALL_FAILURE_STORAGE: 5, + STATUS_INSTALL_FAILURE_INCOMPATIBLE: 6, + STATUS_UNINSTALL_FAILURE: 7, + STATUS_UNINSTALL_FAILURE_BLOCKED: 8, + STATUS_UNINSTALL_FAILURE_ABORTED: 9, + STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT: 10, + STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED: 0x0B, + STATUS_RECOVER_FAILURE_INVALID: 0x0C, + STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED: 0x0D, + STATUS_ABILITY_NOT_FOUND: 0x40, + STATUS_BMS_SERVICE_ERROR: 0x41, + STATUS_FAILED_NO_SPACE_LEFT: 0x42, + STATUS_GRANT_REQUEST_PERMISSIONS_FAILED: 0x43, + STATUS_INSTALL_PERMISSION_DENIED: 0x44, + STATUS_UNINSTALL_PERMISSION_DENIED: 0x45, +} export function mockBundle() { - const extensionAbilityType = { - FORM: 0, - WORK_SCHEDULER: 1, - INPUT_METHOD: 2, - SERVICE: 3, - ACCESSIBILITY: 4, - DATA_SHARE: 5, - FILE_SHARE: 6, - STATIC_SUBSCRIBER: 7, - WALLPAPER: 8, - BACKUP: 9, - WINDOW: 10, - UNSPECIFIED: 20, - } - - 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: extensionAbilityType, - permissions: ["[PC preview] unknown permissions"], - applicationInfo: { - name: "[PC preview] unknown is name", - description: "[PC preview] unknown is description", - descriptionId: "[PC preview] unknown is descriptionId", - systemApp: "[PC preview] unknown is systemApp", - enabled: "[PC preview] unknown is enabled", - labelId: "[PC preview] unknown is labelId", - icon: "[PC preview] unknown is icon", - iconId: "[PC preview] unknown is iconId", - process: "[PC preview] unknown is process", - supportedModes: "[PC preview] unknown is supportedModes", - moduleSourceDirs: "[PC preview] unknown is moduleSourceDirs", - permissions: ["[PC preview] unknown is permissions"], - moduleInfos: ["[PC preview] unknown is moduleSourceDirs"], - entryDir: "[PC preview] unknown is entryDir", - metaData: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - resource: "[PC preview] unknown resource", - }], - metadata: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - resource: "[PC preview] unknown resource", - }], - removable: "[PC preview] unknown is removable", - accessTokenId: "[PC preview] unknown is accessTokenId", - uid: "[PC preview] unknown is uid", - entityType: "[PC preview] unknown is entityType", - fingerprint: "[PC preview] unknown is fingerprint", - }, - metadata: [{ - name: "[PC preview] unknown name", - value: "[PC preview] unknown value", - resource: "[PC preview] unknown resource", - }], - enabled: "[PC preview] unknown enabled", - readPermission: "[PC preview] unknown read permission", - writePermission: "[PC preview] unknown write permission", - } - ] - const bundle = { getBundleInfo: function(...args) { console.warn("bundle.getBundleInfo 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, BundleInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, BundleInfo); } else { return new Promise((resolve) => { - resolve(BundleInfoMock); + resolve(BundleInfo); }) } }, @@ -117,10 +75,10 @@ export function mockBundle() { " 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, ApplicationInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, ApplicationInfo); } else { return new Promise((resolve) => { - resolve(ApplicationInfoMock); + resolve(ApplicationInfo); }) } }, @@ -129,10 +87,10 @@ export function mockBundle() { " 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, Array(BundleInfoMock)); + args[len - 1].call(this, paramMock.businessErrorMock, Array(BundleInfo)); } else { return new Promise((resolve) => { - resolve(Array(BundleInfoMock)); + resolve(Array(BundleInfo)); }) } }, @@ -141,10 +99,10 @@ export function mockBundle() { " 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, Array(BundleInfoMock)); + args[len - 1].call(this, paramMock.businessErrorMock, Array(BundleInfo)); } else { return new Promise((resolve) => { - resolve(Array(BundleInfoMock)); + resolve(Array(BundleInfo)); }) } }, @@ -153,10 +111,10 @@ export function mockBundle() { " 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, Array(ApplicationInfoMock)); + args[len - 1].call(this, paramMock.businessErrorMock, Array(ApplicationInfo)); } else { return new Promise((resolve) => { - resolve(Array(ApplicationInfoMock)); + resolve(Array(ApplicationInfo)); }) } }, @@ -165,10 +123,10 @@ export function mockBundle() { " 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, Array(BundleInfoMock)); + args[len - 1].call(this, paramMock.businessErrorMock, Array(BundleInfo)); } else { return new Promise((resolve) => { - resolve(Array(BundleInfoMock)); + resolve(Array(BundleInfo)); }) } }, @@ -177,10 +135,10 @@ export function mockBundle() { " 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, Array(WantMock)); + args[len - 1].call(this, paramMock.businessErrorMock, Array(Want)); } else { return new Promise((resolve) => { - resolve(Array(WantMock)); + resolve(Array(Want)); }) } }, @@ -273,10 +231,10 @@ export function mockBundle() { " 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, Array(ExtensionAbilityInfoMock)) + args[len - 1].call(this,paramMock.businessErrorMock, Array(ExtensionAbilityInfo)) } else { return new Promise((resolve) => { - resolve(Array(ExtensionAbilityInfoMock)) + resolve(Array(ExtensionAbilityInfo)) }); } }, @@ -297,10 +255,10 @@ export function mockBundle() { " 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, DispatchInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, DispatchInfo); } else { return new Promise((resolve) => { - resolve(DispatchInfoMock); + resolve(DispatchInfo); }) } }, @@ -328,6 +286,90 @@ export function mockBundle() { }); } }, + isAbilityEnabled: function(...args) { + console.warn("bundle.isAbilityEnabled 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); + }) + } + }, + isApplicationEnabled: function(...args) { + console.warn("bundle.isApplicationEnabled 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); + }) + } + }, + getAbilityIcon: function(...args) { + console.warn("bundle.getAbilityIcon 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, PixelMapFormat); + } else { + return new Promise((resolve) => { + resolve(PixelMapFormat); + }) + } + }, + getAbilityLabel: function(...args) { + console.warn("bundle.getAbilityLabel 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.paramStringMock); + } else { + return new Promise((resolve) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getPermissionDef: function(...args) { + console.warn("bundle.getPermissionDef 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, PermissionDef); + } else { + return new Promise((resolve) => { + resolve(PermissionDef); + }) + } + }, + getNameForUid: function(...args) { + console.warn("bundle.getNameForUid 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.paramStringMock); + } else { + return new Promise((resolve) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getAbilityInfo: function(...args) { + console.warn("bundle.getAbilityInfo 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, AbilityInfo); + } else { + return new Promise((resolve) => { + resolve(AbilityInfo); + }) + } + }, }; return bundle; } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_bundle_defaultAppManager.js b/runtime/main/extend/systemplugin/napi/ohos_bundle_defaultAppManager.js index d5487114..d5f65973 100755 --- a/runtime/main/extend/systemplugin/napi/ohos_bundle_defaultAppManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_bundle_defaultAppManager.js @@ -14,7 +14,7 @@ */ import { paramMock } from "../utils" -import { BundleInfoMock } from './bundle/bundleInfo' +import { BundleInfo } from './bundle/bundleInfo' export function mockDefaultAppManager() { const defaultAppManager = { @@ -35,10 +35,10 @@ export function mockDefaultAppManager() { " 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, BundleInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, BundleInfo); } else { return new Promise((resolve) => { - resolve(BundleInfoMock); + resolve(BundleInfo); }) } }, diff --git a/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js b/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js index 8487432b..13893410 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_bundle_innerBundleManager.js @@ -14,8 +14,8 @@ */ import { paramMock } from "../utils" -import { ShortcutInfoMock } from './bundle/applicationInfo' -import { LauncherAbilityInfoMock } from './bundle/launcherAbilityInfo' +import { ShortcutInfo } from './bundle/applicationInfo' +import { LauncherAbilityInfo } from './bundle/launcherAbilityInfo' export function mockInnerBundle() { const innerBundleManager = { @@ -24,10 +24,10 @@ export function mockInnerBundle() { " 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, LauncherAbilityInfoMock); + args[len - 1].call(this, paramMock.businessErrorMock, LauncherAbilityInfo); } else { return new Promise((resolve) => { - resolve(LauncherAbilityInfoMock); + resolve(LauncherAbilityInfo); }) } }, @@ -44,10 +44,10 @@ export function mockInnerBundle() { " 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, Array(LauncherAbilityInfoMock)); + args[len - 1].call(this, paramMock.businessErrorMock, Array(LauncherAbilityInfo)); } else { return new Promise((resolve) => { - resolve(Array(LauncherAbilityInfoMock)); + resolve(Array(LauncherAbilityInfo)); }) } }, @@ -56,10 +56,10 @@ export function mockInnerBundle() { " 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, Array(ShortcutInfoMock)); + args[len - 1].call(this, paramMock.businessErrorMock, Array(ShortcutInfo)); } else { return new Promise((resolve) => { - resolve(Array(ShortcutInfoMock)); + resolve(Array(ShortcutInfo)); }) } },