From 83ade5658b59a82ec7e23f05e61b8e43926aa5cf Mon Sep 17 00:00:00 2001 From: hwx1119949 <3052854011@qq.com> Date: Wed, 5 Jan 2022 14:31:31 +0800 Subject: [PATCH] JS API Mock bug fix Signed-off-by: hwx1119949 <3052854011@qq.com> Change-Id: I000cfb6bf49bc463a8baa756eca2c9a54ec2c439 --- runtime/main/extend/systemplugin/ability.js | 24 +- .../main/extend/systemplugin/accessibility.js | 2 - .../main/extend/systemplugin/multimedia.js | 15 - .../napi/application/abilityContext.js | 578 +-- .../napi/applicationFormExtension.js | 106 +- .../napi/applicationServiceExtension.js | 382 +- .../extend/systemplugin/ohos/bluetooth.js | 652 ++-- runtime/main/extend/systemplugin/telephony.js | 3421 ++++++++--------- 8 files changed, 2579 insertions(+), 2601 deletions(-) diff --git a/runtime/main/extend/systemplugin/ability.js b/runtime/main/extend/systemplugin/ability.js index c35346c3..76ed8bcf 100644 --- a/runtime/main/extend/systemplugin/ability.js +++ b/runtime/main/extend/systemplugin/ability.js @@ -1258,13 +1258,11 @@ export function mockAbilityContinuationRegisterManager() { console.warn("ability.ContinuationRegisterManager.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 (args[0] === 'deviceConnect') { - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, ContinuationResultMock) - } - } else { - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.paramStringMock) + if(typeof args[len -1]==='function'){ + if(args[0] ==='deviceConnect'){ + args[len-1].call(this,ContinuationResultMock) + }else{ + args[len-1].call(this,paramMock.paramStringMock) } } }, @@ -1272,13 +1270,11 @@ export function mockAbilityContinuationRegisterManager() { console.warn("ability.ContinuationRegisterManager.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 (args[0] === 'deviceConnect') { - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, ContinuationResultMock) - } - } else { - if (typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.paramStringMock) + if(typeof args[len -1]==='function'){ + if(args[0] ==='deviceConnect'){ + args[len-1].call(this,ContinuationResultMock) + }else{ + args[len-1].call(this,paramMock.paramStringMock) } } }, diff --git a/runtime/main/extend/systemplugin/accessibility.js b/runtime/main/extend/systemplugin/accessibility.js index 9d478af2..0656ca76 100644 --- a/runtime/main/extend/systemplugin/accessibility.js +++ b/runtime/main/extend/systemplugin/accessibility.js @@ -167,8 +167,6 @@ export function mockAccessibility() { const len = args.length; if (len > 0 && typeof args[len - 1] === 'function') { args[len - 1].call(this, paramMock.businessErrorMock, StateEventMock); - } else { - return; } }, getAbilityLists: function(...args) { diff --git a/runtime/main/extend/systemplugin/multimedia.js b/runtime/main/extend/systemplugin/multimedia.js index ca870aaa..50e15d68 100644 --- a/runtime/main/extend/systemplugin/multimedia.js +++ b/runtime/main/extend/systemplugin/multimedia.js @@ -230,37 +230,30 @@ export function mockMultimediaMedia() { play: function () { console.warn("AudioPlayer.play interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return }, pause: function () { console.warn("AudioPlayer.pause interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return }, stop: function () { console.warn("AudioPlayer.stop interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return }, reset: function () { console.warn("AudioPlayer.stop interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return }, seek: function (...args) { console.warn("AudioPlayer.seek interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return }, setVolume: function (...args) { console.warn("AudioPlayer.setVolume interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") - return }, release: function () { console.warn("AudioPlayer.release interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return }, src: "[PC Preview] unknow src", loop: "[PC Preview] unknow loop", @@ -403,27 +396,22 @@ export function mockMultimediaMedia() { start: function (...args) { console.warn("MediaDecoder.start interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return }, seek: function (...args) { console.warn("MediaDecoder.seek interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return }, stop: function () { console.warn("MediaDecoder.stop interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return }, release: function () { console.warn("MediaDecoder.release interface mocked in the Previewer. How this interface works on the" + " Previewer may be different from that on a real device.") - return }, requestFrame: function () { console.warn("MediaDecoder.requestFrame interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return }, on: function (...args) { console.warn("MediaDecoder.on interface mocked in the Previewer. How this interface works on the Previewer" + @@ -679,12 +667,10 @@ export function mockMultimediaMedialibrary() { on: function (...args) { console.warn("MediaLibrary.on interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return }, off: function (...args) { console.warn("MediaLibrary.off interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return } } const FetchFileResultMock = { @@ -701,7 +687,6 @@ export function mockMultimediaMedialibrary() { close: function (...args) { console.warn("FetchFileResult.close interface mocked in the Previewer. How this interface works on the Previewer" + " may be different from that on a real device.") - return }, getFirstObject: function (...args) { console.warn("FetchFileResult.getFirstObject interface mocked in the Previewer. How this interface works on the" + diff --git a/runtime/main/extend/systemplugin/napi/application/abilityContext.js b/runtime/main/extend/systemplugin/napi/application/abilityContext.js index c6ba91df..5a27bd74 100644 --- a/runtime/main/extend/systemplugin/napi/application/abilityContext.js +++ b/runtime/main/extend/systemplugin/napi/application/abilityContext.js @@ -1,317 +1,317 @@ -import {paramMock} from "../../utils" +import { paramMock } from "../../utils" const ModuleInfoMock = { - moduleName: '[PC preview] unknow moduleName', - moduleSourceDir: '[PC preview] unknow moduleSourceDir', + moduleName: '[PC preview] unknow moduleName', + moduleSourceDir: '[PC preview] unknow moduleSourceDir', } export const AbilityInfoMock = { - bundleName: '[PC preview] unknow bundleName', - name: '[PC preview] unknow name', - label: '[PC preview] unknow label', - description: '[PC preview] unknow description', - icon: '[PC preview] unknow icon', - labelId: '[PC preview] unknow labelId', - descriptionId: '[PC preview] unknow descriptionId', - iconId: '[PC preview] unknow iconId', - moduleName: '[PC preview] unknow moduleName', - process: '[PC preview] unknow process', - targetAbility: '[PC preview] unknow targetAbility', - backgroundModes: '[PC preview] unknow backgroundModes', - isVisible: '[PC preview] unknow isVisible', - abilityTypeMock: '[PC preview] unknow abilityTypeMock', - AbilitySubTypeMock: '[PC preview] unknow AbilitySubTypeMock', - DisplayOrientationMock: '[PC preview] unknow DisplayOrientationMock', - launchModeMock: '[PC preview] unknow launchModeMock', - formEnabled: '[PC preview] unknow formEnabled', - permissions: [paramMock.paramStringMock], - deviceTypes: [paramMock.paramStringMock], - deviceCapabilities: [paramMock.paramStringMock], - readPermission: '[PC preview] unknow readPermission', - writePermission: '[PC preview] unknow writePermission', - applicationInfo: applicationInfoMock, - formEntity: '[PC preview] unknow formEntity', - minFormHeight: '[PC preview] unknow minFormHeight', - defaultFormHeight: '[PC preview] unknow defaultFormHeight', - minFormWidth: '[PC preview] unknow minFormWidth', - defaultFormWidth: '[PC preview] unknow defaultFormWidth', - uri: '[PC preview] unknow uri', - customizeData: new Map([["[PC Preview] unknow customizeDataKey", "[PC Preview] unknow customizeDataValue"]]) + bundleName: '[PC preview] unknow bundleName', + name: '[PC preview] unknow name', + label: '[PC preview] unknow label', + description: '[PC preview] unknow description', + icon: '[PC preview] unknow icon', + labelId: '[PC preview] unknow labelId', + descriptionId: '[PC preview] unknow descriptionId', + iconId: '[PC preview] unknow iconId', + moduleName: '[PC preview] unknow moduleName', + process: '[PC preview] unknow process', + targetAbility: '[PC preview] unknow targetAbility', + backgroundModes: '[PC preview] unknow backgroundModes', + isVisible: '[PC preview] unknow isVisible', + abilityTypeMock: '[PC preview] unknow abilityTypeMock', + AbilitySubTypeMock: '[PC preview] unknow AbilitySubTypeMock', + DisplayOrientationMock: '[PC preview] unknow DisplayOrientationMock', + launchModeMock: '[PC preview] unknow launchModeMock', + formEnabled: '[PC preview] unknow formEnabled', + permissions: [paramMock.paramStringMock], + deviceTypes: [paramMock.paramStringMock], + deviceCapabilities: [paramMock.paramStringMock], + readPermission: '[PC preview] unknow readPermission', + writePermission: '[PC preview] unknow writePermission', + applicationInfo: applicationInfoMock, + formEntity: '[PC preview] unknow formEntity', + minFormHeight: '[PC preview] unknow minFormHeight', + defaultFormHeight: '[PC preview] unknow defaultFormHeight', + minFormWidth: '[PC preview] unknow minFormWidth', + defaultFormWidth: '[PC preview] unknow defaultFormWidth', + uri: '[PC preview] unknow uri', + customizeData: new Map([["[PC Preview] unknow customizeDataKey", "[PC Preview] unknow customizeDataValue"]]) } const applicationInfoMock = { - name: '[PC preview] unknow name', - description: '[PC preview] unknow description', - descriptionId: '[PC preview] unknow descriptionId', - systemApp: '[PC preview] unknow systemApp', - enabled: '[PC preview] unknow enabled', - label: '[PC preview] unknow label', - labelId: '[PC preview] unknow labelId', - icon: '[PC preview] unknow icon', - iconId: '[PC preview] unknow iconId', - process: '[PC preview] unknow process', - supportedModes: '[PC preview] unknow supportedModes', - moduleSourceDirs: [paramMock.paramStringMock], - permissions: [paramMock.paramStringMock], - moduleInfo: [ModuleInfoMock], - entryDir: '[PC preview] unknow entryDir', - codepath: '[PC preview] unknow codepath', - removable: '[PC preview] unknow removable', - customizeData: new Map([["[PC Preview] unknow customizeDataKey", "[PC Preview] unknow customizeDataValue"]]) + name: '[PC preview] unknow name', + description: '[PC preview] unknow description', + descriptionId: '[PC preview] unknow descriptionId', + systemApp: '[PC preview] unknow systemApp', + enabled: '[PC preview] unknow enabled', + label: '[PC preview] unknow label', + labelId: '[PC preview] unknow labelId', + icon: '[PC preview] unknow icon', + iconId: '[PC preview] unknow iconId', + process: '[PC preview] unknow process', + supportedModes: '[PC preview] unknow supportedModes', + moduleSourceDirs: [paramMock.paramStringMock], + permissions: [paramMock.paramStringMock], + moduleInfo: [ModuleInfoMock], + entryDir: '[PC preview] unknow entryDir', + codepath: '[PC preview] unknow codepath', + removable: '[PC preview] unknow removable', + customizeData: new Map([["[PC Preview] unknow customizeDataKey", "[PC Preview] unknow customizeDataValue"]]) } const HapModuleInfoMock = { - name: '[PC preview] unknow name', - description: '[PC preview] unknow description', - descriptionId: '[PC preview] unknow descriptionId', - icon: '[PC preview] unknow icon', - label: '[PC preview] unknow label', - labelId: '[PC preview] unknow labelId', - iconId: '[PC preview] unknow iconId', - backgroundImg: '[PC preview] unknow backgroundImg', - supportedModes: '[PC preview] unknow supportedModes', - reqCapabilities: [paramMock.paramStringMock], - deviceTypes: [paramMock.paramStringMock], - abilityInfo: AbilityInfoMock, - moduleName: '[PC preview] unknow moduleName', - mainAbilityName: '[PC preview] unknow mainAbilityName', - installationFree: '[PC preview] unknow installationFree', + name: '[PC preview] unknow name', + description: '[PC preview] unknow description', + descriptionId: '[PC preview] unknow descriptionId', + icon: '[PC preview] unknow icon', + label: '[PC preview] unknow label', + labelId: '[PC preview] unknow labelId', + iconId: '[PC preview] unknow iconId', + backgroundImg: '[PC preview] unknow backgroundImg', + supportedModes: '[PC preview] unknow supportedModes', + reqCapabilities: [paramMock.paramStringMock], + deviceTypes: [paramMock.paramStringMock], + abilityInfo: AbilityInfoMock, + moduleName: '[PC preview] unknow moduleName', + mainAbilityName: '[PC preview] unknow mainAbilityName', + installationFree: '[PC preview] unknow installationFree', } const screenDensityMock = { - SCREEN_SDPI: '[PC preview] unknow SCREEN_SDPI', - SCREEN_MDPI: '[PC preview] unknow SCREEN_MDPI', - SCREEN_LDPI: '[PC preview] unknow SCREEN_LDPI', - SCREEN_XLDPI: '[PC preview] unknow SCREEN_XLDPI', - SCREEN_XXLDPI: '[PC preview] unknow SCREEN_XXLDPI', - SCREEN_XXXLDPI: '[PC preview] unknow SCREEN_XXXLDPI' + SCREEN_SDPI: '[PC preview] unknow SCREEN_SDPI', + SCREEN_MDPI: '[PC preview] unknow SCREEN_MDPI', + SCREEN_LDPI: '[PC preview] unknow SCREEN_LDPI', + SCREEN_XLDPI: '[PC preview] unknow SCREEN_XLDPI', + SCREEN_XXLDPI: '[PC preview] unknow SCREEN_XXLDPI', + SCREEN_XXXLDPI: '[PC preview] unknow SCREEN_XXXLDPI' } const deviceTypeMock = { - DEVICE_TYPE_PHONE: '[PC preview] unknow DEVICE_TYPE_PHONE', - DEVICE_TYPE_TABLET: '[PC preview] unknow DEVICE_TYPE_TABLET', - DEVICE_TYPE_CAR: '[PC preview] unknow DEVICE_TYPE_CAR', - DEVICE_TYPE_PC: '[PC preview] unknow DEVICE_TYPE_PC', - DEVICE_TYPE_TV: '[PC preview] unknow DEVICE_TYPE_TV', - DEVICE_TYPE_WEARABLE: '[PC preview] unknow DEVICE_TYPE_WEARABLE' + DEVICE_TYPE_PHONE: '[PC preview] unknow DEVICE_TYPE_PHONE', + DEVICE_TYPE_TABLET: '[PC preview] unknow DEVICE_TYPE_TABLET', + DEVICE_TYPE_CAR: '[PC preview] unknow DEVICE_TYPE_CAR', + DEVICE_TYPE_PC: '[PC preview] unknow DEVICE_TYPE_PC', + DEVICE_TYPE_TV: '[PC preview] unknow DEVICE_TYPE_TV', + DEVICE_TYPE_WEARABLE: '[PC preview] unknow DEVICE_TYPE_WEARABLE' } const DeviceCapabilityClass = class DeviceCapability { - constructor() { - console.warn('DeviceCapability.constructor interface mocked in the Previewer. How this interface works on' + - ' the Previewer may be different from that on a real device.'); - screenDensity = screenDensityMock, - deviceType = deviceTypeMock - } + constructor() { + console.warn('DeviceCapability.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + this.screenDensity = screenDensityMock; + this.deviceType = deviceTypeMock; + } } -const configurationClass = class configuration{ - constructor() { - console.warn('configuration.constructor interface mocked in the Previewer. How this interface works on' + - ' the Previewer may be different from that on a real device.'); - directionMock = '[PC preview] unknow directionMock', - locale = '[PC preview] unknow locale' - } +const configurationClass = class configuration { + constructor() { + console.warn('configuration.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + this.directionMock = '[PC preview] unknow directionMock'; + this.locale = '[PC preview] unknow locale'; + } } const resourceManagerMock = { - getString: function (...args) { - console.warn("ResourceManager.getString interface mocked in the Previewer." + - " How this interface works on the Previewer may be different from that on a real device.") - const len = args.length - if (len > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - getStringArray: function (...args) { - console.warn("ResourceManager.getStringArray interface mocked in the Previewer." + - " How this interface works on the Previewer may be different from that on a real device.") - const len = args.length - if (len > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramStringMock]); - } else { - return new Promise((resolve, reject) => { - resolve([paramMock.paramStringMock]); - }) - } - }, - getMedia: function (...args) { - console.warn("ResourceManager.getMedia 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, new Uint8Array()); - } else { - return new Promise((resolve, reject) => { - resolve(new Uint8Array()); - }) - } - }, - getMediaBase64: function (...args) { - console.warn("ResourceManager.getMediaBase64 interface mocked in the Previewer." + - " How this interface works on the Previewer may be different from that on a real device.") - const len = args.length - if (len > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - getDeviceCapability: function (...args) { - console.warn("ResourceManager.getDeviceCapability 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, new DeviceCapabilityClass()); - } else { - return new Promise((resolve, reject) => { - resolve(new DeviceCapabilityClass()); - }) - } - }, - getConfiguration: function (...args) { - console.warn("ResourceManager.getConfiguration 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, new configurationClass()); - } else { - return new Promise((resolve, reject) => { - resolve(new configurationClass()); - }) - } - }, - getPluralString: function (...args) { - console.warn("ResourceManager.getPluralString interface mocked in the Previewer." + - " How this interface works on the Previewer may be different from that on a real device.") - const len = args.length - if (len > 0 && typeof args[len - 1] === 'function') { - args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - getRawFile: function (...args) { - console.warn("ResourceManager.getRawFile 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, new Uint8Array()); - } else { - return new Promise((resolve, reject) => { - resolve(new Uint8Array()); - }) - } - }, + getString: function (...args) { + console.warn("ResourceManager.getString interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getStringArray: function (...args) { + console.warn("ResourceManager.getStringArray interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramStringMock]); + } else { + return new Promise((resolve, reject) => { + resolve([paramMock.paramStringMock]); + }) + } + }, + getMedia: function (...args) { + console.warn("ResourceManager.getMedia 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, new Uint8Array()); + } else { + return new Promise((resolve, reject) => { + resolve(new Uint8Array()); + }) + } + }, + getMediaBase64: function (...args) { + console.warn("ResourceManager.getMediaBase64 interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getDeviceCapability: function (...args) { + console.warn("ResourceManager.getDeviceCapability 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, new DeviceCapabilityClass()); + } else { + return new Promise((resolve, reject) => { + resolve(new DeviceCapabilityClass()); + }) + } + }, + getConfiguration: function (...args) { + console.warn("ResourceManager.getConfiguration 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, new configurationClass()); + } else { + return new Promise((resolve, reject) => { + resolve(new configurationClass()); + }) + } + }, + getPluralString: function (...args) { + console.warn("ResourceManager.getPluralString interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (len > 0 && typeof args[len - 1] === 'function') { + args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getRawFile: function (...args) { + console.warn("ResourceManager.getRawFile 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, new Uint8Array()); + } else { + return new Promise((resolve, reject) => { + resolve(new Uint8Array()); + }) + } + }, } -export const contextClass = class context{ - constructor() { - console.warn('context.constructor interface mocked in the Previewer. How this interface works on' + - ' the Previewer may be different from that on a real device.'); - this.resourceManager = resourceManagerMock; - this.applicationInfo = applicationInfoMock; - this.HapModuleInfo = HapModuleInfoMock; - this.cacheDir = '[PC preview] unknow cacheDir'; - this.tempDir = '[PC preview] unknow tempDir'; - this.filesDir = '[PC preview] unknow filesDir'; - this.databaseDir = '[PC preview] unknow databaseDir'; - this.storageDir = '[PC preview] unknow storageDir'; - this.bundleCodeDir = '[PC preview] unknow bundleCodeDir'; - this.distributedFilesDir = '[PC preview] unknow distributedFilesDir'; - } +export const contextClass = class context { + constructor() { + console.warn('context.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + this.resourceManager = resourceManagerMock; + this.applicationInfo = applicationInfoMock; + this.HapModuleInfo = HapModuleInfoMock; + this.cacheDir = '[PC preview] unknow cacheDir'; + this.tempDir = '[PC preview] unknow tempDir'; + this.filesDir = '[PC preview] unknow filesDir'; + this.databaseDir = '[PC preview] unknow databaseDir'; + this.storageDir = '[PC preview] unknow storageDir'; + this.bundleCodeDir = '[PC preview] unknow bundleCodeDir'; + this.distributedFilesDir = '[PC preview] unknow distributedFilesDir'; + } }; -export const abilityStageContextClass = class abilityStageContext extends contextClass{ - constructor() { - super(); - console.warn('Context.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 = HapModuleInfoMock; - } +export const abilityStageContextClass = class abilityStageContext extends contextClass { + constructor() { + super(); + console.warn('Context.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 = HapModuleInfoMock; + } } export const ExtensionContextClass = class ExtensionContext extends contextClass { - constructor() { - super(); - console.warn('Context.ExtensionContext.constructor interface mocked in the Previewer. How this interface works on' + - ' the Previewer may be different from that on a real device.'); - } + constructor() { + super(); + console.warn('Context.ExtensionContext.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + } }; export const AbilityResultMock = { - resultCode: "[PC Preview] unknow resultCode", + resultCode: "[PC Preview] unknow resultCode", } export const AbilityContextClass = class AbilityContext extends contextClass { - constructor() { - super(); - console.warn('Ability.AbilityContext.constructor interface mocked in the Previewer. How this interface works on' + - ' the Previewer may be different from that on a real device.'); - this.abilityInfo = AbilityInfoMock; - this.currentHapModuleInfo = HapModuleInfoMock; - this.startAbility = function (...args) { - console.warn("Ability.AbilityContext.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.startAbilityForResult = function (...args) { - console.warn("Ability.AbilityContext.startAbilityForResult 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, AbilityResultMock); - } else { - return new Promise((resolve, reject) => { - resolve(AbilityResultMock); - }) - } - }; - this.terminateSelf = function (...args) { - console.warn("Ability.AbilityContext.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.terminateSelfWithResult = function (...args) { - console.warn("Ability.AbilityContext.terminateSelfWithResult 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("Ability.AbilityContext.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.disconnectAbility = function (...args) { - console.warn("Ability.AbilityContext.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(); - }) - } - }; - } + constructor() { + super(); + console.warn('Ability.AbilityContext.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + this.abilityInfo = AbilityInfoMock; + this.currentHapModuleInfo = HapModuleInfoMock; + this.startAbility = function (...args) { + console.warn("Ability.AbilityContext.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.startAbilityForResult = function (...args) { + console.warn("Ability.AbilityContext.startAbilityForResult 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, AbilityResultMock); + } else { + return new Promise((resolve, reject) => { + resolve(AbilityResultMock); + }) + } + }; + this.terminateSelf = function (...args) { + console.warn("Ability.AbilityContext.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.terminateSelfWithResult = function (...args) { + console.warn("Ability.AbilityContext.terminateSelfWithResult 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("Ability.AbilityContext.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.disconnectAbility = function (...args) { + console.warn("Ability.AbilityContext.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(); + }) + } + }; + } } export function mockAbilityContext() { - return new AbilityContextClass(); + return new AbilityContextClass(); } diff --git a/runtime/main/extend/systemplugin/napi/applicationFormExtension.js b/runtime/main/extend/systemplugin/napi/applicationFormExtension.js index 5bcc102c..242b2e55 100644 --- a/runtime/main/extend/systemplugin/napi/applicationFormExtension.js +++ b/runtime/main/extend/systemplugin/napi/applicationFormExtension.js @@ -1,60 +1,60 @@ import { paramMock } from "../utils" import { ExtensionContextClass } from "./application/abilityContext" -export function mockFormExtension(){ - const formBindingDataMock = { - data: paramMock.paramObjectMock - } - const formExtensionContextClass = class formExtensionContext extends ExtensionContextClass { - constructor() { - super(); - console.warn('formExtension.formExtensionContext.constructor interface mocked in the Previewer. How this interface works on' + - ' the Previewer may be different from that on a real device.'); - this.updateForm = function (...args) { - console.warn("formExtension.formExtensionContext.updateForm 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(); - }) - } - } +export function mockFormExtension() { + const formBindingDataMock = { + data: paramMock.paramObjectMock + } + const formExtensionContextClass = class formExtensionContext extends ExtensionContextClass { + constructor() { + super(); + console.warn('formExtension.formExtensionContext.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + this.updateForm = function (...args) { + console.warn("formExtension.formExtensionContext.updateForm 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(); + }) } + } } - const formExtensionClass = class formExtension { - constructor() { - console.warn('application.formExtension.constructor interface mocked in the Previewer. How this interface works on' + - ' the Previewer may be different from that on a real device.'); - this.context = new formExtensionContextClass(); - this.onCreate = function (...args) { - console.warn("application.formExtension.onCreate interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return formBindingDataMock - }; - this.onCastToNormal = function (...args) { - console.warn("application.formExtension.onCastToNormal interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - this.onUpdate = function (...args) { - console.warn("application.formExtension.onUpdate interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - this.onVisibilityChange = function (...args) { - console.warn("application.formExtension.onVisibilityChange interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - this.onEvent = function (...args) { - console.warn("application.formExtension.onEvent interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - this.onDestroy = function (...args) { - console.warn("application.formExtension.onDestroy interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - } - } + } + const formExtensionClass = class formExtension { + constructor() { + console.warn('application.formExtension.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + this.context = new formExtensionContextClass(); + this.onCreate = function (...args) { + console.warn("application.formExtension.onCreate interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return formBindingDataMock + }; + this.onCastToNormal = function (...args) { + console.warn("application.formExtension.onCastToNormal interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.onUpdate = function (...args) { + console.warn("application.formExtension.onUpdate interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.onVisibilityChange = function (...args) { + console.warn("application.formExtension.onVisibilityChange interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.onEvent = function (...args) { + console.warn("application.formExtension.onEvent interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.onDestroy = function (...args) { + console.warn("application.formExtension.onDestroy interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; } - return new formExtensionClass(); + } + return new formExtensionClass(); } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/napi/applicationServiceExtension.js b/runtime/main/extend/systemplugin/napi/applicationServiceExtension.js index 044c439d..153019bc 100644 --- a/runtime/main/extend/systemplugin/napi/applicationServiceExtension.js +++ b/runtime/main/extend/systemplugin/napi/applicationServiceExtension.js @@ -1,201 +1,201 @@ import { paramMock } from "../utils" import { ExtensionContextClass } from "./application/abilityContext" -export function mockServiceExtension(){ - const IRemoteBrokerMock = { - asObject: function () { - console.warn("IRemoteBroker.asObject interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return IRemoteObjectMock; - }, +export function mockServiceExtension() { + const IRemoteBrokerMock = { + asObject: function () { + console.warn("IRemoteBroker.asObject interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return IRemoteObjectMock; + }, + } + const IRemoteObjectMock = { + queryLocalInterface: function () { + console.warn("IRemoteObject.queryLocalInterface interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return IRemoteBrokerMock; + }, + sendRequest: function (...args) { + console.warn("IRemoteObject.sendRequest interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + return new Promise((resolve, reject) => { + resolve(); + }) + }, + addDeathRecipient: function () { + console.warn("IRemoteObject.addDeathRecipient interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + removeDeathRecipient: function () { + console.warn("IRemoteObject.removeDeathRecipient interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + getInterfaceDescriptor: function () { + console.warn("IRemoteObject.getInterfaceDescriptor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }, + isObjectDead: function () { + console.warn("IRemoteObject.isObjectDead interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; } - const IRemoteObjectMock = { - queryLocalInterface: function () { - console.warn("IRemoteObject.queryLocalInterface interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return IRemoteBrokerMock; - }, - sendRequest: function (...args) { - console.warn("IRemoteObject.sendRequest interface mocked in the Previewer." + - " How this interface works on the Previewer may be different from that on a real device.") - return new Promise((resolve, reject) => { - resolve(); - }) - }, - addDeathRecipient: function () { - console.warn("IRemoteObject.addDeathRecipient interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - removeDeathRecipient: function () { - console.warn("IRemoteObject.removeDeathRecipient interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - getInterfaceDescriptor: function () { - console.warn("IRemoteObject.getInterfaceDescriptor interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock; - }, - isObjectDead: function () { - console.warn("IRemoteObject.isObjectDead interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; + } + const RemoteObjectClass = class RemoteObject { + constructor() { + console.warn('RemoteObject.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + this.queryLocalInterface = function () { + console.warn("RemoteObject.queryLocalInterface interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return IRemoteBrokerMock; + }; + this.sendRequest = function (...args) { + console.warn("RemoteObject.sendRequest interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + return new Promise((resolve, reject) => { + resolve(); + }) + }; + this.addDeathRecipient = function () { + console.warn("RemoteObject.addDeathRecipient interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.removeDeathRecipient = function () { + console.warn("RemoteObject.removeDeathRecipient interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.getInterfaceDescriptor = function () { + console.warn("RemoteObject.getInterfaceDescriptor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock; + }; + this.isObjectDead = function () { + console.warn("RemoteObject.isObjectDead interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock; + }; + this.queryLocalInterface = function (...args) { + console.warn("RemoteObject.queryLocalInterface interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return IRemoteObjectMock + }; + this.getInterfaceDescriptor = function () { + console.warn("RemoteObject.getInterfaceDescriptor interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramStringMock + }; + this.onRemoteRequest = function (...args) { + console.warn("RemoteObject.onRemoteRequest interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return paramMock.paramBooleanMock + }; + this.sendRequest = function (...args) { + console.warn("RemoteObject.sendRequest interface mocked in the Previewer." + + " How this interface works on the Previewer may be different from that on a real device.") + return new Promise((resolve, reject) => { + resolve(); + }) + }; + this.getCallingPid = function () { + console.warn("RemoteObject.getCallingPid 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.getCallingUid = function () { + console.warn("RemoteObject.getCallingUid 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.attachLocalInterface = function (...args) { + console.warn("RemoteObject.attachLocalInterface interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + } + } + const serviceExtensionContextClass = class serviceExtensionContext extends ExtensionContextClass { + constructor() { + super(); + console.warn('ServiceExtension.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("ServiceExtension.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(); + }) } - } - const RemoteObjectClass = class RemoteObject { - constructor() { - console.warn('RemoteObject.constructor interface mocked in the Previewer. How this interface works on' + - ' the Previewer may be different from that on a real device.'); - this.queryLocalInterface = function () { - console.warn("RemoteObject.queryLocalInterface interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return IRemoteBrokerMock; - }, - this.sendRequest = function (...args) { - console.warn("RemoteObject.sendRequest interface mocked in the Previewer." + - " How this interface works on the Previewer may be different from that on a real device.") - return new Promise((resolve, reject) => { - resolve(); - }) - }, - this.addDeathRecipient = function () { - console.warn("RemoteObject.addDeathRecipient interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - this.removeDeathRecipient = function () { - console.warn("RemoteObject.removeDeathRecipient interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - this.getInterfaceDescriptor = function () { - console.warn("RemoteObject.getInterfaceDescriptor interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock; - }, - this.isObjectDead = function () { - console.warn("RemoteObject.isObjectDead interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock; - } - this.queryLocalInterface = function (...args) { - console.warn("RemoteObject.queryLocalInterface interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return IRemoteObjectMock - }, - this.getInterfaceDescriptor = function () { - console.warn("RemoteObject.getInterfaceDescriptor interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramStringMock - }, - this.onRemoteRequest = function (...args) { - console.warn("RemoteObject.onRemoteRequest interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return paramMock.paramBooleanMock - }, - this.sendRequest = function (...args) { - console.warn("RemoteObject.sendRequest interface mocked in the Previewer." + - " How this interface works on the Previewer may be different from that on a real device.") - return new Promise((resolve, reject) => { - resolve(); - }) - }; - this.getCallingPid = function () { - console.warn("RemoteObject.getCallingPid 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.getCallingUid = function () { - console.warn("RemoteObject.getCallingUid 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.attachLocalInterface = function (...args) { - console.warn("RemoteObject.attachLocalInterface interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }; + }; + this.terminateSelf = function (...args) { + console.warn("ServiceExtension.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(); + }) } - } - const serviceExtensionContextClass = class serviceExtensionContext extends ExtensionContextClass{ - constructor() { - super(); - console.warn('ServiceExtension.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("ServiceExtension.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.terminateSelf = function (...args) { - console.warn("ServiceExtension.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("ServiceExtension.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.disconnectAbility = function (...args) { - console.warn("ServiceExtension.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(); - }) - } - } + }; + this.connectAbility = function (...args) { + console.warn("ServiceExtension.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.disconnectAbility = function (...args) { + console.warn("ServiceExtension.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(); + }) } + } } - const ServiceExtensionClass = class ServiceExtension { - constructor() { - console.warn('application.ServiceExtension.constructor interface mocked in the Previewer. How this interface works on' + - ' the Previewer may be different from that on a real device.'); - this.context = new serviceExtensionContextClass(); - this.onCreate = function (...args) { - console.warn("application.ServiceExtension.onCreate interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - this.onDestroy = function () { - console.warn("application.ServiceExtension.onDestroy interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - this.onRequest = function (...args) { - console.warn("application.ServiceExtension.onRequest interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - this.onConnect = function (...args) { - console.warn("application.ServiceExtension.onConnect interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - return new RemoteObjectClass(); - }, - this.onDisconnect = function (...args) { - console.warn("application.ServiceExtension.onDisconnect interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - }, - this.onReconnect = function (...args) { - console.warn("application.ServiceExtension.onReconnect interface mocked in the Previewer. How this interface works on the Previewer" + - " may be different from that on a real device.") - } - } + } + const ServiceExtensionClass = class ServiceExtension { + constructor() { + console.warn('application.ServiceExtension.constructor interface mocked in the Previewer. How this interface works on' + + ' the Previewer may be different from that on a real device.'); + this.context = new serviceExtensionContextClass(); + this.onCreate = function (...args) { + console.warn("application.ServiceExtension.onCreate interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.onDestroy = function () { + console.warn("application.ServiceExtension.onDestroy interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.onRequest = function (...args) { + console.warn("application.ServiceExtension.onRequest interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.onConnect = function (...args) { + console.warn("application.ServiceExtension.onConnect interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + return new RemoteObjectClass(); + }; + this.onDisconnect = function (...args) { + console.warn("application.ServiceExtension.onDisconnect interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; + this.onReconnect = function (...args) { + console.warn("application.ServiceExtension.onReconnect interface mocked in the Previewer. How this interface works on the Previewer" + + " may be different from that on a real device.") + }; } - return new ServiceExtensionClass(); + } + return new ServiceExtensionClass(); } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/ohos/bluetooth.js b/runtime/main/extend/systemplugin/ohos/bluetooth.js index 191776e3..f1018abd 100644 --- a/runtime/main/extend/systemplugin/ohos/bluetooth.js +++ b/runtime/main/extend/systemplugin/ohos/bluetooth.js @@ -1,334 +1,334 @@ import { paramMock } from "../utils" export function mockOhosBluetooth() { - const connectedBLEDevicesMock = [ - { - connectedBLEDevice: "[PC Preview] unknow connectedBLEDevice", - } + const connectedBLEDevicesMock = [ + { + connectedBLEDevice: "[PC Preview] unknow connectedBLEDevice", + } + ] + const gattServiceMock = { + serviceUuid: "[PC preview] unknown serviceUuid", + isPrimary: "[PC preview] unknown isPrimary", + characteristics: [ + BLECharacteristicMock + ], + includeServices: [ + gattServiceMock ] - const gattServiceMock = { - serviceUuid: "[PC preview] unknown serviceUuid", - isPrimary: "[PC preview] unknown isPrimary", - characteristics: [ - BLECharacteristicMock - ], - includeServices: [ - gattServiceMock - ] - } - const BLECharacteristicMock = { - serviceUuid: "[PC preview] unknown serviceUuid", - characteristicUuid: "[PC preview] unknown characteristicUuid", - characteristicValue: "[PC preview] unknown characteristicValue", - descriptors: [ - BLEDescriptorMock - ] - } - const BLEDescriptorMock = { - serviceUuid: "[PC preview] unknown serviceUuid", - characteristicUuid: "[PC preview] unknown characteristicUuid", - descriptorUuid: "[PC preview] unknown descriptorUuid", - descriptorValue: "[PC preview] unknown descriptorValue" - } - const gattServicesMock = [ - gattServiceMock + } + const BLECharacteristicMock = { + serviceUuid: "[PC preview] unknown serviceUuid", + characteristicUuid: "[PC preview] unknown characteristicUuid", + characteristicValue: "[PC preview] unknown characteristicValue", + descriptors: [ + BLEDescriptorMock ] - const scanResultMock = { - deviceId: "[PC preview] unknown deviceId", - rssi: "[PC preview] unknown rssi", - data: "[PC preview] unknown data" - } - const characteristicReadReqMock = { - deviceId: "[PC preview] unknown deviceId", - transId: "[PC preview] unknown transId", - offset: "[PC preview] unknown offset", - characteristicUuid: "[PC preview] unknown characteristicUuid", - serviceUuid: "[PC preview] unknown serviceUuid" - } - const characteristicWriteReqMock = { - deviceId: "[PC preview] unknown deviceId", - transId: "[PC preview] unknown transId", - offset: "[PC preview] unknown offset", - isPrep: "[PC preview] unknown isPrep", - needRsp: "[PC preview] unknown needRsp", - value: "[PC preview] unknown value", - characteristicUuid: "[PC preview] unknown characteristicUuid", - serviceUuid: "[PC preview] unknown serviceUuid" - } - const descriptorReadReqMock = { - deviceId: "[PC preview] unknown v", - transId: "[PC preview] unknown transId", - offset: "[PC preview] unknown offset", - descriptorUuid: "[PC preview] unknown descriptorUuid", - characteristicUuid: "[PC preview] unknown characteristicUuid", - serviceUuid: "[PC preview] unknown serviceUuid" - } - const descriptorWriteReqMock = { - deviceId: "[PC preview] unknown deviceId", - transId: "[PC preview] unknown transId", - offset: "[PC preview] unknown offset", - isPrep: "[PC preview] unknown isPrep", - needRsp: "[PC preview] unknown needRsp", - value: "[PC preview] unknown value", - descriptorUuid: "[PC preview] unknown descriptorUuid", - characteristicUuid: "[PC preview] unknown characteristicUuid", - serviceUuid: "[PC preview] unknown serviceUuid" - } - const BLEConnectChangedStateMock = { - deviceId: "[PC preview] unknown deviceId", - state: "[PC preview] unknown state" - } - const GattServerMock = { - startAdvertising: function (...args) { - console.warn("GattServer.startAdvertising interface mocked in the Previewer." + - "How this interface works on the Previewer may be different from that on a real device.") - }, - stopAdvertising: function () { - console.warn("GattServer.stopAdvertising interface mocked in the Previewer." + - "How this interface works on the Previewer may be different from that on a real device.") - }, - addService: function (...args) { - console.warn("GattServer.addService interface mocked in the Previewer." + - "How this interface works on the Previewer may be different from that on a real device.") - return paramMock.paramBooleanMock - }, - removeService: function (...args) { - console.warn("GattServer.removeService 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("GattServer.close interface mocked in the Previewer." + - "How this interface works on the Previewer may be different from that on a real device.") - }, - notifyCharacteristicChanged: function (...args) { - console.warn("GattServer.notifyCharacteristicChanged interface mocked in the Previewer." + - "How this interface works on the Previewer may be different from that on a real device.") - return paramMock.paramBooleanMock - }, - sendResponse: function (...args) { - console.warn("GattServer.sendResponse interface mocked in the Previewer." + - "How this interface works on the Previewer may be different from that on a real device.") - return paramMock.paramBooleanMock - }, - on: function (...args) { - console.warn("GattServer.on interface mocked in the Previewer." + - "How this interface works on the Previewer may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - if (args[0] == 'characteristicRead') { - args[len - 1].call(this, characteristicReadReqMock); - } else if (args[0] == 'characteristicWrite') { - args[len - 1].call(this, characteristicWriteReqMock); - } else if (args[0] == 'descriptorRead') { - args[len - 1].call(this, descriptorReadReqMock); - } else if (args[0] == 'descriptorWrite') { - args[len - 1].call(this, descriptorWriteReqMock); - } else if (args[0] == 'connectStateChange') { - args[len - 1].call(this, BLEConnectChangedStateMock); - } - } - }, - off: function (...args) { - console.warn("GattServer.off interface mocked in the Previewer." + - "How this interface works on the Previewer may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - if (args[0] == 'characteristicRead') { - args[len - 1].call(this, characteristicReadReqMock); - } else if (args[0] == 'characteristicWrite') { - args[len - 1].call(this, characteristicWriteReqMock); - } else if (args[0] == 'descriptorRead') { - args[len - 1].call(this, descriptorReadReqMock); - } else if (args[0] == 'descriptorWrite') { - args[len - 1].call(this, descriptorWriteReqMock); - } else if (args[0] == 'connectStateChange') { - args[len - 1].call(this, BLEConnectChangedStateMock); - } - } - }, - } - const GattClientDeviceMock = { - connect: function () { - console.warn("GattClientDevice.connect interface mocked in the Previewer." + - "How this interface works on the Previewer may be different from that on a real device.") - return paramMock.paramBooleanMock - }, - disconnect: function () { - console.warn("GattClientDevice.disconnect 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("GattClientDevice.close interface mocked in the Previewer." + - "How this interface works on the Previewer may be different from that on a real device.") - return paramMock.paramBooleanMock - }, - getDeviceName: function (...args) { - console.warn("GattClientDevice.getDeviceName 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, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - getServices: function (...args) { - console.warn("GattClientDevice.getServices 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, gattServicesMock); - } else { - return new Promise((resolve, reject) => { - resolve(gattServicesMock); - }) - } - }, - readCharacteristicValue: function (...args) { - console.warn("GattClientDevice.readCharacteristicValue 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, BLECharacteristicMock); - } else { - return new Promise((resolve, reject) => { - resolve(BLECharacteristicMock); - }) - } - }, - readDescriptorValue: function (...args) { - console.warn("GattClientDevice.readDescriptorValue 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, BLEDescriptorMock); - } else { - return new Promise((resolve, reject) => { - resolve(BLEDescriptorMock); - }) - } - }, - writeCharacteristicValue: function (...args) { - console.warn("GattClientDevice.writeCharacteristicValue interface mocked in the Previewer." + - "How this interface works on the Previewer may be different from that on a real device.") - return paramMock.paramBooleanMock - }, - writeDescriptorValue: function (...args) { - console.warn("GattClientDevice.writeDescriptorValue interface mocked in the Previewer." + - "How this interface works on the Previewer may be different from that on a real device.") - return paramMock.paramBooleanMock - }, - getRssiValue: function (...args) { - console.warn("GattClientDevice.getRssiValue 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, reject) => { - resolve(paramMock.paramNumberMock); - }) - } - }, - setBLEMtuSize: function (...args) { - console.warn("GattClientDevice.setBLEMtuSize interface mocked in the Previewer." + - "How this interface works on the Previewer may be different from that on a real device.") - return paramMock.paramBooleanMock - }, - setNotifyCharacteristicChanged: function (...args) { - console.warn("GattClientDevice.setNotifyCharacteristicChanged interface mocked in the Previewer." + - "How this interface works on the Previewer may be different from that on a real device.") - return paramMock.paramBooleanMock - }, - on: function (...args) { - console.warn("GattClientDevice.on interface mocked in the Previewer." + - "How this interface works on the Previewer may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - if (args[0] == 'BLECharacteristicChange') { - args[len - 1].call(this, BLECharacteristicMock); - } else if (args[0] == 'BLEConnectionStateChange') { - args[len - 1].call(this, BLEConnectChangedStateMock); - } - } - }, - off: function (...args) { - console.warn("GattClientDevice.off interface mocked in the Previewer." + - "How this interface works on the Previewer may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - if (args[0] == 'BLECharacteristicChange') { - args[len - 1].call(this, BLECharacteristicMock); - } else if (args[0] == 'BLEConnectionStateChange') { - args[len - 1].call(this, BLEConnectChangedStateMock); - } - } - }, - } - global.ohosplugin.bluetooth = { - getState: function () { - console.warn("bluetooth.getState interface mocked in the Previewer." + - "How this interface works on the Previewer may be different from that on a real device.") - return paramMock.paramNumberMock - }, - getBtConnectionState: function () { - console.warn("bluetooth.getBtConnectionState interface mocked in the Previewer." + - "How this interface works on the Previewer may be different from that on a real device.") - return paramMock.paramNumberMock - }, - pairDevice: function (...args) { - console.warn("bluetooth.pairDevice interface mocked in the Previewer." + - "How this interface works on the Previewer may be different from that on a real device.") - return paramMock.paramBooleanMock - }, + } + const BLEDescriptorMock = { + serviceUuid: "[PC preview] unknown serviceUuid", + characteristicUuid: "[PC preview] unknown characteristicUuid", + descriptorUuid: "[PC preview] unknown descriptorUuid", + descriptorValue: "[PC preview] unknown descriptorValue" + } + const gattServicesMock = [ + gattServiceMock + ] + const scanResultMock = { + deviceId: "[PC preview] unknown deviceId", + rssi: "[PC preview] unknown rssi", + data: "[PC preview] unknown data" + } + const characteristicReadReqMock = { + deviceId: "[PC preview] unknown deviceId", + transId: "[PC preview] unknown transId", + offset: "[PC preview] unknown offset", + characteristicUuid: "[PC preview] unknown characteristicUuid", + serviceUuid: "[PC preview] unknown serviceUuid" + } + const characteristicWriteReqMock = { + deviceId: "[PC preview] unknown deviceId", + transId: "[PC preview] unknown transId", + offset: "[PC preview] unknown offset", + isPrep: "[PC preview] unknown isPrep", + needRsp: "[PC preview] unknown needRsp", + value: "[PC preview] unknown value", + characteristicUuid: "[PC preview] unknown characteristicUuid", + serviceUuid: "[PC preview] unknown serviceUuid" + } + const descriptorReadReqMock = { + deviceId: "[PC preview] unknown v", + transId: "[PC preview] unknown transId", + offset: "[PC preview] unknown offset", + descriptorUuid: "[PC preview] unknown descriptorUuid", + characteristicUuid: "[PC preview] unknown characteristicUuid", + serviceUuid: "[PC preview] unknown serviceUuid" + } + const descriptorWriteReqMock = { + deviceId: "[PC preview] unknown deviceId", + transId: "[PC preview] unknown transId", + offset: "[PC preview] unknown offset", + isPrep: "[PC preview] unknown isPrep", + needRsp: "[PC preview] unknown needRsp", + value: "[PC preview] unknown value", + descriptorUuid: "[PC preview] unknown descriptorUuid", + characteristicUuid: "[PC preview] unknown characteristicUuid", + serviceUuid: "[PC preview] unknown serviceUuid" + } + const BLEConnectChangedStateMock = { + deviceId: "[PC preview] unknown deviceId", + state: "[PC preview] unknown state" + } + const GattServerMock = { + startAdvertising: function (...args) { + console.warn("GattServer.startAdvertising interface mocked in the Previewer." + + "How this interface works on the Previewer may be different from that on a real device.") }, - global.ohosplugin.bluetooth.BLE = { - createGattServer: function () { - console.warn("bluetooth.BLE.createGattServer interface mocked in the Previewer." + - "How this interface works on the Previewer may be different from that on a real device.") - return GattServerMock - }, - createGattClientDevice: function (...args) { - console.warn("bluetooth.BLE.createGattClientDevice interface mocked in the Previewer." + - "How this interface works on the Previewer may be different from that on a real device.") - return GattClientDeviceMock - }, - getConnectedBLEDevices: function () { - console.warn("bluetooth.BLE.getConnectedBLEDevices interface mocked in the Previewer." + - "How this interface works on the Previewer may be different from that on a real device.") - return connectedBLEDevicesMock - }, - startBLEScan: function (...args) { - console.warn("bluetooth.BLE.startBLEScan interface mocked in the Previewer." + - "How this interface works on the Previewer may be different from that on a real device.") - }, - stopBLEScan: function () { - console.warn("bluetooth.BLE.stopBLEScan interface mocked in the Previewer." + - "How this interface works on the Previewer may be different from that on a real device.") - }, - on: function (...args) { - console.warn("bluetooth.BLE.on interface mocked in the Previewer." + - "How this interface works on the Previewer may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - if (args[0] == 'BLEDeviceFind') { - args[len - 1].call(this, [scanResultMock]); - } - } - }, - off: function (...args) { - console.warn("bluetooth.BLE.off interface mocked in the Previewer." + - "How this interface works on the Previewer may be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - if (args[0] == 'BLEDeviceFind') { - args[len - 1].call(this, [scanResultMock]); - } - } - }, + stopAdvertising: function () { + console.warn("GattServer.stopAdvertising interface mocked in the Previewer." + + "How this interface works on the Previewer may be different from that on a real device.") + }, + addService: function (...args) { + console.warn("GattServer.addService interface mocked in the Previewer." + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock + }, + removeService: function (...args) { + console.warn("GattServer.removeService 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("GattServer.close interface mocked in the Previewer." + + "How this interface works on the Previewer may be different from that on a real device.") + }, + notifyCharacteristicChanged: function (...args) { + console.warn("GattServer.notifyCharacteristicChanged interface mocked in the Previewer." + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock + }, + sendResponse: function (...args) { + console.warn("GattServer.sendResponse interface mocked in the Previewer." + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock + }, + on: function (...args) { + console.warn("GattServer.on interface mocked in the Previewer." + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + if (args[0] == 'characteristicRead') { + args[len - 1].call(this, characteristicReadReqMock); + } else if (args[0] == 'characteristicWrite') { + args[len - 1].call(this, characteristicWriteReqMock); + } else if (args[0] == 'descriptorRead') { + args[len - 1].call(this, descriptorReadReqMock); + } else if (args[0] == 'descriptorWrite') { + args[len - 1].call(this, descriptorWriteReqMock); + } else if (args[0] == 'connectStateChange') { + args[len - 1].call(this, BLEConnectChangedStateMock); } + } + }, + off: function (...args) { + console.warn("GattServer.off interface mocked in the Previewer." + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + if (args[0] == 'characteristicRead') { + args[len - 1].call(this, characteristicReadReqMock); + } else if (args[0] == 'characteristicWrite') { + args[len - 1].call(this, characteristicWriteReqMock); + } else if (args[0] == 'descriptorRead') { + args[len - 1].call(this, descriptorReadReqMock); + } else if (args[0] == 'descriptorWrite') { + args[len - 1].call(this, descriptorWriteReqMock); + } else if (args[0] == 'connectStateChange') { + args[len - 1].call(this, BLEConnectChangedStateMock); + } + } + }, + } + const GattClientDeviceMock = { + connect: function () { + console.warn("GattClientDevice.connect interface mocked in the Previewer." + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock + }, + disconnect: function () { + console.warn("GattClientDevice.disconnect 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("GattClientDevice.close interface mocked in the Previewer." + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock + }, + getDeviceName: function (...args) { + console.warn("GattClientDevice.getDeviceName 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, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getServices: function (...args) { + console.warn("GattClientDevice.getServices 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, gattServicesMock); + } else { + return new Promise((resolve, reject) => { + resolve(gattServicesMock); + }) + } + }, + readCharacteristicValue: function (...args) { + console.warn("GattClientDevice.readCharacteristicValue 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, BLECharacteristicMock); + } else { + return new Promise((resolve, reject) => { + resolve(BLECharacteristicMock); + }) + } + }, + readDescriptorValue: function (...args) { + console.warn("GattClientDevice.readDescriptorValue 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, BLEDescriptorMock); + } else { + return new Promise((resolve, reject) => { + resolve(BLEDescriptorMock); + }) + } + }, + writeCharacteristicValue: function (...args) { + console.warn("GattClientDevice.writeCharacteristicValue interface mocked in the Previewer." + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock + }, + writeDescriptorValue: function (...args) { + console.warn("GattClientDevice.writeDescriptorValue interface mocked in the Previewer." + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock + }, + getRssiValue: function (...args) { + console.warn("GattClientDevice.getRssiValue 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, reject) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + setBLEMtuSize: function (...args) { + console.warn("GattClientDevice.setBLEMtuSize interface mocked in the Previewer." + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock + }, + setNotifyCharacteristicChanged: function (...args) { + console.warn("GattClientDevice.setNotifyCharacteristicChanged interface mocked in the Previewer." + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock + }, + on: function (...args) { + console.warn("GattClientDevice.on interface mocked in the Previewer." + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + if (args[0] == 'BLECharacteristicChange') { + args[len - 1].call(this, BLECharacteristicMock); + } else if (args[0] == 'BLEConnectionStateChange') { + args[len - 1].call(this, BLEConnectChangedStateMock); + } + } + }, + off: function (...args) { + console.warn("GattClientDevice.off interface mocked in the Previewer." + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + if (args[0] == 'BLECharacteristicChange') { + args[len - 1].call(this, BLECharacteristicMock); + } else if (args[0] == 'BLEConnectionStateChange') { + args[len - 1].call(this, BLEConnectChangedStateMock); + } + } + }, + } + global.ohosplugin.bluetooth = { + getState: function () { + console.warn("bluetooth.getState interface mocked in the Previewer." + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock + }, + getBtConnectionState: function () { + console.warn("bluetooth.getBtConnectionState interface mocked in the Previewer." + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramNumberMock + }, + pairDevice: function (...args) { + console.warn("bluetooth.pairDevice interface mocked in the Previewer." + + "How this interface works on the Previewer may be different from that on a real device.") + return paramMock.paramBooleanMock + }, + } + global.ohosplugin.bluetooth.BLE = { + createGattServer: function () { + console.warn("bluetooth.BLE.createGattServer interface mocked in the Previewer." + + "How this interface works on the Previewer may be different from that on a real device.") + return GattServerMock + }, + createGattClientDevice: function (...args) { + console.warn("bluetooth.BLE.createGattClientDevice interface mocked in the Previewer." + + "How this interface works on the Previewer may be different from that on a real device.") + return GattClientDeviceMock + }, + getConnectedBLEDevices: function () { + console.warn("bluetooth.BLE.getConnectedBLEDevices interface mocked in the Previewer." + + "How this interface works on the Previewer may be different from that on a real device.") + return connectedBLEDevicesMock + }, + startBLEScan: function (...args) { + console.warn("bluetooth.BLE.startBLEScan interface mocked in the Previewer." + + "How this interface works on the Previewer may be different from that on a real device.") + }, + stopBLEScan: function () { + console.warn("bluetooth.BLE.stopBLEScan interface mocked in the Previewer." + + "How this interface works on the Previewer may be different from that on a real device.") + }, + on: function (...args) { + console.warn("bluetooth.BLE.on interface mocked in the Previewer." + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + if (args[0] == 'BLEDeviceFind') { + args[len - 1].call(this, [scanResultMock]); + } + } + }, + off: function (...args) { + console.warn("bluetooth.BLE.off interface mocked in the Previewer." + + "How this interface works on the Previewer may be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + if (args[0] == 'BLEDeviceFind') { + args[len - 1].call(this, [scanResultMock]); + } + } + }, + } } \ No newline at end of file diff --git a/runtime/main/extend/systemplugin/telephony.js b/runtime/main/extend/systemplugin/telephony.js index aa4d8b23..fe1ed723 100644 --- a/runtime/main/extend/systemplugin/telephony.js +++ b/runtime/main/extend/systemplugin/telephony.js @@ -2,1741 +2,1740 @@ import { paramMock } from "./utils" const CallState = "[PC Preview] unknow CallState"; export function mockCall() { - const CallWaitingStatus = "[PC Preview] unknow CallWaitingStatus"; - const RestrictionStatus = "[PC Preview] unknow RestrictionStatus"; - const CallAttributeOptions = { - accountNumber: "[PC Preview] unknow accountNumber", - speakerphoneOn: "[PC Preview] unknow speakerphoneOn", - accountId: "[PC Preview] unknow accountId", - videoState: "[PC Preview] unknow videoState", - startTime: "[PC Preview] unknow startTime", - isEcc: "[PC Preview] unknow isEcc", - callType: "[PC Preview] unknow callType", - callId: "[PC Preview] unknow callId", - callState: "[PC Preview] unknow callState", - conferenceState: "[PC Preview] unknow conferenceState" - } - const CallTransferResult = { - status: "[PC Preview] unknow status", - number: "[PC Preview] unknow number", - } - global.systemplugin.telephony = global.systemplugin.telephony || {} - global.systemplugin.telephony.call = { - dial: function (...args) { - console.warn("telephony.call.dial 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, reject) => { - resolve(paramMock.paramBooleanMock); - }) - } - }, - makeCall: function (...args) { - console.warn("telephony.call.makeCall 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, reject) => { - resolve(); - }) - } - }, - hasCall: function (...args) { - console.warn("telephony.call.hasCall 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, reject) => { - resolve(paramMock.paramBooleanMock); - }) - } - }, - getCallState: function (...args) { - console.warn("telephony.call.getCallState 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, CallState); - } else { - return new Promise((resolve, reject) => { - resolve(CallState); - }) - } - }, - displayCallScreen: function (...args) { - console.warn("telephony.call.displayCallScreen 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, reject) => { - resolve(); - }) - } - }, - muteRinger: function (...args) { - console.warn("telephony.call.muteRinger 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, reject) => { - resolve(); - }) - } - }, - hasVoiceCapability: function () { - console.warn("telephony.call.hasVoiceCapability interface mocked in the Previewer. How this interface works on the Previewer may" + - " be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isVideoCallingEnabled: function (...args) { - console.warn("telephony.call.isVideoCallingEnabled 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, reject) => { - resolve(paramMock.paramBooleanMock); - }) - } - }, - inputDialerSpecialCode: function (...args) { - console.warn("telephony.call.inputDialerSpecialCode 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, reject) => { - resolve(); - }) - } - }, - isHacEnabled: function (...args) { - console.warn("telephony.call.isHacEnabled 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, reject) => { - resolve(paramMock.paramBooleanMock); - }) - } - }, - isEmergencyPhoneNumber: function (...args) { - console.warn("telephony.call.isEmergencyPhoneNumber 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, reject) => { - resolve(paramMock.paramBooleanMock); - }) - } - }, - formatPhoneNumber: function (...args) { - console.warn("telephony.call.formatPhoneNumber 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, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - formatPhoneNumberToE164: function (...args) { - console.warn("telephony.call.formatPhoneNumberToE164 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, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - comparePhoneNumbers: function (...args) { - console.warn("telephony.call.comparePhoneNumbers 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, reject) => { - resolve(paramMock.paramBooleanMock); - }) - } - }, - getCallerIndex: function (...args) { - console.warn("telephony.call.getCallerIndex 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, reject) => { - resolve(paramMock.paramNumberMock); - }) - } - }, - getCountryCodeFromDbNumber: function (...args) { - console.warn("telephony.call.getCountryCodeFromDbNumber 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, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - getIntlPrefixAndCountryCodeLen: function (...args) { - console.warn("telephony.call.getIntlPrefixAndCountryCodeLen 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, reject) => { - resolve(paramMock.paramNumberMock); - }) - } - }, - answer: function (...args) { - console.warn("telephony.call.answer 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, reject) => { - resolve(); - }) - } - }, - hangup: function (...args) { - console.warn("telephony.call.hangup 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, reject) => { - resolve(); - }) - } - }, - reject: function (...args) { - console.warn("telephony.call.reject 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, reject) => { - resolve(); - }) - } - }, - holdCall: function (...args) { - console.warn("telephony.call.holdCall 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, reject) => { - resolve(); - }) - } - }, - unHoldCall: function (...args) { - console.warn("telephony.call.unHoldCall 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, reject) => { - resolve(); - }) - } - }, - switchCall: function (...args) { - console.warn("telephony.call.switchCall 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, reject) => { - resolve(); - }) - } - }, - combineConference: function (...args) { - console.warn("telephony.call.combineConference 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, reject) => { - resolve(); - }) - } - }, - getMainCallId: function (...args) { - console.warn("telephony.call.getMainCallId 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, reject) => { - resolve(paramMock.paramNumberMock); - }) - } - }, - getSubCallIdList: function (...args) { - console.warn("telephony.call.getSubCallIdList 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.paramArrayMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }) - } - }, - getCallIdListForConference: function (...args) { - console.warn("telephony.call.getCallIdListForConference 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.paramArrayMock); - } else { - return new Promise((resolve, reject) => { - resolve(paramMock.paramArrayMock); - }) - } - }, - getCallWaitingStatus: function (...args) { - console.warn("telephony.call.getCallWaitingStatus 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, CallWaitingStatus); - } else { - return new Promise((resolve, reject) => { - resolve(CallWaitingStatus); - }) - } - }, - setCallWaiting: function (...args) { - console.warn("telephony.call.setCallWaiting 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, reject) => { - resolve(); - }) - } - }, - startDTMF: function (...args) { - console.warn("telephony.call.startDTMF 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, reject) => { - resolve(); - }) - } - }, - stopDTMF: function (...args) { - console.warn("telephony.call.stopDTMF 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, reject) => { - resolve(); - }) - } - }, - isInEmergencyCall: function (...args) { - console.warn("telephony.call.isInEmergencyCall 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, reject) => { - resolve(paramMock.paramBooleanMock); - }) - } - }, - on: function (...args) { - console.warn("telephony.call.on interface mocked in the Previewer. How this interface works on the Previewer may " + - "be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - if (args[0] == 'callDetailsChange') { - args[len - 1].call(this, CallAttributeOptions); - } else if (args[0] == 'callEventChange') { - args[len - 1].call(this, paramMock.paramObjectMock); - } - } - }, - off: function (...args) { - console.warn("telephony.call.off interface mocked in the Previewer. How this interface works on the Previewer may" + - " be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - if (args[0] == 'callDetailsChange') { - args[len - 1].call(this, CallAttributeOptions); - } else if (args[0] == 'callEventChange') { - args[len - 1].call(this, paramMock.paramObjectMock); - } - } - }, - isNewCallAllowed: function (...args) { - console.warn("telephony.call.isNewCallAllowed 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, reject) => { - resolve(paramMock.paramBooleanMock); - }) - } - }, - separateConference: function (...args) { - console.warn("telephony.call.separateConference 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, reject) => { - resolve(); - }) - } - }, - getCallRestrictionStatus: function (...args) { - console.warn("telephony.call.getCallRestrictionStatus 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, RestrictionStatus); - } else { - return new Promise((resolve, reject) => { - resolve(RestrictionStatus); - }) - } - }, - setCallRestriction: function (...args) { - console.warn("telephony.call.setCallRestriction 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, reject) => { - resolve(); - }) - } - }, - setCallTransfer: function (...args) { - console.warn("telephony.call.setCallTransfer 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, reject) => { - resolve(); - }) - } - }, - getCallTransferInfo: function (...args) { - console.warn("telephony.call.getCallTransferInfo 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, CallTransferResult); - } else { - return new Promise((resolve, reject) => { - resolve(CallTransferResult); - }) - } - }, - setCallTransferInfo: function (...args) { - console.warn("telephony.call.setCallTransferInfo 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, reject) => { - resolve(); - }) - } - }, - isRinging: function (...args) { - console.warn("telephony.call.isRinging 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, reject) => { - resolve(paramMock.paramBooleanMock); - }) - } - }, - setMuted: function (...args) { - console.warn("telephony.call.setMuted 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, reject) => { - resolve(); - }) - } - }, - setAudioDevice: function (...args) { - console.warn("telephony.call.setAudioDevice 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, reject) => { - resolve(); - }) - } + const CallWaitingStatus = "[PC Preview] unknow CallWaitingStatus"; + const RestrictionStatus = "[PC Preview] unknow RestrictionStatus"; + const CallAttributeOptions = { + accountNumber: "[PC Preview] unknow accountNumber", + speakerphoneOn: "[PC Preview] unknow speakerphoneOn", + accountId: "[PC Preview] unknow accountId", + videoState: "[PC Preview] unknow videoState", + startTime: "[PC Preview] unknow startTime", + isEcc: "[PC Preview] unknow isEcc", + callType: "[PC Preview] unknow callType", + callId: "[PC Preview] unknow callId", + callState: "[PC Preview] unknow callState", + conferenceState: "[PC Preview] unknow conferenceState" + } + const CallTransferResult = { + status: "[PC Preview] unknow status", + number: "[PC Preview] unknow number", + } + global.systemplugin.telephony = global.systemplugin.telephony || {} + global.systemplugin.telephony.call = { + dial: function (...args) { + console.warn("telephony.call.dial 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, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, + makeCall: function (...args) { + console.warn("telephony.call.makeCall 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, reject) => { + resolve(); + }) + } + }, + hasCall: function (...args) { + console.warn("telephony.call.hasCall 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, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, + getCallState: function (...args) { + console.warn("telephony.call.getCallState 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, CallState); + } else { + return new Promise((resolve, reject) => { + resolve(CallState); + }) + } + }, + displayCallScreen: function (...args) { + console.warn("telephony.call.displayCallScreen 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, reject) => { + resolve(); + }) + } + }, + muteRinger: function (...args) { + console.warn("telephony.call.muteRinger 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, reject) => { + resolve(); + }) + } + }, + hasVoiceCapability: function () { + console.warn("telephony.call.hasVoiceCapability interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isVideoCallingEnabled: function (...args) { + console.warn("telephony.call.isVideoCallingEnabled 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, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, + inputDialerSpecialCode: function (...args) { + console.warn("telephony.call.inputDialerSpecialCode 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, reject) => { + resolve(); + }) + } + }, + isHacEnabled: function (...args) { + console.warn("telephony.call.isHacEnabled 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, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, + isEmergencyPhoneNumber: function (...args) { + console.warn("telephony.call.isEmergencyPhoneNumber 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, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, + formatPhoneNumber: function (...args) { + console.warn("telephony.call.formatPhoneNumber 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, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + formatPhoneNumberToE164: function (...args) { + console.warn("telephony.call.formatPhoneNumberToE164 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, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + comparePhoneNumbers: function (...args) { + console.warn("telephony.call.comparePhoneNumbers 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, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, + getCallerIndex: function (...args) { + console.warn("telephony.call.getCallerIndex 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, reject) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + getCountryCodeFromDbNumber: function (...args) { + console.warn("telephony.call.getCountryCodeFromDbNumber 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, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getIntlPrefixAndCountryCodeLen: function (...args) { + console.warn("telephony.call.getIntlPrefixAndCountryCodeLen 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, reject) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + answer: function (...args) { + console.warn("telephony.call.answer 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, reject) => { + resolve(); + }) + } + }, + hangup: function (...args) { + console.warn("telephony.call.hangup 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, reject) => { + resolve(); + }) + } + }, + reject: function (...args) { + console.warn("telephony.call.reject 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, reject) => { + resolve(); + }) + } + }, + holdCall: function (...args) { + console.warn("telephony.call.holdCall 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, reject) => { + resolve(); + }) + } + }, + unHoldCall: function (...args) { + console.warn("telephony.call.unHoldCall 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, reject) => { + resolve(); + }) + } + }, + switchCall: function (...args) { + console.warn("telephony.call.switchCall 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, reject) => { + resolve(); + }) + } + }, + combineConference: function (...args) { + console.warn("telephony.call.combineConference 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, reject) => { + resolve(); + }) + } + }, + getMainCallId: function (...args) { + console.warn("telephony.call.getMainCallId 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, reject) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + getSubCallIdList: function (...args) { + console.warn("telephony.call.getSubCallIdList 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.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }) + } + }, + getCallIdListForConference: function (...args) { + console.warn("telephony.call.getCallIdListForConference 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.paramArrayMock); + } else { + return new Promise((resolve, reject) => { + resolve(paramMock.paramArrayMock); + }) + } + }, + getCallWaitingStatus: function (...args) { + console.warn("telephony.call.getCallWaitingStatus 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, CallWaitingStatus); + } else { + return new Promise((resolve, reject) => { + resolve(CallWaitingStatus); + }) + } + }, + setCallWaiting: function (...args) { + console.warn("telephony.call.setCallWaiting 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, reject) => { + resolve(); + }) + } + }, + startDTMF: function (...args) { + console.warn("telephony.call.startDTMF 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, reject) => { + resolve(); + }) + } + }, + stopDTMF: function (...args) { + console.warn("telephony.call.stopDTMF 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, reject) => { + resolve(); + }) + } + }, + isInEmergencyCall: function (...args) { + console.warn("telephony.call.isInEmergencyCall 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, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, + on: function (...args) { + console.warn("telephony.call.on interface mocked in the Previewer. How this interface works on the Previewer may " + + "be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + if (args[0] == 'callDetailsChange') { + args[len - 1].call(this, CallAttributeOptions); + } else if (args[0] == 'callEventChange') { + args[len - 1].call(this, paramMock.paramObjectMock); } + } + }, + off: function (...args) { + console.warn("telephony.call.off interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + if (args[0] == 'callDetailsChange') { + args[len - 1].call(this, CallAttributeOptions); + } else if (args[0] == 'callEventChange') { + args[len - 1].call(this, paramMock.paramObjectMock); + } + } + }, + isNewCallAllowed: function (...args) { + console.warn("telephony.call.isNewCallAllowed 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, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, + separateConference: function (...args) { + console.warn("telephony.call.separateConference 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, reject) => { + resolve(); + }) + } + }, + getCallRestrictionStatus: function (...args) { + console.warn("telephony.call.getCallRestrictionStatus 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, RestrictionStatus); + } else { + return new Promise((resolve, reject) => { + resolve(RestrictionStatus); + }) + } + }, + setCallRestriction: function (...args) { + console.warn("telephony.call.setCallRestriction 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, reject) => { + resolve(); + }) + } + }, + setCallTransfer: function (...args) { + console.warn("telephony.call.setCallTransfer 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, reject) => { + resolve(); + }) + } + }, + getCallTransferInfo: function (...args) { + console.warn("telephony.call.getCallTransferInfo 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, CallTransferResult); + } else { + return new Promise((resolve, reject) => { + resolve(CallTransferResult); + }) + } + }, + setCallTransferInfo: function (...args) { + console.warn("telephony.call.setCallTransferInfo 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, reject) => { + resolve(); + }) + } + }, + isRinging: function (...args) { + console.warn("telephony.call.isRinging 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, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, + setMuted: function (...args) { + console.warn("telephony.call.setMuted 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, reject) => { + resolve(); + }) + } + }, + setAudioDevice: function (...args) { + console.warn("telephony.call.setAudioDevice 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, reject) => { + resolve(); + }) + } } + } } export function mockData() { - global.systemplugin.telephony.data = { - getDefaultCellularDataSlotId: function (...args) { - console.warn("telephony.data.getDefaultCellularDataSlotId 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, reject) => { - resolve(paramMock.paramNumberMock); - }) - } - }, - setDefaultCellularDataSlotId: function (...args) { - console.warn("telephony.data.setDefaultCellularDataSlotId 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, reject) => { - resolve(); - }) - } - }, - getCellularDataFlowType: function (...args) { - console.warn("telephony.data.getCellularDataFlowType 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, reject) => { - resolve(paramMock.paramNumberMock); - }) - } - }, - getCellularDataState: function (...args) { - console.warn("telephony.data.getCellularDataState 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, reject) => { - resolve(paramMock.paramNumberMock); - }) - } - }, - isCellularDataEnabled: function (...args) { - console.warn("telephony.data.isCellularDataEnabled 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, reject) => { - resolve(paramMock.paramBooleanMock); - }) - } - }, - enableCellularData: function (...args) { - console.warn("telephony.data.enableCellularData 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, reject) => { - resolve(); - }) - } - }, - disableCellularData: function (...args) { - console.warn("telephony.data.disableCellularData 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, reject) => { - resolve(); - }) - } - }, - isCellularDataRoamingEnabled: function (...args) { - console.warn("telephony.data.isCellularDataRoamingEnabled 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, reject) => { - resolve(paramMock.paramBooleanMock); - }) - } - }, - enableCellularDataRoaming: function (...args) { - console.warn("telephony.data.enableCellularDataRoaming 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, reject) => { - resolve(); - }) - } - }, - disableCellularDataRoaming: function (...args) { - console.warn("telephony.data.disableCellularDataRoaming 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, reject) => { - resolve(); - }) - } - } + global.systemplugin.telephony.data = { + getDefaultCellularDataSlotId: function (...args) { + console.warn("telephony.data.getDefaultCellularDataSlotId 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, reject) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + setDefaultCellularDataSlotId: function (...args) { + console.warn("telephony.data.setDefaultCellularDataSlotId 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, reject) => { + resolve(); + }) + } + }, + getCellularDataFlowType: function (...args) { + console.warn("telephony.data.getCellularDataFlowType 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, reject) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + getCellularDataState: function (...args) { + console.warn("telephony.data.getCellularDataState 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, reject) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + isCellularDataEnabled: function (...args) { + console.warn("telephony.data.isCellularDataEnabled 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, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, + enableCellularData: function (...args) { + console.warn("telephony.data.enableCellularData 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, reject) => { + resolve(); + }) + } + }, + disableCellularData: function (...args) { + console.warn("telephony.data.disableCellularData 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, reject) => { + resolve(); + }) + } + }, + isCellularDataRoamingEnabled: function (...args) { + console.warn("telephony.data.isCellularDataRoamingEnabled 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, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, + enableCellularDataRoaming: function (...args) { + console.warn("telephony.data.enableCellularDataRoaming 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, reject) => { + resolve(); + }) + } + }, + disableCellularDataRoaming: function (...args) { + console.warn("telephony.data.disableCellularDataRoaming 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, reject) => { + resolve(); + }) + } } + } } const NetworkState = { - longOperatorName: "[PC Preview] unknow longOperatorName", - shortOperatorName: "[PC Preview] unknow shortOperatorName", - plmnNumeric: "[PC Preview] unknow plmnNumeric", - isRoaming: "[PC Preview] unknow isRoaming", - regState: "[PC Preview] unknow regState", - nsaState: "[PC Preview] unknow nsaState", - isCaActive: "[PC Preview] unknow isCaActive", - isEmergency: "[PC Preview] unknow isEmergency", + longOperatorName: "[PC Preview] unknow longOperatorName", + shortOperatorName: "[PC Preview] unknow shortOperatorName", + plmnNumeric: "[PC Preview] unknow plmnNumeric", + isRoaming: "[PC Preview] unknow isRoaming", + regState: "[PC Preview] unknow regState", + nsaState: "[PC Preview] unknow nsaState", + isCaActive: "[PC Preview] unknow isCaActive", + isEmergency: "[PC Preview] unknow isEmergency", } const SignalInformation = { - signalType: "[PC Preview] unknow signalType", - signalLevel: "[PC Preview] unknow signalLevel" + signalType: "[PC Preview] unknow signalType", + signalLevel: "[PC Preview] unknow signalLevel" } const DataFlowType = "[PC Preview] unknow DataFlowType" const DataConnectState = "[PC Preview] unknow DataConnectState" const CellInformation = { - networkType: "[PC Preview] unknow networkType", - isCamped: "[PC Preview] unknow isCamped", - timeStamp: "[PC Preview] unknow timeStamp", - signalInformation: "[PC Preview] unknow signalInformation", - data: "[PC Preview] unknow unkown data" + networkType: "[PC Preview] unknow networkType", + isCamped: "[PC Preview] unknow isCamped", + timeStamp: "[PC Preview] unknow timeStamp", + signalInformation: "[PC Preview] unknow signalInformation", + data: "[PC Preview] unknow unkown data" } export function mockRadio() { - const NetworkSearchResult = { - isNetworkSearchSuccess: "[PC Preview] unknow isNetworkSearchSuccess", - networkSearchResult: [{ - operatorName: "[PC Preview] unknow operatorName", - operatorNumeric: "[PC Preview] unknow operatorNumeric", - state: "[PC Preview] unknow state", - radioTech: "[PC Preview] unknow radioTech" - }] - } - const PreferredNetworkMode = "[PC Preview] unknow PreferredNetworkMode" - const NrOptionMode = "[PC Preview] unknow NrOptionMode" - const NetworkSelectionMode = "[PC Preview] unknow unkown NetworkSelectionMode" - global.systemplugin.telephony.radio = { - getRadioTech: function (...args) { - console.warn("telephony.radio.getRadioTech 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, { - psRadioTech: "[PC Preview] unknow psRadioTech", - csRadioTech: "[PC Preview] unknow csRadioTech" - }); - } else { - return new Promise((resolve, reject) => { - resolve({ - psRadioTech: "[PC Preview] unknow psRadioTech", - csRadioTech: "[PC Preview] unknow csRadioTech" - }); - }) - } - }, - getNetworkState: function (...args) { - console.warn("telephony.radio.getNetworkState 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, NetworkState); - } else { - return new Promise((resolve, reject) => { - resolve(NetworkState); - }) - } - }, - sendUpdateCellLocationRequest: function (...args) { - console.warn("telephony.radio.sendUpdateCellLocationRequest 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, reject) => { - resolve(); - }) - } - }, - getCellInformation: function (...args) { - console.warn("telephony.radio.getCellInformation 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, [CellInformation]); - } else { - return new Promise((resolve, reject) => { - resolve([CellInformation]); - }) - } - }, - getNetworkSelectionMode: function (...args) { - console.warn("telephony.radio.getNetworkSelectionMode 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, NetworkSelectionMode); - } else { - return new Promise((resolve, reject) => { - resolve(NetworkSelectionMode); - }) - } - }, - setNetworkSelectionMode: function (...args) { - console.warn("telephony.radio.setNetworkSelectionMode 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, reject) => { - resolve(); - }) - } - }, - getNetworkSearchInformation: function (...args) { - console.warn("telephony.radio.getNetworkSearchInformation 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, NetworkSearchResult); - } else { - return new Promise((resolve, reject) => { - resolve(NetworkSearchResult); - }) - } - }, - getISOCountryCodeForNetwork: function (...args) { - console.warn("telephony.radio.getISOCountryCodeForNetwork 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, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - getNrOptionMode: function (...args) { - console.warn("telephony.radio.getNrOptionMode 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, NrOptionMode); - } else { - return new Promise((resolve, reject) => { - resolve(NrOptionMode); - }) - } - }, - getIMEI: function (...args) { - console.warn("telephony.radio.getIMEI 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, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - getMEID: function (...args) { - console.warn("telephony.radio.getMEID 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, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - getUniqueDeviceId: function (...args) { - console.warn("telephony.radio.getUniqueDeviceId 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, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - getPrimarySlotId: function (...args) { - console.warn("telephony.radio.getPrimarySlotId 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, reject) => { - resolve(paramMock.paramNumberMock); - }) - } - }, - getSignalInformation: function (...args) { - console.warn("telephony.radio.getSignalInformation 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, [SignalInformation]); - } else { - return new Promise((resolve, reject) => { - resolve([SignalInformation]); - }) - } - }, - isNrSupported: function () { - console.warn("telephony.radio.isNrSupported interface mocked in the Previewer. How this interface works on the Previewer may" + - " be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - isRadioOn: function (...args) { - console.warn("telephony.radio.isRadioOn 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, reject) => { - resolve(paramMock.paramBooleanMock); - }) - } - }, - turnOnRadio: function (...args) { - console.warn("telephony.radio.turnOnRadio 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, reject) => { - resolve(); - }) - } - }, - turnOffRadio: function (...args) { - console.warn("telephony.radio.turnOffRadio 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, reject) => { - resolve(); - }) - } - }, - getOperatorName: function (...args) { - console.warn("telephony.radio.getOperatorName 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, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - setPreferredNetwork: function (...args) { - console.warn("telephony.radio.setPreferredNetwork 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, reject) => { - resolve(); - }) - } - }, - getPreferredNetwork: function (...args) { - console.warn("telephony.radio.getPreferredNetwork 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, PreferredNetworkMode); - } else { - return new Promise((resolve, reject) => { - resolve(PreferredNetworkMode); - }) - } - }, - getIMEISV: function (...args) { - console.warn("telephony.radio.getIMEISV 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, reject) => { - resolve(paramMock.paramStringMock); - }) - } - } + const NetworkSearchResult = { + isNetworkSearchSuccess: "[PC Preview] unknow isNetworkSearchSuccess", + networkSearchResult: [{ + operatorName: "[PC Preview] unknow operatorName", + operatorNumeric: "[PC Preview] unknow operatorNumeric", + state: "[PC Preview] unknow state", + radioTech: "[PC Preview] unknow radioTech" + }] + } + const PreferredNetworkMode = "[PC Preview] unknow PreferredNetworkMode" + const NrOptionMode = "[PC Preview] unknow NrOptionMode" + const NetworkSelectionMode = "[PC Preview] unknow unkown NetworkSelectionMode" + global.systemplugin.telephony.radio = { + getRadioTech: function (...args) { + console.warn("telephony.radio.getRadioTech 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, { + psRadioTech: "[PC Preview] unknow psRadioTech", + csRadioTech: "[PC Preview] unknow csRadioTech" + }); + } else { + return new Promise((resolve, reject) => { + resolve({ + psRadioTech: "[PC Preview] unknow psRadioTech", + csRadioTech: "[PC Preview] unknow csRadioTech" + }); + }) + } + }, + getNetworkState: function (...args) { + console.warn("telephony.radio.getNetworkState 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, NetworkState); + } else { + return new Promise((resolve, reject) => { + resolve(NetworkState); + }) + } + }, + sendUpdateCellLocationRequest: function (...args) { + console.warn("telephony.radio.sendUpdateCellLocationRequest 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, reject) => { + resolve(); + }) + } + }, + getCellInformation: function (...args) { + console.warn("telephony.radio.getCellInformation 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, [CellInformation]); + } else { + return new Promise((resolve, reject) => { + resolve([CellInformation]); + }) + } + }, + getNetworkSelectionMode: function (...args) { + console.warn("telephony.radio.getNetworkSelectionMode 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, NetworkSelectionMode); + } else { + return new Promise((resolve, reject) => { + resolve(NetworkSelectionMode); + }) + } + }, + setNetworkSelectionMode: function (...args) { + console.warn("telephony.radio.setNetworkSelectionMode 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, reject) => { + resolve(); + }) + } + }, + getNetworkSearchInformation: function (...args) { + console.warn("telephony.radio.getNetworkSearchInformation 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, NetworkSearchResult); + } else { + return new Promise((resolve, reject) => { + resolve(NetworkSearchResult); + }) + } + }, + getISOCountryCodeForNetwork: function (...args) { + console.warn("telephony.radio.getISOCountryCodeForNetwork 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, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getNrOptionMode: function (...args) { + console.warn("telephony.radio.getNrOptionMode 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, NrOptionMode); + } else { + return new Promise((resolve, reject) => { + resolve(NrOptionMode); + }) + } + }, + getIMEI: function (...args) { + console.warn("telephony.radio.getIMEI 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, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getMEID: function (...args) { + console.warn("telephony.radio.getMEID 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, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getUniqueDeviceId: function (...args) { + console.warn("telephony.radio.getUniqueDeviceId 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, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getPrimarySlotId: function (...args) { + console.warn("telephony.radio.getPrimarySlotId 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, reject) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + getSignalInformation: function (...args) { + console.warn("telephony.radio.getSignalInformation 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, [SignalInformation]); + } else { + return new Promise((resolve, reject) => { + resolve([SignalInformation]); + }) + } + }, + isNrSupported: function () { + console.warn("telephony.radio.isNrSupported interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + isRadioOn: function (...args) { + console.warn("telephony.radio.isRadioOn 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, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, + turnOnRadio: function (...args) { + console.warn("telephony.radio.turnOnRadio 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, reject) => { + resolve(); + }) + } + }, + turnOffRadio: function (...args) { + console.warn("telephony.radio.turnOffRadio 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, reject) => { + resolve(); + }) + } + }, + getOperatorName: function (...args) { + console.warn("telephony.radio.getOperatorName 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, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + setPreferredNetwork: function (...args) { + console.warn("telephony.radio.setPreferredNetwork 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, reject) => { + resolve(); + }) + } + }, + getPreferredNetwork: function (...args) { + console.warn("telephony.radio.getPreferredNetwork 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, PreferredNetworkMode); + } else { + return new Promise((resolve, reject) => { + resolve(PreferredNetworkMode); + }) + } + }, + getIMEISV: function (...args) { + console.warn("telephony.radio.getIMEISV 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, reject) => { + resolve(paramMock.paramStringMock); + }) + } } + } } export function mockSim() { - const IccAccountInfo = { - simId: "[PC Preview] unknow simId", - slotIndex: "[PC Preview] unknow slotIndex", - isEsim: "[PC Preview] unknow isEsim", - isActive: "[PC Preview] unknow isActive", - iccId: "[PC Preview] unknow iccId", - showName: "[PC Preview] unknow showName", - showNumber: "[PC Preview] unknow showNumber" - } - const OperatorConfigMock = { - field: "[PC Preview] unknow field", - value: "[PC Preview] unknow value" - } - const LockStatusResponse = { - result: "[PC Preview] unknow result", - remain: "[PC Preview] unknow remain" - } - const DiallingNumbersInfo = { - efid: "[PC Preview] unknow efid", - recordNumber: "[PC Preview] unknow recordNumber", - alphaTag: "[PC Preview] unknow alphaTag", - number: "[PC Preview] unknow number", - emails: "[PC Preview] unknow emails" - } - const CardType = "[PC Preview] unknow CardType"; - const SimState = "[PC Preview] unknow SimState"; - global.systemplugin.telephony.sim = { - isSimActive: function (...args) { - console.warn("telephony.sim.isSimActive 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, reject) => { - resolve(paramMock.paramBooleanMock); - }) - } - }, - getDefaultVoiceSlotId: function (...args) { - console.warn("telephony.sim.getDefaultVoiceSlotId 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, reject) => { - resolve(paramMock.paramNumberMock); - }) - } - }, - hasOperatorPrivileges: function (...args) { - console.warn("telephony.sim.hasOperatorPrivileges 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, reject) => { - resolve(paramMock.paramBooleanMock); - }) - } - }, - getISOCountryCodeForSim: function (...args) { - console.warn("telephony.sim.getISOCountryCodeForSim 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, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - getSimOperatorNumeric: function (...args) { - console.warn("telephony.sim.getSimOperatorNumeric 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, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - getSimSpn: function (...args) { - console.warn("telephony.sim.getSimSpn 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, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - getSimState: function (...args) { - console.warn("telephony.sim.getSimState 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, SimState); - } else { - return new Promise((resolve, reject) => { - resolve(SimState); - }) - } - }, - getCardType: function (...args) { - console.warn("telephony.sim.getCardType 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, CardType); - } else { - return new Promise((resolve, reject) => { - resolve(CardType); - }) - } - }, - getSimIccId: function (...args) { - console.warn("telephony.sim.getSimIccId 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, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - getVoiceMailIdentifier: function (...args) { - console.warn("telephony.sim.getVoiceMailIdentifier 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, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - getVoiceMailNumber: function (...args) { - console.warn("telephony.sim.getVoiceMailNumber 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, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - getVoiceMailCount: function (...args) { - console.warn("telephony.sim.getVoiceMailCount 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, reject) => { - resolve(paramMock.paramNumberMock); - }) - } - }, - getSimTelephoneNumber: function (...args) { - console.warn("telephony.sim.getSimTelephoneNumber 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, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - getSimGid1: function (...args) { - console.warn("telephony.sim.getSimGid1 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, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - getSimTeleNumberIdentifier: function (...args) { - console.warn("telephony.sim.getSimTeleNumberIdentifier 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, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - getLine1NumberFromImpu: function (...args) { - console.warn("telephony.sim.getLine1NumberFromImpu 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, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - getMaxSimCount: function () { - console.warn("telephony.sim.getMaxSimCount interface mocked in the Previewer. How this interface works on the Previewer may" + - " be different from that on a real device.") - return paramMock.paramNumberMock; - }, - getIMSI: function (...args) { - console.warn("telephony.sim.getIMSI 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, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - hasSimCard: function (...args) { - console.warn("telephony.sim.hasSimCard 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, reject) => { - resolve(paramMock.paramBooleanMock); - }) - } - }, - getSimAccountInfo: function (...args) { - console.warn("telephony.sim.getSimAccountInfo 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, IccAccountInfo); - } else { - return new Promise((resolve, reject) => { - resolve(IccAccountInfo); - }) - } - }, - getActiveSimAccountInfoList: function (...args) { - console.warn("telephony.sim.getActiveSimAccountInfoList 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, [IccAccountInfo]); - } else { - return new Promise((resolve, reject) => { - resolve([IccAccountInfo]); - }) - } - }, - setDefaultVoiceSlotId: function (...args) { - console.warn("telephony.sim.setDefaultVoiceSlotId 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, reject) => { - resolve(); - }) - } - }, - activateSim: function (...args) { - console.warn("telephony.sim.activateSim 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, reject) => { - resolve(); - }) - } - }, - deactivateSim: function (...args) { - console.warn("telephony.sim.deactivateSim 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, reject) => { - resolve(); - }) - } - }, - setShowName: function (...args) { - console.warn("telephony.sim.setShowName 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, reject) => { - resolve(); - }) - } - }, - getShowName: function (...args) { - console.warn("telephony.sim.getShowName 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, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - setShowNumber: function (...args) { - console.warn("telephony.sim.setShowNumber 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, reject) => { - resolve(); - }) - } - }, - getShowNumber: function (...args) { - console.warn("telephony.sim.getShowNumber 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, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - getOperatorConfigs: function (...args) { - console.warn("telephony.sim.getOperatorConfigs 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, [OperatorConfigMock]); - } else { - return new Promise((resolve, reject) => { - resolve([OperatorConfigMock]); - }) - } - }, - unlockPin: function (...args) { - console.warn("telephony.sim.unlockPin 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, LockStatusResponse); - } else { - return new Promise((resolve, reject) => { - resolve(LockStatusResponse); - }) - } - }, - unlockPuk: function (...args) { - console.warn("telephony.sim.unlockPuk 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, LockStatusResponse); - } else { - return new Promise((resolve, reject) => { - resolve(LockStatusResponse); - }) - } - }, - alterPin: function (...args) { - console.warn("telephony.sim.alterPin 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, LockStatusResponse); - } else { - return new Promise((resolve, reject) => { - resolve(LockStatusResponse); - }) - } - }, - setLockState: function (...args) { - console.warn("telephony.sim.setLockState 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, LockStatusResponse); - } else { - return new Promise((resolve, reject) => { - resolve(LockStatusResponse); - }) - } - }, - unlockPin2: function (...args) { - console.warn("telephony.sim.unlockPin2 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, LockStatusResponse); - } else { - return new Promise((resolve, reject) => { - resolve(LockStatusResponse); - }) - } - }, - unlockPuk2: function (...args) { - console.warn("telephony.sim.unlockPuk2 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, LockStatusResponse); - } else { - return new Promise((resolve, reject) => { - resolve(LockStatusResponse); - }) - } - }, - alterPin2: function (...args) { - console.warn("telephony.sim.alterPin2 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, LockStatusResponse); - } else { - return new Promise((resolve, reject) => { - resolve(LockStatusResponse); - }) - } - }, - queryIccDiallingNumbers: function (...args) { - console.warn("telephony.sim.queryIccDiallingNumbers 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, [DiallingNumbersInfo]); - } else { - return new Promise((resolve, reject) => { - resolve([DiallingNumbersInfo]); - }) - } - }, - addIccDiallingNumbers: function (...args) { - console.warn("telephony.sim.addIccDiallingNumbers 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, reject) => { - resolve(); - }) - } - }, - delIccDiallingNumbers: function (...args) { - console.warn("telephony.sim.delIccDiallingNumbers 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, reject) => { - resolve(); - }) - } - }, - updateIccDiallingNumbers: function (...args) { - console.warn("telephony.sim.updateIccDiallingNumbers 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, reject) => { - resolve(); - }) - } - } + const IccAccountInfo = { + simId: "[PC Preview] unknow simId", + slotIndex: "[PC Preview] unknow slotIndex", + isEsim: "[PC Preview] unknow isEsim", + isActive: "[PC Preview] unknow isActive", + iccId: "[PC Preview] unknow iccId", + showName: "[PC Preview] unknow showName", + showNumber: "[PC Preview] unknow showNumber" + } + const OperatorConfigMock = { + field: "[PC Preview] unknow field", + value: "[PC Preview] unknow value" + } + const LockStatusResponse = { + result: "[PC Preview] unknow result", + remain: "[PC Preview] unknow remain" + } + const DiallingNumbersInfo = { + efid: "[PC Preview] unknow efid", + recordNumber: "[PC Preview] unknow recordNumber", + alphaTag: "[PC Preview] unknow alphaTag", + number: "[PC Preview] unknow number", + emails: "[PC Preview] unknow emails" + } + const CardType = "[PC Preview] unknow CardType"; + const SimState = "[PC Preview] unknow SimState"; + global.systemplugin.telephony.sim = { + isSimActive: function (...args) { + console.warn("telephony.sim.isSimActive 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, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, + getDefaultVoiceSlotId: function (...args) { + console.warn("telephony.sim.getDefaultVoiceSlotId 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, reject) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + hasOperatorPrivileges: function (...args) { + console.warn("telephony.sim.hasOperatorPrivileges 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, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, + getISOCountryCodeForSim: function (...args) { + console.warn("telephony.sim.getISOCountryCodeForSim 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, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getSimOperatorNumeric: function (...args) { + console.warn("telephony.sim.getSimOperatorNumeric 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, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getSimSpn: function (...args) { + console.warn("telephony.sim.getSimSpn 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, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getSimState: function (...args) { + console.warn("telephony.sim.getSimState 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, SimState); + } else { + return new Promise((resolve, reject) => { + resolve(SimState); + }) + } + }, + getCardType: function (...args) { + console.warn("telephony.sim.getCardType 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, CardType); + } else { + return new Promise((resolve, reject) => { + resolve(CardType); + }) + } + }, + getSimIccId: function (...args) { + console.warn("telephony.sim.getSimIccId 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, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getVoiceMailIdentifier: function (...args) { + console.warn("telephony.sim.getVoiceMailIdentifier 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, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getVoiceMailNumber: function (...args) { + console.warn("telephony.sim.getVoiceMailNumber 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, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getVoiceMailCount: function (...args) { + console.warn("telephony.sim.getVoiceMailCount 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, reject) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + getSimTelephoneNumber: function (...args) { + console.warn("telephony.sim.getSimTelephoneNumber 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, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getSimGid1: function (...args) { + console.warn("telephony.sim.getSimGid1 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, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getSimTeleNumberIdentifier: function (...args) { + console.warn("telephony.sim.getSimTeleNumberIdentifier 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, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getLine1NumberFromImpu: function (...args) { + console.warn("telephony.sim.getLine1NumberFromImpu 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, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getMaxSimCount: function () { + console.warn("telephony.sim.getMaxSimCount interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + return paramMock.paramNumberMock; + }, + getIMSI: function (...args) { + console.warn("telephony.sim.getIMSI 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, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + hasSimCard: function (...args) { + console.warn("telephony.sim.hasSimCard 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, reject) => { + resolve(paramMock.paramBooleanMock); + }) + } + }, + getSimAccountInfo: function (...args) { + console.warn("telephony.sim.getSimAccountInfo 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, IccAccountInfo); + } else { + return new Promise((resolve, reject) => { + resolve(IccAccountInfo); + }) + } + }, + getActiveSimAccountInfoList: function (...args) { + console.warn("telephony.sim.getActiveSimAccountInfoList 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, [IccAccountInfo]); + } else { + return new Promise((resolve, reject) => { + resolve([IccAccountInfo]); + }) + } + }, + setDefaultVoiceSlotId: function (...args) { + console.warn("telephony.sim.setDefaultVoiceSlotId 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, reject) => { + resolve(); + }) + } + }, + activateSim: function (...args) { + console.warn("telephony.sim.activateSim 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, reject) => { + resolve(); + }) + } + }, + deactivateSim: function (...args) { + console.warn("telephony.sim.deactivateSim 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, reject) => { + resolve(); + }) + } + }, + setShowName: function (...args) { + console.warn("telephony.sim.setShowName 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, reject) => { + resolve(); + }) + } + }, + getShowName: function (...args) { + console.warn("telephony.sim.getShowName 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, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + setShowNumber: function (...args) { + console.warn("telephony.sim.setShowNumber 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, reject) => { + resolve(); + }) + } + }, + getShowNumber: function (...args) { + console.warn("telephony.sim.getShowNumber 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, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + getOperatorConfigs: function (...args) { + console.warn("telephony.sim.getOperatorConfigs 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, [OperatorConfigMock]); + } else { + return new Promise((resolve, reject) => { + resolve([OperatorConfigMock]); + }) + } + }, + unlockPin: function (...args) { + console.warn("telephony.sim.unlockPin 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, LockStatusResponse); + } else { + return new Promise((resolve, reject) => { + resolve(LockStatusResponse); + }) + } + }, + unlockPuk: function (...args) { + console.warn("telephony.sim.unlockPuk 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, LockStatusResponse); + } else { + return new Promise((resolve, reject) => { + resolve(LockStatusResponse); + }) + } + }, + alterPin: function (...args) { + console.warn("telephony.sim.alterPin 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, LockStatusResponse); + } else { + return new Promise((resolve, reject) => { + resolve(LockStatusResponse); + }) + } + }, + setLockState: function (...args) { + console.warn("telephony.sim.setLockState 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, LockStatusResponse); + } else { + return new Promise((resolve, reject) => { + resolve(LockStatusResponse); + }) + } + }, + unlockPin2: function (...args) { + console.warn("telephony.sim.unlockPin2 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, LockStatusResponse); + } else { + return new Promise((resolve, reject) => { + resolve(LockStatusResponse); + }) + } + }, + unlockPuk2: function (...args) { + console.warn("telephony.sim.unlockPuk2 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, LockStatusResponse); + } else { + return new Promise((resolve, reject) => { + resolve(LockStatusResponse); + }) + } + }, + alterPin2: function (...args) { + console.warn("telephony.sim.alterPin2 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, LockStatusResponse); + } else { + return new Promise((resolve, reject) => { + resolve(LockStatusResponse); + }) + } + }, + queryIccDiallingNumbers: function (...args) { + console.warn("telephony.sim.queryIccDiallingNumbers 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, [DiallingNumbersInfo]); + } else { + return new Promise((resolve, reject) => { + resolve([DiallingNumbersInfo]); + }) + } + }, + addIccDiallingNumbers: function (...args) { + console.warn("telephony.sim.addIccDiallingNumbers 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, reject) => { + resolve(); + }) + } + }, + delIccDiallingNumbers: function (...args) { + console.warn("telephony.sim.delIccDiallingNumbers 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, reject) => { + resolve(); + }) + } + }, + updateIccDiallingNumbers: function (...args) { + console.warn("telephony.sim.updateIccDiallingNumbers 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, reject) => { + resolve(); + }) + } } + } } export function mockSMS() { - const SimShortMessage = { - shortMessage: "[PC Preview] unknow shortMessage", - simMessageStatus: "[PC Preview] unknow simMessageStatus", - indexOnSim: "[PC Preview] unknow indexOnSim" - } - const ShortMessage = { - visibleMessageBody: "[PC Preview] unknow visibleMessageBody", - visibleRawAddress: "[PC Preview] unknow visibleRawAddress", - messageClass: "[PC Preview] unknow messageClass", - protocolId: "[PC Preview] unknow protocolId", - scAddress: "[PC Preview] unknow scAddress", - scTimestamp: "[PC Preview] unknow scTimestamp", - isReplaceMessage: "[PC Preview] unknow isReplaceMessage", - hasReplyPath: "[PC Preview] unknow hasReplyPath", - pdu: ["[PC Preview] unknow pdu"], - status: "[PC Preview] unknow status", - isSmsStatusReportMessage: "[PC Preview] unknow isSmsStatusReportMessage", - emailAddress: "[PC Preview] unknow emailAddress", - emailMessageBody: "[PC Preview] unknow emailMessageBody", - userRawData: ["[PC Preview] unknow userRawData"], - isEmailMessage: "[PC Preview] unknow isEmailMessage", - } - global.systemplugin.telephony.sms = { - splitMessage: function (...args) { - console.warn("telephony.sms.splitMessage 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, reject) => { - resolve([paramMock.paramStringMock]); - }) - } - }, - createMessage: function (...args) { - console.warn("telephony.sms.createMessage 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, ShortMessage); - } else { - return new Promise((resolve, reject) => { - resolve(ShortMessage); - }) - } - }, - sendMessage: function (...args) { - console.warn("telephony.sms.sendMessage interface mocked in the Previewer. How this interface works on the Previewer may" + - " be different from that on a real device.") - return; - }, - setDefaultSmsSlotId: function (...args) { - console.warn("telephony.sms.setDefaultSmsSlotId 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, reject) => { - resolve(); - }) - } - }, - getDefaultSmsSlotId: function (...args) { - console.warn("telephony.sms.getDefaultSmsSlotId 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, reject) => { - resolve(paramMock.paramNumberMock); - }) - } - }, - setSmscAddr: function (...args) { - console.warn("telephony.sms.setSmscAddr 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, reject) => { - resolve(); - }) - } - }, - getSmscAddr: function (...args) { - console.warn("telephony.sms.getSmscAddr 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, reject) => { - resolve(paramMock.paramStringMock); - }) - } - }, - hasSmsCapability: function () { - console.warn("telephony.sms.hasSmsCapability interface mocked in the Previewer. How this interface works on the Previewer may" + - " be different from that on a real device.") - return paramMock.paramBooleanMock; - }, - addSimMessage: function (...args) { - console.warn("telephony.sms.addSimMessage 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, reject) => { - resolve(); - }) - } - }, - delSimMessage: function (...args) { - console.warn("telephony.sms.delSimMessage 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, reject) => { - resolve(); - }) - } - }, - updateSimMessage: function (...args) { - console.warn("telephony.sms.updateSimMessage 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, reject) => { - resolve(); - }) - } - }, - getAllSimMessages: function (...args) { - console.warn("telephony.sms.getAllSimMessages 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, [SimShortMessage]); - } else { - return new Promise((resolve, reject) => { - resolve([SimShortMessage]); - }) - } - }, - setCBConfig: function (...args) { - console.warn("telephony.sms.setCBConfig 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, reject) => { - resolve(); - }) - } - } + const SimShortMessage = { + shortMessage: "[PC Preview] unknow shortMessage", + simMessageStatus: "[PC Preview] unknow simMessageStatus", + indexOnSim: "[PC Preview] unknow indexOnSim" + } + const ShortMessage = { + visibleMessageBody: "[PC Preview] unknow visibleMessageBody", + visibleRawAddress: "[PC Preview] unknow visibleRawAddress", + messageClass: "[PC Preview] unknow messageClass", + protocolId: "[PC Preview] unknow protocolId", + scAddress: "[PC Preview] unknow scAddress", + scTimestamp: "[PC Preview] unknow scTimestamp", + isReplaceMessage: "[PC Preview] unknow isReplaceMessage", + hasReplyPath: "[PC Preview] unknow hasReplyPath", + pdu: ["[PC Preview] unknow pdu"], + status: "[PC Preview] unknow status", + isSmsStatusReportMessage: "[PC Preview] unknow isSmsStatusReportMessage", + emailAddress: "[PC Preview] unknow emailAddress", + emailMessageBody: "[PC Preview] unknow emailMessageBody", + userRawData: ["[PC Preview] unknow userRawData"], + isEmailMessage: "[PC Preview] unknow isEmailMessage", + } + global.systemplugin.telephony.sms = { + splitMessage: function (...args) { + console.warn("telephony.sms.splitMessage 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, reject) => { + resolve([paramMock.paramStringMock]); + }) + } + }, + createMessage: function (...args) { + console.warn("telephony.sms.createMessage 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, ShortMessage); + } else { + return new Promise((resolve, reject) => { + resolve(ShortMessage); + }) + } + }, + sendMessage: function (...args) { + console.warn("telephony.sms.sendMessage interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + }, + setDefaultSmsSlotId: function (...args) { + console.warn("telephony.sms.setDefaultSmsSlotId 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, reject) => { + resolve(); + }) + } + }, + getDefaultSmsSlotId: function (...args) { + console.warn("telephony.sms.getDefaultSmsSlotId 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, reject) => { + resolve(paramMock.paramNumberMock); + }) + } + }, + setSmscAddr: function (...args) { + console.warn("telephony.sms.setSmscAddr 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, reject) => { + resolve(); + }) + } + }, + getSmscAddr: function (...args) { + console.warn("telephony.sms.getSmscAddr 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, reject) => { + resolve(paramMock.paramStringMock); + }) + } + }, + hasSmsCapability: function () { + console.warn("telephony.sms.hasSmsCapability interface mocked in the Previewer. How this interface works on the Previewer may" + + " be different from that on a real device.") + return paramMock.paramBooleanMock; + }, + addSimMessage: function (...args) { + console.warn("telephony.sms.addSimMessage 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, reject) => { + resolve(); + }) + } + }, + delSimMessage: function (...args) { + console.warn("telephony.sms.delSimMessage 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, reject) => { + resolve(); + }) + } + }, + updateSimMessage: function (...args) { + console.warn("telephony.sms.updateSimMessage 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, reject) => { + resolve(); + }) + } + }, + getAllSimMessages: function (...args) { + console.warn("telephony.sms.getAllSimMessages 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, [SimShortMessage]); + } else { + return new Promise((resolve, reject) => { + resolve([SimShortMessage]); + }) + } + }, + setCBConfig: function (...args) { + console.warn("telephony.sms.setCBConfig 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, reject) => { + resolve(); + }) + } } + } } export function mockObserver() { - const SimStateData = { - type: "[PC Preview] unknow type", - state: "[PC Preview] unknow state", - } - global.systemplugin.telephony.observer = { - on: function (...args) { - console.warn("telephony.observer.on interface mocked in the Previewer. How this interface works on the Previewer may " + - "be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - if (args[0] === 'networkStateChange') { - args[len - 1].call(this, NetworkState); - } else if (args[0] === 'signalInfoChange') { - args[len - 1].call(this, [SignalInformation]); - } else if (args[0] === 'cellInfoChange') { - args[len - 1].call(this, [CellInformation]); - } else if (args[0] === 'cellularDataConnectionStateChange') { - args[len - 1].call(this, paramMock.businessErrorMock, { - state: "[PC Preview] unknow state", - network: "[PC Preview] unknow network" - }); - } else if (args[0] === 'cellularDataFlowChange') { - args[len - 1].call(this, DataFlowType); - } else if (args[0] === 'callStateChange') { - args[len - 1].call(this, paramMock.businessErrorMock, { - state: "[PC Preview] unknow state", - number: "[PC Preview] unknow number" - }); - } else if (args[0] === 'cfuIndicatorChange' || 'voiceMailMsgIndicatorChange') { - args[len - 1].call(this, paramMock.paramBooleanMock); - } else if (args[0] === 'simStateChange') { - args[len - 1].call(this, SimStateData); - } - } - }, - off: function (...args) { - console.warn("telephony.observer.off interface mocked in the Previewer. How this interface works on the Previewer may " + - "be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - if (args[0] === 'networkStateChange') { - args[len - 1].call(this, NetworkState); - } else if (args[0] === 'signalInfoChange') { - args[len - 1].call(this, [SignalInformation]); - } else if (args[0] === 'cellInfoChange') { - args[len - 1].call(this, [CellInformation]); - } else if (args[0] === 'cellularDataConnectionStateChange') { - args[len - 1].call(this, paramMock.businessErrorMock, { - state: "[PC Preview] unknow state", - network: "[PC Preview] unknow network" - }); - } else if (args[0] === 'cellularDataFlowChange') { - args[len - 1].call(this, DataFlowType); - } else if (args[0] === 'callStateChange') { - args[len - 1].call(this, paramMock.businessErrorMock, { - state: "[PC Preview] unknow state", - number: "[PC Preview] unknow number" - }); - } else if (args[0] === 'cfuIndicatorChange' || 'voiceMailMsgIndicatorChange') { - args[len - 1].call(this, paramMock.paramBooleanMock); - } else if (args[0] === 'simStateChange') { - args[len - 1].call(this, SimStateData); - } - } - }, - once: function (...args) { - console.warn("telephony.observer.once interface mocked in the Previewer. How this interface works on the Previewer may " + - "be different from that on a real device.") - const len = args.length - if (typeof args[len - 1] === 'function') { - if (args[0] === 'networkStateChange') { - args[len - 1].call(this, NetworkState); - } else if (args[0] === 'signalInfoChange') { - args[len - 1].call(this, [SignalInformation]); - } else if (args[0] === 'cellInfoChange') { - args[len - 1].call(this, [CellInformation]); - } else if (args[0] === 'cellularDataConnectionStateChange') { - args[len - 1].call(this, paramMock.businessErrorMock, { - state: "[PC Preview] unknow state", - network: "[PC Preview] unknow network" - }); - } else if (args[0] === 'cellularDataFlowChange') { - args[len - 1].call(this, DataFlowType); - } else if (args[0] === 'callStateChange') { - args[len - 1].call(this, paramMock.businessErrorMock, { - state: "[PC Preview] unknow state", - number: "[PC Preview] unknow number" - }); - } else if (args[0] === 'cfuIndicatorChange' || 'voiceMailMsgIndicatorChange') { - args[len - 1].call(this, paramMock.paramBooleanMock); - } else if (args[0] === 'simStateChange') { - args[len - 1].call(this, SimStateData); - } - } + const SimStateData = { + type: "[PC Preview] unknow type", + state: "[PC Preview] unknow state", + } + global.systemplugin.telephony.observer = { + on: function (...args) { + console.warn("telephony.observer.on interface mocked in the Previewer. How this interface works on the Previewer may " + + "be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + if (args[0] === 'networkStateChange') { + args[len - 1].call(this, NetworkState); + } else if (args[0] === 'signalInfoChange') { + args[len - 1].call(this, [SignalInformation]); + } else if (args[0] === 'cellInfoChange') { + args[len - 1].call(this, [CellInformation]); + } else if (args[0] === 'cellularDataConnectionStateChange') { + args[len - 1].call(this, paramMock.businessErrorMock, { + state: "[PC Preview] unknow state", + network: "[PC Preview] unknow network" + }); + } else if (args[0] === 'cellularDataFlowChange') { + args[len - 1].call(this, DataFlowType); + } else if (args[0] === 'callStateChange') { + args[len - 1].call(this, paramMock.businessErrorMock, { + state: "[PC Preview] unknow state", + number: "[PC Preview] unknow number" + }); + } else if (args[0] === 'cfuIndicatorChange' || 'voiceMailMsgIndicatorChange') { + args[len - 1].call(this, paramMock.paramBooleanMock); + } else if (args[0] === 'simStateChange') { + args[len - 1].call(this, SimStateData); } + } + }, + off: function (...args) { + console.warn("telephony.observer.off interface mocked in the Previewer. How this interface works on the Previewer may " + + "be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + if (args[0] === 'networkStateChange') { + args[len - 1].call(this, NetworkState); + } else if (args[0] === 'signalInfoChange') { + args[len - 1].call(this, [SignalInformation]); + } else if (args[0] === 'cellInfoChange') { + args[len - 1].call(this, [CellInformation]); + } else if (args[0] === 'cellularDataConnectionStateChange') { + args[len - 1].call(this, paramMock.businessErrorMock, { + state: "[PC Preview] unknow state", + network: "[PC Preview] unknow network" + }); + } else if (args[0] === 'cellularDataFlowChange') { + args[len - 1].call(this, DataFlowType); + } else if (args[0] === 'callStateChange') { + args[len - 1].call(this, paramMock.businessErrorMock, { + state: "[PC Preview] unknow state", + number: "[PC Preview] unknow number" + }); + } else if (args[0] === 'cfuIndicatorChange' || 'voiceMailMsgIndicatorChange') { + args[len - 1].call(this, paramMock.paramBooleanMock); + } else if (args[0] === 'simStateChange') { + args[len - 1].call(this, SimStateData); + } + } + }, + once: function (...args) { + console.warn("telephony.observer.once interface mocked in the Previewer. How this interface works on the Previewer may " + + "be different from that on a real device.") + const len = args.length + if (typeof args[len - 1] === 'function') { + if (args[0] === 'networkStateChange') { + args[len - 1].call(this, NetworkState); + } else if (args[0] === 'signalInfoChange') { + args[len - 1].call(this, [SignalInformation]); + } else if (args[0] === 'cellInfoChange') { + args[len - 1].call(this, [CellInformation]); + } else if (args[0] === 'cellularDataConnectionStateChange') { + args[len - 1].call(this, paramMock.businessErrorMock, { + state: "[PC Preview] unknow state", + network: "[PC Preview] unknow network" + }); + } else if (args[0] === 'cellularDataFlowChange') { + args[len - 1].call(this, DataFlowType); + } else if (args[0] === 'callStateChange') { + args[len - 1].call(this, paramMock.businessErrorMock, { + state: "[PC Preview] unknow state", + number: "[PC Preview] unknow number" + }); + } else if (args[0] === 'cfuIndicatorChange' || 'voiceMailMsgIndicatorChange') { + args[len - 1].call(this, paramMock.paramBooleanMock); + } else if (args[0] === 'simStateChange') { + args[len - 1].call(this, SimStateData); + } + } } + } } \ No newline at end of file