From 8d778ea214a2dad1b25b51e592a23ec181a8359c Mon Sep 17 00:00:00 2001 From: dingxiaochen Date: Tue, 26 Jul 2022 16:10:26 +0800 Subject: [PATCH] js api mock. Signed-off-by: dingxiaochen --- .../systemplugin/napi/ohos_telephony_call.js | 19 ++++++++++++++ .../napi/ohos_telephony_observer.js | 12 ++++----- .../systemplugin/napi/ohos_telephony_radio.js | 26 +++++++++++++++++++ .../systemplugin/napi/ohos_telephony_sim.js | 17 ++++++++++++ .../systemplugin/napi/ohos_telephony_sms.js | 1 + 5 files changed, 69 insertions(+), 6 deletions(-) diff --git a/runtime/main/extend/systemplugin/napi/ohos_telephony_call.js b/runtime/main/extend/systemplugin/napi/ohos_telephony_call.js index 0f7c281b..e9f0a908 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_call.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_call.js @@ -138,9 +138,27 @@ export const TransferStatus = { TRANSFER_DISABLE: 0, TRANSFER_ENABLE: 1, }; +export const CallAttributeOptions = { + accountNumber: "[PC Preview] unknow accountNumber", + speakerphoneOn: "[PC Preview] unknow speakerphoneOn", + accountId: "[PC Preview] unknow accountId", + videoState: VideoStateType, + startTime: "[PC Preview] unknow startTime", + isEcc: "[PC Preview] unknow isEcc", + callType: CallType, + callId: "[PC Preview] unknow callId", + callState: DetailedCallState, + conferenceState: ConferenceState, + status: "[PC Preview] unknow status", + number: "[PC Preview] unknow number", +} export const EmergencyNumberOptions = { slotId: "[PC Preview] unknow slotId" } +export const CallTransferResult = { + status: "[PC Preview] unknow status", + number: "[PC Preview] unknow number", +} export const DisconnectedDetails = { UNASSIGNED_NUMBER: 1, NO_ROUTE_TO_DESTINATION: 3, @@ -181,6 +199,7 @@ export function mockCall() { CallState, DialScene, RestrictionStatus, + CallTransferResult, DialType, CallRestrictionMode, dial: function (...args) { diff --git a/runtime/main/extend/systemplugin/napi/ohos_telephony_observer.js b/runtime/main/extend/systemplugin/napi/ohos_telephony_observer.js index 4c9c60af..0f3ef44e 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_observer.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_observer.js @@ -14,6 +14,7 @@ */ import { paramMock } from "../utils" +import { CardType, SimState } from "./ohos_telephony_sim" export const LockReason = { SIM_NONE: "[PC Preview] unknow SIM_NONE", SIM_PIN: "[PC Preview] unknow SIM_PIN", @@ -29,15 +30,14 @@ export const LockReason = { SIM_SIM_PIN: "[PC Preview] unknow SIM_SIM_PIN", SIM_SIM_PUK: "[PC Preview] unknow SIM_SIM_PUK", }; +export const SimStateData = { + type: CardType, + state: SimState, + reason: LockReason, +} export function mockObserver() { - const SimStateData = { - type: "[PC Preview] unknow type", - state: "[PC Preview] unknow state", - reason: LockReason, - } const observer = { LockReason, - SimStateData, 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.") diff --git a/runtime/main/extend/systemplugin/napi/ohos_telephony_radio.js b/runtime/main/extend/systemplugin/napi/ohos_telephony_radio.js index 2a12c5b5..56de5d38 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_radio.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_radio.js @@ -116,6 +116,17 @@ export const TdscdmaCellInformation = { mcc: "[PC Preview] unknow mcc", mnc: "[PC Preview] unknow mnc", } +export const NetworkState = { + longOperatorName: "[PC Preview] unknow longOperatorName", + shortOperatorName: "[PC Preview] unknow shortOperatorName", + plmnNumeric: "[PC Preview] unknow plmnNumeric", + isRoaming: "[PC Preview] unknow isRoaming", + regState: RegState, + cfgTech: RadioTechnology, + nsaState: NsaState, + isCaActive: "[PC Preview] unknow isCaActive", + isEmergency: "[PC Preview] unknow isEmergency", +} export const NrCellInformation = { nrArfcn: "[PC Preview] unknow nrArfcn", pci: "[PC Preview] unknow pci", @@ -166,6 +177,21 @@ export const NrOptionMode = { NR_OPTION_SA_ONLY: "[PC Preview] unknow NR_OPTION_SA_ONLY", NR_OPTION_NSA_AND_SA: "[PC Preview] unknow NR_OPTION_NSA_AND_SA", }; +export const CellInformation = { + networkType: NetworkType, + isCamped: "[PC Preview] unknow isCamped", + timeStamp: "[PC Preview] unknow timeStamp", + signalInformation: SignalInformation, + data: CdmaCellInformation, +}; +export const SignalInformation = { + signalType: NetworkType, + signalLevel: "[PC Preview] unknow signalLevel", +}; +export const NetworkSearchResult = { + isNetworkSearchSuccess: "[PC Preview] unknow isNetworkSearchSuccess", + networkSearchResult: [NetworkInformation], +} export function mockRadio() { const radio = { RegState, diff --git a/runtime/main/extend/systemplugin/napi/ohos_telephony_sim.js b/runtime/main/extend/systemplugin/napi/ohos_telephony_sim.js index 72171671..1faba27d 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_sim.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_sim.js @@ -61,6 +61,15 @@ export const CardType = { DUAL_MODE_UG_CARD: 50, SINGLE_MODE_ISIM_CARD: 60 }; +export 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", +} export const SimState = { SIM_STATE_UNKNOWN: "[PC Preview] unknow SIM_STATE_UNKNOWN", SIM_STATE_NOT_PRESENT: "[PC Preview] unknow SIM_STATE_NOT_PRESENT", @@ -73,6 +82,14 @@ export const ContactType = { GENERAL_CONTACT: 1, FIXED_DIALING: 2, }; +export const OperatorConfig = { + field: "[PC Preview] unknow field", + value: "[PC Preview] unknow value" +} +export const LockStatusResponse = { + result: "[PC Preview] unknow result", + remain: "[PC Preview] unknow remain", +} export function mockSim() { const sim = { ContactType, diff --git a/runtime/main/extend/systemplugin/napi/ohos_telephony_sms.js b/runtime/main/extend/systemplugin/napi/ohos_telephony_sms.js index a562634e..b78411ea 100644 --- a/runtime/main/extend/systemplugin/napi/ohos_telephony_sms.js +++ b/runtime/main/extend/systemplugin/napi/ohos_telephony_sms.js @@ -119,6 +119,7 @@ export const MmsDeliveryInd = { to: [MmsAddress], status: "[PC Preview] unknow status", version: MmsVersionType, + messageId: "[PC Preview] unknow messageId", } export const MmsReadRecInd = { version: MmsVersionType,