├── Android.mk ├── CleanSpec.mk ├── README.txt ├── jarjar-rules.txt ├── proto └── telephony.proto ├── resources ├── Android.mk ├── AndroidManifest.xml └── res │ └── values │ └── config.xml ├── src └── java │ ├── android │ ├── provider │ │ └── Telephony.java │ └── telephony │ │ ├── CarrierMessagingServiceManager.java │ │ ├── CellBroadcastMessage.java │ │ ├── SmsCbCmasInfo.java │ │ ├── SmsCbEtwsInfo.java │ │ ├── SmsCbLocation.java │ │ ├── SmsCbMessage.java │ │ ├── SmsManager.java │ │ ├── SmsMessage.java │ │ └── gsm │ │ ├── SmsManager.java │ │ └── SmsMessage.java │ └── com │ ├── android │ └── internal │ │ └── telephony │ │ ├── ATParseEx.java │ │ ├── ATResponseParser.java │ │ ├── AsyncEmergencyContactNotifier.java │ │ ├── BaseCommands.java │ │ ├── BlockChecker.java │ │ ├── Call.java │ │ ├── CallFailCause.java │ │ ├── CallForwardInfo.java │ │ ├── CallManager.java │ │ ├── CallStateException.java │ │ ├── CallTracker.java │ │ ├── CarrierServiceBindHelper.java │ │ ├── CarrierSignalAgent.java │ │ ├── CellBroadcastHandler.java │ │ ├── CommandException.java │ │ ├── CommandsInterface.java │ │ ├── ConfigResourceUtil.java │ │ ├── Connection.java │ │ ├── DebugService.java │ │ ├── DefaultPhoneNotifier.java │ │ ├── DriverCall.java │ │ ├── EventLogTags.logtags │ │ ├── GsmCdmaCall.java │ │ ├── GsmCdmaCallTracker.java │ │ ├── GsmCdmaConnection.java │ │ ├── GsmCdmaPhone.java │ │ ├── HardwareConfig.java │ │ ├── HbpcdLookup.java │ │ ├── HbpcdUtils.java │ │ ├── IIccPhoneBook.aidl │ │ ├── IccCard.java │ │ ├── IccPhoneBookInterfaceManager.java │ │ ├── IccProvider.java │ │ ├── IccSmsInterfaceManager.java │ │ ├── ImsSMSDispatcher.java │ │ ├── InboundSmsHandler.java │ │ ├── InboundSmsTracker.java │ │ ├── IntRangeManager.java │ │ ├── LastCallFailCause.java │ │ ├── MccTable.java │ │ ├── MmiCode.java │ │ ├── Phone.java │ │ ├── PhoneFactory.java │ │ ├── PhoneInternalInterface.java │ │ ├── PhoneNotifier.java │ │ ├── PhoneStateIntentReceiver.java │ │ ├── PhoneSubInfoController.java │ │ ├── PhoneSwitcher.java │ │ ├── ProxyController.java │ │ ├── RIL.java │ │ ├── RadioCapability.java │ │ ├── RadioNVItems.java │ │ ├── RatRatcheter.java │ │ ├── RestrictedState.java │ │ ├── RetryManager.java │ │ ├── SMSDispatcher.java │ │ ├── ServiceStateTracker.java │ │ ├── Sms7BitEncodingTranslator.java │ │ ├── SmsAddress.java │ │ ├── SmsApplication.java │ │ ├── SmsBroadcastUndelivered.java │ │ ├── SmsHeader.java │ │ ├── SmsMessageBase.java │ │ ├── SmsNumberUtils.java │ │ ├── SmsResponse.java │ │ ├── SmsStorageMonitor.java │ │ ├── SmsUsageMonitor.java │ │ ├── SubscriptionController.java │ │ ├── SubscriptionInfoUpdater.java │ │ ├── SubscriptionMonitor.java │ │ ├── TelephonyCapabilities.java │ │ ├── TelephonyComponentFactory.java │ │ ├── TelephonyDevController.java │ │ ├── TelephonyTester.java │ │ ├── UUSInfo.java │ │ ├── UiccPhoneBookController.java │ │ ├── UiccSmsController.java │ │ ├── VisualVoicemailSmsFilter.java │ │ ├── VisualVoicemailSmsParser.java │ │ ├── WakeLockStateMachine.java │ │ ├── WapPushManagerParams.java │ │ ├── WapPushOverSms.java │ │ ├── WspTypeDecoder.java │ │ ├── cat │ │ ├── AppInterface.java │ │ ├── BerTlv.java │ │ ├── CallControlResult.java │ │ ├── CatCmdMessage.java │ │ ├── CatException.java │ │ ├── CatLog.java │ │ ├── CatResponseMessage.java │ │ ├── CatService.java │ │ ├── CommandDetails.java │ │ ├── CommandParams.java │ │ ├── CommandParamsFactory.java │ │ ├── ComprehensionTlv.java │ │ ├── ComprehensionTlvTag.java │ │ ├── Duration.java │ │ ├── FontSize.java │ │ ├── IconLoader.java │ │ ├── ImageDescriptor.java │ │ ├── Input.java │ │ ├── Item.java │ │ ├── LaunchBrowserMode.java │ │ ├── Menu.java │ │ ├── PresentationType.java │ │ ├── ResponseData.java │ │ ├── ResultCode.java │ │ ├── ResultException.java │ │ ├── RilMessageDecoder.java │ │ ├── TextAlignment.java │ │ ├── TextAttribute.java │ │ ├── TextColor.java │ │ ├── TextMessage.java │ │ ├── Tone.java │ │ ├── ToneSettings.java │ │ ├── ValueParser.java │ │ └── package.html │ │ ├── cdma │ │ ├── CdmaCallWaitingNotification.java │ │ ├── CdmaInboundSmsHandler.java │ │ ├── CdmaInformationRecords.java │ │ ├── CdmaMmiCode.java │ │ ├── CdmaSMSDispatcher.java │ │ ├── CdmaServiceCategoryProgramHandler.java │ │ ├── CdmaSmsBroadcastConfigInfo.java │ │ ├── CdmaSubscriptionSourceManager.java │ │ ├── EriInfo.java │ │ ├── EriManager.java │ │ ├── SignalToneUtil.java │ │ ├── SmsMessage.java │ │ ├── package.html │ │ └── sms │ │ │ ├── BearerData.java │ │ │ ├── CdmaSmsAddress.java │ │ │ ├── CdmaSmsSubaddress.java │ │ │ ├── SmsEnvelope.java │ │ │ ├── UserData.java │ │ │ └── package.html │ │ ├── dataconnection │ │ ├── ApnContext.java │ │ ├── ApnSetting.java │ │ ├── DataCallResponse.java │ │ ├── DataConnection.java │ │ ├── DataEnabledSettings.java │ │ ├── DataProfile.java │ │ ├── DcAsyncChannel.java │ │ ├── DcController.java │ │ ├── DcFailBringUp.java │ │ ├── DcFailCause.java │ │ ├── DcRequest.java │ │ ├── DcTesterDeactivateAll.java │ │ ├── DcTesterFailBringUpAll.java │ │ ├── DcTracker.java │ │ └── TelephonyNetworkFactory.java │ │ ├── gsm │ │ ├── GsmCellBroadcastHandler.java │ │ ├── GsmInboundSmsHandler.java │ │ ├── GsmMmiCode.java │ │ ├── GsmSMSDispatcher.java │ │ ├── GsmSmsAddress.java │ │ ├── GsmSmsCbMessage.java │ │ ├── SimTlv.java │ │ ├── SmsBroadcastConfigInfo.java │ │ ├── SmsCbConstants.java │ │ ├── SmsCbHeader.java │ │ ├── SmsMessage.java │ │ ├── SsData.java │ │ ├── SuppServiceNotification.java │ │ ├── UsimDataDownloadHandler.java │ │ ├── UsimPhoneBookManager.java │ │ └── package.html │ │ ├── imsphone │ │ ├── ImsExternalCall.java │ │ ├── ImsExternalCallTracker.java │ │ ├── ImsExternalConnection.java │ │ ├── ImsPhone.java │ │ ├── ImsPhoneBase.java │ │ ├── ImsPhoneCall.java │ │ ├── ImsPhoneCallTracker.java │ │ ├── ImsPhoneCommandInterface.java │ │ ├── ImsPhoneConnection.java │ │ ├── ImsPhoneFactory.java │ │ ├── ImsPhoneMmiCode.java │ │ └── ImsPullCall.java │ │ ├── metrics │ │ ├── CallSessionEventBuilder.java │ │ ├── InProgressCallSession.java │ │ ├── InProgressSmsSession.java │ │ ├── SmsSessionEventBuilder.java │ │ ├── TelephonyEventBuilder.java │ │ └── TelephonyMetrics.java │ │ ├── package.html │ │ ├── sip │ │ ├── SipCallBase.java │ │ ├── SipCommandInterface.java │ │ ├── SipConnectionBase.java │ │ ├── SipPhone.java │ │ ├── SipPhoneBase.java │ │ └── SipPhoneFactory.java │ │ ├── test │ │ ├── ModelInterpreter.java │ │ ├── SimulatedCommands.java │ │ ├── SimulatedCommandsVerifier.java │ │ ├── SimulatedGsmCallState.java │ │ ├── SimulatedRadioControl.java │ │ ├── TestConferenceEventPackageParser.java │ │ └── package.html │ │ └── uicc │ │ ├── AdnRecord.aidl │ │ ├── AdnRecord.java │ │ ├── AdnRecordCache.java │ │ ├── AdnRecordLoader.java │ │ ├── CsimFileHandler.java │ │ ├── IccCardApplicationStatus.java │ │ ├── IccCardProxy.java │ │ ├── IccCardStatus.java │ │ ├── IccConstants.java │ │ ├── IccException.java │ │ ├── IccFileHandler.java │ │ ├── IccFileNotFound.java │ │ ├── IccFileTypeMismatch.java │ │ ├── IccIoResult.java │ │ ├── IccRecords.java │ │ ├── IccRefreshResponse.java │ │ ├── IccServiceTable.java │ │ ├── IccUtils.java │ │ ├── IccVmFixedException.java │ │ ├── IccVmNotSupportedException.java │ │ ├── IsimFileHandler.java │ │ ├── IsimRecords.java │ │ ├── IsimUiccRecords.java │ │ ├── README │ │ ├── RuimFileHandler.java │ │ ├── RuimRecords.java │ │ ├── SIMFileHandler.java │ │ ├── SIMRecords.java │ │ ├── SimPhoneBookAdnRecord.java │ │ ├── SimPhoneBookAdnRecordCache.java │ │ ├── SpnOverride.java │ │ ├── UiccCard.java │ │ ├── UiccCardApplication.java │ │ ├── UiccCarrierPrivilegeRules.java │ │ ├── UiccController.java │ │ ├── UiccPkcs15.java │ │ ├── UiccTlvData.java │ │ ├── UsimFileHandler.java │ │ ├── UsimServiceTable.java │ │ └── VoiceMailConstants.java │ └── google │ └── android │ └── mms │ ├── ContentType.java │ ├── InvalidHeaderValueException.java │ ├── MmsException.java │ ├── package.html │ ├── pdu │ ├── AcknowledgeInd.java │ ├── Base64.java │ ├── CharacterSets.java │ ├── DeliveryInd.java │ ├── EncodedStringValue.java │ ├── GenericPdu.java │ ├── MultimediaMessagePdu.java │ ├── NotificationInd.java │ ├── NotifyRespInd.java │ ├── PduBody.java │ ├── PduComposer.java │ ├── PduContentTypes.java │ ├── PduHeaders.java │ ├── PduParser.java │ ├── PduPart.java │ ├── PduPersister.java │ ├── QuotedPrintable.java │ ├── ReadOrigInd.java │ ├── ReadRecInd.java │ ├── RetrieveConf.java │ ├── SendConf.java │ ├── SendReq.java │ └── package.html │ └── util │ ├── AbstractCache.java │ ├── DownloadDrmHelper.java │ ├── DrmConvertSession.java │ ├── PduCache.java │ ├── PduCacheEntry.java │ ├── SqliteWrapper.java │ └── package.html ├── tests ├── Android.mk └── telephonytests │ ├── Android.mk │ ├── AndroidManifest.xml │ └── src │ ├── com │ └── android │ │ └── internal │ │ └── telephony │ │ ├── ATResponseParserTest.java │ │ ├── AdnRecordTest.java │ │ ├── CallManagerTest.java │ │ ├── CallStateExceptionTest.java │ │ ├── CarrierAppUtilsTest.java │ │ ├── ContextFixture.java │ │ ├── DefaultPhoneNotifierTest.java │ │ ├── FakeSmsContentProvider.java │ │ ├── GsmAlphabetTest.java │ │ ├── GsmCdmaCallTest.java │ │ ├── GsmCdmaCallTrackerTest.java │ │ ├── GsmCdmaConnectionTest.java │ │ ├── GsmCdmaPhoneTest.java │ │ ├── GsmSmsTest.java │ │ ├── IccServiceTableTest.java │ │ ├── ImsSMSDispatcherTest.java │ │ ├── InboundSmsTrackerTest.java │ │ ├── IntRangeManagerTest.java │ │ ├── MccTableTest.java │ │ ├── NeighboringCellInfoTest.java │ │ ├── PhoneFactoryTest.java │ │ ├── PhoneNumberUtilsTest.java │ │ ├── PhoneNumberWatcherTest.java │ │ ├── PhoneStateListenerTest.java │ │ ├── PhoneSubInfoControllerTest.java │ │ ├── PhoneSwitcherTest.java │ │ ├── SMSDispatcherTest.java.broken │ │ ├── ServiceStateTest.java │ │ ├── ServiceStateTrackerTest.java │ │ ├── SignalToneUtilTest.java │ │ ├── SimPhoneBookTest.java │ │ ├── SimSmsTest.java │ │ ├── SimUtilsTest.java │ │ ├── Sms7BitEncodingTranslatorTest.java │ │ ├── SmsMessageBodyTest.java │ │ ├── SmsNumberUtilsTest.java │ │ ├── SmsStorageMonitorTest.java │ │ ├── SmsUsageMonitorShortCodeTest.java │ │ ├── SubscriptionControllerTest.java │ │ ├── SubscriptionInfoTest.java │ │ ├── SubscriptionInfoUpdaterTest.java │ │ ├── SubscriptionMonitorTest.java │ │ ├── TelephonyComponentFactoryTest.java │ │ ├── TelephonyHistogramTest.java │ │ ├── TelephonyTest.java │ │ ├── TelephonyTestUtils.java │ │ ├── TestApplication.java │ │ ├── TestFixture.java │ │ ├── TestPhoneNotifier.java.broken │ │ ├── VisualVoicemailSmsFilterTest.java │ │ ├── VisualVoicemailSmsParserTest.java │ │ ├── VoLteServiceStateTest.java │ │ ├── Wap230WspContentTypeTest.java │ │ ├── WapPushOverSmsTest.java │ │ ├── cat │ │ └── CatServiceTest.java │ │ ├── cdma │ │ ├── CdmaInboundSmsHandlerTest.java │ │ ├── CdmaSmsCbTest.java │ │ ├── CdmaSmsDispatcherTest.java │ │ └── sms │ │ │ ├── BearerDataTest.java │ │ │ └── CdmaSmsTest.java │ │ ├── dataconnection │ │ ├── ApnContextTest.java │ │ ├── ApnSettingParameterizedTest.java │ │ ├── ApnSettingTest.java │ │ ├── DataCallResponseTest.java │ │ ├── DataConnectionTest.java │ │ ├── DataProfileTest.java │ │ ├── DcControllerTest.java │ │ ├── DcFailCauseTest.java │ │ ├── DcTrackerTest.java │ │ ├── RetryManagerTest.java │ │ └── TelephonyNetworkFactoryTest.java │ │ ├── gsm │ │ ├── GSMPhoneTest.java.broken │ │ ├── GSMTestHandler.java.broken │ │ ├── GsmCellBroadcastHandlerTest.java │ │ ├── GsmInboundSmsHandlerTest.java │ │ ├── GsmSmsCbTest.java │ │ ├── GsmSmsDispatcherTest.java │ │ ├── UsimDataDownloadCommands.java.broken │ │ ├── UsimDataDownloadTest.java.broken │ │ └── UsimServiceTableTest.java │ │ ├── imsphone │ │ ├── ImsCallTest.java │ │ ├── ImsExternalCallTrackerTest.java │ │ ├── ImsPhoneCallTest.java │ │ ├── ImsPhoneCallTrackerTest.java │ │ ├── ImsPhoneConnectionTest.java │ │ ├── ImsPhoneFactoryTest.java │ │ └── ImsPhoneTest.java │ │ ├── metrics │ │ ├── InProgressCallSessionTest.java │ │ ├── InProgressSmsSessionTest.java │ │ └── TelephonyMetricsTest.java │ │ ├── mocks │ │ ├── ConnectivityServiceMock.java │ │ ├── DcTrackerMock.java │ │ ├── PhoneMock.java │ │ ├── PhoneSwitcherMock.java │ │ ├── SubscriptionControllerMock.java │ │ ├── SubscriptionMonitorMock.java │ │ └── TelephonyRegistryMock.java │ │ └── uicc │ │ ├── IccCardStatusTest.java │ │ ├── IccPhoneBookInterfaceManagerTest.java │ │ ├── IccRecordsTest.java │ │ ├── IsimUiccRecordsTest.java │ │ ├── UiccCardApplicationTest.java │ │ ├── UiccCardTest.java │ │ └── UiccControllerTest.java │ └── java │ └── android │ └── telephony │ └── SmsMessageTest.java └── tools └── tdi /Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # enable this build only when platform library is available 16 | ifeq ($(TARGET_BUILD_JAVA_SUPPORT_LEVEL),platform) 17 | 18 | LOCAL_PATH := $(call my-dir) 19 | 20 | include $(CLEAR_VARS) 21 | 22 | LOCAL_AIDL_INCLUDES := $(LOCAL_PATH)/src/java 23 | LOCAL_SRC_FILES := $(call all-java-files-under, src/java) \ 24 | $(call all-Iaidl-files-under, src/java) \ 25 | $(call all-logtags-files-under, src/java) \ 26 | $(call all-proto-files-under, proto) 27 | 28 | LOCAL_JAVA_LIBRARIES := voip-common ims-common 29 | LOCAL_STATIC_JAVA_LIBRARIES := ims-ext-common 30 | 31 | ifneq ($(BOARD_RIL_CLASS),) 32 | LOCAL_SRC_FILES += $(call find-other-java-files,$(BOARD_RIL_CLASS)) 33 | endif 34 | 35 | LOCAL_MODULE_TAGS := optional 36 | LOCAL_MODULE := telephony-common 37 | LOCAL_PROTOC_OPTIMIZE_TYPE := nano 38 | LOCAL_PROTO_JAVA_OUTPUT_PARAMS := optional_field_style=accessors,store_unknown_fields=true,enum_style=java 39 | 40 | LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt 41 | LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk $(LOCAL_PATH)/jarjar-rules.txt 42 | 43 | ifeq ($(EMMA_INSTRUMENT_FRAMEWORK),true) 44 | LOCAL_EMMA_INSTRUMENT := true 45 | endif 46 | 47 | include $(BUILD_JAVA_LIBRARY) 48 | 49 | # Include subdirectory makefiles 50 | # ============================================================ 51 | include $(call all-makefiles-under,$(LOCAL_PATH)) 52 | 53 | endif # JAVA platform 54 | -------------------------------------------------------------------------------- /CleanSpec.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | # If you don't need to do a full clean build but would like to touch 17 | # a file or delete some intermediate files, add a clean step to the end 18 | # of the list. These steps will only be run once, if they haven't been 19 | # run before. 20 | # 21 | # E.g.: 22 | # $(call add-clean-step, touch -c external/sqlite/sqlite3.h) 23 | # $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates) 24 | # 25 | # Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with 26 | # files that are missing or have been moved. 27 | # 28 | # Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory. 29 | # Use $(OUT_DIR) to refer to the "out" directory. 30 | # 31 | # If you need to re-do something that's already mentioned, just copy 32 | # the command and add it to the bottom of the list. E.g., if a change 33 | # that you made last week required touching a file and a change you 34 | # made today requires touching the same file, just copy the old 35 | # touch step and add it to the end of the list. 36 | # 37 | # ************************************************ 38 | # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST 39 | # ************************************************ 40 | 41 | $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates) 42 | $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates) 43 | $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates) 44 | $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates) 45 | $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates) 46 | $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates) 47 | $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates) 48 | $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates) 49 | $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates) 50 | $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates) 51 | $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates) 52 | 53 | # ************************************************ 54 | # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST 55 | # ************************************************ 56 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | This package contains classes used to manage a DataConnection. 2 | 3 | A criticial aspect of this class is that most objects in this 4 | package run on the same thread except DataConnectionTracker 5 | This makes processing efficient as it minimizes context 6 | switching and it eliminates issues with multi-threading. 7 | 8 | This can be done because all actions are either asynchronous 9 | or are known to be non-blocking and fast. At this time only 10 | DcTesterDeactivateAll takes specific advantage of this 11 | single threading knowledge by using Dcc#mDcListAll so be 12 | very careful when making changes that break this assumption. 13 | 14 | A related change was in DataConnectionAc I added code that 15 | checks to see if the caller is on a different thread. If 16 | it is then the AsyncChannel#sendMessageSynchronously is 17 | used. If the caller is on the same thread then a getter 18 | is used. This allows the DCAC to be used from any thread 19 | and was required to fix a bug when Dcc called 20 | PhoneBase#notifyDataConnection which calls DCT#getLinkProperties 21 | and DCT#getLinkCapabilities which call Dcc all on the same 22 | thread. Without this change there was a dead lock when 23 | sendMessageSynchronously blocks. 24 | 25 | 26 | == Testing == 27 | 28 | The following are Intents that can be sent for testing pruproses on 29 | DEBUGGABLE builds (userdebug, eng) 30 | 31 | *) Causes bringUp and retry requests to fail for all DC's 32 | 33 | adb shell am broadcast -a com.android.internal.telephony.dataconnection.action_fail_bringup --ei counter 2 --ei fail_cause -3 34 | 35 | *) Causes all DC's to get torn down, simulating a temporary network outage: 36 | 37 | adb shell am broadcast -a com.android.internal.telephony.dataconnection.action_deactivate_all 38 | 39 | *) To simplify testing we also have detach and attach simulations below where {x} is gsm, cdma or sip 40 | 41 | adb shell am broadcast -a com.android.internal.telephony.{x}.action_detached 42 | adb shell am broadcast -a com.android.internal.telephony.{x}.action_attached 43 | 44 | 45 | == System properties for Testing == 46 | 47 | On debuggable builds (userdebug, eng) you can change additional 48 | settings through system properties. These properties can be set with 49 | "setprop" for the current boot, or added to local.prop to persist 50 | across boots. 51 | 52 | device# setprop key value 53 | 54 | device# echo "key=value" >> /data/local.prop 55 | device# chmod 644 /data/local.prop 56 | 57 | 58 | -- Retry configuration -- 59 | 60 | You can replace the connection retry configuration. For example, you 61 | could change it to perform 4 retries at 5 second intervals: 62 | 63 | device# setprop test.data_retry_config "5000,5000,5000" 64 | 65 | 66 | -- Roaming -- 67 | 68 | You can force the telephony stack to always assume that it's roaming 69 | to verify higher-level framework functionality: 70 | 71 | device# setprop telephony.test.forceRoaming true 72 | -------------------------------------------------------------------------------- /jarjar-rules.txt: -------------------------------------------------------------------------------- 1 | rule com.google.protobuf.nano.** com.android.framework.protobuf.nano.@1 2 | 3 | -------------------------------------------------------------------------------- /resources/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | LOCAL_PACKAGE_NAME := telresources 5 | LOCAL_CERTIFICATE := platform 6 | LOCAL_MODULE_TAGS := optional eng 7 | LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res 8 | include $(BUILD_PACKAGE) 9 | include $(call all-makefiles-under,$(LOCAL_PATH)) 10 | -------------------------------------------------------------------------------- /resources/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 30 | 31 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /resources/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 29 | 30 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/ATParseEx.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony; 18 | 19 | /** 20 | * {@hide} 21 | */ 22 | public class ATParseEx extends RuntimeException 23 | { 24 | public 25 | ATParseEx() 26 | { 27 | super(); 28 | } 29 | 30 | public 31 | ATParseEx(String s) 32 | { 33 | super(s); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/AsyncEmergencyContactNotifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License 15 | */ 16 | 17 | package com.android.internal.telephony; 18 | 19 | import android.content.Context; 20 | import android.os.AsyncTask; 21 | import android.provider.BlockedNumberContract; 22 | import android.telephony.Rlog; 23 | 24 | /** 25 | * An {@link AsyncTask} that notifies the Blocked number provider that emergency services were 26 | * contacted. See {@link BlockedNumberContract.SystemContract#notifyEmergencyContact(Context)} 27 | * for details. 28 | * {@hide} 29 | */ 30 | public class AsyncEmergencyContactNotifier extends AsyncTask { 31 | private static final String TAG = "AsyncEmergencyContactNotifier"; 32 | 33 | private final Context mContext; 34 | 35 | public AsyncEmergencyContactNotifier(Context context) { 36 | mContext = context; 37 | } 38 | 39 | @Override 40 | protected Void doInBackground(Void... params) { 41 | try { 42 | BlockedNumberContract.SystemContract.notifyEmergencyContact(mContext); 43 | } catch (Exception e) { 44 | Rlog.e(TAG, "Exception notifying emergency contact: " + e); 45 | } 46 | return null; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/BlockChecker.java: -------------------------------------------------------------------------------- 1 | package com.android.internal.telephony; 2 | 3 | import android.content.Context; 4 | import android.provider.BlockedNumberContract; 5 | import android.telephony.Rlog; 6 | 7 | /** 8 | * {@hide} Checks for blocked phone numbers against {@link BlockedNumberContract} 9 | */ 10 | public class BlockChecker { 11 | private static final String TAG = "BlockChecker"; 12 | private static final boolean VDBG = false; // STOPSHIP if true. 13 | 14 | /** 15 | * Returns {@code true} if {@code phoneNumber} is blocked. 16 | *

17 | * This method catches all underlying exceptions to ensure that this method never throws any 18 | * exception. 19 | */ 20 | public static boolean isBlocked(Context context, String phoneNumber) { 21 | boolean isBlocked = false; 22 | long startTimeNano = System.nanoTime(); 23 | 24 | try { 25 | if (BlockedNumberContract.SystemContract.shouldSystemBlockNumber( 26 | context, phoneNumber)) { 27 | Rlog.d(TAG, phoneNumber + " is blocked."); 28 | isBlocked = true; 29 | } 30 | } catch (Exception e) { 31 | Rlog.e(TAG, "Exception checking for blocked number: " + e); 32 | } 33 | 34 | int durationMillis = (int) ((System.nanoTime() - startTimeNano) / 1000000); 35 | if (durationMillis > 500 || VDBG) { 36 | Rlog.d(TAG, "Blocked number lookup took: " + durationMillis + " ms."); 37 | } 38 | return isBlocked; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/CallFailCause.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony; 18 | 19 | /** 20 | * Call fail causes from TS 24.008 . 21 | * These are mostly the cause codes we need to distinguish for the UI. 22 | * See 22.001 Annex F.4 for mapping of cause codes to local tones. 23 | * 24 | * CDMA call failure reasons are derived from the possible call failure scenarios described 25 | * in "CDMA IS2000 - Release A (C.S0005-A v6.0)" standard. 26 | * 27 | * {@hide} 28 | * 29 | */ 30 | public interface CallFailCause { 31 | // Unassigned/Unobtainable number 32 | int UNOBTAINABLE_NUMBER = 1; 33 | 34 | int NORMAL_CLEARING = 16; 35 | // Busy Tone 36 | int USER_BUSY = 17; 37 | 38 | // No Tone 39 | int NUMBER_CHANGED = 22; 40 | int STATUS_ENQUIRY = 30; 41 | int NORMAL_UNSPECIFIED = 31; 42 | 43 | // Congestion Tone 44 | int NO_CIRCUIT_AVAIL = 34; 45 | int TEMPORARY_FAILURE = 41; 46 | int SWITCHING_CONGESTION = 42; 47 | int CHANNEL_NOT_AVAIL = 44; 48 | int QOS_NOT_AVAIL = 49; 49 | int BEARER_NOT_AVAIL = 58; 50 | 51 | // others 52 | int ACM_LIMIT_EXCEEDED = 68; 53 | int CALL_BARRED = 240; 54 | int FDN_BLOCKED = 241; 55 | 56 | // Stk Call Control 57 | int DIAL_MODIFIED_TO_USSD = 244; 58 | int DIAL_MODIFIED_TO_SS = 245; 59 | int DIAL_MODIFIED_TO_DIAL = 246; 60 | 61 | int CDMA_LOCKED_UNTIL_POWER_CYCLE = 1000; 62 | int CDMA_DROP = 1001; 63 | int CDMA_INTERCEPT = 1002; 64 | int CDMA_REORDER = 1003; 65 | int CDMA_SO_REJECT = 1004; 66 | int CDMA_RETRY_ORDER = 1005; 67 | int CDMA_ACCESS_FAILURE = 1006; 68 | int CDMA_PREEMPTED = 1007; 69 | 70 | // For non-emergency number dialed while in emergency callback mode. 71 | int CDMA_NOT_EMERGENCY = 1008; 72 | 73 | // Access Blocked by CDMA Network. 74 | int CDMA_ACCESS_BLOCKED = 1009; 75 | 76 | int ERROR_UNSPECIFIED = 0xffff; 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/CallForwardInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony; 18 | 19 | /** 20 | * See also RIL_CallForwardInfo in include/telephony/ril.h 21 | * 22 | * {@hide} 23 | */ 24 | public class CallForwardInfo { 25 | public int status; /*1 = active, 0 = not active */ 26 | public int reason; /* from TS 27.007 7.11 "reason" */ 27 | public int serviceClass; /* Saum of CommandsInterface.SERVICE_CLASS */ 28 | public int toa; /* "type" from TS 27.007 7.11 */ 29 | public String number; /* "number" from TS 27.007 7.11 */ 30 | public int timeSeconds; /* for CF no reply only */ 31 | 32 | @Override 33 | public String toString() { 34 | return super.toString() + (status == 0 ? " not active " : " active ") 35 | + " reason: " + reason 36 | + " serviceClass: " + serviceClass + " " + timeSeconds + " seconds"; 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/CallStateException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony; 18 | 19 | /** 20 | * {@hide} 21 | */ 22 | public class CallStateException extends Exception 23 | { 24 | private int mError = ERROR_INVALID; 25 | 26 | /** The error code is not valid (Not received a disconnect cause) */ 27 | public static final int ERROR_INVALID = -1; 28 | 29 | public static final int ERROR_DISCONNECTED = 1; 30 | 31 | public 32 | CallStateException() 33 | { 34 | } 35 | 36 | public 37 | CallStateException(String string) 38 | { 39 | super(string); 40 | } 41 | 42 | public 43 | CallStateException(int error, String string) 44 | { 45 | super(string); 46 | mError = error; 47 | } 48 | 49 | public int getError() { 50 | return mError; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/DebugService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony; 18 | 19 | import android.telephony.Rlog; 20 | import android.text.TextUtils; 21 | 22 | import com.android.internal.telephony.metrics.TelephonyMetrics; 23 | 24 | import java.io.FileDescriptor; 25 | import java.io.PrintWriter; 26 | 27 | /** 28 | * A debug service that will dump telephony's state 29 | * 30 | * Currently this "Service" has a proxy in the phone app 31 | * com.android.phone.TelephonyDebugService which actually 32 | * invokes the dump method. 33 | */ 34 | public class DebugService { 35 | private static String TAG = "DebugService"; 36 | 37 | /** Constructor */ 38 | public DebugService() { 39 | log("DebugService:"); 40 | } 41 | 42 | /** 43 | * Dump the state of various objects, add calls to other objects as desired. 44 | */ 45 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { 46 | if (args != null && args.length > 0) { 47 | if (TextUtils.equals(args[0], "--metrics") || 48 | TextUtils.equals(args[0], "--metricsproto")) 49 | { 50 | log("Collecting telephony metrics.."); 51 | TelephonyMetrics.getInstance().dump(fd, pw, args); 52 | return; 53 | } 54 | } 55 | log("Dump telephony."); 56 | PhoneFactory.dump(fd, pw, args); 57 | } 58 | 59 | private static void log(String s) { 60 | Rlog.d(TAG, "DebugService " + s); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/LastCallFailCause.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony; 18 | 19 | public class LastCallFailCause { 20 | public int causeCode; 21 | public String vendorCause; 22 | 23 | @Override 24 | public String toString() { 25 | return super.toString() 26 | + " causeCode: " + causeCode 27 | + " vendorCause: " + vendorCause; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/MmiCode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony; 18 | 19 | /** 20 | * {@hide} 21 | */ 22 | public interface MmiCode 23 | { 24 | /** 25 | * {@hide} 26 | */ 27 | public enum State { 28 | PENDING, 29 | CANCELLED, 30 | COMPLETE, 31 | FAILED 32 | } 33 | 34 | 35 | /** 36 | * @return Current state of MmiCode request 37 | */ 38 | public State getState(); 39 | 40 | /** 41 | * @return Localized message for UI display, valid only in COMPLETE 42 | * or FAILED states. null otherwise 43 | */ 44 | 45 | public CharSequence getMessage(); 46 | 47 | /** 48 | * @return Phone associated with the MMI/USSD message 49 | */ 50 | public Phone getPhone(); 51 | 52 | /** 53 | * Cancels pending MMI request. 54 | * State becomes CANCELLED unless already COMPLETE or FAILED 55 | */ 56 | public void cancel(); 57 | 58 | /** 59 | * @return true if the network response is a REQUEST for more user input. 60 | */ 61 | public boolean isUssdRequest(); 62 | 63 | /** 64 | * @return true if an outstanding request can be canceled. 65 | */ 66 | public boolean isCancelable(); 67 | 68 | /** 69 | * @return true if the Service Code is PIN/PIN2/PUK/PUK2-related 70 | */ 71 | public boolean isPinPukCommand(); 72 | 73 | /** 74 | * Process a MMI code or short code...anything that isn't a dialing number 75 | */ 76 | void processCode() throws CallStateException; 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/PhoneNotifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony; 18 | 19 | import android.telephony.CellInfo; 20 | import android.telephony.VoLteServiceState; 21 | 22 | import java.util.List; 23 | 24 | /** 25 | * {@hide} 26 | */ 27 | public interface PhoneNotifier { 28 | 29 | public void notifyPhoneState(Phone sender); 30 | 31 | public void notifyServiceState(Phone sender); 32 | 33 | public void notifyCellLocation(Phone sender); 34 | 35 | public void notifySignalStrength(Phone sender); 36 | 37 | public void notifyMessageWaitingChanged(Phone sender); 38 | 39 | public void notifyCallForwardingChanged(Phone sender); 40 | 41 | /** TODO - reason should never be null */ 42 | public void notifyDataConnection(Phone sender, String reason, String apnType, 43 | PhoneConstants.DataState state); 44 | 45 | public void notifyDataConnectionFailed(Phone sender, String reason, String apnType); 46 | 47 | public void notifyDataActivity(Phone sender); 48 | 49 | public void notifyOtaspChanged(Phone sender, int otaspMode); 50 | 51 | public void notifyCellInfo(Phone sender, List cellInfo); 52 | 53 | public void notifyPreciseCallState(Phone sender); 54 | 55 | public void notifyDisconnectCause(int cause, int preciseCause); 56 | 57 | public void notifyPreciseDataConnectionFailed(Phone sender, String reason, String apnType, 58 | String apn, String failCause); 59 | 60 | public void notifyVoLteServiceStateChanged(Phone sender, VoLteServiceState lteState); 61 | 62 | public void notifyOemHookRawEventForSubscriber(int subId, byte[] rawData); 63 | } 64 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/SmsAddress.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony; 18 | 19 | public abstract class SmsAddress { 20 | // From TS 23.040 9.1.2.5 and TS 24.008 table 10.5.118 21 | // and C.S0005-D table 2.7.1.3.2.4-2 22 | public static final int TON_UNKNOWN = 0; 23 | public static final int TON_INTERNATIONAL = 1; 24 | public static final int TON_NATIONAL = 2; 25 | public static final int TON_NETWORK = 3; 26 | public static final int TON_SUBSCRIBER = 4; 27 | public static final int TON_ALPHANUMERIC = 5; 28 | public static final int TON_ABBREVIATED = 6; 29 | 30 | public int ton; 31 | public String address; 32 | public byte[] origBytes; 33 | 34 | /** 35 | * Returns the address of the SMS message in String form or null if unavailable 36 | */ 37 | public String getAddressString() { 38 | return address; 39 | } 40 | 41 | /** 42 | * Returns true if this is an alphanumeric address 43 | */ 44 | public boolean isAlphanumeric() { 45 | return ton == TON_ALPHANUMERIC; 46 | } 47 | 48 | /** 49 | * Returns true if this is a network address 50 | */ 51 | public boolean isNetworkSpecific() { 52 | return ton == TON_NETWORK; 53 | } 54 | 55 | public boolean couldBeEmailGateway() { 56 | // Some carriers seems to send email gateway messages in this form: 57 | // from: an UNKNOWN TON, 3 or 4 digits long, beginning with a 5 58 | // PID: 0x00, Data coding scheme 0x03 59 | // So we just attempt to treat any message from an address length <= 4 60 | // as an email gateway 61 | 62 | return address.length() <= 4; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/SmsResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony; 18 | 19 | /** 20 | * Object returned by the RIL upon successful completion of sendSMS. 21 | * Contains message reference and ackPdu. 22 | * 23 | */ 24 | public class SmsResponse { 25 | /** Message reference of the just-sent SMS. */ 26 | int mMessageRef; 27 | /** ackPdu for the just-sent SMS. */ 28 | String mAckPdu; 29 | /** 30 | * errorCode: See 3GPP 27.005, 3.2.5 for GSM/UMTS, 31 | * 3GPP2 N.S0005 (IS-41C) Table 171 for CDMA, -1 if unknown or not applicable. 32 | */ 33 | public int mErrorCode; 34 | 35 | public SmsResponse(int messageRef, String ackPdu, int errorCode) { 36 | mMessageRef = messageRef; 37 | mAckPdu = ackPdu; 38 | mErrorCode = errorCode; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | String ret = "{ mMessageRef = " + mMessageRef 44 | + ", mErrorCode = " + mErrorCode 45 | + ", mAckPdu = " + mAckPdu 46 | + "}"; 47 | return ret; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/UUSInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony; 18 | 19 | public class UUSInfo { 20 | 21 | /* 22 | * User-to-User signaling Info activation types derived from 3GPP 23.087 23 | * v8.0 24 | */ 25 | 26 | public static final int UUS_TYPE1_IMPLICIT = 0; 27 | 28 | public static final int UUS_TYPE1_REQUIRED = 1; 29 | 30 | public static final int UUS_TYPE1_NOT_REQUIRED = 2; 31 | 32 | public static final int UUS_TYPE2_REQUIRED = 3; 33 | 34 | public static final int UUS_TYPE2_NOT_REQUIRED = 4; 35 | 36 | public static final int UUS_TYPE3_REQUIRED = 5; 37 | 38 | public static final int UUS_TYPE3_NOT_REQUIRED = 6; 39 | 40 | /* 41 | * User-to-User Signaling Information data coding schemes. Possible values 42 | * for Octet 3 (Protocol Discriminator field) in the UUIE. The values have 43 | * been specified in section 10.5.4.25 of 3GPP TS 24.008 44 | */ 45 | 46 | public static final int UUS_DCS_USP = 0; /* User specified protocol */ 47 | 48 | public static final int UUS_DCS_OSIHLP = 1; /* OSI higher layer protocol */ 49 | 50 | public static final int UUS_DCS_X244 = 2; /* X.244 */ 51 | 52 | public static final int UUS_DCS_RMCF = 3; /* 53 | * Reserved for system management 54 | * convergence function 55 | */ 56 | 57 | public static final int UUS_DCS_IA5c = 4; /* IA5 characters */ 58 | 59 | private int mUusType; 60 | 61 | private int mUusDcs; 62 | 63 | private byte[] mUusData; 64 | 65 | public UUSInfo() { 66 | mUusType = UUS_TYPE1_IMPLICIT; 67 | mUusDcs = UUS_DCS_IA5c; 68 | mUusData = null; 69 | } 70 | 71 | public UUSInfo(int uusType, int uusDcs, byte[] uusData) { 72 | mUusType = uusType; 73 | mUusDcs = uusDcs; 74 | mUusData = uusData; 75 | } 76 | 77 | public int getDcs() { 78 | return mUusDcs; 79 | } 80 | 81 | public void setDcs(int uusDcs) { 82 | mUusDcs = uusDcs; 83 | } 84 | 85 | public int getType() { 86 | return mUusType; 87 | } 88 | 89 | public void setType(int uusType) { 90 | mUusType = uusType; 91 | } 92 | 93 | public byte[] getUserData() { 94 | return mUusData; 95 | } 96 | 97 | public void setUserData(byte[] uusData) { 98 | mUusData = uusData; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/WapPushManagerParams.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony; 18 | 19 | /** 20 | * WapPushManager constant value definitions 21 | */ 22 | public class WapPushManagerParams { 23 | /** 24 | * Application type activity 25 | */ 26 | public static final int APP_TYPE_ACTIVITY = 0; 27 | 28 | /** 29 | * Application type service 30 | */ 31 | public static final int APP_TYPE_SERVICE = 1; 32 | 33 | /** 34 | * Process Message return value 35 | * Message is handled 36 | */ 37 | public static final int MESSAGE_HANDLED = 0x1; 38 | 39 | /** 40 | * Process Message return value 41 | * Application ID or content type was not found in the application ID table 42 | */ 43 | public static final int APP_QUERY_FAILED = 0x2; 44 | 45 | /** 46 | * Process Message return value 47 | * Receiver application signature check failed 48 | */ 49 | public static final int SIGNATURE_NO_MATCH = 0x4; 50 | 51 | /** 52 | * Process Message return value 53 | * Receiver application was not found 54 | */ 55 | public static final int INVALID_RECEIVER_NAME = 0x8; 56 | 57 | /** 58 | * Process Message return value 59 | * Unknown exception 60 | */ 61 | public static final int EXCEPTION_CAUGHT = 0x10; 62 | 63 | /** 64 | * Process Message return value 65 | * Need further processing after WapPushManager message processing 66 | */ 67 | public static final int FURTHER_PROCESSING = 0x8000; 68 | 69 | } 70 | 71 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/cat/CallControlResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.cat; 18 | 19 | 20 | public enum CallControlResult { 21 | 22 | CALL_CONTROL_NO_CONTROL(0x00), 23 | CALL_CONTROL_ALLOWED_NO_MOD(0x01), 24 | CALL_CONTROL_NOT_ALLOWED(0x02), 25 | CALL_CONTROL_ALLOWED_WITH_MOD(0x03); 26 | private int mValue; 27 | 28 | CallControlResult(int value) { 29 | mValue = value; 30 | } 31 | 32 | public static CallControlResult fromInt(int value) { 33 | for (CallControlResult e : CallControlResult.values()) { 34 | if (e.mValue == value) { 35 | return e; 36 | } 37 | } 38 | return null; 39 | } 40 | 41 | public int value() { 42 | return mValue; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/cat/CatException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.cat; 18 | 19 | import android.util.AndroidException; 20 | 21 | 22 | /** 23 | * Base class for all the exceptions in CAT service. 24 | * 25 | * {@hide} 26 | */ 27 | class CatException extends AndroidException { 28 | public CatException() { 29 | super(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/cat/CatLog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.cat; 18 | 19 | import android.telephony.Rlog; 20 | 21 | public abstract class CatLog { 22 | static final boolean DEBUG = true; 23 | 24 | public static void d(Object caller, String msg) { 25 | if (!DEBUG) { 26 | return; 27 | } 28 | 29 | String className = caller.getClass().getName(); 30 | Rlog.d("CAT", className.substring(className.lastIndexOf('.') + 1) + ": " 31 | + msg); 32 | } 33 | 34 | public static void d(String caller, String msg) { 35 | if (!DEBUG) { 36 | return; 37 | } 38 | 39 | Rlog.d("CAT", caller + ": " + msg); 40 | } 41 | public static void e(Object caller, String msg) { 42 | String className = caller.getClass().getName(); 43 | Rlog.e("CAT", className.substring(className.lastIndexOf('.') + 1) + ": " 44 | + msg); 45 | } 46 | 47 | public static void e(String caller, String msg) { 48 | Rlog.e("CAT", caller + ": " + msg); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/cat/CatResponseMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.cat; 18 | 19 | public class CatResponseMessage { 20 | CommandDetails mCmdDet = null; 21 | ResultCode mResCode = ResultCode.OK; 22 | int mUsersMenuSelection = 0; 23 | String mUsersInput = null; 24 | boolean mUsersYesNoSelection = false; 25 | boolean mUsersConfirm = false; 26 | boolean mIncludeAdditionalInfo = false; 27 | int mAdditionalInfo = 0; 28 | int mEventValue = -1; 29 | byte[] mAddedInfo = null; 30 | 31 | public CatResponseMessage(CatCmdMessage cmdMsg) { 32 | mCmdDet = cmdMsg.mCmdDet; 33 | } 34 | 35 | public void setResultCode(ResultCode resCode) { 36 | mResCode = resCode; 37 | } 38 | 39 | public void setMenuSelection(int selection) { 40 | mUsersMenuSelection = selection; 41 | } 42 | 43 | public void setInput(String input) { 44 | mUsersInput = input; 45 | } 46 | 47 | public void setEventDownload(int event, byte[] addedInfo) { 48 | this.mEventValue = event; 49 | this.mAddedInfo = addedInfo; 50 | } 51 | 52 | public void setYesNo(boolean yesNo) { 53 | mUsersYesNoSelection = yesNo; 54 | } 55 | 56 | public void setConfirmation(boolean confirm) { 57 | mUsersConfirm = confirm; 58 | } 59 | 60 | public void setAdditionalInfo(int info) { 61 | mIncludeAdditionalInfo = true; 62 | mAdditionalInfo = info; 63 | } 64 | 65 | CommandDetails getCmdDetails() { 66 | return mCmdDet; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/cat/ComprehensionTlvTag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.cat; 18 | 19 | /** 20 | * Enumeration for representing the tag value of COMPREHENSION-TLV objects. If 21 | * you want to get the actual value, call {@link #value() value} method. 22 | * 23 | * {@hide} 24 | */ 25 | public enum ComprehensionTlvTag { 26 | COMMAND_DETAILS(0x01), 27 | DEVICE_IDENTITIES(0x02), 28 | RESULT(0x03), 29 | DURATION(0x04), 30 | ALPHA_ID(0x05), 31 | ADDRESS(0x06), 32 | USSD_STRING(0x0a), 33 | SMS_TPDU(0x0b), 34 | TEXT_STRING(0x0d), 35 | TONE(0x0e), 36 | ITEM(0x0f), 37 | ITEM_ID(0x10), 38 | RESPONSE_LENGTH(0x11), 39 | FILE_LIST(0x12), 40 | HELP_REQUEST(0x15), 41 | DEFAULT_TEXT(0x17), 42 | EVENT_LIST(0x19), 43 | ICON_ID(0x1e), 44 | ITEM_ICON_ID_LIST(0x1f), 45 | IMMEDIATE_RESPONSE(0x2b), 46 | LANGUAGE(0x2d), 47 | URL(0x31), 48 | BROWSER_TERMINATION_CAUSE(0x34), 49 | TEXT_ATTRIBUTE(0x50), 50 | ACTIVATE_DESCRIPTOR(0x7b); 51 | 52 | private int mValue; 53 | 54 | ComprehensionTlvTag(int value) { 55 | mValue = value; 56 | } 57 | 58 | /** 59 | * Returns the actual value of this COMPREHENSION-TLV object. 60 | * 61 | * @return Actual tag value of this object 62 | */ 63 | public int value() { 64 | return mValue; 65 | } 66 | 67 | public static ComprehensionTlvTag fromInt(int value) { 68 | for (ComprehensionTlvTag e : ComprehensionTlvTag.values()) { 69 | if (e.mValue == value) { 70 | return e; 71 | } 72 | } 73 | return null; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/cat/Duration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.cat; 18 | 19 | import android.os.Parcel; 20 | import android.os.Parcelable; 21 | 22 | 23 | /** 24 | * Class for representing "Duration" object for CAT. 25 | * 26 | * {@hide} 27 | */ 28 | public class Duration implements Parcelable { 29 | public int timeInterval; 30 | public TimeUnit timeUnit; 31 | 32 | public enum TimeUnit { 33 | MINUTE(0x00), 34 | SECOND(0x01), 35 | TENTH_SECOND(0x02); 36 | 37 | private int mValue; 38 | 39 | TimeUnit(int value) { 40 | mValue = value; 41 | } 42 | 43 | public int value() { 44 | return mValue; 45 | } 46 | } 47 | 48 | /** 49 | * @param timeInterval Between 1 and 255 inclusive. 50 | */ 51 | public Duration(int timeInterval, TimeUnit timeUnit) { 52 | this.timeInterval = timeInterval; 53 | this.timeUnit = timeUnit; 54 | } 55 | 56 | private Duration(Parcel in) { 57 | timeInterval = in.readInt(); 58 | timeUnit = TimeUnit.values()[in.readInt()]; 59 | } 60 | 61 | @Override 62 | public void writeToParcel(Parcel dest, int flags) { 63 | dest.writeInt(timeInterval); 64 | dest.writeInt(timeUnit.ordinal()); 65 | } 66 | 67 | @Override 68 | public int describeContents() { 69 | return 0; 70 | } 71 | 72 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { 73 | @Override 74 | public Duration createFromParcel(Parcel in) { 75 | return new Duration(in); 76 | } 77 | 78 | @Override 79 | public Duration[] newArray(int size) { 80 | return new Duration[size]; 81 | } 82 | }; 83 | } 84 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/cat/FontSize.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.cat; 18 | 19 | 20 | /** 21 | * Enumeration for representing text font size. 22 | * 23 | * {@hide} 24 | */ 25 | public enum FontSize { 26 | NORMAL(0x0), 27 | LARGE(0x1), 28 | SMALL(0x2); 29 | 30 | private int mValue; 31 | 32 | FontSize(int value) { 33 | mValue = value; 34 | } 35 | 36 | /** 37 | * Create a FontSize object. 38 | * @param value Integer value to be converted to a FontSize object. 39 | * @return FontSize object whose value is {@code value}. If no 40 | * FontSize object has that value, null is returned. 41 | */ 42 | public static FontSize fromInt(int value) { 43 | for (FontSize e : FontSize.values()) { 44 | if (e.mValue == value) { 45 | return e; 46 | } 47 | } 48 | return null; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/cat/ImageDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.cat; 18 | 19 | /** 20 | * {@hide} 21 | */ 22 | public class ImageDescriptor { 23 | // members 24 | int mWidth; 25 | int mHeight; 26 | int mCodingScheme; 27 | int mImageId; 28 | int mHighOffset; 29 | int mLowOffset; 30 | int mLength; 31 | 32 | // constants 33 | static final int CODING_SCHEME_BASIC = 0x11; 34 | static final int CODING_SCHEME_COLOUR = 0x21; 35 | 36 | // public static final int ID_LENGTH = 9; 37 | // ID_LENGTH substituted by IccFileHandlerBase.GET_RESPONSE_EF_IMG_SIZE_BYTES 38 | 39 | ImageDescriptor() { 40 | mWidth = 0; 41 | mHeight = 0; 42 | mCodingScheme = 0; 43 | mImageId = 0; 44 | mHighOffset = 0; 45 | mLowOffset = 0; 46 | mLength = 0; 47 | } 48 | 49 | /** 50 | * Extract descriptor information about image instance. 51 | * 52 | * @param rawData 53 | * @param valueIndex 54 | * @return ImageDescriptor 55 | */ 56 | static ImageDescriptor parse(byte[] rawData, int valueIndex) { 57 | ImageDescriptor d = new ImageDescriptor(); 58 | try { 59 | d.mWidth = rawData[valueIndex++] & 0xff; 60 | d.mHeight = rawData[valueIndex++] & 0xff; 61 | d.mCodingScheme = rawData[valueIndex++] & 0xff; 62 | 63 | // parse image id 64 | d.mImageId = (rawData[valueIndex++] & 0xff) << 8; 65 | d.mImageId |= rawData[valueIndex++] & 0xff; 66 | // parse offset 67 | d.mHighOffset = (rawData[valueIndex++] & 0xff); // high byte offset 68 | d.mLowOffset = rawData[valueIndex++] & 0xff; // low byte offset 69 | 70 | d.mLength = ((rawData[valueIndex++] & 0xff) << 8 | (rawData[valueIndex++] & 0xff)); 71 | CatLog.d("ImageDescriptor", "parse; Descriptor : " + d.mWidth + ", " + d.mHeight + 72 | ", " + d.mCodingScheme + ", 0x" + Integer.toHexString(d.mImageId) + ", " + 73 | d.mHighOffset + ", " + d.mLowOffset + ", " + d.mLength); 74 | } catch (IndexOutOfBoundsException e) { 75 | CatLog.d("ImageDescriptor", "parse; failed parsing image descriptor"); 76 | d = null; 77 | } 78 | return d; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/cat/Input.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.cat; 18 | 19 | import android.graphics.Bitmap; 20 | import android.os.Parcel; 21 | import android.os.Parcelable; 22 | 23 | /** 24 | * Container class for CAT GET INPUT, GET IN KEY commands parameters. 25 | * 26 | */ 27 | public class Input implements Parcelable { 28 | public String text; 29 | public String defaultText; 30 | public Bitmap icon; 31 | public int minLen; 32 | public int maxLen; 33 | public boolean ucs2; 34 | public boolean packed; 35 | public boolean digitOnly; 36 | public boolean echo; 37 | public boolean yesNo; 38 | public boolean helpAvailable; 39 | public Duration duration; 40 | 41 | Input() { 42 | text = ""; 43 | defaultText = null; 44 | icon = null; 45 | minLen = 0; 46 | maxLen = 1; 47 | ucs2 = false; 48 | packed = false; 49 | digitOnly = false; 50 | echo = false; 51 | yesNo = false; 52 | helpAvailable = false; 53 | duration = null; 54 | } 55 | 56 | private Input(Parcel in) { 57 | text = in.readString(); 58 | defaultText = in.readString(); 59 | icon = in.readParcelable(null); 60 | minLen = in.readInt(); 61 | maxLen = in.readInt(); 62 | ucs2 = in.readInt() == 1 ? true : false; 63 | packed = in.readInt() == 1 ? true : false; 64 | digitOnly = in.readInt() == 1 ? true : false; 65 | echo = in.readInt() == 1 ? true : false; 66 | yesNo = in.readInt() == 1 ? true : false; 67 | helpAvailable = in.readInt() == 1 ? true : false; 68 | duration = in.readParcelable(null); 69 | } 70 | 71 | @Override 72 | public int describeContents() { 73 | return 0; 74 | } 75 | 76 | @Override 77 | public void writeToParcel(Parcel dest, int flags) { 78 | dest.writeString(text); 79 | dest.writeString(defaultText); 80 | dest.writeParcelable(icon, 0); 81 | dest.writeInt(minLen); 82 | dest.writeInt(maxLen); 83 | dest.writeInt(ucs2 ? 1 : 0); 84 | dest.writeInt(packed ? 1 : 0); 85 | dest.writeInt(digitOnly ? 1 : 0); 86 | dest.writeInt(echo ? 1 : 0); 87 | dest.writeInt(yesNo ? 1 : 0); 88 | dest.writeInt(helpAvailable ? 1 : 0); 89 | dest.writeParcelable(duration, 0); 90 | } 91 | 92 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { 93 | @Override 94 | public Input createFromParcel(Parcel in) { 95 | return new Input(in); 96 | } 97 | 98 | @Override 99 | public Input[] newArray(int size) { 100 | return new Input[size]; 101 | } 102 | }; 103 | 104 | boolean setIcon(Bitmap Icon) { return true; } 105 | } -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/cat/Item.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.cat; 18 | 19 | import android.graphics.Bitmap; 20 | import android.os.Parcel; 21 | import android.os.Parcelable; 22 | 23 | /** 24 | * Represents an Item COMPREHENSION-TLV object. 25 | * 26 | * {@hide} 27 | */ 28 | public class Item implements Parcelable { 29 | /** Identifier of the item. */ 30 | public int id; 31 | /** Text string of the item. */ 32 | public String text; 33 | /** Icon of the item */ 34 | public Bitmap icon; 35 | 36 | public Item(int id, String text) { 37 | this(id, text, null); 38 | } 39 | 40 | public Item(int id, String text, Bitmap icon) { 41 | this.id = id; 42 | this.text = text; 43 | this.icon = icon; 44 | } 45 | 46 | public Item(Parcel in) { 47 | id = in.readInt(); 48 | text = in.readString(); 49 | icon = in.readParcelable(null); 50 | } 51 | 52 | @Override 53 | public int describeContents() { 54 | return 0; 55 | } 56 | 57 | @Override 58 | public void writeToParcel(Parcel dest, int flags) { 59 | dest.writeInt(id); 60 | dest.writeString(text); 61 | dest.writeParcelable(icon, flags); 62 | } 63 | 64 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { 65 | @Override 66 | public Item createFromParcel(Parcel in) { 67 | return new Item(in); 68 | } 69 | 70 | @Override 71 | public Item[] newArray(int size) { 72 | return new Item[size]; 73 | } 74 | }; 75 | 76 | @Override 77 | public String toString() { 78 | return text; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/cat/LaunchBrowserMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.cat; 18 | 19 | 20 | /** 21 | * Browser launch mode for LAUNCH BROWSER proactive command. 22 | * 23 | * {@hide} 24 | */ 25 | public enum LaunchBrowserMode { 26 | /** Launch browser if not already launched. */ 27 | LAUNCH_IF_NOT_ALREADY_LAUNCHED, 28 | /** 29 | * Use the existing browser (the browser shall not use the active existing 30 | * secured session). 31 | */ 32 | USE_EXISTING_BROWSER, 33 | /** Close the existing browser session and launch new browser session. */ 34 | LAUNCH_NEW_BROWSER; 35 | } 36 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/cat/PresentationType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.cat; 18 | 19 | 20 | /** 21 | * Presentation types for SELECT TYPE proactive command. 22 | * 23 | * {@hide} 24 | */ 25 | public enum PresentationType { 26 | /** Presentation type is not specified */ 27 | NOT_SPECIFIED, 28 | /** Presentation as a choice of data values */ 29 | DATA_VALUES, 30 | /** Presentation as a choice of navigation options */ 31 | NAVIGATION_OPTIONS; 32 | } 33 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/cat/ResultException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.cat; 18 | 19 | 20 | /** 21 | * Class for errors in the Result object. 22 | * 23 | * {@hide} 24 | */ 25 | public class ResultException extends CatException { 26 | private ResultCode mResult; 27 | private int mAdditionalInfo; 28 | private String mExplanation; 29 | 30 | public ResultException(ResultCode result) { 31 | super(); 32 | 33 | // ETSI TS 102 223, 8.12 -- For the general results '20', '21', '26', 34 | // '38', '39', '3A', '3C', and '3D', it is mandatory for the terminal 35 | // to provide a specific cause value as additional information. 36 | switch (result) { 37 | case TERMINAL_CRNTLY_UNABLE_TO_PROCESS: // 0x20 38 | case NETWORK_CRNTLY_UNABLE_TO_PROCESS: // 0x21 39 | case LAUNCH_BROWSER_ERROR: // 0x26 40 | case MULTI_CARDS_CMD_ERROR: // 0x38 41 | case USIM_CALL_CONTROL_PERMANENT: // 0x39 42 | case BIP_ERROR: // 0x3a 43 | case FRAMES_ERROR: // 0x3c 44 | case MMS_ERROR: // 0x3d 45 | throw new AssertionError( 46 | "For result code, " + result + 47 | ", additional information must be given!"); 48 | default: 49 | break; 50 | } 51 | 52 | mResult = result; 53 | mAdditionalInfo = -1; 54 | mExplanation = ""; 55 | } 56 | 57 | public ResultException(ResultCode result, String explanation) { 58 | this(result); 59 | mExplanation = explanation; 60 | } 61 | 62 | public ResultException(ResultCode result, int additionalInfo) { 63 | this(result); 64 | 65 | if (additionalInfo < 0) { 66 | throw new AssertionError( 67 | "Additional info must be greater than zero!"); 68 | } 69 | 70 | mAdditionalInfo = additionalInfo; 71 | } 72 | 73 | public ResultException(ResultCode result, int additionalInfo, String explanation) { 74 | this(result, additionalInfo); 75 | mExplanation = explanation; 76 | } 77 | 78 | public ResultCode result() { 79 | return mResult; 80 | } 81 | 82 | public boolean hasAdditionalInfo() { 83 | return mAdditionalInfo >= 0; 84 | } 85 | 86 | public int additionalInfo() { 87 | return mAdditionalInfo; 88 | } 89 | 90 | public String explanation() { 91 | return mExplanation; 92 | } 93 | 94 | @Override 95 | public String toString() { 96 | return "result=" + mResult + " additionalInfo=" + mAdditionalInfo + 97 | " explantion=" + mExplanation; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/cat/TextAlignment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.cat; 18 | 19 | 20 | /** 21 | * Enumeration for representing text alignment. 22 | * 23 | * {@hide} 24 | */ 25 | public enum TextAlignment { 26 | LEFT(0x0), 27 | CENTER(0x1), 28 | RIGHT(0x2), 29 | /** Language dependent (default) */ 30 | DEFAULT(0x3); 31 | 32 | private int mValue; 33 | 34 | TextAlignment(int value) { 35 | mValue = value; 36 | } 37 | 38 | /** 39 | * Create a TextAlignment object. 40 | * @param value Integer value to be converted to a TextAlignment object. 41 | * @return TextAlignment object whose value is {@code value}. If no 42 | * TextAlignment object has that value, null is returned. 43 | */ 44 | public static TextAlignment fromInt(int value) { 45 | for (TextAlignment e : TextAlignment.values()) { 46 | if (e.mValue == value) { 47 | return e; 48 | } 49 | } 50 | return null; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/cat/TextAttribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.cat; 18 | 19 | 20 | /** 21 | * Class for representing text attributes for SIM Toolkit. 22 | * 23 | * {@hide} 24 | */ 25 | public class TextAttribute { 26 | public int start; 27 | public int length; 28 | public TextAlignment align; 29 | public FontSize size; 30 | public boolean bold; 31 | public boolean italic; 32 | public boolean underlined; 33 | public boolean strikeThrough; 34 | public TextColor color; 35 | 36 | public TextAttribute(int start, int length, TextAlignment align, 37 | FontSize size, boolean bold, boolean italic, boolean underlined, 38 | boolean strikeThrough, TextColor color) { 39 | this.start = start; 40 | this.length = length; 41 | this.align = align; 42 | this.size = size; 43 | this.bold = bold; 44 | this.italic = italic; 45 | this.underlined = underlined; 46 | this.strikeThrough = strikeThrough; 47 | this.color = color; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/cat/TextColor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.cat; 18 | 19 | 20 | /** 21 | * Enumeration for representing text color. 22 | * 23 | * {@hide} 24 | */ 25 | public enum TextColor { 26 | BLACK(0x0), 27 | DARK_GRAY(0x1), 28 | DARK_RED(0x2), 29 | DARK_YELLOW(0x3), 30 | DARK_GREEN(0x4), 31 | DARK_CYAN(0x5), 32 | DARK_BLUE(0x6), 33 | DARK_MAGENTA(0x7), 34 | GRAY(0x8), 35 | WHITE(0x9), 36 | BRIGHT_RED(0xa), 37 | BRIGHT_YELLOW(0xb), 38 | BRIGHT_GREEN(0xc), 39 | BRIGHT_CYAN(0xd), 40 | BRIGHT_BLUE(0xe), 41 | BRIGHT_MAGENTA(0xf); 42 | 43 | private int mValue; 44 | 45 | TextColor(int value) { 46 | mValue = value; 47 | } 48 | 49 | /** 50 | * Create a TextColor object. 51 | * @param value Integer value to be converted to a TextColor object. 52 | * @return TextColor object whose value is {@code value}. If no TextColor 53 | * object has that value, null is returned. 54 | */ 55 | public static TextColor fromInt(int value) { 56 | for (TextColor e : TextColor.values()) { 57 | if (e.mValue == value) { 58 | return e; 59 | } 60 | } 61 | return null; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/cat/TextMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.cat; 18 | 19 | import android.graphics.Bitmap; 20 | import android.os.Parcel; 21 | import android.os.Parcelable; 22 | 23 | public class TextMessage implements Parcelable { 24 | public String title = ""; 25 | public String text = null; 26 | public Bitmap icon = null; 27 | public boolean iconSelfExplanatory = false; 28 | public boolean isHighPriority = false; 29 | public boolean responseNeeded = true; 30 | public boolean userClear = false; 31 | public Duration duration = null; 32 | 33 | TextMessage() { 34 | } 35 | 36 | private TextMessage(Parcel in) { 37 | title = in.readString(); 38 | text = in.readString(); 39 | icon = in.readParcelable(null); 40 | iconSelfExplanatory = in.readInt() == 1 ? true : false; 41 | isHighPriority = in.readInt() == 1 ? true : false; 42 | responseNeeded = in.readInt() == 1 ? true : false; 43 | userClear = in.readInt() == 1 ? true : false; 44 | duration = in.readParcelable(null); 45 | } 46 | 47 | @Override 48 | public int describeContents() { 49 | return 0; 50 | } 51 | 52 | @Override 53 | public void writeToParcel(Parcel dest, int flags) { 54 | dest.writeString(title); 55 | dest.writeString(text); 56 | dest.writeParcelable(icon, 0); 57 | dest.writeInt(iconSelfExplanatory ? 1 : 0); 58 | dest.writeInt(isHighPriority ? 1 : 0); 59 | dest.writeInt(responseNeeded ? 1 : 0); 60 | dest.writeInt(userClear ? 1 : 0); 61 | dest.writeParcelable(duration, 0); 62 | } 63 | 64 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { 65 | @Override 66 | public TextMessage createFromParcel(Parcel in) { 67 | return new TextMessage(in); 68 | } 69 | 70 | @Override 71 | public TextMessage[] newArray(int size) { 72 | return new TextMessage[size]; 73 | } 74 | }; 75 | 76 | @Override 77 | public String toString() { 78 | return "title=" + title + " text=" + text + " icon=" + icon + 79 | " iconSelfExplanatory=" + iconSelfExplanatory + " isHighPriority=" + 80 | isHighPriority + " responseNeeded=" + responseNeeded + " userClear=" + 81 | userClear + " duration=" + duration; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/cat/ToneSettings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.cat; 18 | 19 | import android.os.Parcel; 20 | import android.os.Parcelable; 21 | 22 | /** 23 | * Container class for PlayTone commands parameters. 24 | * 25 | */ 26 | public class ToneSettings implements Parcelable { 27 | public Duration duration; 28 | public Tone tone; 29 | public boolean vibrate; 30 | 31 | public ToneSettings(Duration duration, Tone tone, boolean vibrate) { 32 | this.duration = duration; 33 | this.tone = tone; 34 | this.vibrate = vibrate; 35 | } 36 | 37 | private ToneSettings(Parcel in) { 38 | duration = in.readParcelable(null); 39 | tone = in.readParcelable(null); 40 | vibrate = in.readInt() == 1; 41 | } 42 | 43 | @Override 44 | public int describeContents() { 45 | return 0; 46 | } 47 | 48 | @Override 49 | public void writeToParcel(Parcel dest, int flags) { 50 | dest.writeParcelable(duration, 0); 51 | dest.writeParcelable(tone, 0); 52 | dest.writeInt(vibrate ? 1 : 0); 53 | } 54 | 55 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { 56 | @Override 57 | public ToneSettings createFromParcel(Parcel in) { 58 | return new ToneSettings(in); 59 | } 60 | 61 | @Override 62 | public ToneSettings[] newArray(int size) { 63 | return new ToneSettings[size]; 64 | } 65 | }; 66 | } -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/cat/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Provides classes for ICC Toolkit Service (CAT). 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/cdma/CdmaCallWaitingNotification.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.cdma; 18 | 19 | import android.telephony.Rlog; 20 | import com.android.internal.telephony.PhoneConstants; 21 | 22 | /** 23 | * Represents a Supplementary Service Notification received from the network. 24 | * 25 | * {@hide} 26 | */ 27 | public class CdmaCallWaitingNotification { 28 | static final String LOG_TAG = "CdmaCallWaitingNotification"; 29 | public String number = null; 30 | public int numberPresentation = 0; 31 | public String name = null; 32 | public int namePresentation = 0; 33 | public int numberType = 0; 34 | public int numberPlan = 0; 35 | public int isPresent = 0; 36 | public int signalType = 0; 37 | public int alertPitch = 0; 38 | public int signal = 0; 39 | 40 | @Override 41 | public String toString() 42 | { 43 | return super.toString() + "Call Waiting Notification " 44 | + " number: " + number 45 | + " numberPresentation: " + numberPresentation 46 | + " name: " + name 47 | + " namePresentation: " + namePresentation 48 | + " numberType: " + numberType 49 | + " numberPlan: " + numberPlan 50 | + " isPresent: " + isPresent 51 | + " signalType: " + signalType 52 | + " alertPitch: " + alertPitch 53 | + " signal: " + signal ; 54 | } 55 | 56 | public static int 57 | presentationFromCLIP(int cli) 58 | { 59 | switch(cli) { 60 | case 0: return PhoneConstants.PRESENTATION_ALLOWED; 61 | case 1: return PhoneConstants.PRESENTATION_RESTRICTED; 62 | case 2: return PhoneConstants.PRESENTATION_UNKNOWN; 63 | default: 64 | // This shouldn't happen, just log an error and treat as Unknown 65 | Rlog.d(LOG_TAG, "Unexpected presentation " + cli); 66 | return PhoneConstants.PRESENTATION_UNKNOWN; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/cdma/CdmaSmsBroadcastConfigInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.android.internal.telephony.cdma; 19 | 20 | /** 21 | * CdmaSmsBroadcastConfigInfo defines one configuration of Cdma Broadcast 22 | * Message to be received by the ME 23 | * 24 | * serviceCategory defines a Broadcast message identifier 25 | * whose value is 0x0000 - 0xFFFF as defined in C.R1001G 9.3.1 and 9.3.2. 26 | * All other values can be treated as empty message ID. 27 | * 28 | * language defines a language code of Broadcast Message 29 | * whose value is 0x00 - 0x07 as defined in C.R1001G 9.2. 30 | * All other values can be treated as empty language code. 31 | * 32 | * selected false means message types specified in serviceCategory 33 | * are not accepted, while true means accepted. 34 | * 35 | */ 36 | public class CdmaSmsBroadcastConfigInfo { 37 | private int mFromServiceCategory; 38 | private int mToServiceCategory; 39 | private int mLanguage; 40 | private boolean mSelected; 41 | 42 | /** 43 | * Initialize the object from rssi and cid. 44 | */ 45 | public CdmaSmsBroadcastConfigInfo(int fromServiceCategory, int toServiceCategory, 46 | int language, boolean selected) { 47 | mFromServiceCategory = fromServiceCategory; 48 | mToServiceCategory = toServiceCategory; 49 | mLanguage = language; 50 | mSelected = selected; 51 | } 52 | 53 | /** 54 | * @return the mFromServiceCategory 55 | */ 56 | public int getFromServiceCategory() { 57 | return mFromServiceCategory; 58 | } 59 | 60 | /** 61 | * @return the mToServiceCategory 62 | */ 63 | public int getToServiceCategory() { 64 | return mToServiceCategory; 65 | } 66 | 67 | /** 68 | * @return the mLanguage 69 | */ 70 | public int getLanguage() { 71 | return mLanguage; 72 | } 73 | 74 | /** 75 | * @return the selected 76 | */ 77 | public boolean isSelected() { 78 | return mSelected; 79 | } 80 | 81 | @Override 82 | public String toString() { 83 | return "CdmaSmsBroadcastConfigInfo: Id [" + 84 | mFromServiceCategory + ", " + mToServiceCategory + "] " + 85 | (isSelected() ? "ENABLED" : "DISABLED"); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/cdma/EriInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.cdma; 18 | 19 | public final class EriInfo { 20 | 21 | public static final int ROAMING_INDICATOR_ON = 0; 22 | public static final int ROAMING_INDICATOR_OFF = 1; 23 | public static final int ROAMING_INDICATOR_FLASH = 2; 24 | 25 | public static final int ROAMING_ICON_MODE_NORMAL = 0; 26 | public static final int ROAMING_ICON_MODE_FLASH = 1; 27 | 28 | public int roamingIndicator; 29 | public int iconIndex; 30 | public int iconMode; 31 | public String eriText; 32 | public int callPromptId; 33 | public int alertId; 34 | 35 | public EriInfo (int roamingIndicator, int iconIndex, int iconMode, String eriText, 36 | int callPromptId, int alertId) { 37 | 38 | this.roamingIndicator = roamingIndicator; 39 | this.iconIndex = iconIndex; 40 | this.iconMode = iconMode; 41 | this.eriText = eriText; 42 | this.callPromptId = callPromptId; 43 | this.alertId = alertId; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/cdma/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Provides classes to control or read data from CDMA phones. 4 | @hide 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/cdma/sms/CdmaSmsSubaddress.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.cdma.sms; 18 | 19 | public class CdmaSmsSubaddress { 20 | public int type; 21 | 22 | public byte odd; 23 | 24 | public byte[] origBytes; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/cdma/sms/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Provides CDMA-specific features for text/data/PDU SMS messages 4 | @hide 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/dataconnection/DcFailBringUp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.dataconnection; 18 | 19 | import android.content.Intent; 20 | import android.telephony.Rlog; 21 | 22 | /** 23 | * A package visible class for supporting testing failing bringUp commands. This 24 | * saves the parameters from a action_fail_bringup intent. See 25 | * {@link DataConnection#doOnConnect} and {@see DcTesterFailBringUpAll} for more info. 26 | */ 27 | public class DcFailBringUp { 28 | private static final String LOG_TAG = "DcFailBringUp"; 29 | private static final boolean DBG = true; 30 | 31 | static final String INTENT_BASE = DataConnection.class.getPackage().getName(); 32 | 33 | static final String ACTION_FAIL_BRINGUP = "action_fail_bringup"; 34 | 35 | // counter with its --ei option name and default value 36 | static final String COUNTER = "counter"; 37 | static final int DEFAULT_COUNTER = 2; 38 | int mCounter; 39 | 40 | // failCause with its --ei option name and default value 41 | static final String FAIL_CAUSE = "fail_cause"; 42 | static final DcFailCause DEFAULT_FAIL_CAUSE = DcFailCause.ERROR_UNSPECIFIED; 43 | DcFailCause mFailCause; 44 | 45 | // suggestedRetryTime with its --ei option name and default value 46 | static final String SUGGESTED_RETRY_TIME = "suggested_retry_time"; 47 | static final int DEFAULT_SUGGESTED_RETRY_TIME = -1; 48 | int mSuggestedRetryTime; 49 | 50 | // Get the Extra Intent parameters 51 | void saveParameters(Intent intent, String s) { 52 | if (DBG) log(s + ".saveParameters: action=" + intent.getAction()); 53 | mCounter = intent.getIntExtra(COUNTER, DEFAULT_COUNTER); 54 | mFailCause = DcFailCause.fromInt( 55 | intent.getIntExtra(FAIL_CAUSE, DEFAULT_FAIL_CAUSE.getErrorCode())); 56 | mSuggestedRetryTime = 57 | intent.getIntExtra(SUGGESTED_RETRY_TIME, DEFAULT_SUGGESTED_RETRY_TIME); 58 | if (DBG) { 59 | log(s + ".saveParameters: " + this); 60 | } 61 | } 62 | 63 | public void saveParameters(int counter, int failCause, int suggestedRetryTime) { 64 | mCounter = counter; 65 | mFailCause = DcFailCause.fromInt(failCause); 66 | mSuggestedRetryTime = suggestedRetryTime; 67 | } 68 | 69 | @Override 70 | public String toString() { 71 | return "{mCounter=" + mCounter + 72 | " mFailCause=" + mFailCause + 73 | " mSuggestedRetryTime=" + mSuggestedRetryTime + "}"; 74 | 75 | } 76 | 77 | private static void log(String s) { 78 | Rlog.d(LOG_TAG, s); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/dataconnection/DcTesterDeactivateAll.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.dataconnection; 18 | 19 | import android.content.BroadcastReceiver; 20 | import android.content.Context; 21 | import android.content.Intent; 22 | import android.content.IntentFilter; 23 | import android.os.Build; 24 | import android.os.Handler; 25 | import android.telephony.Rlog; 26 | 27 | import com.android.internal.telephony.Phone; 28 | 29 | /** 30 | * To bring down all DC's send the following intent: 31 | * 32 | * adb shell am broadcast -a com.android.internal.telephony.dataconnection.action_deactivate_all 33 | */ 34 | public class DcTesterDeactivateAll { 35 | private static final String LOG_TAG = "DcTesterDeacativateAll"; 36 | private static final boolean DBG = true; 37 | 38 | private Phone mPhone; 39 | private DcController mDcc; 40 | 41 | public static String sActionDcTesterDeactivateAll = 42 | "com.android.internal.telephony.dataconnection.action_deactivate_all"; 43 | 44 | 45 | // The static intent receiver one for all instances and we assume this 46 | // is running on the same thread as Dcc. 47 | protected BroadcastReceiver sIntentReceiver = new BroadcastReceiver() { 48 | @Override 49 | public void onReceive(Context context, Intent intent) { 50 | String action = intent.getAction(); 51 | if (DBG) log("sIntentReceiver.onReceive: action=" + action); 52 | if (action.equals(sActionDcTesterDeactivateAll) 53 | || action.equals(mPhone.getActionDetached())) { 54 | log("Send DEACTIVATE to all Dcc's"); 55 | if (mDcc != null) { 56 | for (DataConnection dc : mDcc.mDcListAll) { 57 | dc.tearDownNow(); 58 | } 59 | } else { 60 | if (DBG) log("onReceive: mDcc is null, ignoring"); 61 | } 62 | } else { 63 | if (DBG) log("onReceive: unknown action=" + action); 64 | } 65 | } 66 | }; 67 | 68 | DcTesterDeactivateAll(Phone phone, DcController dcc, Handler handler) { 69 | mPhone = phone; 70 | mDcc = dcc; 71 | 72 | if (Build.IS_DEBUGGABLE) { 73 | IntentFilter filter = new IntentFilter(); 74 | 75 | filter.addAction(sActionDcTesterDeactivateAll); 76 | log("register for intent action=" + sActionDcTesterDeactivateAll); 77 | 78 | filter.addAction(mPhone.getActionDetached()); 79 | log("register for intent action=" + mPhone.getActionDetached()); 80 | 81 | phone.getContext().registerReceiver(sIntentReceiver, filter, null, handler); 82 | } 83 | } 84 | 85 | void dispose() { 86 | if (Build.IS_DEBUGGABLE) { 87 | mPhone.getContext().unregisterReceiver(sIntentReceiver); 88 | } 89 | } 90 | 91 | private static void log(String s) { 92 | Rlog.d(LOG_TAG, s); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/gsm/SuppServiceNotification.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.gsm; 18 | 19 | import android.telephony.PhoneNumberUtils; 20 | 21 | /** 22 | * Represents a Supplementary Service Notification received from the network. 23 | * 24 | * {@hide} 25 | */ 26 | public class SuppServiceNotification { 27 | /** Type of notification: 0 = MO; 1 = MT */ 28 | public int notificationType; 29 | /** TS 27.007 7.17 "code1" or "code2" */ 30 | public int code; 31 | /** TS 27.007 7.17 "index" */ 32 | public int index; 33 | /** TS 27.007 7.17 "type" (MT only) */ 34 | public int type; 35 | /** TS 27.007 7.17 "number" (MT only) */ 36 | public String number; 37 | 38 | /** List of forwarded numbers, if any */ 39 | public String[] history; 40 | 41 | static public final int NOTIFICATION_TYPE_MO = 0; 42 | static public final int NOTIFICATION_TYPE_MT = 1; 43 | 44 | static public final int MO_CODE_UNCONDITIONAL_CF_ACTIVE = 0; 45 | static public final int MO_CODE_SOME_CF_ACTIVE = 1; 46 | static public final int MO_CODE_CALL_FORWARDED = 2; 47 | static public final int MO_CODE_CALL_IS_WAITING = 3; 48 | static public final int MO_CODE_CUG_CALL = 4; 49 | static public final int MO_CODE_OUTGOING_CALLS_BARRED = 5; 50 | static public final int MO_CODE_INCOMING_CALLS_BARRED = 6; 51 | static public final int MO_CODE_CLIR_SUPPRESSION_REJECTED = 7; 52 | static public final int MO_CODE_CALL_DEFLECTED = 8; 53 | 54 | static public final int MT_CODE_FORWARDED_CALL = 0; 55 | static public final int MT_CODE_CUG_CALL = 1; 56 | static public final int MT_CODE_CALL_ON_HOLD = 2; 57 | static public final int MT_CODE_CALL_RETRIEVED = 3; 58 | static public final int MT_CODE_MULTI_PARTY_CALL = 4; 59 | static public final int MT_CODE_ON_HOLD_CALL_RELEASED = 5; 60 | static public final int MT_CODE_FORWARD_CHECK_RECEIVED = 6; 61 | static public final int MT_CODE_CALL_CONNECTING_ECT = 7; 62 | static public final int MT_CODE_CALL_CONNECTED_ECT = 8; 63 | static public final int MT_CODE_DEFLECTED_CALL = 9; 64 | static public final int MT_CODE_ADDITIONAL_CALL_FORWARDED = 10; 65 | 66 | @Override 67 | public String toString() 68 | { 69 | return super.toString() + " mobile" 70 | + (notificationType == NOTIFICATION_TYPE_MO ? " originated " : " terminated ") 71 | + " code: " + code 72 | + " index: " + index 73 | + " history: " + history 74 | + " \"" 75 | + PhoneNumberUtils.stringFromStringAndTOA(number, type) + "\" "; 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/gsm/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Provides classes to control or read data from GSM phones. 4 | @hide 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/imsphone/ImsExternalCall.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License 15 | */ 16 | 17 | package com.android.internal.telephony.imsphone; 18 | 19 | import com.android.internal.telephony.Call; 20 | import com.android.internal.telephony.CallStateException; 21 | import com.android.internal.telephony.Connection; 22 | import com.android.internal.telephony.Phone; 23 | 24 | import java.util.List; 25 | 26 | /** 27 | * Companion class for {@link ImsExternalConnection}; represents an external call which was 28 | * received via {@link com.android.ims.ImsExternalCallState} info. 29 | */ 30 | public class ImsExternalCall extends Call { 31 | 32 | private Phone mPhone; 33 | 34 | public ImsExternalCall(Phone phone, ImsExternalConnection connection) { 35 | mPhone = phone; 36 | mConnections.add(connection); 37 | } 38 | 39 | @Override 40 | public List getConnections() { 41 | return mConnections; 42 | } 43 | 44 | @Override 45 | public Phone getPhone() { 46 | return mPhone; 47 | } 48 | 49 | @Override 50 | public boolean isMultiparty() { 51 | return false; 52 | } 53 | 54 | @Override 55 | public void hangup() throws CallStateException { 56 | 57 | } 58 | 59 | /** 60 | * Sets the call state to active. 61 | */ 62 | public void setActive() { 63 | setState(State.ACTIVE); 64 | } 65 | 66 | /** 67 | * Sets the call state to terminated. 68 | */ 69 | public void setTerminated() { 70 | setState(State.DISCONNECTED); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/imsphone/ImsPhoneFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.imsphone; 18 | 19 | import com.android.internal.telephony.Phone; 20 | import com.android.internal.telephony.PhoneNotifier; 21 | 22 | import android.content.Context; 23 | import android.telephony.Rlog; 24 | 25 | /** 26 | * {@hide} 27 | */ 28 | public class ImsPhoneFactory { 29 | 30 | /** 31 | * Makes a {@link ImsPhone} object. 32 | * @param context {@code Context} needed to create a Phone object 33 | * @param phoneNotifier {@code PhoneNotifier} needed to create a Phone 34 | * object 35 | * @return the {@code ImsPhone} object 36 | */ 37 | public static ImsPhone makePhone(Context context, 38 | PhoneNotifier phoneNotifier, Phone defaultPhone) { 39 | 40 | try { 41 | return new ImsPhone(context, phoneNotifier, defaultPhone); 42 | } catch (Exception e) { 43 | Rlog.e("VoltePhoneFactory", "makePhone", e); 44 | return null; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/imsphone/ImsPullCall.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License 15 | */ 16 | 17 | package com.android.internal.telephony.imsphone; 18 | 19 | import com.android.ims.ImsCallProfile; 20 | 21 | /** 22 | * Interface implemented by modules which are capable of performing a pull of an external call. 23 | * This is used to break the dependency between {@link ImsExternalCallTracker} and 24 | * {@link ImsPhoneCallTracker}. 25 | * 26 | * @hide 27 | */ 28 | public interface ImsPullCall { 29 | /** 30 | * Initiate a pull of a call which has the specified phone number. 31 | * 32 | * @param number The phone number of the call to be pulled. 33 | * @param videoState The video state of the call to be pulled. 34 | * @param dialogId The {@link ImsExternalConnection#getCallId()} dialog Id associated with the 35 | * call to be pulled. 36 | */ 37 | void pullExternalCall(String number, int videoState, int dialogId); 38 | } 39 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/metrics/InProgressCallSession.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.metrics; 18 | 19 | import android.os.SystemClock; 20 | 21 | import com.android.internal.telephony.TelephonyProto.TelephonyCallSession; 22 | 23 | import java.util.ArrayDeque; 24 | import java.util.Deque; 25 | 26 | /** The ongoing Call session */ 27 | public class InProgressCallSession { 28 | 29 | /** Maximum events stored in the session */ 30 | private static final int MAX_EVENTS = 300; 31 | 32 | /** Phone id */ 33 | public final int phoneId; 34 | 35 | /** Call session events */ 36 | public final Deque events; 37 | 38 | /** Call session starting system time in minute */ 39 | public final int startSystemTimeMin; 40 | 41 | /** Call session starting elapsed time in milliseconds */ 42 | public final long startElapsedTimeMs; 43 | 44 | /** The last event's time */ 45 | private long mLastElapsedTimeMs; 46 | 47 | /** Indicating events dropped */ 48 | private boolean mEventsDropped = false; 49 | 50 | /** Check if events dropped */ 51 | public boolean isEventsDropped() { return mEventsDropped; } 52 | 53 | /** 54 | * Constructor 55 | * 56 | * @param phoneId Phone id 57 | */ 58 | public InProgressCallSession(int phoneId) { 59 | this.phoneId = phoneId; 60 | events = new ArrayDeque<>(); 61 | // Save session start with lowered precision due to the privacy requirements 62 | startSystemTimeMin = TelephonyMetrics.roundSessionStart(System.currentTimeMillis()); 63 | startElapsedTimeMs = SystemClock.elapsedRealtime(); 64 | mLastElapsedTimeMs = startElapsedTimeMs; 65 | } 66 | 67 | /** 68 | * Add event 69 | * 70 | * @param builder Event builder 71 | */ 72 | public void addEvent(CallSessionEventBuilder builder) { 73 | addEvent(SystemClock.elapsedRealtime(), builder); 74 | } 75 | 76 | /** 77 | * Add event 78 | * 79 | * @param timestamp Timestamp to be recoded with the event 80 | * @param builder Event builder 81 | */ 82 | synchronized public void addEvent(long timestamp, CallSessionEventBuilder builder) { 83 | if (events.size() >= MAX_EVENTS) { 84 | events.removeFirst(); 85 | mEventsDropped = true; 86 | } 87 | 88 | builder.setDelay(TelephonyMetrics.toPrivacyFuzzedTimeInterval( 89 | mLastElapsedTimeMs, timestamp)); 90 | 91 | events.add(builder.build()); 92 | mLastElapsedTimeMs = timestamp; 93 | } 94 | } -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/metrics/SmsSessionEventBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.metrics; 18 | 19 | import com.android.internal.telephony.TelephonyProto.ImsCapabilities; 20 | import com.android.internal.telephony.TelephonyProto.ImsConnectionState; 21 | import com.android.internal.telephony.TelephonyProto.RilDataCall; 22 | import com.android.internal.telephony.TelephonyProto.SmsSession; 23 | import com.android.internal.telephony.TelephonyProto.TelephonyServiceState; 24 | import com.android.internal.telephony.TelephonyProto.TelephonySettings; 25 | 26 | public class SmsSessionEventBuilder { 27 | SmsSession.Event mEvent = new SmsSession.Event(); 28 | 29 | public SmsSession.Event build() { 30 | return mEvent; 31 | } 32 | 33 | public SmsSessionEventBuilder(int type) { 34 | mEvent.setType(type); 35 | } 36 | 37 | public SmsSessionEventBuilder setDelay(int delay) { 38 | mEvent.setDelay(delay); 39 | return this; 40 | } 41 | 42 | public SmsSessionEventBuilder setTech(int tech) { 43 | mEvent.setTech(tech); 44 | return this; 45 | } 46 | 47 | public SmsSessionEventBuilder setErrorCode(int code) { 48 | mEvent.setErrorCode(code); 49 | return this; 50 | } 51 | 52 | public SmsSessionEventBuilder setRilErrno(int errno) { 53 | mEvent.setError(errno); 54 | return this; 55 | } 56 | 57 | public SmsSessionEventBuilder setSettings(TelephonySettings settings) { 58 | mEvent.settings = settings; 59 | return this; 60 | } 61 | 62 | public SmsSessionEventBuilder setServiceState(TelephonyServiceState state) { 63 | mEvent.serviceState = state; 64 | return this; 65 | } 66 | 67 | public SmsSessionEventBuilder setImsConnectionState(ImsConnectionState state) { 68 | mEvent.imsConnectionState = state; 69 | return this; 70 | } 71 | 72 | public SmsSessionEventBuilder setImsCapabilities(ImsCapabilities capabilities) { 73 | mEvent.imsCapabilities = capabilities; 74 | return this; 75 | } 76 | 77 | public SmsSessionEventBuilder setDataCalls(RilDataCall[] dataCalls) { 78 | mEvent.dataCalls = dataCalls; 79 | return this; 80 | } 81 | 82 | public SmsSessionEventBuilder setRilRequestId(int id) { 83 | mEvent.setRilRequestId(id); 84 | return this; 85 | } 86 | 87 | public SmsSessionEventBuilder setFormat(int format) { 88 | mEvent.setFormat(format); 89 | return this; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {@hide} 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/sip/SipCallBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.sip; 18 | 19 | import com.android.internal.telephony.Call; 20 | import com.android.internal.telephony.Connection; 21 | import java.util.Iterator; 22 | import java.util.List; 23 | 24 | abstract class SipCallBase extends Call { 25 | 26 | @Override 27 | public List getConnections() { 28 | // FIXME should return Collections.unmodifiableList(); 29 | return mConnections; 30 | } 31 | 32 | @Override 33 | public boolean isMultiparty() { 34 | return mConnections.size() > 1; 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return mState.toString() + ":" + super.toString(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/sip/SipPhoneFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.sip; 18 | 19 | import com.android.internal.telephony.PhoneNotifier; 20 | 21 | import android.content.Context; 22 | import android.net.sip.SipProfile; 23 | import android.telephony.Rlog; 24 | 25 | import java.text.ParseException; 26 | 27 | /** 28 | * {@hide} 29 | */ 30 | public class SipPhoneFactory { 31 | /** 32 | * Makes a {@link SipPhone} object. 33 | * @param sipUri the local SIP URI the phone runs on 34 | * @param context {@code Context} needed to create a Phone object 35 | * @param phoneNotifier {@code PhoneNotifier} needed to create a Phone 36 | * object 37 | * @return the {@code SipPhone} object or null if the SIP URI is not valid 38 | */ 39 | public static SipPhone makePhone(String sipUri, Context context, 40 | PhoneNotifier phoneNotifier) { 41 | try { 42 | SipProfile profile = new SipProfile.Builder(sipUri).build(); 43 | return new SipPhone(context, phoneNotifier, profile); 44 | } catch (ParseException e) { 45 | Rlog.w("SipPhoneFactory", "makePhone", e); 46 | return null; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/test/SimulatedRadioControl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.test; 18 | 19 | public interface SimulatedRadioControl 20 | { 21 | public void triggerRing(String number); 22 | 23 | public void progressConnectingCallState(); 24 | 25 | public void progressConnectingToActive(); 26 | 27 | public void setAutoProgressConnectingCall(boolean b); 28 | 29 | public void setNextDialFailImmediately(boolean b); 30 | 31 | public void setNextCallFailCause(int gsmCause); 32 | 33 | public void triggerHangupForeground(); 34 | 35 | public void triggerHangupBackground(); 36 | 37 | public void triggerHangupAll(); 38 | 39 | public void triggerIncomingSMS(String message); 40 | 41 | public void shutdown(); 42 | 43 | /** Pause responses to async requests until (ref-counted) resumeResponses() */ 44 | public void pauseResponses(); 45 | 46 | /** see pauseResponses */ 47 | public void resumeResponses(); 48 | 49 | public void triggerSsn(int type, int code); 50 | 51 | /** Generates an incoming USSD message. */ 52 | public void triggerIncomingUssd(String statusCode, String message); 53 | } 54 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/test/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {@hide} 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/uicc/AdnRecord.aidl: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright 2007, The Android Open Source Project 3 | ** 4 | ** Licensed under the Apache License, Version 2.0 (the "License"); 5 | ** you may not use this file except in compliance with the License. 6 | ** You may obtain a copy of the License at 7 | ** 8 | ** http://www.apache.org/licenses/LICENSE-2.0 9 | ** 10 | ** Unless required by applicable law or agreed to in writing, software 11 | ** distributed under the License is distributed on an "AS IS" BASIS, 12 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | ** See the License for the specific language governing permissions and 14 | ** limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.uicc; 18 | 19 | parcelable AdnRecord; 20 | 21 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/uicc/CsimFileHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006, 2012 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.uicc; 18 | 19 | import android.telephony.Rlog; 20 | 21 | import com.android.internal.telephony.CommandsInterface; 22 | 23 | /** 24 | * {@hide} 25 | * This class should be used to access files in CSIM ADF 26 | */ 27 | public final class CsimFileHandler extends IccFileHandler implements IccConstants { 28 | static final String LOG_TAG = "CsimFH"; 29 | 30 | public CsimFileHandler(UiccCardApplication app, String aid, CommandsInterface ci) { 31 | super(app, aid, ci); 32 | } 33 | 34 | @Override 35 | protected String getEFPath(int efid) { 36 | switch(efid) { 37 | case EF_SMS: 38 | case EF_CST: 39 | case EF_FDN: 40 | case EF_MSISDN: 41 | case EF_RUIM_SPN: 42 | case EF_CSIM_LI: 43 | case EF_CSIM_MDN: 44 | case EF_CSIM_IMSIM: 45 | case EF_CSIM_CDMAHOME: 46 | case EF_CSIM_EPRL: 47 | case EF_CSIM_PRL: 48 | case EF_CSIM_MIPUPP: 49 | return MF_SIM + DF_ADF; 50 | case EF_CSIM_MSPL: 51 | case EF_CSIM_MLPL: 52 | return MF_SIM + DF_TELECOM + DF_MMSS; 53 | } 54 | String path = getCommonIccEFPath(efid); 55 | if (path == null) { 56 | // The EFids in UICC phone book entries are decided by the card manufacturer. 57 | // So if we don't match any of the cases above and if its a UICC return 58 | // the global 3g phone book path. 59 | return MF_SIM + DF_TELECOM + DF_PHONEBOOK; 60 | } 61 | return path; 62 | } 63 | 64 | @Override 65 | protected void logd(String msg) { 66 | Rlog.d(LOG_TAG, msg); 67 | } 68 | 69 | @Override 70 | protected void loge(String msg) { 71 | Rlog.e(LOG_TAG, msg); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/uicc/IccException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.uicc; 18 | 19 | /** 20 | * {@hide} 21 | */ 22 | public class IccException extends Exception { 23 | public IccException() { 24 | 25 | } 26 | 27 | public IccException(String s) { 28 | super(s); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/uicc/IccFileNotFound.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.uicc; 18 | 19 | 20 | /** 21 | * {@hide} 22 | */ 23 | public class IccFileNotFound extends IccException { 24 | IccFileNotFound() { 25 | 26 | } 27 | 28 | IccFileNotFound(String s) { 29 | super(s); 30 | } 31 | 32 | IccFileNotFound(int ef) { 33 | super("ICC EF Not Found 0x" + Integer.toHexString(ef)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/uicc/IccFileTypeMismatch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.uicc; 18 | 19 | 20 | /** 21 | * {@hide} 22 | */ 23 | public class IccFileTypeMismatch extends IccException { 24 | public IccFileTypeMismatch() { 25 | 26 | } 27 | 28 | public IccFileTypeMismatch(String s) { 29 | super(s); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/uicc/IccIoResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.uicc; 18 | 19 | 20 | /** 21 | * {@hide} 22 | */ 23 | public class 24 | IccIoResult { 25 | public int sw1; 26 | public int sw2; 27 | 28 | public byte[] payload; 29 | 30 | public IccIoResult(int sw1, int sw2, byte[] payload) { 31 | this.sw1 = sw1; 32 | this.sw2 = sw2; 33 | this.payload = payload; 34 | } 35 | 36 | public IccIoResult(int sw1, int sw2, String hexString) { 37 | this(sw1, sw2, IccUtils.hexStringToBytes(hexString)); 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return "IccIoResponse sw1:0x" + Integer.toHexString(sw1) + " sw2:0x" 43 | + Integer.toHexString(sw2); 44 | } 45 | 46 | /** 47 | * true if this operation was successful 48 | * See GSM 11.11 Section 9.4 49 | * (the fun stuff is absent in 51.011) 50 | */ 51 | public boolean success() { 52 | return sw1 == 0x90 || sw1 == 0x91 || sw1 == 0x9e || sw1 == 0x9f; 53 | } 54 | 55 | /** 56 | * Returns exception on error or null if success 57 | */ 58 | public IccException getException() { 59 | if (success()) return null; 60 | 61 | switch (sw1) { 62 | case 0x94: 63 | if (sw2 == 0x08) { 64 | return new IccFileTypeMismatch(); 65 | } else { 66 | return new IccFileNotFound(); 67 | } 68 | default: 69 | return new IccException("sw1:" + sw1 + " sw2:" + sw2); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/uicc/IccRefreshResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.uicc; 18 | 19 | /** 20 | * See also RIL_SimRefresh in include/telephony/ril.h 21 | * 22 | * {@hide} 23 | */ 24 | 25 | public class IccRefreshResponse { 26 | 27 | public static final int REFRESH_RESULT_FILE_UPDATE = 0; /* Single file was updated */ 28 | public static final int REFRESH_RESULT_INIT = 1; /* The Icc has been initialized */ 29 | public static final int REFRESH_RESULT_RESET = 2; /* The Icc was reset */ 30 | 31 | public int refreshResult; /* Sim Refresh result */ 32 | public int efId; /* EFID */ 33 | public String aid; /* null terminated string, e.g., 34 | from 0xA0, 0x00 -> 0x41, 35 | 0x30, 0x30, 0x30 */ 36 | /* Example: a0000000871002f310ffff89080000ff */ 37 | 38 | @Override 39 | public String toString() { 40 | return "{" + refreshResult + ", " + aid +", " + efId + "}"; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/uicc/IccServiceTable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.uicc; 18 | 19 | import android.telephony.Rlog; 20 | 21 | /** 22 | * Wrapper class for an ICC EF containing a bit field of enabled services. 23 | */ 24 | public abstract class IccServiceTable { 25 | protected final byte[] mServiceTable; 26 | 27 | protected IccServiceTable(byte[] table) { 28 | mServiceTable = table; 29 | } 30 | 31 | // Get the class name to use for log strings 32 | protected abstract String getTag(); 33 | 34 | // Get the array of enums to use for toString 35 | protected abstract Object[] getValues(); 36 | 37 | /** 38 | * Returns if the specified service is available. 39 | * @param service the service number as a zero-based offset (the enum ordinal) 40 | * @return true if the service is available; false otherwise 41 | */ 42 | protected boolean isAvailable(int service) { 43 | int offset = service / 8; 44 | if (offset >= mServiceTable.length) { 45 | // Note: Enums are zero-based, but the TS service numbering is one-based 46 | Rlog.e(getTag(), "isAvailable for service " + (service + 1) + " fails, max service is " + 47 | (mServiceTable.length * 8)); 48 | return false; 49 | } 50 | int bit = service % 8; 51 | return (mServiceTable[offset] & (1 << bit)) != 0; 52 | } 53 | 54 | @Override 55 | public String toString() { 56 | Object[] values = getValues(); 57 | int numBytes = mServiceTable.length; 58 | StringBuilder builder = new StringBuilder(getTag()).append('[') 59 | .append(numBytes * 8).append("]={ "); 60 | 61 | boolean addComma = false; 62 | for (int i = 0; i < numBytes; i++) { 63 | byte currentByte = mServiceTable[i]; 64 | for (int bit = 0; bit < 8; bit++) { 65 | if ((currentByte & (1 << bit)) != 0) { 66 | if (addComma) { 67 | builder.append(", "); 68 | } else { 69 | addComma = true; 70 | } 71 | int ordinal = (i * 8) + bit; 72 | if (ordinal < values.length) { 73 | builder.append(values[ordinal]); 74 | } else { 75 | builder.append('#').append(ordinal + 1); // service number (one-based) 76 | } 77 | } 78 | } 79 | } 80 | return builder.append(" }").toString(); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/uicc/IccVmFixedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.uicc; 18 | 19 | 20 | /** 21 | * {@hide} 22 | */ 23 | public final class IccVmFixedException extends IccException { 24 | IccVmFixedException() 25 | { 26 | 27 | } 28 | 29 | public IccVmFixedException(String s) 30 | { 31 | super(s); 32 | } 33 | } -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/uicc/IccVmNotSupportedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.uicc; 18 | 19 | 20 | /** 21 | * {@hide} 22 | */ 23 | public final class IccVmNotSupportedException extends IccException { 24 | IccVmNotSupportedException() 25 | { 26 | 27 | } 28 | 29 | public IccVmNotSupportedException(String s) 30 | { 31 | super(s); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/uicc/IsimFileHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006, 2012 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.uicc; 18 | 19 | import android.telephony.Rlog; 20 | 21 | import com.android.internal.telephony.CommandsInterface; 22 | 23 | /** 24 | * {@hide} 25 | * This class should be used to access files in ISIM ADF 26 | */ 27 | public final class IsimFileHandler extends IccFileHandler implements IccConstants { 28 | static final String LOG_TAG = "IsimFH"; 29 | 30 | public IsimFileHandler(UiccCardApplication app, String aid, CommandsInterface ci) { 31 | super(app, aid, ci); 32 | } 33 | 34 | @Override 35 | protected String getEFPath(int efid) { 36 | switch(efid) { 37 | case EF_IMPI: 38 | case EF_IMPU: 39 | case EF_DOMAIN: 40 | case EF_IST: 41 | case EF_PCSCF: 42 | return MF_SIM + DF_ADF; 43 | } 44 | String path = getCommonIccEFPath(efid); 45 | return path; 46 | } 47 | 48 | @Override 49 | protected void logd(String msg) { 50 | Rlog.d(LOG_TAG, msg); 51 | } 52 | 53 | @Override 54 | protected void loge(String msg) { 55 | Rlog.e(LOG_TAG, msg); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/uicc/IsimRecords.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.uicc; 18 | 19 | /** 20 | * {@hide} 21 | */ 22 | public interface IsimRecords { 23 | 24 | /** 25 | * Return the IMS private user identity (IMPI). 26 | * Returns null if the IMPI hasn't been loaded or isn't present on the ISIM. 27 | * @return the IMS private user identity string, or null if not available 28 | */ 29 | String getIsimImpi(); 30 | 31 | /** 32 | * Return the IMS home network domain name. 33 | * Returns null if the IMS domain hasn't been loaded or isn't present on the ISIM. 34 | * @return the IMS home network domain name, or null if not available 35 | */ 36 | String getIsimDomain(); 37 | 38 | /** 39 | * Return an array of IMS public user identities (IMPU). 40 | * Returns null if the IMPU hasn't been loaded or isn't present on the ISIM. 41 | * @return an array of IMS public user identity strings, or null if not available 42 | */ 43 | String[] getIsimImpu(); 44 | 45 | /** 46 | * Returns the IMS Service Table (IST) that was loaded from the ISIM. 47 | * @return IMS Service Table or null if not present or not loaded 48 | */ 49 | String getIsimIst(); 50 | 51 | /** 52 | * Returns the IMS Proxy Call Session Control Function(PCSCF) that were loaded from the ISIM. 53 | * @return an array of PCSCF strings with one PCSCF per string, or null if 54 | * not present or not loaded 55 | */ 56 | String[] getIsimPcscf(); 57 | 58 | /** 59 | * Returns the response of ISIM Authetification through RIL. 60 | * Returns null if the Authentification hasn't been successed or isn't present iphonesubinfo. 61 | * @return the response of ISIM Authetification, or null if not available 62 | */ 63 | String getIsimChallengeResponse(String nonce); 64 | } 65 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/uicc/README: -------------------------------------------------------------------------------- 1 | You can see documentation in UiccController.java 2 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/uicc/RuimFileHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.uicc; 18 | 19 | import android.os.*; 20 | import android.telephony.Rlog; 21 | 22 | import com.android.internal.telephony.CommandsInterface; 23 | 24 | /** 25 | * {@hide} 26 | */ 27 | public final class RuimFileHandler extends IccFileHandler { 28 | static final String LOG_TAG = "RuimFH"; 29 | 30 | //***** Instance Variables 31 | 32 | //***** Constructor 33 | public RuimFileHandler(UiccCardApplication app, String aid, CommandsInterface ci) { 34 | super(app, aid, ci); 35 | } 36 | 37 | //***** Overridden from IccFileHandler 38 | 39 | @Override 40 | public void loadEFImgTransparent(int fileid, int highOffset, int lowOffset, 41 | int length, Message onLoaded) { 42 | Message response = obtainMessage(EVENT_READ_ICON_DONE, fileid, 0, 43 | onLoaded); 44 | 45 | /* Per TS 31.102, for displaying of Icon, under 46 | * DF Telecom and DF Graphics , EF instance(s) (4FXX,transparent files) 47 | * are present. The possible image file identifiers (EF instance) for 48 | * EF img ( 4F20, linear fixed file) are : 4F01 ... 4F05. 49 | * It should be MF_SIM + DF_TELECOM + DF_GRAPHICS, same path as EF IMG 50 | */ 51 | mCi.iccIOForApp(COMMAND_GET_RESPONSE, fileid, getEFPath(EF_IMG), 0, 0, 52 | GET_RESPONSE_EF_IMG_SIZE_BYTES, null, null, 53 | mAid, response); 54 | } 55 | 56 | @Override 57 | protected String getEFPath(int efid) { 58 | switch(efid) { 59 | case EF_SMS: 60 | case EF_CST: 61 | case EF_RUIM_SPN: 62 | case EF_CSIM_LI: 63 | case EF_CSIM_MDN: 64 | case EF_CSIM_IMSIM: 65 | case EF_CSIM_CDMAHOME: 66 | case EF_CSIM_EPRL: 67 | case EF_CSIM_PRL: 68 | case EF_CSIM_MIPUPP: 69 | return MF_SIM + DF_CDMA; 70 | case EF_CSIM_MSPL: 71 | case EF_CSIM_MLPL: 72 | return MF_SIM + DF_TELECOM + DF_MMSS; 73 | } 74 | return getCommonIccEFPath(efid); 75 | } 76 | 77 | @Override 78 | protected void logd(String msg) { 79 | Rlog.d(LOG_TAG, "[RuimFileHandler] " + msg); 80 | } 81 | 82 | @Override 83 | protected void loge(String msg) { 84 | Rlog.e(LOG_TAG, "[RuimFileHandler] " + msg); 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/uicc/SIMFileHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.uicc; 18 | 19 | import android.telephony.Rlog; 20 | 21 | import com.android.internal.telephony.CommandsInterface; 22 | 23 | /** 24 | * {@hide} 25 | */ 26 | public final class SIMFileHandler extends IccFileHandler implements IccConstants { 27 | static final String LOG_TAG = "SIMFileHandler"; 28 | 29 | //***** Instance Variables 30 | 31 | //***** Constructor 32 | 33 | public SIMFileHandler(UiccCardApplication app, String aid, CommandsInterface ci) { 34 | super(app, aid, ci); 35 | } 36 | 37 | //***** Overridden from IccFileHandler 38 | 39 | @Override 40 | protected String getEFPath(int efid) { 41 | // TODO(): DF_GSM can be 7F20 or 7F21 to handle backward compatibility. 42 | // Implement this after discussion with OEMs. 43 | switch(efid) { 44 | case EF_SMS: 45 | return MF_SIM + DF_TELECOM; 46 | 47 | case EF_EXT6: 48 | case EF_MWIS: 49 | case EF_MBI: 50 | case EF_SPN: 51 | case EF_AD: 52 | case EF_MBDN: 53 | case EF_PNN: 54 | case EF_SPDI: 55 | case EF_SST: 56 | case EF_CFIS: 57 | case EF_GID1: 58 | case EF_GID2: 59 | return MF_SIM + DF_GSM; 60 | 61 | case EF_MAILBOX_CPHS: 62 | case EF_VOICE_MAIL_INDICATOR_CPHS: 63 | case EF_CFF_CPHS: 64 | case EF_SPN_CPHS: 65 | case EF_SPN_SHORT_CPHS: 66 | case EF_INFO_CPHS: 67 | case EF_CSP_CPHS: 68 | case EF_PLMNWACT: 69 | case EF_HPLMNWACT: 70 | return MF_SIM + DF_GSM; 71 | } 72 | String path = getCommonIccEFPath(efid); 73 | if (path == null) { 74 | Rlog.e(LOG_TAG, "Error: EF Path being returned in null"); 75 | } 76 | return path; 77 | } 78 | 79 | @Override 80 | protected void logd(String msg) { 81 | Rlog.d(LOG_TAG, msg); 82 | } 83 | 84 | @Override 85 | protected void loge(String msg) { 86 | Rlog.e(LOG_TAG, msg); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/java/com/android/internal/telephony/uicc/UsimFileHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006, 2012 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.uicc; 18 | 19 | import android.telephony.Rlog; 20 | 21 | import com.android.internal.telephony.CommandsInterface; 22 | import com.android.internal.telephony.uicc.UiccCardApplication; 23 | 24 | /** 25 | * {@hide} 26 | * This class should be used to access files in USIM ADF 27 | */ 28 | public final class UsimFileHandler extends IccFileHandler implements IccConstants { 29 | static final String LOG_TAG = "UsimFH"; 30 | 31 | public UsimFileHandler(UiccCardApplication app, String aid, CommandsInterface ci) { 32 | super(app, aid, ci); 33 | } 34 | 35 | @Override 36 | protected String getEFPath(int efid) { 37 | switch(efid) { 38 | case EF_SMS: 39 | case EF_EXT5: 40 | case EF_EXT6: 41 | case EF_MWIS: 42 | case EF_MBI: 43 | case EF_SPN: 44 | case EF_AD: 45 | case EF_MBDN: 46 | case EF_PNN: 47 | case EF_OPL: 48 | case EF_SPDI: 49 | case EF_SST: 50 | case EF_CFIS: 51 | case EF_MAILBOX_CPHS: 52 | case EF_VOICE_MAIL_INDICATOR_CPHS: 53 | case EF_CFF_CPHS: 54 | case EF_SPN_CPHS: 55 | case EF_SPN_SHORT_CPHS: 56 | case EF_FDN: 57 | case EF_MSISDN: 58 | case EF_EXT2: 59 | case EF_INFO_CPHS: 60 | case EF_CSP_CPHS: 61 | case EF_GID1: 62 | case EF_GID2: 63 | case EF_LI: 64 | case EF_PLMNWACT: 65 | case EF_HPLMNWACT: 66 | return MF_SIM + DF_ADF; 67 | 68 | case EF_PBR: 69 | // we only support global phonebook. 70 | return MF_SIM + DF_TELECOM + DF_PHONEBOOK; 71 | } 72 | String path = getCommonIccEFPath(efid); 73 | if (path == null) { 74 | // The EFids in USIM phone book entries are decided by the card manufacturer. 75 | // So if we don't match any of the cases above and if its a USIM return 76 | // the phone book path. 77 | return MF_SIM + DF_TELECOM + DF_PHONEBOOK; 78 | } 79 | return path; 80 | } 81 | 82 | @Override 83 | protected void logd(String msg) { 84 | Rlog.d(LOG_TAG, msg); 85 | } 86 | 87 | @Override 88 | protected void loge(String msg) { 89 | Rlog.e(LOG_TAG, msg); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/java/com/google/android/mms/InvalidHeaderValueException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Esmertec AG. 3 | * Copyright (C) 2007 The Android Open Source Project 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.google.android.mms; 19 | 20 | /** 21 | * Thrown when an invalid header value was set. 22 | */ 23 | public class InvalidHeaderValueException extends MmsException { 24 | private static final long serialVersionUID = -2053384496042052262L; 25 | 26 | /** 27 | * Constructs an InvalidHeaderValueException with no detailed message. 28 | */ 29 | public InvalidHeaderValueException() { 30 | super(); 31 | } 32 | 33 | /** 34 | * Constructs an InvalidHeaderValueException with the specified detailed message. 35 | * 36 | * @param message the detailed message. 37 | */ 38 | public InvalidHeaderValueException(String message) { 39 | super(message); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/java/com/google/android/mms/MmsException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Esmertec AG. 3 | * Copyright (C) 2007 The Android Open Source Project 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.google.android.mms; 19 | 20 | /** 21 | * A generic exception that is thrown by the Mms client. 22 | */ 23 | public class MmsException extends Exception { 24 | private static final long serialVersionUID = -7323249827281485390L; 25 | 26 | /** 27 | * Creates a new MmsException. 28 | */ 29 | public MmsException() { 30 | super(); 31 | } 32 | 33 | /** 34 | * Creates a new MmsException with the specified detail message. 35 | * 36 | * @param message the detail message. 37 | */ 38 | public MmsException(String message) { 39 | super(message); 40 | } 41 | 42 | /** 43 | * Creates a new MmsException with the specified cause. 44 | * 45 | * @param cause the cause. 46 | */ 47 | public MmsException(Throwable cause) { 48 | super(cause); 49 | } 50 | 51 | /** 52 | * Creates a new MmsException with the specified detail message and cause. 53 | * 54 | * @param message the detail message. 55 | * @param cause the cause. 56 | */ 57 | public MmsException(String message, Throwable cause) { 58 | super(message, cause); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/java/com/google/android/mms/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {@hide} 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/java/com/google/android/mms/pdu/AcknowledgeInd.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Esmertec AG. 3 | * Copyright (C) 2007 The Android Open Source Project 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.google.android.mms.pdu; 19 | 20 | import com.google.android.mms.InvalidHeaderValueException; 21 | 22 | /** 23 | * M-Acknowledge.ind PDU. 24 | */ 25 | public class AcknowledgeInd extends GenericPdu { 26 | /** 27 | * Constructor, used when composing a M-Acknowledge.ind pdu. 28 | * 29 | * @param mmsVersion current viersion of mms 30 | * @param transactionId the transaction-id value 31 | * @throws InvalidHeaderValueException if parameters are invalid. 32 | * NullPointerException if transactionId is null. 33 | */ 34 | public AcknowledgeInd(int mmsVersion, byte[] transactionId) 35 | throws InvalidHeaderValueException { 36 | super(); 37 | 38 | setMessageType(PduHeaders.MESSAGE_TYPE_ACKNOWLEDGE_IND); 39 | setMmsVersion(mmsVersion); 40 | setTransactionId(transactionId); 41 | } 42 | 43 | /** 44 | * Constructor with given headers. 45 | * 46 | * @param headers Headers for this PDU. 47 | */ 48 | AcknowledgeInd(PduHeaders headers) { 49 | super(headers); 50 | } 51 | 52 | /** 53 | * Get X-Mms-Report-Allowed field value. 54 | * 55 | * @return the X-Mms-Report-Allowed value 56 | */ 57 | public int getReportAllowed() { 58 | return mPduHeaders.getOctet(PduHeaders.REPORT_ALLOWED); 59 | } 60 | 61 | /** 62 | * Set X-Mms-Report-Allowed field value. 63 | * 64 | * @param value the value 65 | * @throws InvalidHeaderValueException if the value is invalid. 66 | */ 67 | public void setReportAllowed(int value) throws InvalidHeaderValueException { 68 | mPduHeaders.setOctet(value, PduHeaders.REPORT_ALLOWED); 69 | } 70 | 71 | /** 72 | * Get X-Mms-Transaction-Id field value. 73 | * 74 | * @return the X-Mms-Report-Allowed value 75 | */ 76 | public byte[] getTransactionId() { 77 | return mPduHeaders.getTextString(PduHeaders.TRANSACTION_ID); 78 | } 79 | 80 | /** 81 | * Set X-Mms-Transaction-Id field value. 82 | * 83 | * @param value the value 84 | * @throws NullPointerException if the value is null. 85 | */ 86 | public void setTransactionId(byte[] value) { 87 | mPduHeaders.setTextString(value, PduHeaders.TRANSACTION_ID); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/java/com/google/android/mms/pdu/GenericPdu.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Esmertec AG. 3 | * Copyright (C) 2007 The Android Open Source Project 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.google.android.mms.pdu; 19 | 20 | import com.google.android.mms.InvalidHeaderValueException; 21 | 22 | public class GenericPdu { 23 | /** 24 | * The headers of pdu. 25 | */ 26 | PduHeaders mPduHeaders = null; 27 | 28 | /** 29 | * Constructor. 30 | */ 31 | public GenericPdu() { 32 | mPduHeaders = new PduHeaders(); 33 | } 34 | 35 | /** 36 | * Constructor. 37 | * 38 | * @param headers Headers for this PDU. 39 | */ 40 | GenericPdu(PduHeaders headers) { 41 | mPduHeaders = headers; 42 | } 43 | 44 | /** 45 | * Get the headers of this PDU. 46 | * 47 | * @return A PduHeaders of this PDU. 48 | */ 49 | PduHeaders getPduHeaders() { 50 | return mPduHeaders; 51 | } 52 | 53 | /** 54 | * Get X-Mms-Message-Type field value. 55 | * 56 | * @return the X-Mms-Report-Allowed value 57 | */ 58 | public int getMessageType() { 59 | return mPduHeaders.getOctet(PduHeaders.MESSAGE_TYPE); 60 | } 61 | 62 | /** 63 | * Set X-Mms-Message-Type field value. 64 | * 65 | * @param value the value 66 | * @throws InvalidHeaderValueException if the value is invalid. 67 | * RuntimeException if field's value is not Octet. 68 | */ 69 | public void setMessageType(int value) throws InvalidHeaderValueException { 70 | mPduHeaders.setOctet(value, PduHeaders.MESSAGE_TYPE); 71 | } 72 | 73 | /** 74 | * Get X-Mms-MMS-Version field value. 75 | * 76 | * @return the X-Mms-MMS-Version value 77 | */ 78 | public int getMmsVersion() { 79 | return mPduHeaders.getOctet(PduHeaders.MMS_VERSION); 80 | } 81 | 82 | /** 83 | * Set X-Mms-MMS-Version field value. 84 | * 85 | * @param value the value 86 | * @throws InvalidHeaderValueException if the value is invalid. 87 | * RuntimeException if field's value is not Octet. 88 | */ 89 | public void setMmsVersion(int value) throws InvalidHeaderValueException { 90 | mPduHeaders.setOctet(value, PduHeaders.MMS_VERSION); 91 | } 92 | 93 | /** 94 | * Get From value. 95 | * From-value = Value-length 96 | * (Address-present-token Encoded-string-value | Insert-address-token) 97 | * 98 | * @return the value 99 | */ 100 | public EncodedStringValue getFrom() { 101 | return mPduHeaders.getEncodedStringValue(PduHeaders.FROM); 102 | } 103 | 104 | /** 105 | * Set From value. 106 | * 107 | * @param value the value 108 | * @throws NullPointerException if the value is null. 109 | */ 110 | public void setFrom(EncodedStringValue value) { 111 | mPduHeaders.setEncodedStringValue(value, PduHeaders.FROM); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/java/com/google/android/mms/pdu/QuotedPrintable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Esmertec AG. 3 | * Copyright (C) 2007 The Android Open Source Project 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.google.android.mms.pdu; 19 | 20 | import java.io.ByteArrayOutputStream; 21 | 22 | public class QuotedPrintable { 23 | private static byte ESCAPE_CHAR = '='; 24 | 25 | /** 26 | * Decodes an array quoted-printable characters into an array of original bytes. 27 | * Escaped characters are converted back to their original representation. 28 | * 29 | *

30 | * This function implements a subset of 31 | * quoted-printable encoding specification (rule #1 and rule #2) 32 | * as defined in RFC 1521. 33 | *

34 | * 35 | * @param bytes array of quoted-printable characters 36 | * @return array of original bytes, 37 | * null if quoted-printable decoding is unsuccessful. 38 | */ 39 | public static final byte[] decodeQuotedPrintable(byte[] bytes) { 40 | if (bytes == null) { 41 | return null; 42 | } 43 | ByteArrayOutputStream buffer = new ByteArrayOutputStream(); 44 | for (int i = 0; i < bytes.length; i++) { 45 | int b = bytes[i]; 46 | if (b == ESCAPE_CHAR) { 47 | try { 48 | if('\r' == (char)bytes[i + 1] && 49 | '\n' == (char)bytes[i + 2]) { 50 | i += 2; 51 | continue; 52 | } 53 | int u = Character.digit((char) bytes[++i], 16); 54 | int l = Character.digit((char) bytes[++i], 16); 55 | if (u == -1 || l == -1) { 56 | return null; 57 | } 58 | buffer.write((char) ((u << 4) + l)); 59 | } catch (ArrayIndexOutOfBoundsException e) { 60 | return null; 61 | } 62 | } else { 63 | buffer.write(b); 64 | } 65 | } 66 | return buffer.toByteArray(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/java/com/google/android/mms/pdu/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {@hide} 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/java/com/google/android/mms/util/PduCacheEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Esmertec AG. 3 | * Copyright (C) 2008 The Android Open Source Project 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.google.android.mms.util; 19 | 20 | import com.google.android.mms.pdu.GenericPdu; 21 | 22 | public final class PduCacheEntry { 23 | private final GenericPdu mPdu; 24 | private final int mMessageBox; 25 | private final long mThreadId; 26 | 27 | public PduCacheEntry(GenericPdu pdu, int msgBox, long threadId) { 28 | mPdu = pdu; 29 | mMessageBox = msgBox; 30 | mThreadId = threadId; 31 | } 32 | 33 | public GenericPdu getPdu() { 34 | return mPdu; 35 | } 36 | 37 | public int getMessageBox() { 38 | return mMessageBox; 39 | } 40 | 41 | public long getThreadId() { 42 | return mThreadId; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/java/com/google/android/mms/util/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {@hide} 4 | 5 | 6 | -------------------------------------------------------------------------------- /tests/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH := $(call my-dir) 16 | 17 | include $(CLEAR_VARS) 18 | 19 | # Include subdirectory makefiles 20 | # ============================================================ 21 | include $(call all-makefiles-under,$(LOCAL_PATH)) 22 | -------------------------------------------------------------------------------- /tests/telephonytests/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | LOCAL_MODULE_TAGS := tests 5 | 6 | LOCAL_SRC_FILES := $(call all-subdir-java-files) 7 | 8 | #LOCAL_STATIC_JAVA_LIBRARIES := librilproto-java 9 | 10 | LOCAL_JAVA_LIBRARIES := android.test.runner telephony-common ims-common services.core 11 | LOCAL_STATIC_JAVA_LIBRARIES := guava \ 12 | mockito-target \ 13 | android-support-test \ 14 | platform-test-annotations 15 | 16 | LOCAL_PACKAGE_NAME := FrameworksTelephonyTests 17 | 18 | include $(BUILD_PACKAGE) 19 | -------------------------------------------------------------------------------- /tests/telephonytests/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 20 | 21 | 22 | 23 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /tests/telephonytests/src/com/android/internal/telephony/CallStateExceptionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.android.internal.telephony; 17 | 18 | import android.test.suitebuilder.annotation.SmallTest; 19 | import org.junit.After; 20 | import org.junit.Test; 21 | import static org.junit.Assert.assertEquals; 22 | 23 | public class CallStateExceptionTest { 24 | private CallStateException mCallStateException; 25 | 26 | @After 27 | public void tearDown() throws Exception { 28 | mCallStateException = null; 29 | } 30 | 31 | @Test 32 | @SmallTest 33 | public void testCallStateExceptionDefault() { 34 | mCallStateException = new CallStateException("sanity test"); 35 | assertEquals("sanity test", mCallStateException.getMessage()); 36 | assertEquals(mCallStateException.ERROR_INVALID, mCallStateException.getError()); 37 | } 38 | 39 | @Test 40 | @SmallTest 41 | public void testCallStateExceptionWithErrCode() { 42 | mCallStateException = new CallStateException(mCallStateException.ERROR_DISCONNECTED, 43 | "sanity test with err code"); 44 | assertEquals("sanity test with err code", mCallStateException.getMessage()); 45 | assertEquals(mCallStateException.ERROR_DISCONNECTED, mCallStateException.getError()); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /tests/telephonytests/src/com/android/internal/telephony/NeighboringCellInfoTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.android.internal.telephony; 17 | 18 | import android.os.Parcel; 19 | import android.test.AndroidTestCase; 20 | import android.telephony.NeighboringCellInfo; 21 | import android.test. suitebuilder.annotation.SmallTest; 22 | 23 | import static android.telephony.TelephonyManager.NETWORK_TYPE_UNKNOWN; 24 | import static android.telephony.TelephonyManager.NETWORK_TYPE_EDGE; 25 | import static android.telephony.TelephonyManager.NETWORK_TYPE_GPRS; 26 | import static android.telephony.TelephonyManager.NETWORK_TYPE_UMTS; 27 | 28 | public class NeighboringCellInfoTest extends AndroidTestCase { 29 | @SmallTest 30 | public void testConstructor() { 31 | int rssi = 31; 32 | NeighboringCellInfo nc; 33 | 34 | nc = new NeighboringCellInfo(rssi, "FFFFFFF", NETWORK_TYPE_EDGE); 35 | assertEquals(NETWORK_TYPE_EDGE, nc.getNetworkType()); 36 | assertEquals(rssi, nc.getRssi()); 37 | assertEquals(0xfff, nc.getLac()); 38 | assertEquals(0xffff, nc.getCid()); 39 | assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getPsc()); 40 | 41 | nc = new NeighboringCellInfo(rssi, "1FF", NETWORK_TYPE_UMTS); 42 | assertEquals(NETWORK_TYPE_UMTS, nc.getNetworkType()); 43 | assertEquals(rssi, nc.getRssi()); 44 | assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getCid()); 45 | assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getLac()); 46 | assertEquals(0x1ff, nc.getPsc()); 47 | 48 | nc = new NeighboringCellInfo(rssi, "1FF", NETWORK_TYPE_UNKNOWN); 49 | assertEquals(NETWORK_TYPE_UNKNOWN, nc.getNetworkType()); 50 | assertEquals(rssi, nc.getRssi()); 51 | assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getCid()); 52 | assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getLac()); 53 | assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getPsc()); 54 | } 55 | 56 | @SmallTest 57 | public void testParcel() { 58 | int rssi = 20; 59 | 60 | NeighboringCellInfo nc = new NeighboringCellInfo(rssi, "12345678", NETWORK_TYPE_GPRS); 61 | assertEquals(NETWORK_TYPE_GPRS, nc.getNetworkType()); 62 | assertEquals(rssi, nc.getRssi()); 63 | assertEquals(0x1234, nc.getLac()); 64 | assertEquals(0x5678, nc.getCid()); 65 | assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getPsc()); 66 | 67 | Parcel p = Parcel.obtain(); 68 | p.setDataPosition(0); 69 | nc.writeToParcel(p, 0); 70 | 71 | p.setDataPosition(0); 72 | NeighboringCellInfo nw = new NeighboringCellInfo(p); 73 | assertEquals(NETWORK_TYPE_GPRS, nw.getNetworkType()); 74 | assertEquals(rssi, nw.getRssi()); 75 | assertEquals(0x1234, nw.getLac()); 76 | assertEquals(0x5678, nw.getCid()); 77 | assertEquals(NeighboringCellInfo.UNKNOWN_CID, nw.getPsc()); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /tests/telephonytests/src/com/android/internal/telephony/PhoneFactoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony; 18 | 19 | import android.test.suitebuilder.annotation.SmallTest; 20 | 21 | import org.junit.Test; 22 | 23 | import static org.junit.Assert.fail; 24 | 25 | public class PhoneFactoryTest { 26 | @Test 27 | @SmallTest 28 | public void testBeforeMakePhone() { 29 | try { 30 | Phone phone = PhoneFactory.getDefaultPhone(); 31 | fail("Expecting IllegalStateException"); 32 | } catch (IllegalStateException e) { 33 | } 34 | 35 | try { 36 | Phone phone = PhoneFactory.getPhone(0); 37 | fail("Expecting IllegalStateException"); 38 | } catch (IllegalStateException e) { 39 | } 40 | 41 | try { 42 | Phone[] phone = PhoneFactory.getPhones(); 43 | fail("Expecting IllegalStateException"); 44 | } catch (IllegalStateException e) { 45 | } 46 | } 47 | 48 | //todo: add test for makeDefaultPhone(). will need some refactoring in PhoneFactory. 49 | } 50 | -------------------------------------------------------------------------------- /tests/telephonytests/src/com/android/internal/telephony/PhoneStateListenerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.android.internal.telephony; 17 | 18 | import android.os.HandlerThread; 19 | import android.telephony.PhoneStateListener; 20 | import android.telephony.ServiceState; 21 | import android.test.suitebuilder.annotation.SmallTest; 22 | import org.junit.After; 23 | import org.junit.Before; 24 | import org.junit.Test; 25 | import java.lang.reflect.Field; 26 | import static org.mockito.Mockito.verify; 27 | 28 | public class PhoneStateListenerTest extends TelephonyTest { 29 | 30 | private PhoneStateListener mPhoneStateListenerUT; 31 | private PhoneStateListenerHandler mPhoneStateListenerHandler; 32 | 33 | private class PhoneStateListenerHandler extends HandlerThread { 34 | private PhoneStateListenerHandler(String name) { 35 | super(name); 36 | } 37 | @Override 38 | public void onLooperPrepared() { 39 | 40 | mPhoneStateListenerUT = new PhoneStateListener() { 41 | @Override 42 | public void onServiceStateChanged(ServiceState serviceState) { 43 | logd("Service State Changed"); 44 | mServiceState.setVoiceRegState(serviceState.getVoiceRegState()); 45 | mServiceState.setDataRegState(serviceState.getDataRegState()); 46 | setReady(true); 47 | } 48 | }; 49 | setReady(true); 50 | } 51 | } 52 | 53 | @Before 54 | public void setUp() throws Exception { 55 | this.setUp(this.getClass().getSimpleName()); 56 | mPhoneStateListenerHandler = new PhoneStateListenerHandler(TAG); 57 | mPhoneStateListenerHandler.start(); 58 | waitUntilReady(); 59 | } 60 | 61 | @After 62 | public void tearDown() throws Exception { 63 | mPhoneStateListenerHandler.quitSafely(); 64 | super.tearDown(); 65 | } 66 | 67 | @Test @SmallTest 68 | public void testTriggerServiceStateChanged() throws Exception { 69 | Field field = PhoneStateListener.class.getDeclaredField("callback"); 70 | field.setAccessible(true); 71 | 72 | ServiceState ss = new ServiceState(); 73 | ss.setDataRegState(ServiceState.STATE_IN_SERVICE); 74 | ss.setVoiceRegState(ServiceState.STATE_EMERGENCY_ONLY); 75 | 76 | setReady(false); 77 | ((IPhoneStateListener) field.get(mPhoneStateListenerUT)).onServiceStateChanged(ss); 78 | waitUntilReady(); 79 | 80 | verify(mServiceState).setDataRegState(ServiceState.STATE_IN_SERVICE); 81 | verify(mServiceState).setVoiceRegState(ServiceState.STATE_EMERGENCY_ONLY); 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /tests/telephonytests/src/com/android/internal/telephony/SimSmsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony; 18 | 19 | import android.app.ActivityThread; 20 | import android.os.ServiceManager; 21 | import android.test.suitebuilder.annotation.MediumTest; 22 | import android.test.suitebuilder.annotation.Suppress; 23 | 24 | import java.util.List; 25 | 26 | import junit.framework.TestCase; 27 | 28 | public class SimSmsTest extends TestCase { 29 | 30 | @MediumTest 31 | @Suppress // TODO: suppress this test for now since it doesn't work on the emulator 32 | public void testBasic() throws Exception { 33 | 34 | ISms sms = ISms.Stub.asInterface(ServiceManager.getService("isms")); 35 | assertNotNull(sms); 36 | 37 | int preferredSmsSubscription = sms.getPreferredSmsSubscription(); 38 | List records = sms.getAllMessagesFromIccEfForSubscriber( 39 | preferredSmsSubscription, ActivityThread.currentPackageName()); 40 | assertNotNull(records); 41 | assertTrue(records.size() >= 0); 42 | 43 | int firstNullIndex = -1; 44 | int firstValidIndex = -1; 45 | byte[] pdu = null; 46 | for (int i = 0; i < records.size(); i++) { 47 | SmsRawData data = records.get(i); 48 | if (data != null && firstValidIndex == -1) { 49 | firstValidIndex = i; 50 | pdu = data.getBytes(); 51 | } 52 | if (data == null && firstNullIndex == -1) { 53 | firstNullIndex = i; 54 | } 55 | if (firstNullIndex != -1 && firstValidIndex != -1) { 56 | break; 57 | } 58 | } 59 | if (firstNullIndex == -1 || firstValidIndex == -1) 60 | return; 61 | assertNotNull(pdu); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /tests/telephonytests/src/com/android/internal/telephony/SimUtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony; 18 | 19 | import com.android.internal.telephony.gsm.SimTlv; 20 | import com.android.internal.telephony.uicc.IccUtils; 21 | 22 | import junit.framework.TestCase; 23 | import android.test.suitebuilder.annotation.SmallTest; 24 | 25 | 26 | public class SimUtilsTest extends TestCase { 27 | 28 | @SmallTest 29 | public void testBasic() throws Exception { 30 | byte[] data, data2; 31 | 32 | /* 33 | * bcdToString() 34 | */ 35 | 36 | // An EF[ICCID] record 37 | data = IccUtils.hexStringToBytes("981062400510444868f2"); 38 | assertEquals("8901260450014484862", IccUtils.bcdToString(data, 0, data.length)); 39 | 40 | // skip the first and last bytes 41 | assertEquals("0126045001448486", IccUtils.bcdToString(data, 1, data.length - 2)); 42 | 43 | // Stops on invalid BCD value 44 | data = IccUtils.hexStringToBytes("98E062400510444868f2"); 45 | assertEquals("890", IccUtils.bcdToString(data, 0, data.length)); 46 | 47 | // skip the high nibble 'F' since some PLMNs have it 48 | data = IccUtils.hexStringToBytes("98F062400510444868f2"); 49 | assertEquals("890260450014484862", IccUtils.bcdToString(data, 0, data.length)); 50 | 51 | /* 52 | * gsmBcdByteToInt() 53 | */ 54 | 55 | assertEquals(98, IccUtils.gsmBcdByteToInt((byte) 0x89)); 56 | 57 | // Out of range is treated as 0 58 | assertEquals(8, IccUtils.gsmBcdByteToInt((byte) 0x8c)); 59 | 60 | /* 61 | * cdmaBcdByteToInt() 62 | */ 63 | 64 | assertEquals(89, IccUtils.cdmaBcdByteToInt((byte) 0x89)); 65 | 66 | // Out of range is treated as 0 67 | assertEquals(80, IccUtils.cdmaBcdByteToInt((byte) 0x8c)); 68 | 69 | /* 70 | * adnStringFieldToString() 71 | */ 72 | 73 | 74 | data = IccUtils.hexStringToBytes("00566f696365204d61696c07918150367742f3ffffffffffff"); 75 | // Again, skip prepended 0 76 | // (this is an EF[ADN] record) 77 | assertEquals("Voice Mail", IccUtils.adnStringFieldToString(data, 1, data.length - 15)); 78 | 79 | data = IccUtils.hexStringToBytes("809673539A5764002F004DFFFFFFFFFF"); 80 | // (this is from an EF[ADN] record) 81 | assertEquals("\u9673\u539A\u5764/M", IccUtils.adnStringFieldToString(data, 0, data.length)); 82 | 83 | data = IccUtils.hexStringToBytes("810A01566fec6365204de0696cFFFFFF"); 84 | // (this is made up to test since I don't have a real one) 85 | assertEquals("Vo\u00ECce M\u00E0il", IccUtils.adnStringFieldToString(data, 0, data.length)); 86 | 87 | data = IccUtils.hexStringToBytes("820505302D82d32d31"); 88 | // Example from 3GPP TS 11.11 V18.1.3.0 annex B 89 | assertEquals("-\u0532\u0583-1", IccUtils.adnStringFieldToString(data, 0, data.length)); 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.android.internal.telephony; 17 | 18 | import android.telephony.SubscriptionManager; 19 | import android.test.suitebuilder.annotation.SmallTest; 20 | import static org.junit.Assert.*; 21 | import org.junit.After; 22 | import org.junit.Before; 23 | import org.junit.Test; 24 | 25 | import android.telephony.SubscriptionInfo; 26 | 27 | public class SubscriptionInfoTest { 28 | private SubscriptionInfo mSubscriptionInfoUT; 29 | 30 | @After 31 | public void tearDown() throws Exception { 32 | mSubscriptionInfoUT = null; 33 | } 34 | 35 | @Before 36 | public void setUp() throws Exception { 37 | mSubscriptionInfoUT = new SubscriptionInfo(1, "890126042XXXXXXXXXXX", 0, "T-mobile", 38 | "T-mobile", 0, 255, "12345", 0, null, 310, 260, "156", 0); 39 | } 40 | 41 | @Test 42 | @SmallTest 43 | public void testSubProperties() { 44 | assertEquals(260, mSubscriptionInfoUT.getMnc()); 45 | assertEquals(310, mSubscriptionInfoUT.getMcc()); 46 | assertEquals("12345", mSubscriptionInfoUT.getNumber()); 47 | assertEquals(0, mSubscriptionInfoUT.getDataRoaming()); 48 | assertEquals("T-mobile", mSubscriptionInfoUT.getDisplayName()); 49 | assertEquals("T-mobile", mSubscriptionInfoUT.getCarrierName()); 50 | assertEquals("156", mSubscriptionInfoUT.getCountryIso()); 51 | assertEquals(255, mSubscriptionInfoUT.getIconTint()); 52 | assertEquals(0, mSubscriptionInfoUT.getNameSource()); 53 | assertEquals(1, mSubscriptionInfoUT.getSubscriptionId()); 54 | assertEquals(0, mSubscriptionInfoUT.getSimSlotIndex()); 55 | assertEquals("890126042XXXXXXXXXXX", mSubscriptionInfoUT.getIccId()); 56 | } 57 | 58 | @Test 59 | @SmallTest 60 | public void testSetGetCarrierName() { 61 | assertEquals("T-mobile", mSubscriptionInfoUT.getCarrierName()); 62 | mSubscriptionInfoUT.setCarrierName("Verizon"); 63 | assertEquals("Verizon", mSubscriptionInfoUT.getCarrierName()); 64 | } 65 | 66 | @Test 67 | @SmallTest 68 | public void testSetGetDisplayName() { 69 | assertEquals("T-mobile", mSubscriptionInfoUT.getDisplayName()); 70 | mSubscriptionInfoUT.setDisplayName("Verizon"); 71 | assertEquals("Verizon", mSubscriptionInfoUT.getDisplayName()); 72 | } 73 | 74 | @Test 75 | @SmallTest 76 | public void testSetGetIconTint() { 77 | assertEquals(255, mSubscriptionInfoUT.getIconTint()); 78 | mSubscriptionInfoUT.setIconTint(0); 79 | assertEquals(0, mSubscriptionInfoUT.getIconTint()); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /tests/telephonytests/src/com/android/internal/telephony/TestApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony; 18 | 19 | import android.app.Application; 20 | import android.content.Context; 21 | 22 | public class TestApplication extends Application { 23 | private static Context context; 24 | 25 | public void onCreate() { 26 | super.onCreate(); 27 | TestApplication.context = getApplicationContext(); 28 | } 29 | 30 | public static Context getAppContext() { 31 | return TestApplication.context; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tests/telephonytests/src/com/android/internal/telephony/TestFixture.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony; 18 | 19 | /** 20 | * An object that provides supporting methods, fields, and other functionality for configuring 21 | * and inspecting the results of operations on a test double (mock, fake or stub). The test double 22 | * is an object of type {@code T}. 23 | */ 24 | public interface TestFixture { 25 | 26 | /** 27 | * Obtain the actual test double provided by this holder. It is a requirement of this API 28 | * that the test double as returned from this method be a Mockito mock or spy, so that a test 29 | * can use Mockito APIs to directly instrument its behavior where needed. 30 | * 31 | * @return the test double. 32 | */ 33 | T getTestDouble(); 34 | } 35 | -------------------------------------------------------------------------------- /tests/telephonytests/src/com/android/internal/telephony/TestPhoneNotifier.java.broken: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony; 18 | 19 | import com.android.internal.telephony.Phone; 20 | import com.android.internal.telephony.PhoneConstants; 21 | import android.telephony.CellInfo; 22 | 23 | import java.util.List; 24 | 25 | /** 26 | * Stub class used for unit tests 27 | */ 28 | 29 | public class TestPhoneNotifier implements PhoneNotifier { 30 | public TestPhoneNotifier() { 31 | } 32 | 33 | public void notifyPhoneState(Phone sender) { 34 | } 35 | 36 | public void notifyServiceState(Phone sender) { 37 | } 38 | 39 | public void notifyCellLocation(Phone sender) { 40 | } 41 | 42 | public void notifySignalStrength(Phone sender) { 43 | } 44 | 45 | public void notifyMessageWaitingChanged(Phone sender) { 46 | } 47 | 48 | public void notifyCallForwardingChanged(Phone sender) { 49 | } 50 | 51 | public void notifyDataConnection(Phone sender, String reason, String apnType) { 52 | } 53 | 54 | public void notifyDataConnection(Phone sender, String reason, String apnType, 55 | PhoneConstants.DataState state) { 56 | } 57 | 58 | public void notifyDataConnectionFailed(Phone sender, String reason, String apnType) { 59 | } 60 | 61 | public void notifyDataActivity(Phone sender) { 62 | } 63 | 64 | public void notifyOtaspChanged(Phone sender, int otaspMode) { 65 | } 66 | 67 | public void notifyCellInfo(Phone sender, List cellInfo) { 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /tests/telephonytests/src/com/android/internal/telephony/VisualVoicemailSmsFilterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License 15 | */ 16 | 17 | package com.android.internal.telephony; 18 | 19 | import android.content.Context; 20 | import android.telephony.TelephonyManager; 21 | import android.telephony.VisualVoicemailSmsFilterSettings; 22 | 23 | import junit.framework.TestCase; 24 | 25 | import org.mockito.Mockito; 26 | 27 | public class VisualVoicemailSmsFilterTest extends TestCase { 28 | 29 | /** 30 | * b/29123941 iPhone style notification SMS is neither 3GPP nor 3GPP2, but some plain text 31 | * message. {@link android.telephony.SmsMessage.createFromPdu()} will fail to parse it and 32 | * return an invalid object, causing {@link NullPointerException} on any operation if not 33 | * handled. 34 | */ 35 | public void testUnsupportedPdu() { 36 | Context context = Mockito.mock(Context.class); 37 | TelephonyManager telephonyManager = Mockito.mock(TelephonyManager.class); 38 | Mockito.when(context.getSystemServiceName(TelephonyManager.class)) 39 | .thenReturn(Context.TELEPHONY_SERVICE); 40 | Mockito.when(context.getSystemService(Mockito.anyString())).thenReturn(telephonyManager); 41 | 42 | VisualVoicemailSmsFilterSettings settings = new VisualVoicemailSmsFilterSettings.Builder() 43 | .build(); 44 | 45 | Mockito.when(telephonyManager 46 | .getVisualVoicemailSmsFilterSettings(Mockito.anyString(), Mockito.anyInt())) 47 | .thenReturn(settings); 48 | 49 | byte[][] pdus = { 50 | ("MBOXUPDATE?m=11;server=example.com;" 51 | + "port=143;name=1234567890@example.com;pw=CphQJKnYS4jEiDO").getBytes()}; 52 | VisualVoicemailSmsFilter.filter(context, pdus, SmsConstants.FORMAT_3GPP2, 0, 0); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /tests/telephonytests/src/com/android/internal/telephony/VoLteServiceStateTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony; 18 | 19 | import android.os.Bundle; 20 | import android.os.Parcel; 21 | import android.telephony.VoLteServiceState; 22 | import android.test.suitebuilder.annotation.SmallTest; 23 | 24 | import junit.framework.TestCase; 25 | 26 | 27 | public class VoLteServiceStateTest extends TestCase { 28 | 29 | @SmallTest 30 | public void testGetState() { 31 | VoLteServiceState state = new VoLteServiceState(VoLteServiceState.HANDOVER_STARTED); 32 | assertEquals(VoLteServiceState.HANDOVER_STARTED, state.getSrvccState()); 33 | } 34 | 35 | @SmallTest 36 | public void testParcel() { 37 | VoLteServiceState state = new VoLteServiceState(VoLteServiceState.HANDOVER_FAILED); 38 | Parcel p = Parcel.obtain(); 39 | state.writeToParcel(p, 0); 40 | p.setDataPosition(0); 41 | VoLteServiceState newState = VoLteServiceState.CREATOR.createFromParcel(p); 42 | assertEquals(state, newState); 43 | } 44 | 45 | @SmallTest 46 | public void testCreateFromBundle() { 47 | Bundle b = new Bundle(); 48 | b.putInt("mSrvccState", VoLteServiceState.HANDOVER_COMPLETED); 49 | assertEquals(VoLteServiceState.HANDOVER_COMPLETED, 50 | VoLteServiceState.newFromBundle(b).getSrvccState()); 51 | } 52 | 53 | @SmallTest 54 | public void testFillInNotifierBundle() { 55 | Bundle b = new Bundle(); 56 | VoLteServiceState state = new VoLteServiceState(VoLteServiceState.HANDOVER_CANCELED); 57 | state.fillInNotifierBundle(b); 58 | assertEquals(VoLteServiceState.HANDOVER_CANCELED, b.getInt("mSrvccState")); 59 | } 60 | 61 | @SmallTest 62 | public void testCopy() { 63 | VoLteServiceState state = new VoLteServiceState(VoLteServiceState.HANDOVER_STARTED); 64 | VoLteServiceState newState = new VoLteServiceState(state); 65 | assertEquals(state, newState); 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /tests/telephonytests/src/com/android/internal/telephony/cdma/sms/BearerDataTest.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | package com.android.internal.telephony.cdma.sms; 30 | 31 | import android.test.AndroidTestCase; 32 | import java.lang.reflect.*; 33 | 34 | import static org.mockito.Mockito.mock; 35 | 36 | /** 37 | * Test cases for BearerData testDecode7bitAscii 38 | */ 39 | public class BearerDataTest extends AndroidTestCase { 40 | public void testDecode7bitAscii() throws Exception { 41 | Method dm = BearerData.class.getDeclaredMethod("decode7bitAscii", 42 | byte[].class, int.class, int.class); 43 | dm.setAccessible(true); 44 | 45 | // 56 bit test stream, assuming offset=1 byte, padding=6 bits 46 | // numFields=7. So, I want 49 bits. The old logic would give 47 | // 57 bits which is wrong 48 | byte[] testbyte = new byte[7]; 49 | int offset = 1; 50 | int numFields = 7; 51 | 52 | dm.invoke(null, testbyte, offset, numFields); 53 | assertTrue(true); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsCallTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License 15 | */ 16 | 17 | package com.android.internal.telephony.imsphone; 18 | 19 | import android.os.Bundle; 20 | import android.os.Handler; 21 | import android.os.Looper; 22 | import android.telephony.ServiceState; 23 | import android.test.suitebuilder.annotation.SmallTest; 24 | 25 | import com.android.ims.ImsCall; 26 | import com.android.ims.ImsCallProfile; 27 | import com.android.internal.telephony.Call; 28 | import com.android.internal.telephony.TelephonyTest; 29 | 30 | import org.junit.After; 31 | import org.junit.Before; 32 | import org.junit.Test; 33 | 34 | import static org.junit.Assert.assertFalse; 35 | import static org.junit.Assert.assertTrue; 36 | import static org.mockito.Mockito.doReturn; 37 | 38 | public class ImsCallTest extends TelephonyTest { 39 | 40 | private Bundle mBundle; 41 | private ImsCallProfile mTestCallProfile; 42 | 43 | @Before 44 | public void setUp() throws Exception { 45 | super.setUp(getClass().getSimpleName()); 46 | mTestCallProfile = new ImsCallProfile(); 47 | mBundle = mTestCallProfile.mCallExtras; 48 | } 49 | 50 | @After 51 | public void tearDown() throws Exception { 52 | super.tearDown(); 53 | } 54 | 55 | @Test 56 | @SmallTest 57 | public void testSetWifi() { 58 | ImsCall mTestImsCall = new ImsCall(mContext, mTestCallProfile); 59 | assertFalse(mTestImsCall.isWifiCall()); 60 | mBundle.putString(ImsCallProfile.EXTRA_CALL_RAT_TYPE, 61 | ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN + ""); 62 | assertTrue(mTestImsCall.isWifiCall()); 63 | } 64 | 65 | @Test 66 | @SmallTest 67 | public void testSetWifiAlt() { 68 | ImsCall mTestImsCall = new ImsCall(mContext, mTestCallProfile); 69 | assertFalse(mTestImsCall.isWifiCall()); 70 | mBundle.putString(ImsCallProfile.EXTRA_CALL_RAT_TYPE_ALT, 71 | ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN + ""); 72 | assertTrue(mTestImsCall.isWifiCall()); 73 | } 74 | 75 | @Test 76 | @SmallTest 77 | public void testSetLteNoWifi() { 78 | ImsCall mTestImsCall = new ImsCall(mContext, mTestCallProfile); 79 | assertFalse(mTestImsCall.isWifiCall()); 80 | mBundle.putString(ImsCallProfile.EXTRA_CALL_RAT_TYPE, 81 | ServiceState.RIL_RADIO_TECHNOLOGY_LTE + ""); 82 | assertFalse(mTestImsCall.isWifiCall()); 83 | } 84 | 85 | @Test 86 | @SmallTest 87 | public void testSetLteNoWifiAlt() { 88 | ImsCall mTestImsCall = new ImsCall(mContext, mTestCallProfile); 89 | assertFalse(mTestImsCall.isWifiCall()); 90 | mBundle.putString(ImsCallProfile.EXTRA_CALL_RAT_TYPE_ALT, 91 | ServiceState.RIL_RADIO_TECHNOLOGY_LTE + ""); 92 | assertFalse(mTestImsCall.isWifiCall()); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneFactoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.android.internal.telephony.imsphone; 17 | 18 | import android.os.HandlerThread; 19 | import android.test.suitebuilder.annotation.SmallTest; 20 | import com.android.internal.telephony.PhoneNotifier; 21 | import com.android.internal.telephony.TelephonyTest; 22 | 23 | import org.junit.After; 24 | import org.junit.Before; 25 | import org.junit.Test; 26 | import org.mockito.Mock; 27 | import static org.junit.Assert.assertNotNull; 28 | import static org.junit.Assert.assertEquals; 29 | import static org.mockito.Mockito.eq; 30 | import static org.mockito.Mockito.times; 31 | import static org.mockito.Mockito.verify; 32 | 33 | public class ImsPhoneFactoryTest extends TelephonyTest { 34 | 35 | @Mock 36 | private PhoneNotifier mPhoneNotifer; 37 | private ImsPhone mImsPhoneUT; 38 | private ImsPhoneFactoryHandler mImsPhoneFactoryHandler; 39 | 40 | private class ImsPhoneFactoryHandler extends HandlerThread { 41 | 42 | private ImsPhoneFactoryHandler(String name) { 43 | super(name); 44 | } 45 | @Override 46 | public void onLooperPrepared() { 47 | mImsPhoneUT = ImsPhoneFactory.makePhone(mContext, mPhoneNotifer, mPhone); 48 | setReady(true); 49 | } 50 | } 51 | 52 | @Before 53 | public void setUp() throws Exception { 54 | super.setUp(this.getClass().getSimpleName()); 55 | mImsPhoneFactoryHandler = new ImsPhoneFactoryHandler(this.getClass().getSimpleName()); 56 | mImsPhoneFactoryHandler.start(); 57 | 58 | waitUntilReady(); 59 | } 60 | 61 | @After 62 | public void tearDown() throws Exception { 63 | mImsPhoneFactoryHandler.quitSafely(); 64 | super.tearDown(); 65 | } 66 | 67 | @Test @SmallTest 68 | public void testMakeImsPhone() throws Exception { 69 | assertNotNull(mImsPhoneUT); 70 | assertEquals(mPhone, mImsPhoneUT.getDefaultPhone()); 71 | 72 | mImsPhoneUT.notifyDataActivity(); 73 | verify(mPhoneNotifer, times(1)).notifyDataActivity(eq(mImsPhoneUT)); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /tests/telephonytests/src/com/android/internal/telephony/metrics/InProgressCallSessionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.metrics; 18 | 19 | import android.test.suitebuilder.annotation.SmallTest; 20 | 21 | import com.android.internal.telephony.TelephonyProto; 22 | import com.android.internal.telephony.TelephonyTest; 23 | 24 | import org.junit.After; 25 | import org.junit.Before; 26 | import org.junit.Test; 27 | 28 | import static org.junit.Assert.assertEquals; 29 | import static org.junit.Assert.assertFalse; 30 | import static org.junit.Assert.assertTrue; 31 | 32 | public class InProgressCallSessionTest extends TelephonyTest { 33 | 34 | private InProgressCallSession mCallSession; 35 | 36 | @Before 37 | public void setUp() throws Exception { 38 | super.setUp(getClass().getSimpleName()); 39 | mCallSession = new InProgressCallSession(mPhone.getPhoneId()); 40 | } 41 | 42 | @After 43 | public void tearDown() throws Exception { 44 | super.tearDown(); 45 | } 46 | 47 | // Test add event 48 | @Test 49 | @SmallTest 50 | public void testAddEvent() { 51 | CallSessionEventBuilder builder = new CallSessionEventBuilder( 52 | TelephonyProto.TelephonyCallSession.Event.Type.RIL_RESPONSE) 53 | .setRilRequest(1) 54 | .setRilRequestId(2) 55 | .setRilError(3); 56 | mCallSession.addEvent(builder); 57 | assertEquals(builder.build(), mCallSession.events.getFirst()); 58 | assertFalse(mCallSession.isEventsDropped()); 59 | } 60 | 61 | // Test dropped event scenario 62 | @Test 63 | @SmallTest 64 | public void testEventDropped() { 65 | for (int i = 0; i < 301; i++) { 66 | CallSessionEventBuilder builder = new CallSessionEventBuilder( 67 | TelephonyProto.TelephonyCallSession.Event.Type.RIL_RESPONSE) 68 | .setRilRequest(1) 69 | .setRilRequestId(i + 1) 70 | .setRilError(3); 71 | mCallSession.addEvent(builder); 72 | } 73 | 74 | assertTrue(mCallSession.isEventsDropped()); 75 | assertEquals(2, mCallSession.events.getFirst().getRilRequestId()); 76 | } 77 | } -------------------------------------------------------------------------------- /tests/telephonytests/src/com/android/internal/telephony/metrics/InProgressSmsSessionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.metrics; 18 | 19 | import android.test.suitebuilder.annotation.SmallTest; 20 | 21 | import com.android.internal.telephony.TelephonyProto; 22 | import com.android.internal.telephony.TelephonyTest; 23 | 24 | import org.junit.After; 25 | import org.junit.Before; 26 | import org.junit.Test; 27 | 28 | import static org.junit.Assert.assertEquals; 29 | import static org.junit.Assert.assertFalse; 30 | import static org.junit.Assert.assertTrue; 31 | 32 | public class InProgressSmsSessionTest extends TelephonyTest { 33 | 34 | private InProgressSmsSession mSmsSession; 35 | 36 | @Before 37 | public void setUp() throws Exception { 38 | super.setUp(getClass().getSimpleName()); 39 | mSmsSession = new InProgressSmsSession(mPhone.getPhoneId()); 40 | } 41 | 42 | @After 43 | public void tearDown() throws Exception { 44 | super.tearDown(); 45 | } 46 | 47 | // Test add event 48 | @Test 49 | @SmallTest 50 | public void testAddEvent() { 51 | SmsSessionEventBuilder builder = new SmsSessionEventBuilder( 52 | TelephonyProto.SmsSession.Event.Type.SMS_SEND_RESULT) 53 | .setRilRequestId(2); 54 | mSmsSession.addEvent(builder); 55 | assertEquals(builder.build(), mSmsSession.events.getFirst()); 56 | assertFalse(mSmsSession.isEventsDropped()); 57 | } 58 | 59 | // Test dropped event scenario 60 | @Test 61 | @SmallTest 62 | public void testEventDropped() { 63 | for (int i = 0; i < 25; i++) { 64 | SmsSessionEventBuilder builder = new SmsSessionEventBuilder( 65 | TelephonyProto.SmsSession.Event.Type.SMS_SEND_RESULT) 66 | .setRilRequestId(i + 1); 67 | mSmsSession.addEvent(builder); 68 | } 69 | 70 | assertTrue(mSmsSession.isEventsDropped()); 71 | assertEquals(6, mSmsSession.events.getFirst().getRilRequestId()); 72 | } 73 | 74 | // Test dropped event scenario 75 | @Test 76 | @SmallTest 77 | public void testExpectedResponse() { 78 | mSmsSession.increaseExpectedResponse(); 79 | assertEquals(1, mSmsSession.getNumExpectedResponses()); 80 | mSmsSession.decreaseExpectedResponse(); 81 | assertEquals(0, mSmsSession.getNumExpectedResponses()); 82 | 83 | for (int i = 0; i < 100; i++) { 84 | mSmsSession.increaseExpectedResponse(); 85 | } 86 | 87 | assertEquals(100, mSmsSession.getNumExpectedResponses()); 88 | 89 | for (int i = 0; i < 50; i++) { 90 | mSmsSession.decreaseExpectedResponse(); 91 | } 92 | 93 | assertEquals(50, mSmsSession.getNumExpectedResponses()); 94 | } 95 | } -------------------------------------------------------------------------------- /tests/telephonytests/src/com/android/internal/telephony/mocks/PhoneSwitcherMock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.mocks; 18 | 19 | import android.os.Handler; 20 | import android.os.Looper; 21 | import android.os.Registrant; 22 | import android.os.RegistrantList; 23 | 24 | import com.android.internal.annotations.VisibleForTesting; 25 | import com.android.internal.telephony.PhoneSwitcher; 26 | 27 | import java.util.concurrent.atomic.AtomicBoolean; 28 | 29 | public class PhoneSwitcherMock extends PhoneSwitcher { 30 | private final int mNumPhones; 31 | private final RegistrantList mActivePhoneRegistrants[]; 32 | private final AtomicBoolean mIsActive[]; 33 | 34 | public PhoneSwitcherMock(int numPhones, Looper looper) { 35 | super(looper); 36 | 37 | mNumPhones = numPhones; 38 | mActivePhoneRegistrants = new RegistrantList[numPhones]; 39 | mIsActive = new AtomicBoolean[numPhones]; 40 | for(int i = 0; i < numPhones; i++) { 41 | mActivePhoneRegistrants[i] = new RegistrantList(); 42 | mIsActive[i] = new AtomicBoolean(false); 43 | } 44 | } 45 | 46 | @Override 47 | public void resendDataAllowed(int phoneId) { 48 | throw new RuntimeException("resendPhone not implemented"); 49 | } 50 | 51 | @Override 52 | public boolean isPhoneActive(int phoneId) { 53 | return mIsActive[phoneId].get(); 54 | } 55 | 56 | @Override 57 | public void registerForActivePhoneSwitch(int phoneId, Handler h, int what, Object o) { 58 | validatePhoneId(phoneId); 59 | Registrant r = new Registrant(h, what, o); 60 | mActivePhoneRegistrants[phoneId].add(r); 61 | r.notifyRegistrant(); 62 | } 63 | 64 | @Override 65 | public void unregisterForActivePhoneSwitch(int phoneId, Handler h) { 66 | validatePhoneId(phoneId); 67 | mActivePhoneRegistrants[phoneId].remove(h); 68 | } 69 | 70 | private void validatePhoneId(int phoneId) { 71 | if (phoneId < 0 || phoneId >= mNumPhones) { 72 | throw new IllegalArgumentException("Invalid PhoneId"); 73 | } 74 | } 75 | 76 | @VisibleForTesting 77 | public void setPhoneActive(int phoneId, boolean active) { 78 | validatePhoneId(phoneId); 79 | if (mIsActive[phoneId].getAndSet(active) != active) { 80 | mActivePhoneRegistrants[phoneId].notifyRegistrants(); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /tests/telephonytests/src/com/android/internal/telephony/mocks/SubscriptionMonitorMock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.android.internal.telephony.mocks; 18 | 19 | import android.os.Handler; 20 | import android.os.Registrant; 21 | import android.os.RegistrantList; 22 | 23 | import com.android.internal.annotations.VisibleForTesting; 24 | import com.android.internal.telephony.SubscriptionMonitor; 25 | 26 | public class SubscriptionMonitorMock extends SubscriptionMonitor { 27 | private final int mNumPhones; 28 | private final RegistrantList mSubscriptionsChangedRegistrants[]; 29 | private final RegistrantList mDefaultSubscriptionRegistrants[]; 30 | 31 | public SubscriptionMonitorMock(int numPhones) { 32 | super(); 33 | mNumPhones = numPhones; 34 | mSubscriptionsChangedRegistrants = new RegistrantList[numPhones]; 35 | mDefaultSubscriptionRegistrants = new RegistrantList[numPhones]; 36 | 37 | for (int i = 0; i < numPhones; i++) { 38 | mSubscriptionsChangedRegistrants[i] = new RegistrantList(); 39 | mDefaultSubscriptionRegistrants[i] = new RegistrantList(); 40 | } 41 | } 42 | 43 | @Override 44 | public void registerForSubscriptionChanged(int phoneId, Handler h, int what, Object o) { 45 | validatePhoneId(phoneId); 46 | Registrant r = new Registrant(h, what, o); 47 | mSubscriptionsChangedRegistrants[phoneId].add(r); 48 | r.notifyRegistrant(); 49 | } 50 | 51 | @Override 52 | public void unregisterForSubscriptionChanged(int phoneId, Handler h) { 53 | validatePhoneId(phoneId); 54 | mSubscriptionsChangedRegistrants[phoneId].remove(h); 55 | } 56 | 57 | @Override 58 | public void registerForDefaultDataSubscriptionChanged(int phoneId, Handler h, int what, 59 | Object o) { 60 | validatePhoneId(phoneId); 61 | Registrant r = new Registrant(h, what, o); 62 | mDefaultSubscriptionRegistrants[phoneId].add(r); 63 | r.notifyRegistrant(); 64 | } 65 | 66 | @Override 67 | public void unregisterForDefaultDataSubscriptionChanged(int phoneId, Handler h) { 68 | validatePhoneId(phoneId); 69 | mDefaultSubscriptionRegistrants[phoneId].remove(h); 70 | } 71 | 72 | @VisibleForTesting 73 | public void notifySubscriptionChanged(int phoneId) { 74 | validatePhoneId(phoneId); 75 | mSubscriptionsChangedRegistrants[phoneId].notifyRegistrants(); 76 | } 77 | 78 | @VisibleForTesting 79 | public void notifyDefaultSubscriptionChanged(int phoneId) { 80 | validatePhoneId(phoneId); 81 | mDefaultSubscriptionRegistrants[phoneId].notifyRegistrants(); 82 | } 83 | 84 | private void validatePhoneId(int phoneId) { 85 | if (phoneId < 0 || phoneId >= mNumPhones) { 86 | throw new IllegalArgumentException("Invalid PhoneId"); 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /tests/telephonytests/src/com/android/internal/telephony/uicc/IccCardStatusTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.android.internal.telephony.uicc; 17 | 18 | import android.test.suitebuilder.annotation.SmallTest; 19 | import android.util.Log; 20 | 21 | import org.junit.After; 22 | import org.junit.Before; 23 | import org.junit.Test; 24 | import org.mockito.Mock; 25 | import org.mockito.MockitoAnnotations; 26 | 27 | import static org.junit.Assert.assertEquals; 28 | 29 | public class IccCardStatusTest { 30 | 31 | private IccCardStatus mIccCardStatus; 32 | private static final String TAG = "ICCCardStatusTest"; 33 | @Mock 34 | private IccCardApplicationStatus mApplicationStatus; 35 | 36 | @Before 37 | public void setUp() throws Exception { 38 | MockitoAnnotations.initMocks(this); 39 | mIccCardStatus = new IccCardStatus(); 40 | /* set only one applications for cdma */ 41 | mIccCardStatus.mApplications = new IccCardApplicationStatus[]{mApplicationStatus}; 42 | mIccCardStatus.mCdmaSubscriptionAppIndex = 0; 43 | mIccCardStatus.mGsmUmtsSubscriptionAppIndex = -1; 44 | mIccCardStatus.mCdmaSubscriptionAppIndex = -1; 45 | 46 | } 47 | 48 | @After 49 | public void tearDown() throws Exception { 50 | mIccCardStatus = null; 51 | } 52 | 53 | @Test 54 | @SmallTest 55 | public void testSetCardState() { 56 | mIccCardStatus.setCardState(IccCardStatus.CardState.CARDSTATE_ABSENT.ordinal()); 57 | assertEquals(IccCardStatus.CardState.CARDSTATE_ABSENT, mIccCardStatus.mCardState); 58 | logd(mIccCardStatus.toString()); 59 | 60 | mIccCardStatus.setCardState(IccCardStatus.CardState.CARDSTATE_PRESENT.ordinal()); 61 | assertEquals(IccCardStatus.CardState.CARDSTATE_PRESENT, mIccCardStatus.mCardState); 62 | logd(mIccCardStatus.toString()); 63 | 64 | mIccCardStatus.setCardState(IccCardStatus.CardState.CARDSTATE_ERROR.ordinal()); 65 | assertEquals(IccCardStatus.CardState.CARDSTATE_ERROR, mIccCardStatus.mCardState); 66 | logd(mIccCardStatus.toString()); 67 | } 68 | 69 | @Test 70 | @SmallTest 71 | public void testSetPinState() { 72 | mIccCardStatus.setUniversalPinState(IccCardStatus.PinState.PINSTATE_UNKNOWN.ordinal()); 73 | assertEquals(IccCardStatus.PinState.PINSTATE_UNKNOWN, mIccCardStatus.mUniversalPinState); 74 | logd(mIccCardStatus.toString()); 75 | 76 | mIccCardStatus.setUniversalPinState( 77 | IccCardStatus.PinState.PINSTATE_ENABLED_BLOCKED.ordinal()); 78 | assertEquals(IccCardStatus.PinState.PINSTATE_ENABLED_BLOCKED, 79 | mIccCardStatus.mUniversalPinState); 80 | logd(mIccCardStatus.toString()); 81 | } 82 | 83 | private static void logd(String s) { 84 | Log.d(TAG, s); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /tests/telephonytests/src/java/android/telephony/SmsMessageTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package java.android.telephony; 18 | 19 | import android.telephony.SmsMessage; 20 | import android.test.suitebuilder.annotation.SmallTest; 21 | import com.android.internal.telephony.SmsConstants; 22 | import org.junit.After; 23 | import org.junit.Before; 24 | import org.junit.Test; 25 | 26 | import static org.junit.Assert.assertEquals; 27 | 28 | public class SmsMessageTest { 29 | @Test @SmallTest 30 | public void testCreateInvalidSmsMessage() { 31 | // should return null instead of SmsMessage with null wrappedMessage 32 | assertEquals(null, SmsMessage.createFromPdu(null, SmsConstants.FORMAT_3GPP2)); 33 | assertEquals(null, SmsMessage.createFromPdu(null, SmsConstants.FORMAT_3GPP)); 34 | assertEquals(null, SmsMessage.createFromPdu(null)); 35 | assertEquals(null, SmsMessage.newFromCMT(null)); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tools/tdi: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Telephony Debug Intents 3 | #set -x 4 | 5 | file_name='tdi' 6 | 7 | # Get the command as the first parameter 8 | cmd=$1 9 | shift 10 | 11 | function dc_errors() 12 | { 13 | if [ "$1" == "" ]; then 14 | echo "Usage: $file_name $cmd " 15 | echo " must specifiy the DataConnection such as DC or GsmDC-1" 16 | echo " := number of times to retry" 17 | echo " := From DataConnection.FailCause; such as -3 for SIGNAL_LOST" 18 | echo " := suggested retry time in milli-seconds" 19 | exit 20 | fi 21 | the_DC=$1 22 | echo "the_DC=$the_DC" 23 | 24 | if [ "$2" != "" ]; then 25 | counter="--ei counter $2"; 26 | fi 27 | echo "counter=$counter" 28 | 29 | if [ "$3" != "" ]; then 30 | fail_cause="--ei fail_cause $3"; 31 | fi 32 | echo "fail_cause=$fail_cause" 33 | 34 | if [ "$4" != "" ]; then 35 | suggested_retry_time="--ei suggested_retry_time $4"; 36 | fi 37 | echo "suggested_retry_time=$suggested_retry_time" 38 | 39 | 40 | adb shell am broadcast -a com.android.internal.telephony.$the_DC.action_fail_bringup $counter $fail_cause $suggested_retry_time 41 | } 42 | 43 | 44 | case ${cmd} in 45 | dce) dc_errors "$@";; 46 | # Add more commands in the future 47 | *) echo 'Broadcast telephony debug intents'; echo 'usage: tdi [dce]'; echo ' dce=DC errors';; 48 | esac 49 | --------------------------------------------------------------------------------