PhoneInterfaceManager
PhoneInterfaceManager
前置文章
前言
在文章《Android无线电信息管理开篇准备工作》中介绍 PhoneInterfaceManager 的作用,在文章《初识com.android.phone》中介绍了PhoneInterfaceManager 的创建启动过程。本文将继续引领读者深入了解 PhoneInterfaceManager 的功能以及使用方法。
本文将摒弃以文字解说为主的方式去阐述,变为以时序图为主,文字加以说明的方式去阐述PhoneInterfaceManager,这样应该更加适合程序员的阅读方式。
TelephonyManager
在 《Android系统之System Server大纲》一文中,学会了 Android System Server 的架构方式,PhoneInterfaceManager 作为 server 端,TelephonyManager 则作为 client 端。但是 TelephonyManager 不仅仅作为 PhoneInterfaceManager 的 client 端,还会作为 TelecomService 和 TelephonyRegistry 的 client 端。TelecomService 是 Telecom(通话控制中枢) 中的一个 service,后续如有机会,将和读者分享 Telecom 的作用和功能。
在《Android System Server大纲之VibratorService》一文中,清楚的了解到 client 的获取过程以及 getSystemService 返回的本质对象。TelephonyManager 的获取方式是:
TelephoneManager tm = Context.getSystemService(Context.TELEPHONY_SERVICE);
PhoneInterfaceManager方法集
由于 PhoneInterfaceManager方法集较多,本文之针对常用且重要的个别方法进行深入的跟踪。
点击方法名可查看详情
- 方法名(参数) : 返回类型 说明
- answerRingingCall(): void ITelephony 接听来电
- answerRingingCallForSubscriber(int): void 同上
- call(String, String): void 拨打指定电话号码
- callForSubscriber(int, String, String): void 同上
- canChangeDtmFToneLength(): boolean 是否允许改变 DTMF Tome 长度
- carrierActionReportDeFaultNetworkStatus(int, boolean): void 启动/停止指定网络状态上报
- carrierActionSetMeteredApnsEnabled(int, boolean): void 打开/关闭 metered apns
- carrierActionSetRadioEnabled(int, boolean): void 打开/关闭无线电
- checkCarrierPrivilegesForPackage(String): int 监测应用无线电能力
- checkCarrierPrivilegesForPackageAnyPhone(String): int 同上
- dial(String): void ITelephony 类同 call
- dialForSubscriber(int, String): void 类同 call
- disableDataConnectivity(): boolean ITelephony
- disableLocationUpdates(): void ITelephony 类同上
- disableLocationllpdatesForSubscriber(int): void 类同上
- disableVisualVoicemailSmsFilter(String, int): void 类同上
- enableDataConnectivity(): boolean ITelephony 类同disableDataConnectivity
- enableLocationUpdates(): void ITelephony 类同上
- enableLocationllpdatesForSubscriber(int): void 类同上
- enableVideoCalling(boolean): void 类同上
- enableVisualVoicemailSmsFilter(String, int, VisualVoicemailSmsFilterSettings): void 类同上
- endCall(): boolean ITelephony 类同call
- endCallForSubscriber(int): boolean 类同上
- factoryReset(int): void 充值网络设置
- getActivePhoneType(): int ITelephony 获取当前网络类型GSM,CDMA,SIP…
- getActivePhoneTypeForSlot(int): int 同上
- getActiveVisualVoicemailSmsFilterSettings(int): VisualVoicemailSmsFilterSettings
- getAidForAppType(int, int): String uicc app type
- getAllCellInfo(String): List 获取全部基站信息,也就网络类型
- getAllowedCarriers(int): List 获取指定卡信息(Mcc、mnc、spn等)
- getCalculatedPreFerredNetworkType(String): int 首选网络类型
- getCallState(): int ITelephony 通话状态
- getCallStateForSlot(int): int 同上
- getCarrierPackageNamesForIntentAndPhone(lntent, int): List SIM卡应用(参考UiccCard)
- getCarrierPrivilegeStatus(int): int SIM privilege(参考UiccCard)
- getCdmaEriIconIndex(String): int CDMA ERI icon
- getCdmaEriIconIndexForSubscriber(int, String): int 同上
- getCdmaEriIconMode(String): int
- getCdmaEriIconModeForSubscriber(int, String): int
- getCdmaEriText(String): String
- getCdmaEriTextForSubscriber(int, String): String
- getCdmaMdn(int): String
- getCdmaMin(int): String
- getCdmaPrlVersion(int): String
- getCellLocation(String): Bundle 基站定位
- getCellNetworkScanResults(int): CellNetworkScanResult 网络搜索
- getClientRequestStats(String, int): List
- getDataActivationState(int, String): int 网络数据流状态
- getDataActivity(): int ITelephony 网络数据流(上行、下行)
- getDataEnabled(int): boolean 网络开关
- getDataNetworkType(String): int 数据网络类型
- getDataNetworkTypeForSubscriber(int, String): int 同上
- getDataState(): int ITelephony 数据开关状态(连接、断开、挂起)
- getDefaultSim(): int index 0
- getDeviceId(String): String 获取 IMEI
- getDeviceSoftwareVersionForSlot(int, String): String 设备 ImeiSv
- getEmergencyCallbackMode(int): boolean 紧急拨号原路返回模式
- getEsn(int): String 获取Electronic Serial Number,手机贴的那个
- getForbiddenPlmns(int, int): String[] 不支持的 PLMN
- getImeiForSlot(int, String): String
- getImsServiceControllerAndListen(int, int, IImsServiceFeatureListener): IImsServiceController
- getLine1AlphaTagForDisplay(int, String): String
- getLinelNumberForDisplay(int, String): String
- getLocaleFromDefaultSim(): String 读取 SIM lacal language
- getLteOnCdmaMode(String): int
- getLteOnCdmaModeForSubscriber(int, String): int
- getMeidForSlot(int, String): String
- getMergedSubscriberIds(String): String[]
- getNeighboringCelllnFo(String): List
- getNetworkCountrylsoForPhone(int): String
- getNetworkType(): int ITelephony 获取网络类型(GSM/GPRS/LTE/HSDPA/HSUPA…)
- getNetworkTypeForSubscriber(int, String): int 同上
- getPackagesWithCarrierPrivileges(): List
- getPcscFAddress(String, String): StringQ
- getPreFerredNetworkType(int): int
- getRadioAccessFamily(int, String): int
- getServiceStateForSubscriber(int, String): ServiceState
- getSignalStrength(int): SignalStrength 信号强度
- getSubldForPhoneAccount(PhoneAccount): int
- getTelephonyFlistograms(): List
- getTetherApnRequired(): int
- getVisualVoicemailPackageName(String, int): String
- getVisualVoicemailSettings(String, int): Bundle
- getVisualVoicemailSmsFilterSettings(String, int): VisualVoicemailSmsFilterSettings
- getVoiceActivationState(int, String): int
- getVoicemailRingtonellri(PhoneAccountFlandle): Uri
- getVoiceMessageCount(): int ITelephony
- getVoiceMessageCountForSubscriber(int): int
- getVoiceNetworkTypeForSubscriber(int, String): int
- getVtDatallsage(int, boolean): NetworkStats
- getWhenToMakeWifiCalls(): int
- handlePinMmi(String): boolean ITelephony SIM 卡 Pin 码
- handlePinMmiForSubscriber(int, String): boolean 同上
- handleUssdRequest(int, String, Result Receiver): void Unstructured Supplementary Service Data非结构化补充数据业务(#xxx#)
- hasIccCard(): boolean ITelephony 是否插入 SIM 卡
- hasIccCardllsingSlotlndex(int): boolean 同上
- iccCloseLogicalChannel(int, int): boolean
- iccExchangeSimlO(int, int, int, int, int, int, String): byte[]
- iccOpenLogicalChannel(int, String, String, int): IccOpenLogicalChannelResponse
- iccTransmitApduBasicChannel(int, int, int, int, int, int, String): String
- iccTransmitApduLogicalChannel(int, int, int, int, int, int, int,…): String
- isConcurrentVoiceAndDataAllowed(int): boolean
- isDataConnectivityPossible(int): boolean
- isHearingAidCompatibilitySupported(): boolean 辅助功能
- isIdle(String): boolean 待机
- isIdleForSubscriber(int, String): boolean
- isImsRegistered(): boolean
- isOffhook(String): boolean 无通话
- isOffhookForSubscriber(int, String): boolean
- isRadioOn(String): boolean 无线电开关
- isRadioOnForSubscriber(int, String): boolean 同上
- isRinging(String): boolean 来电
- isRingingForSubscriber(int, String): boolean
- isTtyModeSupported(): boolean TTY模式
- isVideoCallingEnabled(String): boolean
- isVideoTelephonyAvailable(): boolean
- isVoicemailVibrationEnabled(PhoneAccountFlandle): boolean
- isVolteAvailable(): boolean 4G 语音
- isWifiCallingAvailable(): boolean
- isWorldPhone(): boolean
- needMobileRadioShutdown(): boolean
- needsOtaServiceProvisioning(): boolean ITelephony
- nvReadItem(int): String NV items
- nvResetConfig(int): boolean
- nvWriteCdmaPrl(byteQ): boolean
- nvWriteItem(int, String): boolean
- requestModemActivityInfo( Result Receiver): void
- request NetworkScan(int, NetworkScan Request, Messenger, I Binder): int
- sendDialerSpecialCode(String, String): void
- sendEnvelopeWithStatus(int, String): String
- sendVisualVoicemailSmsForSubscriber(String, int, String, int, String, PendingIntent): void
- setAllowedCarriers(int, List): int
- setCellInfoListRate(int): void
- setDataActivationState(int, int): void
- setDataEnabled(int, boolean): void
- setlmsRegistrationState(boolean): void
- setLinelNumberForDisplayForSubscriber(int, String, String): boolean
- setNetworkSelectionModeAutomatic(int): void
- setNetworkSelectionModeManual(int, Operatorlnfo, boolean): boolean
- setOperatorBrandOverride(int, String): boolean
- setPhone(Phone): void
- setPoLicyDataEnabLed(boolean, int): void
- setPreferredNetworkType(int, int): boolean
- setRadio(boolean): boolean ITeLephony 设置无线电开关
- setRadioCapabiLity(RadioAccessFamiLyQ): void
- setRadioForSubscribeKint, boolean): boolean
- setRadioPower(boolean): boolean 无线电挂机(Modem)
- setRadioPowerForSubscribeKint, boolean): boolean
- setRoamingOverride(int, List, List, List, List): boolean
- setSimPowerStateForSlot(int, int): void
- setVoiceActivationState(int, int): void
- setVoiceMailNumbeKint, String, String): boolean
- setVoicemailRingtoneUri(String, PhoneAccountHandle, Uri): void
- setVoicemaiLVibrationEnabled(String( PhoneAccountHandle, boolean): void
- setWhenToMakeWifiCalls(int): void
- shutdownMobileRadios(): void 完全关闭 Modem
- silenceRinger(): void ITeLephony
- stopNetworkScan(int, int): void
- supplyPin(String): boolean ITeLephony PIN/PUK
- supplyPinForSubscribeKint, String): boolean PIN/PUK
- supplyPinReportResuLt(String): int[] PIN/PUK
- supplyPinReportResultForSubscriber(int, String): int[] PIN/PUK
- supplyPuk(String( String): boolean ITeLephony PIN/PUK
- supplyPukForSubscribeKint, String, String): boolean PIN/PUK
- supplyPukReportResult(String( String): int[] PIN/PUK
- supplyPukReportResultForSubscribeKint, String, String): int[] PIN/PUK
- toggleRadioOnOff(): void ITeLephony 切换无线电开关
- toggleRadioOnOffForSubscriber(int): void
- updateServiceLocation(): void ITeLephony
- updateServiceLocationForSubscriber(int): void
answerRingingCall
call
disableDataConnectivity
PhoneInterfaceManager接口说明
在 PhoneInterfaceManager 方法集中,大多数接口的真正执行者是 Phone 对象,如 GsmCdmaPhone、ImsPhone。这里有必要了解一下 Phone 的初始化过程,以GsmCdmaPhone为例
总结
本文参数了 PhoneInterfaceManager 的功能,深入了解了部分接口,由于接口非常多,也就不一一展开说了。在 Telephony 中,PhoneInterfaceManager 只是一个 service,更多的就是向外提供接口,所有功能的实现还是在 Phone、IccCard 等模块。