diff --git a/runtime/main/extend/systemplugin/napi/ability/dataAbilityHelper.js b/runtime/main/extend/systemplugin/napi/ability/dataAbilityHelper.js new file mode 100755 index 00000000..7899aa70 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ability/dataAbilityHelper.js @@ -0,0 +1,289 @@ +/* + * 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" + +const DataAbilityResult = { + uri: "[PC Preview] unknow uri", + count: "[PC Preview] unknow count" +} +const ResultSet = { + columnNames: [paramMock.paramStringMock], + columnCount: "[PC Preview] unknow columnCount", + rowCount: "[PC Preview] unknow rowCount", + rowIndex: "[PC Preview] unknow rowIndex", + isAtFirstRow: "[PC Preview] unknow isAtFirstRow", + isAtLastRow: "[PC Preview] unknow isAtLastRow", + isEnded: "[PC Preview] unknow isEnded", + isStarted: "[PC Preview] unknow isStarted", + isClose: "[PC Preview] unknow isClose", + getColumnIndex: function (...args) { + console.warn("ResultSet.getColumnIndex interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getColumnName: function (...args) { + console.warn("ResultSet.getColumnName interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }, + goTo: function (...args) { + console.warn("ResultSet.goTo interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + goToRow: function (...args) { + console.warn("ResultSet.goToRow interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + goToLastRow: function (...args) { + console.warn("ResultSet.goToLastRow interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + goToFirstRow: function (...args) { + console.warn("ResultSet.goToFirstRow interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + goToNextRow: function (...args) { + console.warn("ResultSet.goToNextRow interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + goToPreviousRow: function (...args) { + console.warn("ResultSet.goToPreviousRow interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + getBlob: function (...args) { + console.warn("ResultSet.getBlob interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramArrayMock; + }, + getString: function (...args) { + console.warn("ResultSet.getString interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }, + getLong: function (...args) { + console.warn("ResultSet.getLong interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getDouble: function (...args) { + console.warn("ResultSet.getDouble interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + isColumnNull: function (...args) { + console.warn("ResultSet.isColumnNull interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + close: function () { + console.warn("ResultSet.close interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + } +} + +export const PacMap = {key:{}} +export const dataAbilityHelper = { + openFile: function (...args) { + console.warn("dataAbilityHelper.openFile 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.paramNumberMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + on: function (...args) { + console.warn("dataAbilityHelper.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') { + args[len - 1].call(this, paramMock.businessErrorMock) + } + }, + off: function (...args) { + console.warn("dataAbilityHelper.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') { + args[len - 1].call(this, paramMock.businessErrorMock) + } + }, + call: function (...args) { + console.warn("dataAbilityHelper.call 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, PacMap) + } else { + return new Promise((resolve) => { + resolve(PacMap); + }) + } + }, + getType: function (...args) { + console.warn("dataAbilityHelper.getType 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); + }) + } + }, + getFileTypes: function (...args) { + console.warn("dataAbilityHelper.getFileTypes 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]); + }) + } + }, + normalizeUri: function (...args) { + console.warn("dataAbilityHelper.normalizeUri 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); + }) + } + }, + denormalizeUri: function (...args) { + console.warn("dataAbilityHelper.denormalizeUri 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); + }) + } + }, + notifyChange: function (...args) { + console.warn("dataAbilityHelper.notifyChange 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) + } else { + return new Promise((resolve) => { + resolve(); + }) + } + }, + insert: function (...args) { + console.warn("dataAbilityHelper.insert 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.paramNumberMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + batchInsert: function (...args) { + console.warn("dataAbilityHelper.batchInsert 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.paramNumberMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + delete: function (...args) { + console.warn("dataAbilityHelper.delete 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.paramNumberMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + update: function (...args) { + console.warn("dataAbilityHelper.update 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.paramNumberMock) + } else { + return new Promise((resolve) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + query: function (...args) { + console.warn("dataAbilityHelper.query 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, ResultSet) + } else { + return new Promise((resolve) => { + resolve(ResultSet); + }) + } + }, + call: function (...args) { + console.warn("dataAbilityHelper.call 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, PacMap) + } else { + return new Promise((resolve) => { + resolve(PacMap); + }) + } + }, + executeBatch: function (...args) { + console.warn("dataAbilityHelper.executeBatch 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, [DataAbilityResult]) + } else { + return new Promise((resolve) => { + resolve([DataAbilityResult]); + }) + } + } +} diff --git a/runtime/main/extend/systemplugin/napi/ability/dataAbilityOperation.js b/runtime/main/extend/systemplugin/napi/ability/dataAbilityOperation.js new file mode 100755 index 00000000..7337d35a --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ability/dataAbilityOperation.js @@ -0,0 +1,33 @@ +/* + * 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 { mockDataAbility } from "../ohos_data_dataAbility" + +export const DataAbilityOperation = { + uri: "[PC Preview] unknow uri", + type: { + TYPE_INSERT: 1, + TYPE_UPDATE: 2, + TYPE_DELETE: 3, + TYPE_ASSERT: 4 + }, + valuesBucket: {key:{}}, + valueBackReferences: {key:{}}, + predicates: mockDataAbility().DataAbilityPredicates, + predicatesBackReferences: new Map([[paramMock.paramNumberMock, paramMock.paramNumberMock]]), + interrupted: "[PC Preview] unknow interrupted", + expectedCount: "[PC Preview] unknow expectedCount" +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ability/dataAbilityResult.js b/runtime/main/extend/systemplugin/napi/ability/dataAbilityResult.js new file mode 100755 index 00000000..b2905210 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ability/dataAbilityResult.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 DataAbilityResult = { + uri: "[PC Preview] unknow uri", + count: "[PC Preview] unknow count", +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/AbilityRunningInfo.js b/runtime/main/extend/systemplugin/napi/application/AbilityRunningInfo.js new file mode 100755 index 00000000..1462d1a5 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/AbilityRunningInfo.js @@ -0,0 +1,39 @@ +/* + * 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. + */ + +const ElementName = { + deviceId: '[PC preview] unknow deviceId', + bundleName: '[PC preview] unknow bundleName', + abilityName: '[PC preview] unknow abilityName', + uri: '[PC preview] unknow uri', + shortName: '[PC preview] unknow shortName', + moduleName: '[PC preview] unknow moduleName' +} +const AbilityState = { + INITIAL: 0, + FOREGROUND: 9, + BACKGROUND: 10, + FOREGROUNDING: 11, + BACKGROUNDING: 12 +} + +export const AbilityRunningInfo = { + ability: ElementName, + pid: '[PC preview] unknow pid', + uid: '[PC preview] unknow uid', + processName: '[PC preview] unknow processName', + startTime: '[PC preview] unknow startTime', + abilityState: AbilityState +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/AbilityStageContext.js b/runtime/main/extend/systemplugin/napi/application/AbilityStageContext.js new file mode 100755 index 00000000..f66265e2 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/AbilityStageContext.js @@ -0,0 +1,28 @@ +/* + * 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 { ContextClass } from "./Context" +import { HapModuleInfo } from "../bundle/HapModuleInfo" +import { Configuration } from "../ohos.application.Configuration" + +export const AbilityStageContextClass = class AbilityStageContext extends ContextClass { + constructor() { + super(); + console.warn("AbilityStageContext.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + this.currentHapModuleInfo = HapModuleInfo; + this.config = Configuration; + } +}; diff --git a/runtime/main/extend/systemplugin/napi/application/AbilityStateData.js b/runtime/main/extend/systemplugin/napi/application/AbilityStateData.js new file mode 100755 index 00000000..02192c55 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/AbilityStateData.js @@ -0,0 +1,28 @@ +/* + * 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 AbilityStateDataClass = class AbilityStateData { + constructor() { + console.warn("AbilityStateData.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + this.moduleName = "[PC Preview] unknow moduleName", + this.bundleName = "[PC Preview] unknow bundleName", + this.abilityName = "[PC Preview] unknow abilityName", + this.pid = "[PC Preview] unknow pid", + this.uid = "[PC Preview] unknow uid", + this.state = "[PC Preview] unknow state", + this.abilityType = "[PC Preview] unknow abilityType" + } +}; diff --git a/runtime/main/extend/systemplugin/napi/application/AppStateData.js b/runtime/main/extend/systemplugin/napi/application/AppStateData.js new file mode 100755 index 00000000..b198254a --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/AppStateData.js @@ -0,0 +1,24 @@ +/* + * 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 AppStateDataClass = class AppStateData { + constructor() { + console.warn("AppStateData.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + this.bundleName = "[PC Preview] unknow bundleName", + this.uid = "[PC Preview] unknow uid", + this.state = "[PC Preview] unknow state", + } +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/ApplicationContext.js b/runtime/main/extend/systemplugin/napi/application/ApplicationContext.js new file mode 100755 index 00000000..92290c92 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/ApplicationContext.js @@ -0,0 +1,59 @@ +/* + * 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 { ContextClass } from "./Context" + +export const ApplicationContextClass = class ApplicationContext extends ContextClass { + constructor() { + super(); + console.warn('ApplicationContext.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + this.registerAbilityLifecycleCallback = function (...args) { + console.warn("ApplicationContext.registerAbilityLifecycleCallback interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock + }; + this.unregisterAbilityLifecycleCallback = function (...args) { + console.warn("ApplicationContext.unregisterAbilityLifecycleCallback 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }; + this.registerEnvironmentCallback = function (...args) { + console.warn("ApplicationContext.registerEnvironmentCallback interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock + }; + this.unregisterEnvironmentCallback = function (...args) { + console.warn("ApplicationContext.unregisterEnvironmentCallback 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }; + } + } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/ApplicationStateObserver.js b/runtime/main/extend/systemplugin/napi/application/ApplicationStateObserver.js new file mode 100755 index 00000000..b8327543 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/ApplicationStateObserver.js @@ -0,0 +1,37 @@ +/* + * 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 ApplicationStateObserverClass = class ApplicationStateObserver { + constructor() { + console.warn('ApplicationStateObserver.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + this.onForegroundApplicationChanged = function (...args) { + console.warn("ApplicationStateObserver.onForegroundApplicationChanged interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }; + this.onAbilityStateChanged = function (...args) { + console.warn("ApplicationStateObserver.onAbilityStateChanged interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }; + this.onProcessCreated = function (...args) { + console.warn("ApplicationStateObserver.onProcessCreated interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }; + this.onProcessDied = function (...args) { + console.warn("ApplicationStateObserver.onProcessDied interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }; + } + } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/Context.js b/runtime/main/extend/systemplugin/napi/application/Context.js index bc9339ef..b2a6752e 100644 --- a/runtime/main/extend/systemplugin/napi/application/Context.js +++ b/runtime/main/extend/systemplugin/napi/application/Context.js @@ -280,10 +280,12 @@ export const ContextClass = class Context extends BaseContext { this.tempDir = "[PC Preview] unknow tempDir"; this.filesDir = "[PC Preview] unknow filesDir"; this.databaseDir = "[PC Preview] unknow databaseDir"; + this.preferencesDir = "[PC Preview] unknow preferencesDir"; this.storageDir = "[PC Preview] unknow storageDir"; this.bundleCodeDir = "[PC Preview] unknow bundleCodeDir"; this.distributedFilesDir = "[PC Preview] unknow distributedFilesDir"; this.eventHub = new EventHubClass(); + this.area = AreaMode; this.createBundleContext = function (...args) { console.warn("Context.createBundleContext interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") diff --git a/runtime/main/extend/systemplugin/napi/application/ErrorObserver.js b/runtime/main/extend/systemplugin/napi/application/ErrorObserver.js new file mode 100755 index 00000000..6cfe5d31 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/ErrorObserver.js @@ -0,0 +1,25 @@ +/* + * 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 ErrorObserverClass = class ErrorObserver { + constructor() { + console.warn("ErrorObserver.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + this.onUnhandledException = function (...args) { + console.warn("ErrorObserver.onUnhandledException interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + } +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/EventHub.js b/runtime/main/extend/systemplugin/napi/application/EventHub.js new file mode 100755 index 00000000..d2f68c19 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/EventHub.js @@ -0,0 +1,33 @@ +/* + * 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 EventHubClass = class EventHub { + constructor() { + console.warn("EventHub.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + this.on = function (...args) { + console.warn("EventHub.on interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.off = function (...args) { + console.warn("EventHub.off interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.emit = function (...args) { + console.warn("EventHub.emit interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + } +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/ExtensionContext.js b/runtime/main/extend/systemplugin/napi/application/ExtensionContext.js new file mode 100755 index 00000000..0bfc644d --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/ExtensionContext.js @@ -0,0 +1,30 @@ +/* + * 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 { HapModuleInfo } from "../bundle/HapModuleInfo"; +import { Configuration } from "../ohos.application.Configuration" +import { ExtensionAbilityInfo } from "../bundle/extensionAbilityInfo" +import { ContextClass } from "./Context" + +export const ExtensionContextClass = class ExtensionContext extends ContextClass { + constructor() { + super(); + console.warn("ExtensionContext.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + this.currentHapModuleInfo = HapModuleInfo; + this.config = Configuration; + this.extensionAbilityInfo = ExtensionAbilityInfo; + } +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/ExtensionRunningInfo.js b/runtime/main/extend/systemplugin/napi/application/ExtensionRunningInfo.js new file mode 100755 index 00000000..16406d9a --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/ExtensionRunningInfo.js @@ -0,0 +1,50 @@ +/* + * 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" + +const ElementName = { + deviceId: '[PC preview] unknow deviceId', + bundleName: '[PC preview] unknow bundleName', + abilityName: '[PC preview] unknow abilityName', + uri: '[PC preview] unknow uri', + shortName: '[PC preview] unknow shortName', + moduleName: '[PC preview] unknow moduleName' +} +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, + ENTERPRISE_ADMIN: 11, + UNSPECIFIED: 20 +} + +export const ExtensionRunningInfo = { + extension: ElementName, + pid: '[PC preview] unknow pid', + uid: '[PC preview] unknow uid', + processName: '[PC preview] unknow processName', + startTime: '[PC preview] unknow startTime', + clientPackage: [paramMock.paramStringMock], + abilityState: ExtensionAbilityType +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/MissionInfo.js b/runtime/main/extend/systemplugin/napi/application/MissionInfo.js new file mode 100755 index 00000000..bbf47676 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/MissionInfo.js @@ -0,0 +1,27 @@ +/* + * 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 { WantClass } from "../ohos.application.Want" + +export const MissionInfo = { + missionId: '[PC preview] unknow missionId', + runningState: '[PC preview] unknow runningState', + lockedState: '[PC preview] unknow lockedState', + timestamp: '[PC preview] unknow timestamp', + want: new WantClass(), + label: '[PC preview] unknow label', + iconPath: '[PC preview] unknow iconPath', + continuable: '[PC preview] unknow continuable' +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/MissionListener.js b/runtime/main/extend/systemplugin/napi/application/MissionListener.js new file mode 100755 index 00000000..ae014e52 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/MissionListener.js @@ -0,0 +1,37 @@ +/* + * 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 MissionListener = { + onMissionCreated: function(...args) { + console.warn("MissionListener.onMissionCreated interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }, + onMissionDestroyed: function(...args) { + console.warn("MissionListener.onMissionDestroyed interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }, + onMissionSnapshotChanged: function(...args) { + console.warn("MissionListener.onMissionSnapshotChanged interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }, + onMissionMovedToFront: function(...args) { + console.warn("MissionListener.onMissionMovedToFront interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + }, + onMissionIconUpdated: function(...args) { + console.warn("MissionListener.onMissionIconUpdated interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + } +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/MissionSnapshot.js b/runtime/main/extend/systemplugin/napi/application/MissionSnapshot.js new file mode 100755 index 00000000..a71f4797 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/MissionSnapshot.js @@ -0,0 +1,30 @@ +/* + * 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 { PixelMapMock } from "../../multimedia" + +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' +} + +export const MissionSnapshot = { + abality: ElementName, + snapshot: PixelMapMock +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/PermissionRequestResult.js b/runtime/main/extend/systemplugin/napi/application/PermissionRequestResult.js new file mode 100755 index 00000000..4b7b387c --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/PermissionRequestResult.js @@ -0,0 +1,25 @@ +/* + * 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 PermissionRequestResultClass = class PermissionRequestResult { + constructor() { + console.warn("PermissionRequestResult.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + this.permissions = [paramMock.paramStringMock] + this.authResults = [paramMock.paramNumberMock] + } +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/ProcessData.js b/runtime/main/extend/systemplugin/napi/application/ProcessData.js new file mode 100755 index 00000000..4e651615 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/ProcessData.js @@ -0,0 +1,26 @@ +/* + * 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 ProcessDataClass = class ProcessData { + constructor() { + console.warn("ProcessData.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + this.bundleName = "[PC Preview] unknow bundleName" + this.pid = "[PC Preview] unknow pid" + this.uid = "[PC Preview] unknow uid" + } +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/ProcessRunningInfo.js b/runtime/main/extend/systemplugin/napi/application/ProcessRunningInfo.js new file mode 100755 index 00000000..761fd862 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/ProcessRunningInfo.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. + */ + +import { paramMock } from "../../utils" + +export const ProcessRunningInfo = { + pid: "[PC Preview] unknow pid", + uid: "[PC Preview] unknow uid", + processName: "[PC Preview] unknow processName", + bundleNames: [paramMock.paramStringMock] +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/application/ServiceExtensionContext.js b/runtime/main/extend/systemplugin/napi/application/ServiceExtensionContext.js new file mode 100755 index 00000000..86d92b59 --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/application/ServiceExtensionContext.js @@ -0,0 +1,131 @@ +/* + * 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 { ExtensionContextClass } from "./ExtensionContext" + +export const ServiceExtensionContextClass = class ServiceExtensionContext extends ExtensionContextClass { + constructor() { + super(); + console.warn("ServiceExtensionContext.constructor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + this.startAbility = function (...args) { + console.warn("ServiceExtensionContext.startAbility 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }; + this.startAbilityWithAccount = function (...args) { + console.warn("ServiceExtensionContext.startAbilityWithAccount 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }; + this.startServiceExtensionAbility = function (...args) { + console.warn("ServiceExtensionContext.startServiceExtensionAbility 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }; + this.startServiceExtensionAbilityWithAccount = function (...args) { + console.warn("ServiceExtensionContext.startServiceExtensionAbilityWithAccount 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }; + this.stopServiceExtensionAbility = function (...args) { + console.warn("ServiceExtensionContext.stopServiceExtensionAbility 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }; + this.stopServiceExtensionAbilityWithAccount = function (...args) { + console.warn("ServiceExtensionContext.stopServiceExtensionAbilityWithAccount 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }; + this.terminateSelf = function (...args) { + console.warn("ServiceExtensionContext.terminateSelf 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }; + this.connectAbility = function (...args) { + console.warn("ServiceExtensionContext.connectAbility interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock + }; + this.connectAbilityWithAccount = function (...args) { + console.warn("ServiceExtensionContext.connectAbilityWithAccount interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock + }; + this.disconnectAbility = function (...args) { + console.warn("ServiceExtensionContext.disconnectAbility 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); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }; + } +}; \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/commonEvent/commonEventData.js b/runtime/main/extend/systemplugin/napi/commonEvent/commonEventData.js index 83ee21a6..8631a7ec 100644 --- a/runtime/main/extend/systemplugin/napi/commonEvent/commonEventData.js +++ b/runtime/main/extend/systemplugin/napi/commonEvent/commonEventData.js @@ -18,5 +18,5 @@ export const CommonEventData = { bundleName: '[PC preview] unknow bundleName', code: '[PC preview] unknow code', data: '[PC preview] unknow data', - parameters: {} -} \ No newline at end of file + parameters: {"key": "unknown any"}, +} diff --git a/runtime/main/extend/systemplugin/napi/commonEvent/commonEventPublishData.js b/runtime/main/extend/systemplugin/napi/commonEvent/commonEventPublishData.js index 9174974b..248f625b 100644 --- a/runtime/main/extend/systemplugin/napi/commonEvent/commonEventPublishData.js +++ b/runtime/main/extend/systemplugin/napi/commonEvent/commonEventPublishData.js @@ -21,5 +21,5 @@ export const CommonEventPublishData = { subscriberPermissions: [paramMock.paramStringMock], isOrdered: '[PC preview] unknow isOrdered', isSticky: '[PC preview] unknow isSticky', - parameters: {} -} \ No newline at end of file + parameters: {"key": "unknown any"}, +} diff --git a/runtime/main/extend/systemplugin/napi/continuation/continuationExtraParams.js b/runtime/main/extend/systemplugin/napi/continuation/continuationExtraParams.js index 7d494bf6..f29740cd 100644 --- a/runtime/main/extend/systemplugin/napi/continuation/continuationExtraParams.js +++ b/runtime/main/extend/systemplugin/napi/continuation/continuationExtraParams.js @@ -23,5 +23,5 @@ export const ContinuationExtraParams = { description: "[PC Preview] unknow description", filter: "[PC Preview] unknow filter", continuationMode: ContinuationMode, - authInfo: {} -} \ No newline at end of file + authInfo: {"key":"unknow any"} +} diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js old mode 100644 new mode 100755 index 49183417..9205454d --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -28,6 +28,7 @@ import { mockServiceExtensionAbility } from './ohos_application_ServiceExtension import { mockAbilityStage } from './ohos_application_AbilityStage' import { mockFormBindingData } from './ohos_application_formBindingData' import { mockAbilityManager } from './ohos_application_abilityManager' +import { mockParticleAbility } from './ohos_ability_particleAbility' import { mockAppManager } from './ohos_application_appManager' import { mockDataShareExtensionAbility } from './ohos_application_DataShareExtensionAbility' import { mockMissionManager } from "./ohos_application_missionManager" @@ -276,6 +277,8 @@ export function mockRequireNapiFun() { return mockSystemParameter(); case "ability.dataUriUtils": return mockDataUriUtils(); + case "ability.particleAbility": + return mockParticleAbility(); case "ability.featureAbility": return mockFeatureAbility(); case "application.Ability": diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationActionButton.js b/runtime/main/extend/systemplugin/napi/notification/notificationActionButton.js index f78f5a58..0b4fbb30 100644 --- a/runtime/main/extend/systemplugin/napi/notification/notificationActionButton.js +++ b/runtime/main/extend/systemplugin/napi/notification/notificationActionButton.js @@ -17,6 +17,6 @@ import { NotificationUserInput } from "./notificationUserInput" export const NotificationActionButton = { title: '[PC preview] unknow title', wantAgent: '[PC preview] unknow wantAgent', - extras: {}, + extras: {"key": "unknown any"}, userInput: NotificationUserInput, -} \ No newline at end of file +} diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationRequest.js b/runtime/main/extend/systemplugin/napi/notification/notificationRequest.js index ccb0bb7b..81f0c521 100644 --- a/runtime/main/extend/systemplugin/napi/notification/notificationRequest.js +++ b/runtime/main/extend/systemplugin/napi/notification/notificationRequest.js @@ -30,7 +30,7 @@ export const NotificationRequest = { tapDismissed: '[PC preview] unknow tapDismissed', autoDeletedTime: '[PC preview] unknow autoDeletedTime', wantAgent: '[PC preview] unknow wantAgent', - extraInfo: {}, + extraInfo: {"key": "unknown any"}, color: '[PC preview] unknow color', colorEnabled: '[PC preview] unknow colorEnabled', isAlertOnce: '[PC preview] unknow isAlertOnce', @@ -64,4 +64,4 @@ export const DistributedOptions = { supportDisplayDevices: [paramMock.paramStringMock], supportOperateDevices: [paramMock.paramStringMock], remindType: '[PC preview] unknow remindType', -} \ No newline at end of file +} diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationSortingMap.js b/runtime/main/extend/systemplugin/napi/notification/notificationSortingMap.js index d7ca9875..8ed89dff 100644 --- a/runtime/main/extend/systemplugin/napi/notification/notificationSortingMap.js +++ b/runtime/main/extend/systemplugin/napi/notification/notificationSortingMap.js @@ -15,6 +15,6 @@ import { paramMock } from "../../utils" export const NotificationSortingMap = { - sortings: {}, + sortings: {"key": "unknown any"}, sortedHashCode: [paramMock.paramStringMock], -}; \ No newline at end of file +}; diff --git a/runtime/main/extend/systemplugin/napi/notification/notificationTemplate.js b/runtime/main/extend/systemplugin/napi/notification/notificationTemplate.js index 62d68e12..c235f1ef 100644 --- a/runtime/main/extend/systemplugin/napi/notification/notificationTemplate.js +++ b/runtime/main/extend/systemplugin/napi/notification/notificationTemplate.js @@ -14,5 +14,5 @@ */ export const NotificationTemplate = { name: '[PC preview] unknow name', - data: {}, -} \ No newline at end of file + data: {"key": "unknown any"}, +} diff --git a/runtime/main/extend/systemplugin/napi/ohos_ability_particleAbility.js b/runtime/main/extend/systemplugin/napi/ohos_ability_particleAbility.js new file mode 100755 index 00000000..62e0e61d --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_ability_particleAbility.js @@ -0,0 +1,96 @@ +/* + * 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 { dataAbilityHelper } from "./ability/dataAbilityHelper" + +export function mockParticleAbility() { + const particleAbility = { + startAbility: function (...args) { + console.warn("ability.particleAbility.startAbility 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) + } else { + return new Promise((resolve) => { + resolve() + }) + } + }, + terminateSelf: function (...args) { + console.warn("ability.particleAbility.terminateSelf 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) + } else { + return new Promise((resolve) => { + resolve() + }) + } + }, + acquireDataAbilityHelper: function (...args) { + console.warn("ability.particleAbility.acquireDataAbilityHelper interface mocked in the Previewer. How this interface works" + + " on the Previewer may be different from that on a real device.") + return dataAbilityHelper; + }, + connectAbility: function (...args) { + console.warn("ability.particleAbility.connectAbility interface mocked in the Previewer. How this interface works" + + " on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock; + }, + disconnectAbility: function (...args) { + console.warn("ability.particleAbility.disconnectAbility 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) + } else { + return new Promise((resolve) => { + resolve() + }) + } + }, + startBackgroundRunning: function (...args) { + console.warn("ability.particleAbility.startBackgroundRunning 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) + } else { + return new Promise((resolve) => { + resolve() + }) + } + }, + cancelBackgroundRunning: function (...args) { + console.warn("ability.particleAbility.cancelBackgroundRunning 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) + } else { + return new Promise((resolve) => { + resolve() + }) + } + }, + ErrorCode : { + INVALID_PARAMETER: -1, + } + } + return particleAbility; +} \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_Configuration.js b/runtime/main/extend/systemplugin/napi/ohos_application_Configuration.js index 487bf868..1507e7cc 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_Configuration.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_Configuration.js @@ -19,4 +19,5 @@ export const Configuration = { direction: Direction, screenDensity: ScreenDensity, displayId: '[PC preview] unknow displayId', + hasPointerDevice: '[PC preview] unknow hasPointerDevice', } diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_Want.js b/runtime/main/extend/systemplugin/napi/ohos_application_Want.js index 1fad9fd2..84d3f339 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_Want.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_Want.js @@ -23,7 +23,7 @@ export const WantClass = class Want { this.abilityName = "[PC Preview] unknow abilityName"; this.uri = "[PC Preview] unknow uri"; this.type = "[PC Preview] unknow type"; - this.flag = "[PC Preview] unknow flag"; + this.flags = "[PC Preview] unknow flags"; this.action = "[PC Preview] unknow action"; this.parameters = {}; this.entities = [paramMock.paramStringMock]; diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_errorManager.js b/runtime/main/extend/systemplugin/napi/ohos_application_errorManager.js old mode 100644 new mode 100755 diff --git a/runtime/main/extend/systemplugin/napi/ohos_application_missionManager.js b/runtime/main/extend/systemplugin/napi/ohos_application_missionManager.js index ab5d68ad..86461545 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_application_missionManager.js +++ b/runtime/main/extend/systemplugin/napi/ohos_application_missionManager.js @@ -92,6 +92,18 @@ export function mockMissionManager() { }); } }, + getLowResolutionMissionSnapShot: function (...args) { + console.warn('missionManager.getLowResolutionMissionSnapShot 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, MissionSnapshotMock); + } else { + return new Promise((resolve) => { + resolve(MissionSnapshotMock); + }); + } + }, lockMission: function (...args) { console.warn('missionManager.lockMission interface mocked in the Previewer. How this interface works on the' + ' Previewer may be different from that on a real device.'); diff --git a/runtime/main/extend/systemplugin/napi/wantAgent/triggerInfo.js b/runtime/main/extend/systemplugin/napi/wantAgent/triggerInfo.js index d3acf68f..6c6b07a0 100644 --- a/runtime/main/extend/systemplugin/napi/wantAgent/triggerInfo.js +++ b/runtime/main/extend/systemplugin/napi/wantAgent/triggerInfo.js @@ -17,5 +17,5 @@ export const TriggerInfo = { code: '[PC preview] unknow code', want: new WantClass(), permission: '[PC preview] unknow permission', - extraInfo: {}, -}; \ No newline at end of file + extraInfo: {"key": "unknown any"}, +}; diff --git a/runtime/main/extend/systemplugin/napi/wantAgent/wantAgentInfo.js b/runtime/main/extend/systemplugin/napi/wantAgent/wantAgentInfo.js index c0e91b07..a968baca 100644 --- a/runtime/main/extend/systemplugin/napi/wantAgent/wantAgentInfo.js +++ b/runtime/main/extend/systemplugin/napi/wantAgent/wantAgentInfo.js @@ -20,5 +20,5 @@ export const WantAgentInfo = { operationType: OperationType, requestCode: '[PC preview] unknow requestCode', wantAgentFlags: [WantAgentFlags], - extraInfo: {}, -}; \ No newline at end of file + extraInfo: {"key": "unknown any"}, +};