summaryrefslogtreecommitdiff
path: root/telephony
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2020-08-31 21:21:38 -0700
committerXin Li <delphij@google.com>2020-08-31 21:21:38 -0700
commit628590d7ec80e10a3fc24b1c18a1afb55cca10a8 (patch)
tree4b1c3f52d86d7fb53afbe9e9438468588fa489f8 /telephony
parentb11b8ec3aec8bb42f2c07e1c5ac7942da293baa8 (diff)
parentd2d3a20624d968199353ccf6ddbae6f3ac39c9af (diff)
Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)
Bug: 166295507 Merged-In: I3d92a6de21a938f6b352ec26dc23420c0fe02b27 Change-Id: Ifdb80563ef042738778ebb8a7581a97c4e3d96e2
Diffstat (limited to 'telephony')
-rw-r--r--telephony/api/system-current.txt155
-rw-r--r--telephony/api/system-removed.txt24
-rw-r--r--telephony/common/android/telephony/LocationAccessPolicy.java43
-rw-r--r--telephony/common/com/android/internal/telephony/CarrierAppUtils.java360
-rw-r--r--telephony/common/com/android/internal/telephony/GsmAlphabet.java2
-rw-r--r--telephony/common/com/android/internal/telephony/SmsApplication.java34
-rw-r--r--telephony/common/com/android/internal/telephony/TelephonyPermissions.java98
-rw-r--r--telephony/common/com/android/internal/telephony/util/TelephonyUtils.java10
-rw-r--r--telephony/framework-telephony-jarjar-rules.txt9
-rw-r--r--telephony/java/android/service/euicc/EuiccService.java4
-rw-r--r--telephony/java/android/telephony/Annotation.java2
-rw-r--r--telephony/java/android/telephony/CallAttributes.java6
-rw-r--r--telephony/java/android/telephony/CallQuality.java8
-rwxr-xr-x[-rw-r--r--]telephony/java/android/telephony/CarrierConfigManager.java138
-rw-r--r--telephony/java/android/telephony/CdmaEriInformation.java169
-rw-r--r--telephony/java/android/telephony/CellBroadcastService.java1
-rw-r--r--telephony/java/android/telephony/CellIdentityLte.java2
-rw-r--r--telephony/java/android/telephony/CellIdentityNr.java2
-rw-r--r--telephony/java/android/telephony/CellLocation.java10
-rw-r--r--telephony/java/android/telephony/CellSignalStrength.java2
-rw-r--r--telephony/java/android/telephony/DataFailCause.java22
-rw-r--r--telephony/java/android/telephony/DisconnectCause.java8
-rw-r--r--telephony/java/android/telephony/ModemActivityInfo.java39
-rw-r--r--telephony/java/android/telephony/NetworkScan.java7
-rw-r--r--telephony/java/android/telephony/PhoneCapability.java5
-rw-r--r--telephony/java/android/telephony/PinResult.java12
-rw-r--r--telephony/java/android/telephony/PreciseDataConnectionState.java5
-rw-r--r--telephony/java/android/telephony/ServiceState.java11
-rw-r--r--telephony/java/android/telephony/SignalStrength.java5
-rw-r--r--telephony/java/android/telephony/SmsCbMessage.java8
-rw-r--r--telephony/java/android/telephony/SmsManager.java291
-rw-r--r--telephony/java/android/telephony/SmsMessage.java26
-rw-r--r--telephony/java/android/telephony/SubscriptionInfo.java95
-rw-r--r--telephony/java/android/telephony/SubscriptionManager.java515
-rw-r--r--telephony/java/android/telephony/TelephonyFrameworkInitializer.java101
-rw-r--r--telephony/java/android/telephony/TelephonyManager.java934
-rw-r--r--telephony/java/android/telephony/TelephonyScanManager.java12
-rw-r--r--telephony/java/android/telephony/VoLteServiceState.java3
-rw-r--r--telephony/java/android/telephony/data/ApnSetting.java69
-rw-r--r--telephony/java/android/telephony/euicc/EuiccCardManager.java7
-rw-r--r--telephony/java/android/telephony/euicc/EuiccManager.java68
-rw-r--r--telephony/java/android/telephony/ims/ImsCallProfile.java18
-rw-r--r--telephony/java/android/telephony/ims/ImsMmTelManager.java8
-rw-r--r--telephony/java/android/telephony/ims/ImsRcsManager.java7
-rw-r--r--telephony/java/android/telephony/ims/ProvisioningManager.java8
-rw-r--r--telephony/java/android/telephony/ims/RcsUceAdapter.java11
-rw-r--r--telephony/java/android/telephony/ims/feature/MmTelFeature.java10
-rw-r--r--telephony/java/android/telephony/ims/stub/ImsUtImplBase.java11
-rw-r--r--telephony/java/com/android/internal/telephony/ISms.aidl20
-rw-r--r--telephony/java/com/android/internal/telephony/ISmsImplBase.java11
-rw-r--r--telephony/java/com/android/internal/telephony/ITelephony.aidl20
-rw-r--r--telephony/java/com/android/internal/telephony/PhoneConstants.java9
-rw-r--r--telephony/java/com/android/internal/telephony/SmsMessageBase.java9
-rw-r--r--telephony/java/com/android/internal/telephony/TelephonyIntents.java84
-rw-r--r--telephony/java/com/android/internal/telephony/cdma/UserData.java8
-rw-r--r--telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java8
-rw-r--r--telephony/java/com/android/internal/telephony/cdma/sms/CdmaSmsAddress.java1
-rw-r--r--telephony/java/com/android/internal/telephony/cdma/sms/SmsEnvelope.java1
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/GsmSmsAddress.java1
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/SmsCbHeader.java10
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/SmsMessage.java11
61 files changed, 2319 insertions, 1269 deletions
diff --git a/telephony/api/system-current.txt b/telephony/api/system-current.txt
index 1d44a2dfd4ad..8228d30d0a4f 100644
--- a/telephony/api/system-current.txt
+++ b/telephony/api/system-current.txt
@@ -42,8 +42,8 @@ package android.telephony {
method public int getNumRtpPacketsTransmitted();
method public int getNumRtpPacketsTransmittedLost();
method public int getUplinkCallQualityLevel();
- method public boolean isIncomingSilenceDetected();
- method public boolean isOutgoingSilenceDetected();
+ method public boolean isIncomingSilenceDetectedAtCallSetup();
+ method public boolean isOutgoingSilenceDetectedAtCallSetup();
method public boolean isRtpInactivityDetected();
method public void writeToParcel(android.os.Parcel, int);
field public static final int CALL_QUALITY_BAD = 4; // 0x4
@@ -179,85 +179,6 @@ package android.telephony {
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.DataSpecificRegistrationInfo> CREATOR;
}
- public final class DisconnectCause {
- field public static final int ALREADY_DIALING = 72; // 0x48
- field public static final int ANSWERED_ELSEWHERE = 52; // 0x34
- field public static final int BUSY = 4; // 0x4
- field public static final int CALLING_DISABLED = 74; // 0x4a
- field public static final int CALL_BARRED = 20; // 0x14
- field public static final int CALL_PULLED = 51; // 0x33
- field public static final int CANT_CALL_WHILE_RINGING = 73; // 0x49
- field public static final int CDMA_ACCESS_BLOCKED = 35; // 0x23
- field public static final int CDMA_ACCESS_FAILURE = 32; // 0x20
- field public static final int CDMA_ALREADY_ACTIVATED = 49; // 0x31
- field public static final int CDMA_DROP = 27; // 0x1b
- field public static final int CDMA_INTERCEPT = 28; // 0x1c
- field public static final int CDMA_LOCKED_UNTIL_POWER_CYCLE = 26; // 0x1a
- field public static final int CDMA_NOT_EMERGENCY = 34; // 0x22
- field public static final int CDMA_PREEMPTED = 33; // 0x21
- field public static final int CDMA_REORDER = 29; // 0x1d
- field public static final int CDMA_RETRY_ORDER = 31; // 0x1f
- field public static final int CDMA_SO_REJECT = 30; // 0x1e
- field public static final int CONGESTION = 5; // 0x5
- field public static final int CS_RESTRICTED = 22; // 0x16
- field public static final int CS_RESTRICTED_EMERGENCY = 24; // 0x18
- field public static final int CS_RESTRICTED_NORMAL = 23; // 0x17
- field public static final int DATA_DISABLED = 54; // 0x36
- field public static final int DATA_LIMIT_REACHED = 55; // 0x37
- field public static final int DIALED_CALL_FORWARDING_WHILE_ROAMING = 57; // 0x39
- field public static final int DIALED_MMI = 39; // 0x27
- field public static final int DIAL_LOW_BATTERY = 62; // 0x3e
- field public static final int DIAL_MODIFIED_TO_DIAL = 48; // 0x30
- field public static final int DIAL_MODIFIED_TO_DIAL_VIDEO = 66; // 0x42
- field public static final int DIAL_MODIFIED_TO_SS = 47; // 0x2f
- field public static final int DIAL_MODIFIED_TO_USSD = 46; // 0x2e
- field public static final int DIAL_VIDEO_MODIFIED_TO_DIAL = 69; // 0x45
- field public static final int DIAL_VIDEO_MODIFIED_TO_DIAL_VIDEO = 70; // 0x46
- field public static final int DIAL_VIDEO_MODIFIED_TO_SS = 67; // 0x43
- field public static final int DIAL_VIDEO_MODIFIED_TO_USSD = 68; // 0x44
- field public static final int EMERGENCY_PERM_FAILURE = 64; // 0x40
- field public static final int EMERGENCY_TEMP_FAILURE = 63; // 0x3f
- field public static final int ERROR_UNSPECIFIED = 36; // 0x24
- field public static final int FDN_BLOCKED = 21; // 0x15
- field public static final int ICC_ERROR = 19; // 0x13
- field public static final int IMEI_NOT_ACCEPTED = 58; // 0x3a
- field public static final int IMS_ACCESS_BLOCKED = 60; // 0x3c
- field public static final int IMS_MERGED_SUCCESSFULLY = 45; // 0x2d
- field public static final int IMS_SIP_ALTERNATE_EMERGENCY_CALL = 71; // 0x47
- field public static final int INCOMING_AUTO_REJECTED = 81; // 0x51
- field public static final int INCOMING_MISSED = 1; // 0x1
- field public static final int INCOMING_REJECTED = 16; // 0x10
- field public static final int INVALID_CREDENTIALS = 10; // 0xa
- field public static final int INVALID_NUMBER = 7; // 0x7
- field public static final int LIMIT_EXCEEDED = 15; // 0xf
- field public static final int LOCAL = 3; // 0x3
- field public static final int LOST_SIGNAL = 14; // 0xe
- field public static final int LOW_BATTERY = 61; // 0x3d
- field public static final int MAXIMUM_NUMBER_OF_CALLS_REACHED = 53; // 0x35
- field public static final int MMI = 6; // 0x6
- field public static final int NORMAL = 2; // 0x2
- field public static final int NORMAL_UNSPECIFIED = 65; // 0x41
- field public static final int NOT_DISCONNECTED = 0; // 0x0
- field public static final int NOT_VALID = -1; // 0xffffffff
- field public static final int NO_PHONE_NUMBER_SUPPLIED = 38; // 0x26
- field public static final int NUMBER_UNREACHABLE = 8; // 0x8
- field public static final int OTASP_PROVISIONING_IN_PROCESS = 76; // 0x4c
- field public static final int OUTGOING_CANCELED = 44; // 0x2c
- field public static final int OUTGOING_EMERGENCY_CALL_PLACED = 80; // 0x50
- field public static final int OUTGOING_FAILURE = 43; // 0x2b
- field public static final int OUT_OF_NETWORK = 11; // 0xb
- field public static final int OUT_OF_SERVICE = 18; // 0x12
- field public static final int POWER_OFF = 17; // 0x11
- field public static final int SERVER_ERROR = 12; // 0xc
- field public static final int SERVER_UNREACHABLE = 9; // 0x9
- field public static final int TIMED_OUT = 13; // 0xd
- field public static final int TOO_MANY_ONGOING_CALLS = 75; // 0x4b
- field public static final int UNOBTAINABLE_NUMBER = 25; // 0x19
- field public static final int VIDEO_CALL_NOT_ALLOWED_WHILE_TTY_ENABLED = 50; // 0x32
- field public static final int VOICEMAIL_NUMBER_MISSING = 40; // 0x28
- field public static final int WIFI_LOST = 59; // 0x3b
- }
-
public final class ImsiEncryptionInfo implements android.os.Parcelable {
method public int describeContents();
method @Nullable public String getKeyIdentifier();
@@ -290,30 +211,6 @@ package android.telephony {
field public static final String MBMS_STREAMING_SERVICE_ACTION = "android.telephony.action.EmbmsStreaming";
}
- public final class ModemActivityInfo implements android.os.Parcelable {
- ctor public ModemActivityInfo(long, int, int, @NonNull int[], int);
- method public int describeContents();
- method public int getIdleTimeMillis();
- method public int getReceiveTimeMillis();
- method public int getSleepTimeMillis();
- method public long getTimestamp();
- method @NonNull public java.util.List<android.telephony.ModemActivityInfo.TransmitPower> getTransmitPowerInfo();
- method public boolean isValid();
- method public void writeToParcel(android.os.Parcel, int);
- field @NonNull public static final android.os.Parcelable.Creator<android.telephony.ModemActivityInfo> CREATOR;
- field public static final int TX_POWER_LEVELS = 5; // 0x5
- field public static final int TX_POWER_LEVEL_0 = 0; // 0x0
- field public static final int TX_POWER_LEVEL_1 = 1; // 0x1
- field public static final int TX_POWER_LEVEL_2 = 2; // 0x2
- field public static final int TX_POWER_LEVEL_3 = 3; // 0x3
- field public static final int TX_POWER_LEVEL_4 = 4; // 0x4
- }
-
- public class ModemActivityInfo.TransmitPower {
- method @NonNull public android.util.Range<java.lang.Integer> getPowerRangeInDbm();
- method public int getTimeInMillis();
- }
-
public final class NetworkRegistrationInfo implements android.os.Parcelable {
method @Nullable public android.telephony.DataSpecificRegistrationInfo getDataSpecificInfo();
method public int getRegistrationState();
@@ -418,8 +315,6 @@ package android.telephony {
method @Deprecated @NonNull public String getDataConnectionApn();
method @Deprecated public int getDataConnectionApnTypeBitMask();
method @Deprecated public int getDataConnectionFailCause();
- method @Deprecated @Nullable public android.net.LinkProperties getDataConnectionLinkProperties();
- method @Deprecated public int getDataConnectionNetworkType();
method @Deprecated public int getDataConnectionState();
}
@@ -521,21 +416,15 @@ package android.telephony {
}
public class ServiceState implements android.os.Parcelable {
- method public void fillInNotifierBundle(@NonNull android.os.Bundle);
method @Nullable public android.telephony.NetworkRegistrationInfo getNetworkRegistrationInfo(int, int);
method @NonNull public java.util.List<android.telephony.NetworkRegistrationInfo> getNetworkRegistrationInfoListForDomain(int);
method @NonNull public java.util.List<android.telephony.NetworkRegistrationInfo> getNetworkRegistrationInfoListForTransportType(int);
- method @NonNull public static android.telephony.ServiceState newFromBundle(@NonNull android.os.Bundle);
field public static final int ROAMING_TYPE_DOMESTIC = 2; // 0x2
field public static final int ROAMING_TYPE_INTERNATIONAL = 3; // 0x3
field public static final int ROAMING_TYPE_NOT_ROAMING = 0; // 0x0
field public static final int ROAMING_TYPE_UNKNOWN = 1; // 0x1
}
- public class SignalStrength implements android.os.Parcelable {
- ctor public SignalStrength(@NonNull android.telephony.SignalStrength);
- }
-
public final class SmsCbCmasInfo implements android.os.Parcelable {
ctor public SmsCbCmasInfo(int, int, int, int, int, int);
method public int describeContents();
@@ -660,11 +549,8 @@ package android.telephony {
}
public final class SmsManager {
- method @RequiresPermission(android.Manifest.permission.ACCESS_MESSAGES_ON_ICC) public boolean copyMessageToIcc(@Nullable byte[], @NonNull byte[], int);
- method @RequiresPermission(android.Manifest.permission.ACCESS_MESSAGES_ON_ICC) public boolean deleteMessageFromIcc(int);
method public boolean disableCellBroadcastRange(int, int, int);
method public boolean enableCellBroadcastRange(int, int, int);
- method @NonNull @RequiresPermission(android.Manifest.permission.ACCESS_MESSAGES_ON_ICC) public java.util.List<android.telephony.SmsMessage> getMessagesFromIcc();
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getPremiumSmsConsent(@NonNull String);
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getSmsCapacityOnIcc();
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void sendMultipartTextMessageWithoutPersisting(String, String, java.util.List<java.lang.String>, java.util.List<android.app.PendingIntent>, java.util.List<android.app.PendingIntent>);
@@ -691,10 +577,10 @@ package android.telephony {
public class SubscriptionManager {
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean canDisablePhysicalSubscription();
method public boolean canManageSubscription(@NonNull android.telephony.SubscriptionInfo, @NonNull String);
- method @NonNull public int[] getActiveAndHiddenSubscriptionIdList();
- method @NonNull public int[] getActiveSubscriptionIdList();
+ method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int[] getActiveSubscriptionIdList();
method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public android.telephony.SubscriptionInfo getActiveSubscriptionInfoForIcc(@NonNull String);
method public java.util.List<android.telephony.SubscriptionInfo> getAvailableSubscriptionInfoList();
+ method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int[] getCompleteActiveSubscriptionIdList();
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getEnabledSubscriptionId(int);
method @NonNull public static android.content.res.Resources getResourcesForSubId(@NonNull android.content.Context, int);
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isSubscriptionEnabled(int);
@@ -703,8 +589,6 @@ package android.telephony {
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDefaultDataSubId(int);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDefaultSmsSubId(int);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDefaultVoiceSubscriptionId(int);
- method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setDisplayName(@Nullable String, int, int);
- method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setIconTint(int, int);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setPreferredDataSubscriptionId(int, boolean, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.Consumer<java.lang.Integer>);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setSubscriptionEnabled(int, boolean);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setUiccApplicationsEnabled(int, boolean);
@@ -722,11 +606,6 @@ package android.telephony {
field @NonNull public static final android.net.Uri WFC_ROAMING_MODE_CONTENT_URI;
}
- public class TelephonyFrameworkInitializer {
- method public static void registerServiceWrappers();
- method public static void setTelephonyServiceManager(@NonNull android.os.TelephonyServiceManager);
- }
-
public final class TelephonyHistogram implements android.os.Parcelable {
ctor public TelephonyHistogram(int, int, int);
ctor public TelephonyHistogram(android.telephony.TelephonyHistogram);
@@ -813,7 +692,6 @@ package android.telephony {
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isEmergencyAssistanceEnabled();
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) @WorkerThread public boolean isIccLockEnabled();
method @Deprecated @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public boolean isIdle();
- method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isInEmergencySmsMode();
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isLteCdmaEvdoGsmWcdmaEnabled();
method @Deprecated @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public boolean isOffhook();
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isOpportunisticNetworkEnabled();
@@ -826,7 +704,6 @@ package android.telephony {
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean matchesCurrentSimOperator(@NonNull String, int, @Nullable String);
method public boolean needsOtaServiceProvisioning();
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void notifyOtaEmergencyNumberDbInstalled();
- method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void notifyUserActivity();
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean rebootRadio();
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void reportDefaultNetworkStatus(boolean);
method @RequiresPermission(allOf={android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.MODIFY_PHONE_STATE}) public void requestCellInfoUpdate(@NonNull android.os.WorkSource, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.TelephonyManager.CellInfoCallback);
@@ -839,7 +716,6 @@ package android.telephony {
method @RequiresPermission(android.Manifest.permission.CONNECTIVITY_INTERNAL) public void resetSettings();
method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setAllowedCarriers(int, java.util.List<android.service.carrier.CarrierIdentifier>);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setAllowedNetworkTypes(long);
- method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setAlwaysAllowMmsData(boolean);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCarrierDataEnabled(boolean);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setCarrierRestrictionRules(@NonNull android.telephony.CarrierRestrictionRules);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDataActivationState(int);
@@ -867,48 +743,25 @@ package android.telephony {
method @RequiresPermission(android.Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) public void updateOtaEmergencyNumberDbFilePath(@NonNull android.os.ParcelFileDescriptor);
method public void updateServiceLocation();
field @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public static final String ACTION_ANOMALY_REPORTED = "android.telephony.action.ANOMALY_REPORTED";
- field public static final String ACTION_CARRIER_SIGNAL_DEFAULT_NETWORK_AVAILABLE = "com.android.internal.telephony.CARRIER_SIGNAL_DEFAULT_NETWORK_AVAILABLE";
- field public static final String ACTION_CARRIER_SIGNAL_PCO_VALUE = "com.android.internal.telephony.CARRIER_SIGNAL_PCO_VALUE";
- field public static final String ACTION_CARRIER_SIGNAL_REDIRECTED = "com.android.internal.telephony.CARRIER_SIGNAL_REDIRECTED";
- field public static final String ACTION_CARRIER_SIGNAL_REQUEST_NETWORK_FAILED = "com.android.internal.telephony.CARRIER_SIGNAL_REQUEST_NETWORK_FAILED";
- field public static final String ACTION_CARRIER_SIGNAL_RESET = "com.android.internal.telephony.CARRIER_SIGNAL_RESET";
field public static final String ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED = "android.intent.action.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED";
field public static final String ACTION_DEFAULT_VOICE_SUBSCRIPTION_CHANGED = "android.intent.action.ACTION_DEFAULT_VOICE_SUBSCRIPTION_CHANGED";
field public static final String ACTION_EMERGENCY_ASSISTANCE = "android.telephony.action.EMERGENCY_ASSISTANCE";
field public static final String ACTION_EMERGENCY_CALLBACK_MODE_CHANGED = "android.intent.action.EMERGENCY_CALLBACK_MODE_CHANGED";
field public static final String ACTION_EMERGENCY_CALL_STATE_CHANGED = "android.intent.action.EMERGENCY_CALL_STATE_CHANGED";
field public static final String ACTION_REQUEST_OMADM_CONFIGURATION_UPDATE = "com.android.omadm.service.CONFIGURATION_UPDATE";
- field public static final String ACTION_SERVICE_PROVIDERS_UPDATED = "android.telephony.action.SERVICE_PROVIDERS_UPDATED";
field public static final String ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS = "android.telephony.action.SHOW_NOTICE_ECM_BLOCK_OTHERS";
field public static final String ACTION_SIM_APPLICATION_STATE_CHANGED = "android.telephony.action.SIM_APPLICATION_STATE_CHANGED";
field public static final String ACTION_SIM_CARD_STATE_CHANGED = "android.telephony.action.SIM_CARD_STATE_CHANGED";
field public static final String ACTION_SIM_SLOT_STATUS_CHANGED = "android.telephony.action.SIM_SLOT_STATUS_CHANGED";
- field public static final int CARD_POWER_DOWN = 0; // 0x0
- field public static final int CARD_POWER_UP = 1; // 0x1
- field public static final int CARD_POWER_UP_PASS_THROUGH = 2; // 0x2
field public static final int CARRIER_PRIVILEGE_STATUS_ERROR_LOADING_RULES = -2; // 0xfffffffe
field public static final int CARRIER_PRIVILEGE_STATUS_HAS_ACCESS = 1; // 0x1
field public static final int CARRIER_PRIVILEGE_STATUS_NO_ACCESS = 0; // 0x0
field public static final int CARRIER_PRIVILEGE_STATUS_RULES_NOT_LOADED = -1; // 0xffffffff
field public static final String EXTRA_ANOMALY_DESCRIPTION = "android.telephony.extra.ANOMALY_DESCRIPTION";
field public static final String EXTRA_ANOMALY_ID = "android.telephony.extra.ANOMALY_ID";
- field @Deprecated public static final String EXTRA_APN_PROTOCOL = "apnProto";
- field public static final String EXTRA_APN_PROTOCOL_INT = "apnProtoInt";
- field @Deprecated public static final String EXTRA_APN_TYPE = "apnType";
- field public static final String EXTRA_APN_TYPE_INT = "apnTypeInt";
- field public static final String EXTRA_DATA_SPN = "android.telephony.extra.DATA_SPN";
- field public static final String EXTRA_DEFAULT_NETWORK_AVAILABLE = "defaultNetworkAvailable";
- field public static final String EXTRA_ERROR_CODE = "errorCode";
- field public static final String EXTRA_PCO_ID = "pcoId";
- field public static final String EXTRA_PCO_VALUE = "pcoValue";
field public static final String EXTRA_PHONE_IN_ECM_STATE = "android.telephony.extra.PHONE_IN_ECM_STATE";
field public static final String EXTRA_PHONE_IN_EMERGENCY_CALL = "android.telephony.extra.PHONE_IN_EMERGENCY_CALL";
- field public static final String EXTRA_PLMN = "android.telephony.extra.PLMN";
- field public static final String EXTRA_REDIRECTION_URL = "redirectionUrl";
- field public static final String EXTRA_SHOW_PLMN = "android.telephony.extra.SHOW_PLMN";
- field public static final String EXTRA_SHOW_SPN = "android.telephony.extra.SHOW_SPN";
field public static final String EXTRA_SIM_STATE = "android.telephony.extra.SIM_STATE";
- field public static final String EXTRA_SPN = "android.telephony.extra.SPN";
field public static final String EXTRA_VISUAL_VOICEMAIL_ENABLED_BY_USER_BOOL = "android.telephony.extra.VISUAL_VOICEMAIL_ENABLED_BY_USER_BOOL";
field public static final String EXTRA_VOICEMAIL_SCRAMBLED_PIN_STRING = "android.telephony.extra.VOICEMAIL_SCRAMBLED_PIN_STRING";
field public static final int INVALID_EMERGENCY_NUMBER_DB_VERSION = -1; // 0xffffffff
diff --git a/telephony/api/system-removed.txt b/telephony/api/system-removed.txt
new file mode 100644
index 000000000000..c7fd30438dff
--- /dev/null
+++ b/telephony/api/system-removed.txt
@@ -0,0 +1,24 @@
+// Signature format: 2.0
+package android.telephony {
+
+ public final class PreciseDataConnectionState implements android.os.Parcelable {
+ method @Deprecated @Nullable public android.net.LinkProperties getDataConnectionLinkProperties();
+ method @Deprecated public int getDataConnectionNetworkType();
+ }
+
+ public class TelephonyManager {
+ method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void answerRingingCall();
+ method @Deprecated @RequiresPermission(android.Manifest.permission.CALL_PHONE) public boolean endCall();
+ method @Deprecated public void silenceRinger();
+ }
+
+}
+
+package android.telephony.data {
+
+ public final class DataCallResponse implements android.os.Parcelable {
+ ctor public DataCallResponse(int, int, int, int, int, @Nullable String, @Nullable java.util.List<android.net.LinkAddress>, @Nullable java.util.List<java.net.InetAddress>, @Nullable java.util.List<java.net.InetAddress>, @Nullable java.util.List<java.net.InetAddress>, int);
+ }
+
+}
+
diff --git a/telephony/common/android/telephony/LocationAccessPolicy.java b/telephony/common/android/telephony/LocationAccessPolicy.java
index 892e55942d3f..1985f7810873 100644
--- a/telephony/common/android/telephony/LocationAccessPolicy.java
+++ b/telephony/common/android/telephony/LocationAccessPolicy.java
@@ -24,20 +24,16 @@ import android.app.ActivityManager;
import android.app.AppOpsManager;
import android.content.Context;
import android.content.pm.PackageManager;
-import android.content.pm.UserInfo;
import android.location.LocationManager;
import android.os.Binder;
import android.os.Build;
import android.os.Process;
import android.os.UserHandle;
-import android.os.UserManager;
import android.util.Log;
import android.widget.Toast;
import com.android.internal.telephony.util.TelephonyUtils;
-import java.util.List;
-
/**
* Helper for performing location access checks.
* @hide
@@ -111,6 +107,9 @@ public final class LocationAccessPolicy {
return this;
}
+ /**
+ * Mandatory parameter, used for performing permission checks.
+ */
public Builder setCallingUid(int callingUid) {
mCallingUid = callingUid;
return this;
@@ -195,6 +194,17 @@ public final class LocationAccessPolicy {
}
}
+ private static String getAppOpsString(String manifestPermission) {
+ switch (manifestPermission) {
+ case Manifest.permission.ACCESS_FINE_LOCATION:
+ return AppOpsManager.OPSTR_FINE_LOCATION;
+ case Manifest.permission.ACCESS_COARSE_LOCATION:
+ return AppOpsManager.OPSTR_COARSE_LOCATION;
+ default:
+ return null;
+ }
+ }
+
private static LocationPermissionResult checkAppLocationPermissionHelper(Context context,
LocationPermissionQuery query, String permissionToCheck) {
String locationTypeForLog =
@@ -208,8 +218,8 @@ public final class LocationAccessPolicy {
if (hasManifestPermission) {
// Only check the app op if the app has the permission.
int appOpMode = context.getSystemService(AppOpsManager.class)
- .noteOpNoThrow(AppOpsManager.permissionToOpCode(permissionToCheck),
- query.callingUid, query.callingPackage);
+ .noteOpNoThrow(getAppOpsString(permissionToCheck), query.callingUid,
+ query.callingPackage, query.callingFeatureId, null);
if (appOpMode == AppOpsManager.MODE_ALLOWED) {
// If the app did everything right, return without logging.
return LocationPermissionResult.ALLOWED;
@@ -295,7 +305,7 @@ public final class LocationAccessPolicy {
}
private static boolean checkSystemLocationAccess(@NonNull Context context, int uid, int pid) {
- if (!isLocationModeEnabled(context, UserHandle.getUserId(uid))) {
+ if (!isLocationModeEnabled(context, UserHandle.getUserHandleForUid(uid).getIdentifier())) {
if (DBG) Log.w(TAG, "Location disabled, failed, (" + uid + ")");
return false;
}
@@ -322,20 +332,17 @@ public final class LocationAccessPolicy {
private static boolean isCurrentProfile(@NonNull Context context, int uid) {
long token = Binder.clearCallingIdentity();
try {
- final int currentUser = ActivityManager.getCurrentUser();
- final int callingUserId = UserHandle.getUserId(uid);
- if (callingUserId == currentUser) {
+ if (UserHandle.getUserHandleForUid(uid).getIdentifier()
+ == ActivityManager.getCurrentUser()) {
return true;
+ }
+ ActivityManager activityManager = context.getSystemService(ActivityManager.class);
+ if (activityManager != null) {
+ return activityManager.isProfileForeground(
+ UserHandle.getUserHandleForUid(ActivityManager.getCurrentUser()));
} else {
- List<UserInfo> userProfiles = context.getSystemService(
- UserManager.class).getProfiles(currentUser);
- for (UserInfo user : userProfiles) {
- if (user.id == callingUserId) {
- return true;
- }
- }
+ return false;
}
- return false;
} finally {
Binder.restoreCallingIdentity(token);
}
diff --git a/telephony/common/com/android/internal/telephony/CarrierAppUtils.java b/telephony/common/com/android/internal/telephony/CarrierAppUtils.java
index 4af19b5489ca..e57b03098758 100644
--- a/telephony/common/com/android/internal/telephony/CarrierAppUtils.java
+++ b/telephony/common/com/android/internal/telephony/CarrierAppUtils.java
@@ -20,25 +20,23 @@ import android.annotation.Nullable;
import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.ApplicationInfo;
-import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
-import android.content.res.Resources;
-import android.os.RemoteException;
+import android.os.Build;
+import android.os.CarrierAssociatedAppEntry;
+import android.os.SystemConfigManager;
import android.os.UserHandle;
+import android.permission.PermissionManager;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.util.ArrayMap;
-import android.util.ArraySet;
import android.util.Log;
-import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
-import com.android.internal.telephony.util.ArrayUtils;
-import com.android.server.SystemConfig;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.Set;
/**
* Utilities for handling carrier applications.
@@ -55,19 +53,19 @@ public final class CarrierAppUtils {
* Handle preinstalled carrier apps which should be disabled until a matching SIM is inserted.
*
* Evaluates the list of applications in
- * {@link SystemConfig#getDisabledUntilUsedPreinstalledCarrierApps()}. We want to disable each
- * such application which is present on the system image until the user inserts a SIM which
- * causes that application to gain carrier privilege (indicating a "match"), without interfering
- * with the user if they opt to enable/disable the app explicitly.
+ * {@link SystemConfigManager#getDisabledUntilUsedPreinstalledCarrierApps()}. We want to disable
+ * each such application which is present on the system image until the user inserts a SIM
+ * which causes that application to gain carrier privilege (indicating a "match"), without
+ * interfering with the user if they opt to enable/disable the app explicitly.
*
* So, for each such app, we either disable until used IFF the app is not carrier privileged AND
* in the default state (e.g. not explicitly DISABLED/DISABLED_BY_USER/ENABLED), or we enable if
* the app is carrier privileged and in either the default state or DISABLED_UNTIL_USED.
*
* In addition, there is a list of carrier-associated applications in
- * {@link SystemConfig#getDisabledUntilUsedPreinstalledCarrierAssociatedApps}. Each app in this
- * list is associated with a carrier app. When the given carrier app is enabled/disabled per the
- * above, the associated applications are enabled/disabled to match.
+ * {@link SystemConfigManager#getDisabledUntilUsedPreinstalledCarrierAssociatedApps}. Each app
+ * in this list is associated with a carrier app. When the given carrier app is enabled/disabled
+ * per the above, the associated applications are enabled/disabled to match.
*
* When enabling a carrier app we also grant it default permissions.
*
@@ -76,25 +74,24 @@ public final class CarrierAppUtils {
* privileged apps may have changed.
*/
public static synchronized void disableCarrierAppsUntilPrivileged(String callingPackage,
- IPackageManager packageManager, TelephonyManager telephonyManager,
- int userId, Context context) {
+ TelephonyManager telephonyManager, int userId, Context context) {
if (DEBUG) {
Log.d(TAG, "disableCarrierAppsUntilPrivileged");
}
- SystemConfig config = SystemConfig.getInstance();
- ArraySet<String> systemCarrierAppsDisabledUntilUsed =
+ SystemConfigManager config = context.getSystemService(SystemConfigManager.class);
+ Set<String> systemCarrierAppsDisabledUntilUsed =
config.getDisabledUntilUsedPreinstalledCarrierApps();
- ArrayMap<String, List<String>> systemCarrierAssociatedAppsDisabledUntilUsed =
- config.getDisabledUntilUsedPreinstalledCarrierAssociatedApps();
+ Map<String, List<CarrierAssociatedAppEntry>> systemCarrierAssociatedAppsDisabledUntilUsed =
+ config.getDisabledUntilUsedPreinstalledCarrierAssociatedAppEntries();
ContentResolver contentResolver = getContentResolverForUser(context, userId);
- disableCarrierAppsUntilPrivileged(callingPackage, packageManager, telephonyManager,
- contentResolver, userId, systemCarrierAppsDisabledUntilUsed,
- systemCarrierAssociatedAppsDisabledUntilUsed);
+ disableCarrierAppsUntilPrivileged(callingPackage, telephonyManager, contentResolver,
+ userId, systemCarrierAppsDisabledUntilUsed,
+ systemCarrierAssociatedAppsDisabledUntilUsed, context);
}
/**
- * Like {@link #disableCarrierAppsUntilPrivileged(String, IPackageManager, TelephonyManager,
- * ContentResolver, int)}, but assumes that no carrier apps have carrier privileges.
+ * Like {@link #disableCarrierAppsUntilPrivileged(String, TelephonyManager, int, Context)},
+ * but assumes that no carrier apps have carrier privileges.
*
* This prevents a potential race condition on first boot - since the app's default state is
* enabled, we will initially disable it when the telephony stack is first initialized as it has
@@ -104,21 +101,20 @@ public final class CarrierAppUtils {
* Manager can kill it, and this can lead to crashes as the app is in an unexpected state.
*/
public static synchronized void disableCarrierAppsUntilPrivileged(String callingPackage,
- IPackageManager packageManager, int userId, Context context) {
+ int userId, Context context) {
if (DEBUG) {
Log.d(TAG, "disableCarrierAppsUntilPrivileged");
}
- SystemConfig config = SystemConfig.getInstance();
- ArraySet<String> systemCarrierAppsDisabledUntilUsed =
+ SystemConfigManager config = context.getSystemService(SystemConfigManager.class);
+ Set<String> systemCarrierAppsDisabledUntilUsed =
config.getDisabledUntilUsedPreinstalledCarrierApps();
-
- ArrayMap<String, List<String>> systemCarrierAssociatedAppsDisabledUntilUsed =
- config.getDisabledUntilUsedPreinstalledCarrierAssociatedApps();
+ Map<String, List<CarrierAssociatedAppEntry>> systemCarrierAssociatedAppsDisabledUntilUsed =
+ config.getDisabledUntilUsedPreinstalledCarrierAssociatedAppEntries();
ContentResolver contentResolver = getContentResolverForUser(context, userId);
- disableCarrierAppsUntilPrivileged(callingPackage, packageManager,
- null /* telephonyManager */, contentResolver, userId,
- systemCarrierAppsDisabledUntilUsed, systemCarrierAssociatedAppsDisabledUntilUsed);
+ disableCarrierAppsUntilPrivileged(callingPackage, null /* telephonyManager */,
+ contentResolver, userId, systemCarrierAppsDisabledUntilUsed,
+ systemCarrierAssociatedAppsDisabledUntilUsed, context);
}
private static ContentResolver getContentResolverForUser(Context context, int userId) {
@@ -142,49 +138,51 @@ public final class CarrierAppUtils {
// Must be public b/c framework unit tests can't access package-private methods.
@VisibleForTesting
public static void disableCarrierAppsUntilPrivileged(String callingPackage,
- IPackageManager packageManager, @Nullable TelephonyManager telephonyManager,
- ContentResolver contentResolver, int userId,
- ArraySet<String> systemCarrierAppsDisabledUntilUsed,
- ArrayMap<String, List<String>> systemCarrierAssociatedAppsDisabledUntilUsed) {
+ @Nullable TelephonyManager telephonyManager, ContentResolver contentResolver,
+ int userId, Set<String> systemCarrierAppsDisabledUntilUsed,
+ Map<String, List<CarrierAssociatedAppEntry>>
+ systemCarrierAssociatedAppsDisabledUntilUsed, Context context) {
+ PackageManager packageManager = context.getPackageManager();
+ PermissionManager permissionManager =
+ (PermissionManager) context.getSystemService(Context.PERMISSION_SERVICE);
List<ApplicationInfo> candidates = getDefaultCarrierAppCandidatesHelper(
- packageManager, userId, systemCarrierAppsDisabledUntilUsed);
+ userId, systemCarrierAppsDisabledUntilUsed, context);
if (candidates == null || candidates.isEmpty()) {
return;
}
- Map<String, List<ApplicationInfo>> associatedApps = getDefaultCarrierAssociatedAppsHelper(
- packageManager,
- userId,
- systemCarrierAssociatedAppsDisabledUntilUsed);
+ Map<String, List<AssociatedAppInfo>> associatedApps = getDefaultCarrierAssociatedAppsHelper(
+ userId, systemCarrierAssociatedAppsDisabledUntilUsed, context);
List<String> enabledCarrierPackages = new ArrayList<>();
- boolean hasRunOnce = Settings.Secure.getInt(contentResolver,
- Settings.Secure.CARRIER_APPS_HANDLED, 0) == 1;
+ int carrierAppsHandledSdk =
+ Settings.Secure.getInt(contentResolver, Settings.Secure.CARRIER_APPS_HANDLED, 0);
+ if (DEBUG) {
+ Log.i(TAG, "Last execution SDK: " + carrierAppsHandledSdk);
+ }
+ boolean hasRunEver = carrierAppsHandledSdk != 0; // SDKs < R used to just set 1 here
+ boolean hasRunForSdk = carrierAppsHandledSdk == Build.VERSION.SDK_INT;
try {
for (ApplicationInfo ai : candidates) {
String packageName = ai.packageName;
- String[] restrictedCarrierApps = Resources.getSystem().getStringArray(
- R.array.config_restrictedPreinstalledCarrierApps);
boolean hasPrivileges = telephonyManager != null
&& telephonyManager.checkCarrierPrivilegesForPackageAnyPhone(packageName)
- == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS
- && !ArrayUtils.contains(restrictedCarrierApps, packageName);
+ == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS;
// add hiddenUntilInstalled flag for carrier apps and associated apps
- packageManager.setSystemAppHiddenUntilInstalled(packageName, true);
- List<ApplicationInfo> associatedAppList = associatedApps.get(packageName);
+ packageManager.setSystemAppState(
+ packageName, PackageManager.SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_HIDDEN);
+ List<AssociatedAppInfo> associatedAppList = associatedApps.get(packageName);
if (associatedAppList != null) {
- for (ApplicationInfo associatedApp : associatedAppList) {
- packageManager.setSystemAppHiddenUntilInstalled(
- associatedApp.packageName,
- true
- );
+ for (AssociatedAppInfo associatedApp : associatedAppList) {
+ packageManager.setSystemAppState(associatedApp.appInfo.packageName,
+ PackageManager.SYSTEM_APP_STATE_HIDDEN_UNTIL_INSTALLED_HIDDEN);
}
}
- int enabledSetting = packageManager.getApplicationEnabledSetting(packageName,
- userId);
+ int enabledSetting = context.createContextAsUser(UserHandle.of(userId), 0)
+ .getPackageManager().getApplicationEnabledSetting(packageName);
if (hasPrivileges) {
// Only update enabled state for the app on /system. Once it has been
// updated we shouldn't touch it.
@@ -193,44 +191,55 @@ public final class CarrierAppUtils {
|| enabledSetting
== PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED
|| (ai.flags & ApplicationInfo.FLAG_INSTALLED) == 0) {
- Log.i(TAG, "Update state(" + packageName + "): ENABLED for user "
+ Log.i(TAG, "Update state (" + packageName + "): ENABLED for user "
+ userId);
- packageManager.setSystemAppInstallState(
- packageName,
- true /*installed*/,
- userId);
- packageManager.setApplicationEnabledSetting(
- packageName,
- PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
- PackageManager.DONT_KILL_APP,
- userId,
- callingPackage);
+ context.createContextAsUser(UserHandle.of(userId), 0)
+ .getPackageManager()
+ .setSystemAppState(
+ packageName, PackageManager.SYSTEM_APP_STATE_INSTALLED);
+ context.createPackageContextAsUser(callingPackage, 0, UserHandle.of(userId))
+ .getPackageManager()
+ .setApplicationEnabledSetting(
+ packageName,
+ PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
+ PackageManager.DONT_KILL_APP);
}
// Also enable any associated apps for this carrier app.
if (associatedAppList != null) {
- for (ApplicationInfo associatedApp : associatedAppList) {
- int associatedAppEnabledSetting =
- packageManager.getApplicationEnabledSetting(
- associatedApp.packageName, userId);
+ for (AssociatedAppInfo associatedApp : associatedAppList) {
+ int associatedAppEnabledSetting = context
+ .createContextAsUser(UserHandle.of(userId), 0)
+ .getPackageManager()
+ .getApplicationEnabledSetting(
+ associatedApp.appInfo.packageName);
+ boolean associatedAppInstalled = (associatedApp.appInfo.flags
+ & ApplicationInfo.FLAG_INSTALLED) != 0;
+ if (DEBUG) {
+ Log.i(TAG, "(hasPrivileges) associated app "
+ + associatedApp.appInfo.packageName + ", enabled = "
+ + associatedAppEnabledSetting + ", installed = "
+ + associatedAppInstalled);
+ }
if (associatedAppEnabledSetting
== PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
|| associatedAppEnabledSetting
== PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED
- || (associatedApp.flags
- & ApplicationInfo.FLAG_INSTALLED) == 0) {
- Log.i(TAG, "Update associated state(" + associatedApp.packageName
- + "): ENABLED for user " + userId);
- packageManager.setSystemAppInstallState(
- associatedApp.packageName,
- true /*installed*/,
- userId);
- packageManager.setApplicationEnabledSetting(
- associatedApp.packageName,
- PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
- PackageManager.DONT_KILL_APP,
- userId,
- callingPackage);
+ || !associatedAppInstalled) {
+ Log.i(TAG, "Update associated state ("
+ + associatedApp.appInfo.packageName + "): ENABLED for user "
+ + userId);
+ context.createContextAsUser(UserHandle.of(userId), 0)
+ .getPackageManager()
+ .setSystemAppState(associatedApp.appInfo.packageName,
+ PackageManager.SYSTEM_APP_STATE_INSTALLED);
+ context.createPackageContextAsUser(
+ callingPackage, 0, UserHandle.of(userId))
+ .getPackageManager()
+ .setApplicationEnabledSetting(
+ associatedApp.appInfo.packageName,
+ PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
+ PackageManager.DONT_KILL_APP);
}
}
}
@@ -243,44 +252,64 @@ public final class CarrierAppUtils {
if (!isUpdatedSystemApp(ai) && enabledSetting
== PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
&& (ai.flags & ApplicationInfo.FLAG_INSTALLED) != 0) {
- Log.i(TAG, "Update state(" + packageName
+ Log.i(TAG, "Update state (" + packageName
+ "): DISABLED_UNTIL_USED for user " + userId);
- packageManager.setSystemAppInstallState(
- packageName,
- false /*installed*/,
- userId);
+ context.createContextAsUser(UserHandle.of(userId), 0)
+ .getPackageManager()
+ .setSystemAppState(
+ packageName, PackageManager.SYSTEM_APP_STATE_UNINSTALLED);
}
- // Also disable any associated apps for this carrier app if this is the first
- // run. We avoid doing this a second time because it is brittle to rely on the
- // distinction between "default" and "enabled".
- if (!hasRunOnce) {
- if (associatedAppList != null) {
- for (ApplicationInfo associatedApp : associatedAppList) {
- int associatedAppEnabledSetting =
- packageManager.getApplicationEnabledSetting(
- associatedApp.packageName, userId);
- if (associatedAppEnabledSetting
- == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
- && (associatedApp.flags
- & ApplicationInfo.FLAG_INSTALLED) != 0) {
- Log.i(TAG,
- "Update associated state(" + associatedApp.packageName
- + "): DISABLED_UNTIL_USED for user " + userId);
- packageManager.setSystemAppInstallState(
- associatedApp.packageName,
- false /*installed*/,
- userId);
- }
+ // Associated apps are more brittle, because we can't rely on the distinction
+ // between "default" and "enabled". To account for this, we have two cases:
+ // 1. We've never run before, so we're fine to disable all associated apps.
+ // 2. We've run before, but not on this SDK version, so we will only operate on
+ // apps with addedInSdk in the range (lastHandledSdk, currentSdk].
+ // Otherwise, don't touch the associated apps.
+ if (associatedAppList != null) {
+ for (AssociatedAppInfo associatedApp : associatedAppList) {
+ boolean allowDisable = !hasRunEver || (!hasRunForSdk
+ && associatedApp.addedInSdk
+ != CarrierAssociatedAppEntry.SDK_UNSPECIFIED
+ && associatedApp.addedInSdk > carrierAppsHandledSdk
+ && associatedApp.addedInSdk <= Build.VERSION.SDK_INT);
+ int associatedAppEnabledSetting = context
+ .createContextAsUser(UserHandle.of(userId), 0)
+ .getPackageManager()
+ .getApplicationEnabledSetting(
+ associatedApp.appInfo.packageName);
+ boolean associatedAppInstalled = (associatedApp.appInfo.flags
+ & ApplicationInfo.FLAG_INSTALLED) != 0;
+ if (DEBUG) {
+ Log.i(TAG, "(!hasPrivileges) associated app "
+ + associatedApp.appInfo.packageName + ", allowDisable = "
+ + allowDisable + ", addedInSdk = "
+ + associatedApp.addedInSdk + ", enabled = "
+ + associatedAppEnabledSetting + ", installed = "
+ + associatedAppInstalled);
+ }
+ if (allowDisable
+ && associatedAppEnabledSetting
+ == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
+ && associatedAppInstalled) {
+ Log.i(TAG,
+ "Update associated state ("
+ + associatedApp.appInfo.packageName
+ + "): DISABLED_UNTIL_USED for user " + userId);
+ context.createContextAsUser(UserHandle.of(userId), 0)
+ .getPackageManager()
+ .setSystemAppState(associatedApp.appInfo.packageName,
+ PackageManager.SYSTEM_APP_STATE_UNINSTALLED);
}
}
}
}
}
- // Mark the execution so we do not disable apps again.
- if (!hasRunOnce) {
- Settings.Secure.putInt(contentResolver, Settings.Secure.CARRIER_APPS_HANDLED, 1);
+ // Mark the execution so we do not disable apps again on this SDK version.
+ if (!hasRunEver || !hasRunForSdk) {
+ Settings.Secure.putInt(contentResolver, Settings.Secure.CARRIER_APPS_HANDLED,
+ Build.VERSION.SDK_INT);
}
if (!enabledCarrierPackages.isEmpty()) {
@@ -288,9 +317,10 @@ public final class CarrierAppUtils {
// apps.
String[] packageNames = new String[enabledCarrierPackages.size()];
enabledCarrierPackages.toArray(packageNames);
- packageManager.grantDefaultPermissionsToEnabledCarrierApps(packageNames, userId);
+ permissionManager.grantDefaultPermissionsToEnabledCarrierApps(packageNames,
+ UserHandle.of(userId), Runnable::run, isSuccess -> { });
}
- } catch (RemoteException e) {
+ } catch (PackageManager.NameNotFoundException e) {
Log.w(TAG, "Could not reach PackageManager", e);
}
}
@@ -299,13 +329,13 @@ public final class CarrierAppUtils {
* Returns the list of "default" carrier apps.
*
* This is the subset of apps returned by
- * {@link #getDefaultCarrierAppCandidates(IPackageManager, int)} which currently have carrier
+ * {@link #getDefaultCarrierAppCandidates(int, Context)} which currently have carrier
* privileges per the SIM(s) inserted in the device.
*/
- public static List<ApplicationInfo> getDefaultCarrierApps(IPackageManager packageManager,
- TelephonyManager telephonyManager, int userId) {
+ public static List<ApplicationInfo> getDefaultCarrierApps(
+ TelephonyManager telephonyManager, int userId, Context context) {
// Get all system apps from the default list.
- List<ApplicationInfo> candidates = getDefaultCarrierAppCandidates(packageManager, userId);
+ List<ApplicationInfo> candidates = getDefaultCarrierAppCandidates(userId, context);
if (candidates == null || candidates.isEmpty()) {
return null;
}
@@ -331,39 +361,33 @@ public final class CarrierAppUtils {
* Returns the list of "default" carrier app candidates.
*
* These are the apps subject to the hiding/showing logic in
- * {@link CarrierAppUtils#disableCarrierAppsUntilPrivileged(String, IPackageManager,
- * TelephonyManager, ContentResolver, int)}, as well as the apps which should have default
+ * {@link CarrierAppUtils#disableCarrierAppsUntilPrivileged(String, TelephonyManager, int,
+ * Context)}, as well as the apps which should have default
* permissions granted, when a matching SIM is inserted.
*
* Whether or not the app is actually considered a default app depends on whether the app has
* carrier privileges as determined by the SIMs in the device.
*/
public static List<ApplicationInfo> getDefaultCarrierAppCandidates(
- IPackageManager packageManager, int userId) {
- ArraySet<String> systemCarrierAppsDisabledUntilUsed =
- SystemConfig.getInstance().getDisabledUntilUsedPreinstalledCarrierApps();
- return getDefaultCarrierAppCandidatesHelper(packageManager, userId,
- systemCarrierAppsDisabledUntilUsed);
+ int userId, Context context) {
+ Set<String> systemCarrierAppsDisabledUntilUsed =
+ context.getSystemService(SystemConfigManager.class)
+ .getDisabledUntilUsedPreinstalledCarrierApps();
+ return getDefaultCarrierAppCandidatesHelper(userId, systemCarrierAppsDisabledUntilUsed,
+ context);
}
private static List<ApplicationInfo> getDefaultCarrierAppCandidatesHelper(
- IPackageManager packageManager,
- int userId,
- ArraySet<String> systemCarrierAppsDisabledUntilUsed) {
- if (systemCarrierAppsDisabledUntilUsed == null) {
- return null;
- }
-
- int size = systemCarrierAppsDisabledUntilUsed.size();
- if (size == 0) {
+ int userId, Set<String> systemCarrierAppsDisabledUntilUsed, Context context) {
+ if (systemCarrierAppsDisabledUntilUsed == null
+ || systemCarrierAppsDisabledUntilUsed.isEmpty()) {
return null;
}
- List<ApplicationInfo> apps = new ArrayList<>(size);
- for (int i = 0; i < size; i++) {
- String packageName = systemCarrierAppsDisabledUntilUsed.valueAt(i);
+ List<ApplicationInfo> apps = new ArrayList<>(systemCarrierAppsDisabledUntilUsed.size());
+ for (String packageName : systemCarrierAppsDisabledUntilUsed) {
ApplicationInfo ai =
- getApplicationInfoIfSystemApp(packageManager, userId, packageName);
+ getApplicationInfoIfSystemApp(userId, packageName, context);
if (ai != null) {
apps.add(ai);
}
@@ -371,29 +395,28 @@ public final class CarrierAppUtils {
return apps;
}
- private static Map<String, List<ApplicationInfo>> getDefaultCarrierAssociatedAppsHelper(
- IPackageManager packageManager,
- int userId,
- ArrayMap<String, List<String>> systemCarrierAssociatedAppsDisabledUntilUsed) {
+ private static Map<String, List<AssociatedAppInfo>> getDefaultCarrierAssociatedAppsHelper(
+ int userId, Map<String, List<CarrierAssociatedAppEntry>>
+ systemCarrierAssociatedAppsDisabledUntilUsed, Context context) {
int size = systemCarrierAssociatedAppsDisabledUntilUsed.size();
- Map<String, List<ApplicationInfo>> associatedApps = new ArrayMap<>(size);
- for (int i = 0; i < size; i++) {
- String carrierAppPackage = systemCarrierAssociatedAppsDisabledUntilUsed.keyAt(i);
- List<String> associatedAppPackages =
- systemCarrierAssociatedAppsDisabledUntilUsed.valueAt(i);
+ Map<String, List<AssociatedAppInfo>> associatedApps = new ArrayMap<>(size);
+ for (Map.Entry<String, List<CarrierAssociatedAppEntry>> entry
+ : systemCarrierAssociatedAppsDisabledUntilUsed.entrySet()) {
+ String carrierAppPackage = entry.getKey();
+ List<CarrierAssociatedAppEntry> associatedAppPackages = entry.getValue();
for (int j = 0; j < associatedAppPackages.size(); j++) {
+ CarrierAssociatedAppEntry associatedApp = associatedAppPackages.get(j);
ApplicationInfo ai =
- getApplicationInfoIfSystemApp(
- packageManager, userId, associatedAppPackages.get(j));
+ getApplicationInfoIfSystemApp(userId, associatedApp.packageName, context);
// Only update enabled state for the app on /system. Once it has been updated we
// shouldn't touch it.
if (ai != null && !isUpdatedSystemApp(ai)) {
- List<ApplicationInfo> appList = associatedApps.get(carrierAppPackage);
+ List<AssociatedAppInfo> appList = associatedApps.get(carrierAppPackage);
if (appList == null) {
appList = new ArrayList<>();
associatedApps.put(carrierAppPackage, appList);
}
- appList.add(ai);
+ appList.add(new AssociatedAppInfo(ai, associatedApp.addedInSdk));
}
}
}
@@ -402,20 +425,31 @@ public final class CarrierAppUtils {
@Nullable
private static ApplicationInfo getApplicationInfoIfSystemApp(
- IPackageManager packageManager,
- int userId,
- String packageName) {
+ int userId, String packageName, Context context) {
try {
- ApplicationInfo ai = packageManager.getApplicationInfo(packageName,
- PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS
- | PackageManager.MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS
- | PackageManager.MATCH_SYSTEM_ONLY, userId);
+ ApplicationInfo ai = context.createContextAsUser(UserHandle.of(userId), 0)
+ .getPackageManager()
+ .getApplicationInfo(packageName,
+ PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS
+ | PackageManager.MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS
+ | PackageManager.MATCH_SYSTEM_ONLY);
if (ai != null) {
return ai;
}
- } catch (RemoteException e) {
+ } catch (PackageManager.NameNotFoundException e) {
Log.w(TAG, "Could not reach PackageManager", e);
}
return null;
}
+
+ private static final class AssociatedAppInfo {
+ public final ApplicationInfo appInfo;
+ // Might be CarrierAssociatedAppEntry.SDK_UNSPECIFIED.
+ public final int addedInSdk;
+
+ AssociatedAppInfo(ApplicationInfo appInfo, int addedInSdk) {
+ this.appInfo = appInfo;
+ this.addedInSdk = addedInSdk;
+ }
+ }
}
diff --git a/telephony/common/com/android/internal/telephony/GsmAlphabet.java b/telephony/common/com/android/internal/telephony/GsmAlphabet.java
index 60cd40094950..5c53f7e5a4d0 100644
--- a/telephony/common/com/android/internal/telephony/GsmAlphabet.java
+++ b/telephony/common/com/android/internal/telephony/GsmAlphabet.java
@@ -40,6 +40,8 @@ import java.util.List;
public class GsmAlphabet {
private static final String TAG = "GSM";
+ private GsmAlphabet() { }
+
/**
* This escapes extended characters, and when present indicates that the
* following character should be looked up in the "extended" table.
diff --git a/telephony/common/com/android/internal/telephony/SmsApplication.java b/telephony/common/com/android/internal/telephony/SmsApplication.java
index d69282579b77..b35b3236afc6 100644
--- a/telephony/common/com/android/internal/telephony/SmsApplication.java
+++ b/telephony/common/com/android/internal/telephony/SmsApplication.java
@@ -35,13 +35,11 @@ import android.content.pm.ServiceInfo;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Binder;
-import android.os.Debug;
import android.os.Process;
import android.os.UserHandle;
import android.provider.Telephony;
import android.provider.Telephony.Sms.Intents;
import android.telephony.PackageChangeReceiver;
-import android.util.Log;
import android.telephony.TelephonyManager;
import android.util.Log;
@@ -57,7 +55,6 @@ import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;
import java.util.stream.Collectors;
-
/**
* Class for managing the primary application that we will deliver SMS/MMS messages to
*
@@ -197,13 +194,13 @@ public final class SmsApplication {
final int callingUid = Binder.getCallingUid();
if (DEBUG_MULTIUSER) {
Log.i(LOG_TAG, "getIncomingUserHandle caller=" + callingUid + ", myuid="
- + android.os.Process.myUid() + "\n\t" + Debug.getCallers(4));
+ + android.os.Process.myUid());
}
if (UserHandle.getAppId(callingUid)
< android.os.Process.FIRST_APPLICATION_UID) {
return contextUserId;
} else {
- return UserHandle.getUserId(callingUid);
+ return UserHandle.getUserHandleForUid(callingUid).getIdentifier();
}
}
@@ -429,9 +426,6 @@ public final class SmsApplication {
final SmsApplicationData smsApplicationData = receivers.get(packageName);
if (smsApplicationData != null) {
if (!smsApplicationData.isComplete()) {
- Log.w(LOG_TAG, "Package " + packageName
- + " lacks required manifest declarations to be a default sms app: "
- + smsApplicationData);
receivers.remove(packageName);
}
}
@@ -675,9 +669,21 @@ public final class SmsApplication {
}
/**
+ * Broadcast action:
+ * Same as {@link Intent#ACTION_DEFAULT_SMS_PACKAGE_CHANGED} but it's implicit (e.g. sent to
+ * all apps) and requires
+ * {@link #PERMISSION_MONITOR_DEFAULT_SMS_PACKAGE} to receive.
+ */
+ public static final String ACTION_DEFAULT_SMS_PACKAGE_CHANGED_INTERNAL =
+ "android.provider.action.DEFAULT_SMS_PACKAGE_CHANGED_INTERNAL";
+
+ public static final String PERMISSION_MONITOR_DEFAULT_SMS_PACKAGE =
+ "android.permission.MONITOR_DEFAULT_SMS_PACKAGE";
+
+ /**
* Sends broadcasts on sms app change:
* {@link Intent#ACTION_DEFAULT_SMS_PACKAGE_CHANGED}
- * {@link Intents.ACTION_DEFAULT_SMS_PACKAGE_CHANGED_INTERNAL}
+ * {@link #ACTION_DEFAULT_SMS_PACKAGE_CHANGED_INTERNAL}
*/
public static void broadcastSmsAppChange(Context context,
UserHandle userHandle, @Nullable String oldPackage, @Nullable String newPackage) {
@@ -727,11 +733,11 @@ public final class SmsApplication {
}
// Send an implicit broadcast for the system server.
- // (or anyone with MONITOR_DEFAULT_SMS_PACKAGE, really.)
+ // (or anyone with PERMISSION_MONITOR_DEFAULT_SMS_PACKAGE, really.)
final Intent intent =
- new Intent(Intents.ACTION_DEFAULT_SMS_PACKAGE_CHANGED_INTERNAL);
+ new Intent(ACTION_DEFAULT_SMS_PACKAGE_CHANGED_INTERNAL);
context.sendBroadcastAsUser(intent, userHandle,
- permission.MONITOR_DEFAULT_SMS_PACKAGE);
+ PERMISSION_MONITOR_DEFAULT_SMS_PACKAGE);
}
/**
@@ -816,10 +822,10 @@ public final class SmsApplication {
// This should never happen in prod -- unit tests will put the receiver into a
// unusual state where the pending result is null, which produces a NPE when calling
// getSendingUserId. Just pretend like it's the system user for testing.
- userId = UserHandle.USER_SYSTEM;
+ userId = UserHandle.SYSTEM.getIdentifier();
}
Context userContext = mContext;
- if (userId != UserHandle.USER_SYSTEM) {
+ if (userId != UserHandle.SYSTEM.getIdentifier()) {
try {
userContext = mContext.createPackageContextAsUser(mContext.getPackageName(), 0,
UserHandle.of(userId));
diff --git a/telephony/common/com/android/internal/telephony/TelephonyPermissions.java b/telephony/common/com/android/internal/telephony/TelephonyPermissions.java
index 0f53fe65463f..0c463949b14a 100644
--- a/telephony/common/com/android/internal/telephony/TelephonyPermissions.java
+++ b/telephony/common/com/android/internal/telephony/TelephonyPermissions.java
@@ -20,7 +20,6 @@ import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import android.Manifest;
import android.annotation.Nullable;
import android.app.AppOpsManager;
-import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
@@ -28,10 +27,10 @@ import android.os.Binder;
import android.os.Build;
import android.os.Process;
import android.os.UserHandle;
+import android.permission.PermissionManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.Log;
-import android.util.StatsLog;
import com.android.internal.annotations.VisibleForTesting;
@@ -157,8 +156,8 @@ public final class TelephonyPermissions {
// We have READ_PHONE_STATE permission, so return true as long as the AppOps bit hasn't been
// revoked.
AppOpsManager appOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
- return appOps.noteOp(AppOpsManager.OPSTR_READ_PHONE_STATE, uid, callingPackage)
- == AppOpsManager.MODE_ALLOWED;
+ return appOps.noteOp(AppOpsManager.OPSTR_READ_PHONE_STATE, uid, callingPackage,
+ callingFeatureId, null) == AppOpsManager.MODE_ALLOWED;
}
/**
@@ -210,8 +209,8 @@ public final class TelephonyPermissions {
// We have READ_PHONE_STATE permission, so return true as long as the AppOps bit hasn't been
// revoked.
AppOpsManager appOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
- return appOps.noteOp(AppOpsManager.OPSTR_READ_PHONE_STATE, uid, callingPackage) ==
- AppOpsManager.MODE_ALLOWED;
+ return appOps.noteOp(AppOpsManager.OPSTR_READ_PHONE_STATE, uid, callingPackage,
+ callingFeatureId, null) == AppOpsManager.MODE_ALLOWED;
}
/**
@@ -306,16 +305,6 @@ public final class TelephonyPermissions {
String message, boolean allowCarrierPrivilegeOnAnySub) {
int uid = Binder.getCallingUid();
int pid = Binder.getCallingPid();
- // Allow system and root access to the device identifiers.
- final int appId = UserHandle.getAppId(uid);
- if (appId == Process.SYSTEM_UID || appId == Process.ROOT_UID) {
- return true;
- }
- // Allow access to packages that have the READ_PRIVILEGED_PHONE_STATE permission.
- if (context.checkPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, pid,
- uid) == PackageManager.PERMISSION_GRANTED) {
- return true;
- }
// If the calling package has carrier privileges for specified sub, then allow access.
if (checkCarrierPrivilegeForSubId(context, subId)) return true;
@@ -326,30 +315,13 @@ public final class TelephonyPermissions {
return true;
}
- // if the calling package is not null then perform the DevicePolicyManager device /
- // profile owner and Appop checks.
- if (callingPackage != null) {
- // Allow access to an app that has been granted the READ_DEVICE_IDENTIFIERS app op.
- long token = Binder.clearCallingIdentity();
- AppOpsManager appOpsManager = (AppOpsManager) context.getSystemService(
- Context.APP_OPS_SERVICE);
- try {
- if (appOpsManager.noteOpNoThrow(AppOpsManager.OPSTR_READ_DEVICE_IDENTIFIERS, uid,
- callingPackage) == AppOpsManager.MODE_ALLOWED) {
- return true;
- }
- } finally {
- Binder.restoreCallingIdentity(token);
- }
- // Allow access to a device / profile owner app.
- DevicePolicyManager devicePolicyManager =
- (DevicePolicyManager) context.getSystemService(
- Context.DEVICE_POLICY_SERVICE);
- if (devicePolicyManager != null && devicePolicyManager.checkDeviceIdentifierAccess(
- callingPackage, pid, uid)) {
- return true;
- }
+ PermissionManager permissionManager = (PermissionManager) context.getSystemService(
+ Context.PERMISSION_SERVICE);
+ if (permissionManager.checkDeviceIdentifierAccess(callingPackage, message, callingFeatureId,
+ pid, uid) == PackageManager.PERMISSION_GRANTED) {
+ return true;
}
+
return reportAccessDeniedToReadIdentifiers(context, subId, pid, uid, callingPackage,
message);
}
@@ -366,16 +338,10 @@ public final class TelephonyPermissions {
*/
private static boolean reportAccessDeniedToReadIdentifiers(Context context, int subId, int pid,
int uid, String callingPackage, String message) {
- boolean isPreinstalled = false;
ApplicationInfo callingPackageInfo = null;
try {
callingPackageInfo = context.getPackageManager().getApplicationInfoAsUser(
callingPackage, 0, UserHandle.getUserHandleForUid(uid));
- if (callingPackageInfo != null) {
- if (callingPackageInfo.isSystemApp()) {
- isPreinstalled = true;
- }
- }
} catch (PackageManager.NameNotFoundException e) {
// If the application info for the calling package could not be found then assume the
// calling app is a non-preinstalled app to detect any issues with the check
@@ -395,11 +361,11 @@ public final class TelephonyPermissions {
invokedMethods = sReportedDeviceIDPackages.get(callingPackage);
}
invokedMethods.add(message);
- StatsLog.write(StatsLog.DEVICE_IDENTIFIER_ACCESS_DENIED, callingPackage, message,
- isPreinstalled, false);
+ TelephonyCommonStatsLog.write(TelephonyCommonStatsLog.DEVICE_IDENTIFIER_ACCESS_DENIED,
+ callingPackage, message, /* isPreinstalled= */ false, false);
}
- Log.w(LOG_TAG, "reportAccessDeniedToReadIdentifiers:" + callingPackage + ":" + message
- + ":isPreinstalled=" + isPreinstalled);
+ Log.w(LOG_TAG, "reportAccessDeniedToReadIdentifiers:" + callingPackage + ":" + message + ":"
+ + subId);
// if the target SDK is pre-Q then check if the calling package would have previously
// had access to device identifiers.
if (callingPackageInfo != null && (
@@ -440,8 +406,8 @@ public final class TelephonyPermissions {
// We have READ_CALL_LOG permission, so return true as long as the AppOps bit hasn't been
// revoked.
AppOpsManager appOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
- return appOps.noteOp(AppOpsManager.OPSTR_READ_CALL_LOG, uid, callingPackage) ==
- AppOpsManager.MODE_ALLOWED;
+ return appOps.noteOp(AppOpsManager.OPSTR_READ_CALL_LOG, uid, callingPackage,
+ callingPackageName, null) == AppOpsManager.MODE_ALLOWED;
}
/**
@@ -470,16 +436,6 @@ public final class TelephonyPermissions {
public static boolean checkReadPhoneNumber(
Context context, int subId, int pid, int uid,
String callingPackage, @Nullable String callingFeatureId, String message) {
- // Default SMS app can always read it.
- AppOpsManager appOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
- if (appOps.noteOp(AppOpsManager.OPSTR_WRITE_SMS, uid, callingPackage) ==
- AppOpsManager.MODE_ALLOWED) {
- return true;
- }
-
- // NOTE(b/73308711): If an app has one of the following AppOps bits explicitly revoked, they
- // will be denied access, even if they have another permission and AppOps bit if needed.
-
// First, check if the SDK version is below R
boolean preR = false;
try {
@@ -514,21 +470,29 @@ public final class TelephonyPermissions {
}
}
+ // Default SMS app can always read it.
+ AppOpsManager appOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
+ if (appOps.noteOp(AppOpsManager.OPSTR_WRITE_SMS, uid, callingPackage, callingFeatureId,
+ null) == AppOpsManager.MODE_ALLOWED) {
+ return true;
+ }
// Can be read with READ_SMS too.
try {
context.enforcePermission(android.Manifest.permission.READ_SMS, pid, uid, message);
- return appOps.noteOp(AppOpsManager.OPSTR_READ_SMS, uid, callingPackage)
- == AppOpsManager.MODE_ALLOWED;
-
+ if (appOps.noteOp(AppOpsManager.OPSTR_READ_SMS, uid, callingPackage,
+ callingFeatureId, null) == AppOpsManager.MODE_ALLOWED) {
+ return true;
+ }
} catch (SecurityException readSmsSecurityException) {
}
// Can be read with READ_PHONE_NUMBERS too.
try {
context.enforcePermission(android.Manifest.permission.READ_PHONE_NUMBERS, pid, uid,
message);
- return appOps.noteOp(AppOpsManager.OPSTR_READ_PHONE_NUMBERS, uid, callingPackage)
- == AppOpsManager.MODE_ALLOWED;
-
+ if (appOps.noteOp(AppOpsManager.OPSTR_READ_PHONE_NUMBERS, uid, callingPackage,
+ callingFeatureId, null) == AppOpsManager.MODE_ALLOWED) {
+ return true;
+ }
} catch (SecurityException readPhoneNumberSecurityException) {
}
diff --git a/telephony/common/com/android/internal/telephony/util/TelephonyUtils.java b/telephony/common/com/android/internal/telephony/util/TelephonyUtils.java
index ec1c6c90905a..682697469af9 100644
--- a/telephony/common/com/android/internal/telephony/util/TelephonyUtils.java
+++ b/telephony/common/com/android/internal/telephony/util/TelephonyUtils.java
@@ -30,6 +30,8 @@ import android.os.SystemProperties;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
/**
@@ -144,4 +146,12 @@ public final class TelephonyUtils {
}
return ret;
}
+
+ /** Wait for latch to trigger */
+ public static void waitUntilReady(CountDownLatch latch, long timeoutMs) {
+ try {
+ latch.await(timeoutMs, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException ignored) {
+ }
+ }
}
diff --git a/telephony/framework-telephony-jarjar-rules.txt b/telephony/framework-telephony-jarjar-rules.txt
new file mode 100644
index 000000000000..212eba153a15
--- /dev/null
+++ b/telephony/framework-telephony-jarjar-rules.txt
@@ -0,0 +1,9 @@
+rule android.telephony.Annotation* android.telephony.framework.Annotation@1
+rule android.util.RecurrenceRule* android.telephony.RecurrenceRule@1
+rule com.android.i18n.phonenumbers.** com.android.telephony.framework.phonenumbers.@1
+rule com.android.internal.os.SomeArgs* android.telephony.SomeArgs@1
+rule com.android.internal.util.BitwiseInputStream* android.telephony.BitwiseInputStream@1
+rule com.android.internal.util.BitwiseOutputStream* android.telephony.BitwiseOutputStream@1
+rule com.android.internal.util.Preconditions* android.telephony.Preconditions@1
+rule com.android.internal.util.IndentingPrintWriter* android.telephony.IndentingPrintWriter@1
+rule com.android.internal.util.HexDump* android.telephony.HexDump@1
diff --git a/telephony/java/android/service/euicc/EuiccService.java b/telephony/java/android/service/euicc/EuiccService.java
index ae2652e6c229..fcbb008c79b3 100644
--- a/telephony/java/android/service/euicc/EuiccService.java
+++ b/telephony/java/android/service/euicc/EuiccService.java
@@ -327,8 +327,8 @@ public abstract class EuiccService extends Service {
* @throws UnsupportedOperationException when sections has more than four layers (e.g 5.8.1.2)
* or when an number is bigger than 15
*/
- public int encodeSmdxSubjectAndReasonCode(@NonNull String subjectCode,
- @NonNull String reasonCode) {
+ public int encodeSmdxSubjectAndReasonCode(@Nullable String subjectCode,
+ @Nullable String reasonCode) {
final int maxSupportedSection = 3;
final int maxSupportedDigit = 15;
final int bitsPerSection = 4;
diff --git a/telephony/java/android/telephony/Annotation.java b/telephony/java/android/telephony/Annotation.java
index f0ed1a3fe070..031c3376f3ba 100644
--- a/telephony/java/android/telephony/Annotation.java
+++ b/telephony/java/android/telephony/Annotation.java
@@ -431,7 +431,7 @@ public class Annotation {
DataFailCause.LIMITED_TO_IPV6,
DataFailCause.VSNCP_TIMEOUT,
DataFailCause.VSNCP_GEN_ERROR,
- DataFailCause.VSNCP_APN_UNATHORIZED,
+ DataFailCause.VSNCP_APN_UNAUTHORIZED,
DataFailCause.VSNCP_PDN_LIMIT_EXCEEDED,
DataFailCause.VSNCP_NO_PDN_GATEWAY_ADDRESS,
DataFailCause.VSNCP_PDN_GATEWAY_UNREACHABLE,
diff --git a/telephony/java/android/telephony/CallAttributes.java b/telephony/java/android/telephony/CallAttributes.java
index cd830adf23b0..0c258f4b6435 100644
--- a/telephony/java/android/telephony/CallAttributes.java
+++ b/telephony/java/android/telephony/CallAttributes.java
@@ -21,8 +21,8 @@ import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
-
import android.telephony.Annotation.NetworkType;
+
import java.util.Objects;
/**
@@ -130,14 +130,14 @@ public final class CallAttributes implements Parcelable {
/**
* {@link Parcelable#describeContents}
*/
- public @Parcelable.ContentsFlags int describeContents() {
+ public int describeContents() {
return 0;
}
/**
* {@link Parcelable#writeToParcel}
*/
- public void writeToParcel(Parcel dest, @Parcelable.WriteFlags int flags) {
+ public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(mPreciseCallState, flags);
dest.writeInt(mNetworkType);
dest.writeParcelable(mCallQuality, flags);
diff --git a/telephony/java/android/telephony/CallQuality.java b/telephony/java/android/telephony/CallQuality.java
index 1e1cdba70ad0..1c82e96a0183 100644
--- a/telephony/java/android/telephony/CallQuality.java
+++ b/telephony/java/android/telephony/CallQuality.java
@@ -287,7 +287,7 @@ public final class CallQuality implements Parcelable {
* Returns true if only silence rtp packets are received for a duration of 20 seconds starting
* at call setup
*/
- public boolean isIncomingSilenceDetected() {
+ public boolean isIncomingSilenceDetectedAtCallSetup() {
return mRxSilenceDetected;
}
@@ -295,7 +295,7 @@ public final class CallQuality implements Parcelable {
* Returns true if only silence rtp packets are sent for a duration of 20 seconds starting at
* call setup
*/
- public boolean isOutgoingSilenceDetected() {
+ public boolean isOutgoingSilenceDetectedAtCallSetup() {
return mTxSilenceDetected;
}
@@ -400,14 +400,14 @@ public final class CallQuality implements Parcelable {
/**
* {@link Parcelable#describeContents}
*/
- public @Parcelable.ContentsFlags int describeContents() {
+ public int describeContents() {
return 0;
}
/**
* {@link Parcelable#writeToParcel}
*/
- public void writeToParcel(Parcel dest, @Parcelable.WriteFlags int flags) {
+ public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(mDownlinkCallQualityLevel);
dest.writeInt(mUplinkCallQualityLevel);
dest.writeInt(mCallDuration);
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index 3bb46cb538be..cb9464020c13 100644..100755
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -29,7 +29,6 @@ import android.content.ComponentName;
import android.content.Context;
import android.os.PersistableBundle;
import android.os.RemoteException;
-import android.os.ServiceManager;
import android.service.carrier.CarrierService;
import android.telecom.TelecomManager;
import android.telephony.ims.ImsReasonInfo;
@@ -1586,6 +1585,50 @@ public class CarrierConfigManager {
"apn_settings_default_apn_types_string_array";
/**
+ * Configs used for APN setup.
+ */
+ public static final class Apn {
+ /** Prefix of all Apn.KEY_* constants. */
+ public static final String KEY_PREFIX = "apn.";
+
+ /** IPv4 internet protocol */
+ public static final String PROTOCOL_IPV4 = "IP";
+ /** IPv6 internet protocol */
+ public static final String PROTOCOL_IPV6 = "IPV6";
+ /** IPv4 or IPv6 internet protocol */
+ public static final String PROTOCOL_IPV4V6 = "IPV4V6";
+
+ /**
+ * Default value of APN protocol field if not specified by user when adding/modifying
+ * an APN.
+ *
+ * Available options are: {@link #PROTOCOL_IPV4}, {@link #PROTOCOL_IPV6},
+ * {@link #PROTOCOL_IPV4V6}
+ */
+ public static final String KEY_SETTINGS_DEFAULT_PROTOCOL_STRING =
+ KEY_PREFIX + "settings_default_protocol_string";
+
+ /**
+ * Default value of APN roaming protocol field if not specified by user when
+ * adding/modifying an APN.
+ *
+ * Available options are: {@link #PROTOCOL_IPV4}, {@link #PROTOCOL_IPV6},
+ * {@link #PROTOCOL_IPV4V6}
+ */
+ public static final String KEY_SETTINGS_DEFAULT_ROAMING_PROTOCOL_STRING =
+ KEY_PREFIX + "settings_default_roaming_protocol_string";
+
+ private Apn() {}
+
+ private static PersistableBundle getDefaults() {
+ PersistableBundle defaults = new PersistableBundle();
+ defaults.putString(KEY_SETTINGS_DEFAULT_PROTOCOL_STRING, "");
+ defaults.putString(KEY_SETTINGS_DEFAULT_ROAMING_PROTOCOL_STRING, "");
+ return defaults;
+ }
+ }
+
+ /**
* Boolean indicating if intent for emergency call state changes should be broadcast
* @hide
*/
@@ -1985,6 +2028,14 @@ public class CarrierConfigManager {
*/
public static final String KEY_CDMA_ROAMING_MODE_INT = "cdma_roaming_mode_int";
+ /**
+ * Determines whether 1X voice calls is supported for some CDMA carriers.
+ * Default value is true.
+ * @hide
+ */
+ @SystemApi
+ public static final String KEY_SUPPORT_CDMA_1X_VOICE_CALLS_BOOL =
+ "support_cdma_1x_voice_calls_bool";
/**
* Boolean indicating if support is provided for directly dialing FDN number from FDN list.
@@ -2251,12 +2302,6 @@ public class CarrierConfigManager {
"allow_metered_network_for_cert_download_bool";
/**
- * Carrier specified WiFi networks.
- * @hide
- */
- public static final String KEY_CARRIER_WIFI_STRING_ARRAY = "carrier_wifi_string_array";
-
- /**
* Time delay (in ms) after which we show the notification to switch the preferred
* network.
* @hide
@@ -2651,7 +2696,6 @@ public class CarrierConfigManager {
*/
public static final String IMSI_KEY_AVAILABILITY_INT = "imsi_key_availability_int";
-
/**
* Key identifying if the CDMA Caller ID presentation and suppression MMI codes
* should be converted to 3GPP CLIR codes when a multimode (CDMA+UMTS+LTE) device is roaming
@@ -3420,6 +3464,15 @@ public class CarrierConfigManager {
"data_switch_validation_timeout_long";
/**
+ * Specifies whether the system should prefix the EAP method to the anonymous identity.
+ * The following prefix will be added if this key is set to TRUE:
+ * EAP-AKA: "0"
+ * EAP-SIM: "1"
+ * EAP-AKA_PRIME: "6"
+ */
+ public static final String ENABLE_EAP_METHOD_PREFIX_BOOL = "enable_eap_method_prefix_bool";
+
+ /**
* GPS configs. See the GNSS HAL documentation for more details.
*/
public static final class Gps {
@@ -3592,7 +3645,7 @@ public class CarrierConfigManager {
defaults.putString(KEY_SUPL_VER_STRING, "0x20000");
defaults.putString(KEY_SUPL_MODE_STRING, "1");
defaults.putString(KEY_SUPL_ES_STRING, "1");
- defaults.putString(KEY_LPP_PROFILE_STRING, "0");
+ defaults.putString(KEY_LPP_PROFILE_STRING, "2");
defaults.putString(KEY_USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_STRING, "1");
defaults.putString(KEY_A_GLONASS_POS_PROTOCOL_SELECT_STRING, "0");
defaults.putString(KEY_GPS_LOCK_STRING, "3");
@@ -3707,12 +3760,17 @@ public class CarrierConfigManager {
/** Prefix of all Ims.KEY_* constants. */
public static final String KEY_PREFIX = "ims.";
- //TODO: Add configs related to IMS.
+ /**
+ * Delay in milliseconds to turn off wifi when IMS is registered over wifi.
+ */
+ public static final String KEY_WIFI_OFF_DEFERRING_TIME_MILLIS_INT =
+ KEY_PREFIX + "wifi_off_deferring_time_millis_int";
private Ims() {}
private static PersistableBundle getDefaults() {
PersistableBundle defaults = new PersistableBundle();
+ defaults.putInt(KEY_WIFI_OFF_DEFERRING_TIME_MILLIS_INT, 4000);
return defaults;
}
}
@@ -3741,6 +3799,15 @@ public class CarrierConfigManager {
"support_wps_over_ims_bool";
/**
+ * The two digital number pattern of MMI code which is defined by carrier.
+ * If the dial number matches this pattern, it will be dialed out normally not USSD.
+ *
+ * @hide
+ */
+ public static final String KEY_MMI_TWO_DIGIT_NUMBER_PATTERN_STRING_ARRAY =
+ "mmi_two_digit_number_pattern_string_array";
+
+ /**
* Holds the list of carrier certificate hashes.
* Note that each carrier has its own certificates.
*/
@@ -3772,6 +3839,14 @@ public class CarrierConfigManager {
"prevent_clir_activation_and_deactivation_code_bool";
/**
+ * Flag specifying whether to show forwarded number on call-in-progress screen.
+ * When true, forwarded number is shown.
+ * When false, forwarded number is not shown.
+ */
+ public static final String KEY_SHOW_FORWARDED_NUMBER_BOOL =
+ "show_forwarded_number_bool";
+
+ /**
* The list of originating address of missed incoming call SMS. If the SMS has originator
* matched, the SMS will be treated as special SMS for notifying missed incoming call to the
* user.
@@ -3943,6 +4018,8 @@ public class CarrierConfigManager {
sDefaults.putStringArray(KEY_READ_ONLY_APN_TYPES_STRING_ARRAY, new String[] {"dun"});
sDefaults.putStringArray(KEY_READ_ONLY_APN_FIELDS_STRING_ARRAY, null);
sDefaults.putStringArray(KEY_APN_SETTINGS_DEFAULT_APN_TYPES_STRING_ARRAY, null);
+ sDefaults.putAll(Apn.getDefaults());
+
sDefaults.putBoolean(KEY_BROADCAST_EMERGENCY_CALL_STATE_CHANGES_BOOL, false);
sDefaults.putBoolean(KEY_ALWAYS_SHOW_EMERGENCY_ALERT_ONOFF_BOOL, false);
sDefaults.putStringArray(KEY_CARRIER_DATA_CALL_RETRY_CONFIG_STRINGS, new String[]{
@@ -4077,6 +4154,7 @@ public class CarrierConfigManager {
sDefaults.putBoolean(KEY_FORCE_IMEI_BOOL, false);
sDefaults.putInt(
KEY_CDMA_ROAMING_MODE_INT, TelephonyManager.CDMA_ROAMING_MODE_RADIO_DEFAULT);
+ sDefaults.putBoolean(KEY_SUPPORT_CDMA_1X_VOICE_CALLS_BOOL, true);
sDefaults.putString(KEY_RCS_CONFIG_SERVER_URL_STRING, "");
// Carrier Signalling Receivers
@@ -4143,7 +4221,6 @@ public class CarrierConfigManager {
sDefaults.putBoolean(KEY_STK_DISABLE_LAUNCH_BROWSER_BOOL, false);
sDefaults.putBoolean(KEY_ALLOW_METERED_NETWORK_FOR_CERT_DOWNLOAD_BOOL, false);
sDefaults.putBoolean(KEY_HIDE_DIGITS_HELPER_TEXT_ON_STK_INPUT_SCREEN_BOOL, true);
- sDefaults.putStringArray(KEY_CARRIER_WIFI_STRING_ARRAY, null);
sDefaults.putInt(KEY_PREF_NETWORK_NOTIFICATION_DELAY_INT, -1);
sDefaults.putInt(KEY_EMERGENCY_NOTIFICATION_DELAY_INT, -1);
sDefaults.putBoolean(KEY_ALLOW_USSD_REQUESTS_VIA_TELEPHONY_MANAGER_BOOL, true);
@@ -4335,8 +4412,13 @@ public class CarrierConfigManager {
new int[] {4 /* BUSY */});
sDefaults.putBoolean(KEY_PREVENT_CLIR_ACTIVATION_AND_DEACTIVATION_CODE_BOOL, false);
sDefaults.putLong(KEY_DATA_SWITCH_VALIDATION_TIMEOUT_LONG, 2000);
+ sDefaults.putStringArray(KEY_MMI_TWO_DIGIT_NUMBER_PATTERN_STRING_ARRAY, new String[0]);
sDefaults.putInt(KEY_PARAMETERS_USED_FOR_LTE_SIGNAL_BAR_INT,
CellSignalStrengthLte.USE_RSRP);
+ // Default wifi configurations.
+ sDefaults.putAll(Wifi.getDefaults());
+ sDefaults.putBoolean(ENABLE_EAP_METHOD_PREFIX_BOOL, false);
+ sDefaults.putBoolean(KEY_SHOW_FORWARDED_NUMBER_BOOL, false);
sDefaults.putLong(KEY_DATA_SWITCH_VALIDATION_MIN_GAP_LONG, TimeUnit.DAYS.toMillis(1));
sDefaults.putStringArray(KEY_MISSED_INCOMING_CALL_SMS_ORIGINATOR_STRING_ARRAY,
new String[0]);
@@ -4349,6 +4431,31 @@ public class CarrierConfigManager {
}
/**
+ * Wi-Fi configs used in WiFi Module.
+ *
+ * @hide
+ */
+ @SystemApi
+ public static final class Wifi {
+ /** Prefix of all Wifi.KEY_* constants. */
+ public static final String KEY_PREFIX = "wifi.";
+ /**
+ * It contains the maximum client count definition that the carrier sets.
+ * The default is 0, which means that the carrier hasn't set a requirement.
+ */
+ public static final String KEY_HOTSPOT_MAX_CLIENT_COUNT =
+ KEY_PREFIX + "hotspot_maximum_client_count";
+
+ private static PersistableBundle getDefaults() {
+ PersistableBundle defaults = new PersistableBundle();
+ defaults.putInt(KEY_HOTSPOT_MAX_CLIENT_COUNT, 0);
+ return defaults;
+ }
+
+ private Wifi() {}
+ }
+
+ /**
* Gets the configuration values for a particular subscription, which is associated with a
* specific SIM card. If an invalid subId is used, the returned config will contain default
* values. After using this method to get the configuration bundle,
@@ -4372,7 +4479,7 @@ public class CarrierConfigManager {
return null;
}
return loader.getConfigForSubIdWithFeature(subId, mContext.getOpPackageName(),
- null);
+ mContext.getAttributionTag());
} catch (RemoteException ex) {
Rlog.e(TAG, "Error getting config for subId " + subId + ": "
+ ex.toString());
@@ -4584,8 +4691,11 @@ public class CarrierConfigManager {
/** @hide */
@Nullable
private ICarrierConfigLoader getICarrierConfigLoader() {
- return ICarrierConfigLoader.Stub
- .asInterface(ServiceManager.getService(Context.CARRIER_CONFIG_SERVICE));
+ return ICarrierConfigLoader.Stub.asInterface(
+ TelephonyFrameworkInitializer
+ .getTelephonyServiceManager()
+ .getCarrierConfigServiceRegisterer()
+ .get());
}
/**
diff --git a/telephony/java/android/telephony/CdmaEriInformation.java b/telephony/java/android/telephony/CdmaEriInformation.java
new file mode 100644
index 000000000000..fd0b905e9c3e
--- /dev/null
+++ b/telephony/java/android/telephony/CdmaEriInformation.java
@@ -0,0 +1,169 @@
+/**
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.telephony;
+
+import android.annotation.IntDef;
+import android.annotation.NonNull;
+import android.annotation.SystemApi;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * CDMA ERI (Enhanced Roaming Indicator) information.
+ *
+ * This contains the following ERI information
+ *
+ * 1. ERI (Enhanced Roaming Indicator) icon index. The number is assigned by
+ * 3GPP2 C.R1001-H v1.0 Table 8.1-1. Additionally carriers define their own
+ * ERI icon index.
+ * 2. CDMA ERI icon mode. This represents how the icon should be displayed.
+ * Its one of the following CDMA ERI icon mode
+ * {@link android.telephony.CdmaEriInformation#ERI_ICON_MODE_NORMAL}
+ * {@link android.telephony.CdmaEriInformation#ERI_ICON_MODE_FLASH}
+ *
+ * @hide
+ */
+public final class CdmaEriInformation implements Parcelable {
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = {"ERI_"}, value = {
+ ERI_ON,
+ ERI_OFF,
+ ERI_FLASH
+ })
+ public @interface EriIconIndex {}
+
+ /**
+ * ERI (Enhanced Roaming Indicator) is ON i.e value 0 defined by
+ * 3GPP2 C.R1001-H v1.0 Table 8.1-1.
+ */
+ public static final int ERI_ON = 0;
+
+ /**
+ * ERI (Enhanced Roaming Indicator) is OFF i.e value 1 defined by
+ * 3GPP2 C.R1001-H v1.0 Table 8.1-1.
+ */
+ public static final int ERI_OFF = 1;
+
+ /**
+ * ERI (Enhanced Roaming Indicator) is FLASH i.e value 2 defined by
+ * 3GPP2 C.R1001-H v1.0 Table 8.1-1.
+ */
+ public static final int ERI_FLASH = 2;
+
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = {"ERI_ICON_MODE_"}, value = {
+ ERI_ICON_MODE_NORMAL,
+ ERI_ICON_MODE_FLASH
+ })
+ public @interface EriIconMode {}
+
+ /**
+ * ERI (Enhanced Roaming Indicator) icon mode is normal. This constant represents that
+ * the ERI icon should be displayed normally.
+ *
+ * Note: ERI is defined 3GPP2 C.R1001-H Table 8.1-1
+ */
+ public static final int ERI_ICON_MODE_NORMAL = 0;
+
+ /**
+ * ERI (Enhanced Roaming Indicator) icon mode flash. This constant represents that
+ * the ERI icon should be flashing.
+ *
+ * Note: ERI is defined 3GPP2 C.R1001-H Table 8.1-1
+ */
+ public static final int ERI_ICON_MODE_FLASH = 1;
+
+ private @EriIconIndex int mIconIndex;
+ private @EriIconMode int mIconMode;
+
+ /**
+ * Creates CdmaEriInformation from iconIndex and iconMode
+ *
+ * @hide
+ */
+ public CdmaEriInformation(@EriIconIndex int iconIndex, @EriIconMode int iconMode) {
+ mIconIndex = iconIndex;
+ mIconMode = iconMode;
+ }
+
+ /** Gets the ERI icon index */
+ public @EriIconIndex int getEriIconIndex() {
+ return mIconIndex;
+ }
+
+ /**
+ * Sets the ERI icon index
+ *
+ * @hide
+ */
+ public void setEriIconIndex(@EriIconIndex int iconIndex) {
+ mIconIndex = iconIndex;
+ }
+
+ /** Gets the ERI icon mode */
+ public @EriIconMode int getEriIconMode() {
+ return mIconMode;
+ }
+
+ /**
+ * Sets the ERI icon mode
+ *
+ * @hide
+ */
+ public void setEriIconMode(@EriIconMode int iconMode) {
+ mIconMode = iconMode;
+ }
+ /** Implement the Parcelable interface */
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ dest.writeInt(mIconIndex);
+ dest.writeInt(mIconMode);
+ }
+
+ /** Implement the Parcelable interface */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /**
+ * Construct a CdmaEriInformation object from the given parcel
+ */
+ private CdmaEriInformation(Parcel in) {
+ mIconIndex = in.readInt();
+ mIconMode = in.readInt();
+ }
+
+ /** Implement the Parcelable interface */
+ public static final @android.annotation.NonNull Parcelable.Creator<CdmaEriInformation> CREATOR =
+ new Parcelable.Creator<CdmaEriInformation>() {
+ @Override
+ public CdmaEriInformation createFromParcel(Parcel in) {
+ return new CdmaEriInformation(in);
+ }
+
+ @Override
+ public CdmaEriInformation[] newArray(int size) {
+ return new CdmaEriInformation[size];
+ }
+ };
+}
diff --git a/telephony/java/android/telephony/CellBroadcastService.java b/telephony/java/android/telephony/CellBroadcastService.java
index 1fe80f466b2a..ac775b391e94 100644
--- a/telephony/java/android/telephony/CellBroadcastService.java
+++ b/telephony/java/android/telephony/CellBroadcastService.java
@@ -119,7 +119,6 @@ public abstract class CellBroadcastService extends Service {
*/
@Override
@CallSuper
- @NonNull
public IBinder onBind(@Nullable Intent intent) {
return mStubWrapper;
}
diff --git a/telephony/java/android/telephony/CellIdentityLte.java b/telephony/java/android/telephony/CellIdentityLte.java
index 1993550d52b8..e6279dc977ee 100644
--- a/telephony/java/android/telephony/CellIdentityLte.java
+++ b/telephony/java/android/telephony/CellIdentityLte.java
@@ -366,7 +366,7 @@ public final class CellIdentityLte extends CellIdentity {
.append(" mPci=").append(mPci)
.append(" mTac=").append(mTac)
.append(" mEarfcn=").append(mEarfcn)
- .append(" mBands=").append(mBands)
+ .append(" mBands=").append(Arrays.toString(mBands))
.append(" mBandwidth=").append(mBandwidth)
.append(" mMcc=").append(mMccStr)
.append(" mMnc=").append(mMncStr)
diff --git a/telephony/java/android/telephony/CellIdentityNr.java b/telephony/java/android/telephony/CellIdentityNr.java
index 6c55c70e6cc2..067b98a16779 100644
--- a/telephony/java/android/telephony/CellIdentityNr.java
+++ b/telephony/java/android/telephony/CellIdentityNr.java
@@ -254,7 +254,7 @@ public final class CellIdentityNr extends CellIdentity {
.append(" mPci = ").append(mPci)
.append(" mTac = ").append(mTac)
.append(" mNrArfcn = ").append(mNrArfcn)
- .append(" mBands = ").append(mBands)
+ .append(" mBands = ").append(Arrays.toString(mBands))
.append(" mMcc = ").append(mMccStr)
.append(" mMnc = ").append(mMncStr)
.append(" mNci = ").append(mNci)
diff --git a/telephony/java/android/telephony/CellLocation.java b/telephony/java/android/telephony/CellLocation.java
index 427721f40e47..cdf735195d61 100644
--- a/telephony/java/android/telephony/CellLocation.java
+++ b/telephony/java/android/telephony/CellLocation.java
@@ -21,7 +21,6 @@ import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.os.Bundle;
import android.os.RemoteException;
-import android.os.ServiceManager;
import android.telephony.cdma.CdmaCellLocation;
import android.telephony.gsm.GsmCellLocation;
@@ -56,7 +55,11 @@ public abstract class CellLocation {
if (appContext == null) return; // should never happen
try {
- ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.getService("phone"));
+ ITelephony phone = ITelephony.Stub.asInterface(
+ TelephonyFrameworkInitializer
+ .getTelephonyServiceManager()
+ .getTelephonyServiceRegisterer()
+ .get());
if (phone != null) {
phone.updateServiceLocationWithPackageName(appContext.getOpPackageName());
}
@@ -68,8 +71,7 @@ public abstract class CellLocation {
/**
* Create a new CellLocation from a intent notifier Bundle
*
- * This method is used by PhoneStateIntentReceiver and maybe by
- * external applications.
+ * This method maybe used by external applications.
*
* @param bundle Bundle from intent notifier
* @return newly created CellLocation
diff --git a/telephony/java/android/telephony/CellSignalStrength.java b/telephony/java/android/telephony/CellSignalStrength.java
index cb8fdf0141b8..2e7bde3b3d89 100644
--- a/telephony/java/android/telephony/CellSignalStrength.java
+++ b/telephony/java/android/telephony/CellSignalStrength.java
@@ -156,6 +156,8 @@ public abstract class CellSignalStrength {
/**
* Returns the number of signal strength levels.
* @return Number of signal strength levels, enforced to be 5
+ *
+ * @hide
*/
public static final int getNumSignalStrengthLevels() {
return NUM_SIGNAL_STRENGTH_BINS;
diff --git a/telephony/java/android/telephony/DataFailCause.java b/telephony/java/android/telephony/DataFailCause.java
index e1c4bef0dd65..8b7a243c30e6 100644
--- a/telephony/java/android/telephony/DataFailCause.java
+++ b/telephony/java/android/telephony/DataFailCause.java
@@ -30,10 +30,8 @@ import java.util.Map;
import java.util.Set;
/**
- * Returned as the reason for a data connection failure as defined by modem and some local errors.
- * @hide
+ * DataFailCause collects data connection failure causes code from different sources.
*/
-@SystemApi
public final class DataFailCause {
/** There is no failure */
public static final int NONE = 0;
@@ -841,8 +839,19 @@ public final class DataFailCause {
/**
* Data call bring up fails in the VSNCP phase due to a network rejection of the VSNCP
* configuration request because the requested APN is unauthorized.
+ *
+ * @deprecated Use {@link #VSNCP_APN_UNAUTHORIZED} instead.
+ *
+ * @hide
+ */
+ @SystemApi
+ @Deprecated
+ public static final int VSNCP_APN_UNATHORIZED = 0x8BE; // NOTYPO
+ /**
+ * Data call bring up fails in the VSNCP phase due to a network rejection of the VSNCP
+ * configuration request because the requested APN is unauthorized.
*/
- public static final int VSNCP_APN_UNATHORIZED = 0x8BE;
+ public static final int VSNCP_APN_UNAUTHORIZED = 0x8BE;
/**
* Data call bring up fails in the VSNCP phase due to a network rejection of the VSNCP
* configuration request because the PDN limit has been exceeded.
@@ -1318,6 +1327,7 @@ public final class DataFailCause {
sFailCauseMap.put(VSNCP_TIMEOUT, "VSNCP_TIMEOUT");
sFailCauseMap.put(VSNCP_GEN_ERROR, "VSNCP_GEN_ERROR");
sFailCauseMap.put(VSNCP_APN_UNATHORIZED, "VSNCP_APN_UNATHORIZED");
+ sFailCauseMap.put(VSNCP_APN_UNAUTHORIZED, "VSNCP_APN_UNAUTHORIZED");
sFailCauseMap.put(VSNCP_PDN_LIMIT_EXCEEDED, "VSNCP_PDN_LIMIT_EXCEEDED");
sFailCauseMap.put(VSNCP_NO_PDN_GATEWAY_ADDRESS, "VSNCP_NO_PDN_GATEWAY_ADDRESS");
sFailCauseMap.put(VSNCP_PDN_GATEWAY_UNREACHABLE, "VSNCP_PDN_GATEWAY_UNREACHABLE");
@@ -1423,8 +1433,8 @@ public final class DataFailCause {
if (configManager != null) {
PersistableBundle b = configManager.getConfigForSubId(subId);
if (b != null) {
- String[] permanentFailureStrings = b.getStringArray(CarrierConfigManager.
- KEY_CARRIER_DATA_CALL_PERMANENT_FAILURE_STRINGS);
+ String[] permanentFailureStrings = b.getStringArray(CarrierConfigManager
+ .KEY_CARRIER_DATA_CALL_PERMANENT_FAILURE_STRINGS);
if (permanentFailureStrings != null) {
permanentFailureSet = new HashSet<>();
for (Map.Entry<Integer, String> e : sFailCauseMap.entrySet()) {
diff --git a/telephony/java/android/telephony/DisconnectCause.java b/telephony/java/android/telephony/DisconnectCause.java
index bf21bb7c2a35..2704418935d9 100644
--- a/telephony/java/android/telephony/DisconnectCause.java
+++ b/telephony/java/android/telephony/DisconnectCause.java
@@ -355,6 +355,12 @@ public final class DisconnectCause {
*/
public static final int OUTGOING_EMERGENCY_CALL_PLACED = 80;
+ /**
+ * Indicates that incoming call was rejected by the modem before the call went in ringing
+ */
+ public static final int INCOMING_AUTO_REJECTED = 81;
+
+
//*********************************************************************************************
// When adding a disconnect type:
// 1) Update toString() with the newly added disconnect type.
@@ -531,6 +537,8 @@ public final class DisconnectCause {
return "WFC_SERVICE_NOT_AVAILABLE_IN_THIS_LOCATION";
case OUTGOING_EMERGENCY_CALL_PLACED:
return "OUTGOING_EMERGENCY_CALL_PLACED";
+ case INCOMING_AUTO_REJECTED:
+ return "INCOMING_AUTO_REJECTED";
default:
return "INVALID: " + cause;
}
diff --git a/telephony/java/android/telephony/ModemActivityInfo.java b/telephony/java/android/telephony/ModemActivityInfo.java
index 47a9d779fdd5..debb119c94bc 100644
--- a/telephony/java/android/telephony/ModemActivityInfo.java
+++ b/telephony/java/android/telephony/ModemActivityInfo.java
@@ -16,13 +16,15 @@
package android.telephony;
+import android.annotation.IntDef;
import android.annotation.NonNull;
-import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.SystemClock;
import android.util.Range;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.List;
@@ -30,7 +32,6 @@ import java.util.List;
* Reports modem activity information.
* @hide
*/
-@SystemApi
public final class ModemActivityInfo implements Parcelable {
/**
* Tx(transmit) power level. see power index below
@@ -43,6 +44,38 @@ public final class ModemActivityInfo implements Parcelable {
* </ul>
*/
public static final int TX_POWER_LEVELS = 5;
+ /**
+ * Tx(transmit) power level 0: tx_power < 0dBm
+ */
+ public static final int TX_POWER_LEVEL_0 = 0;
+ /**
+ * Tx(transmit) power level 1: 0dBm < tx_power < 5dBm
+ */
+ public static final int TX_POWER_LEVEL_1 = 1;
+ /**
+ * Tx(transmit) power level 2: 5dBm < tx_power < 15dBm
+ */
+ public static final int TX_POWER_LEVEL_2 = 2;
+ /**
+ * Tx(transmit) power level 3: 15dBm < tx_power < 20dBm.
+ */
+ public static final int TX_POWER_LEVEL_3 = 3;
+ /**
+ * Tx(transmit) power level 4: tx_power > 20dBm
+ */
+ public static final int TX_POWER_LEVEL_4 = 4;
+
+ /** @hide */
+ @IntDef(prefix = {"TX_POWER_LEVEL_"}, value = {
+ TX_POWER_LEVEL_0,
+ TX_POWER_LEVEL_1,
+ TX_POWER_LEVEL_2,
+ TX_POWER_LEVEL_3,
+ TX_POWER_LEVEL_4,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface TxPowerLevel {}
+
private static final Range<Integer>[] TX_POWER_RANGES = new Range[] {
new Range<>(Integer.MIN_VALUE, 0),
new Range<>(0, 5),
@@ -114,7 +147,7 @@ public final class ModemActivityInfo implements Parcelable {
}
};
- public void writeToParcel(@NonNull Parcel dest, int flags) {
+ public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(mTimestamp);
dest.writeInt(mSleepTimeMs);
dest.writeInt(mIdleTimeMs);
diff --git a/telephony/java/android/telephony/NetworkScan.java b/telephony/java/android/telephony/NetworkScan.java
index 85f46d0f7403..adf31ed45c9a 100644
--- a/telephony/java/android/telephony/NetworkScan.java
+++ b/telephony/java/android/telephony/NetworkScan.java
@@ -17,9 +17,7 @@
package android.telephony;
import android.annotation.IntDef;
-import android.content.Context;
import android.os.RemoteException;
-import android.os.ServiceManager;
import com.android.internal.telephony.ITelephony;
import com.android.telephony.Rlog;
@@ -149,6 +147,9 @@ public class NetworkScan {
private ITelephony getITelephony() {
return ITelephony.Stub.asInterface(
- ServiceManager.getService(Context.TELEPHONY_SERVICE));
+ TelephonyFrameworkInitializer
+ .getTelephonyServiceManager()
+ .getTelephonyServiceRegisterer()
+ .get());
}
}
diff --git a/telephony/java/android/telephony/PhoneCapability.java b/telephony/java/android/telephony/PhoneCapability.java
index 238766a17a0f..b785037e51c1 100644
--- a/telephony/java/android/telephony/PhoneCapability.java
+++ b/telephony/java/android/telephony/PhoneCapability.java
@@ -28,6 +28,8 @@ import java.util.Objects;
/**
* Define capability of a modem group. That is, the capabilities
* are shared between those modems defined by list of modem IDs.
+ *
+ * @hide
*/
public final class PhoneCapability implements Parcelable {
// Hardcoded default DSDS capability.
@@ -50,6 +52,7 @@ public final class PhoneCapability implements Parcelable {
logicalModemList.add(modemInfo1);
DEFAULT_SSSS_CAPABILITY = new PhoneCapability(1, 1, 0, logicalModemList, false);
}
+
/** @hide */
public final int maxActiveVoiceCalls;
/** @hide */
@@ -116,7 +119,7 @@ public final class PhoneCapability implements Parcelable {
/**
* {@link Parcelable#describeContents}
*/
- public @Parcelable.ContentsFlags int describeContents() {
+ public int describeContents() {
return 0;
}
diff --git a/telephony/java/android/telephony/PinResult.java b/telephony/java/android/telephony/PinResult.java
index d9b5de5f878a..c2a4f33e95b9 100644
--- a/telephony/java/android/telephony/PinResult.java
+++ b/telephony/java/android/telephony/PinResult.java
@@ -71,9 +71,9 @@ public final class PinResult implements Parcelable {
/**
* Returns either success, incorrect or failure.
*
- * @see: #PIN_RESULT_TYPE_SUCCESS
- * @see: #PIN_RESULT_TYPE_INCORRECT
- * @see: #PIN_RESULT_TYPE_FAILURE
+ * @see #PIN_RESULT_TYPE_SUCCESS
+ * @see #PIN_RESULT_TYPE_INCORRECT
+ * @see #PIN_RESULT_TYPE_FAILURE
* @return The result type of the pin attempt.
*/
public @PinResultType int getType() {
@@ -98,9 +98,9 @@ public final class PinResult implements Parcelable {
* PinResult constructor
*
* @param type The type of pin result.
- * @see: #PIN_RESULT_TYPE_SUCCESS
- * @see: #PIN_RESULT_TYPE_INCORRECT
- * @see: #PIN_RESULT_TYPE_FAILURE
+ * @see #PIN_RESULT_TYPE_SUCCESS
+ * @see #PIN_RESULT_TYPE_INCORRECT
+ * @see #PIN_RESULT_TYPE_FAILURE
* @param attemptsRemaining Number of pin attempts remaining.
*/
public PinResult(@PinResultType int type, int attemptsRemaining) {
diff --git a/telephony/java/android/telephony/PreciseDataConnectionState.java b/telephony/java/android/telephony/PreciseDataConnectionState.java
index dd37ec3b6e54..b682bdd7aee3 100644
--- a/telephony/java/android/telephony/PreciseDataConnectionState.java
+++ b/telephony/java/android/telephony/PreciseDataConnectionState.java
@@ -171,6 +171,7 @@ public final class PreciseDataConnectionState implements Parcelable {
*
* @deprecated use {@link getNetworkType()}
* @hide
+ * @removed Removed from the R preview SDK but was never part of the stable API surface.
*/
@Deprecated
@SystemApi
@@ -222,6 +223,7 @@ public final class PreciseDataConnectionState implements Parcelable {
*
* @deprecated use {@link #getLinkProperties()}
* @hide
+ * @removed Removed from the R preview SDK but was never part of the stable API surface.
*/
@Deprecated
@SystemApi
@@ -256,8 +258,7 @@ public final class PreciseDataConnectionState implements Parcelable {
* Return the cause code for the most recent change in {@link #getState}. In the event of an
* error, this cause code will be non-zero.
*/
- // FIXME(b144774287): some of these cause codes should have a prescribed meaning.
- public int getLastCauseCode() {
+ public @DataFailureCause int getLastCauseCode() {
return mFailCause;
}
diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java
index c831ae9d6a04..3e7464739f9f 100644
--- a/telephony/java/android/telephony/ServiceState.java
+++ b/telephony/java/android/telephony/ServiceState.java
@@ -397,8 +397,8 @@ public class ServiceState implements Parcelable {
* @return newly created ServiceState
* @hide
*/
- @SystemApi
@NonNull
+ @UnsupportedAppUsage
public static ServiceState newFromBundle(@NonNull Bundle m) {
ServiceState ret;
ret = new ServiceState();
@@ -1336,7 +1336,7 @@ public class ServiceState implements Parcelable {
* @hide
*
*/
- @SystemApi
+ @UnsupportedAppUsage
public void fillInNotifierBundle(@NonNull Bundle m) {
m.putParcelable(EXTRA_SERVICE_STATE, this);
// serviceState already consists of below entries.
@@ -1656,7 +1656,6 @@ public class ServiceState implements Parcelable {
* @return Current data network type
* @hide
*/
- @SystemApi
@TestApi
public @NetworkType int getDataNetworkType() {
final NetworkRegistrationInfo iwlanRegInfo = getNetworkRegistrationInfo(
@@ -2028,11 +2027,12 @@ public class ServiceState implements Parcelable {
/**
* The current registered raw data network operator name in long alphanumeric format.
*
+ * The long format can be up to 16 characters long.
+ *
* @return long raw name of operator, null if unregistered or unknown
* @hide
*/
@Nullable
- @SystemApi
public String getOperatorAlphaLongRaw() {
return mOperatorAlphaLongRaw;
}
@@ -2047,11 +2047,12 @@ public class ServiceState implements Parcelable {
/**
* The current registered raw data network operator name in short alphanumeric format.
*
+ * The short format can be up to 8 characters long.
+ *
* @return short raw name of operator, null if unregistered or unknown
* @hide
*/
@Nullable
- @SystemApi
public String getOperatorAlphaShortRaw() {
return mOperatorAlphaShortRaw;
}
diff --git a/telephony/java/android/telephony/SignalStrength.java b/telephony/java/android/telephony/SignalStrength.java
index 5f09ca203dd9..1376cddbc41f 100644
--- a/telephony/java/android/telephony/SignalStrength.java
+++ b/telephony/java/android/telephony/SignalStrength.java
@@ -18,7 +18,6 @@ package android.telephony;
import android.annotation.ElapsedRealtimeLong;
import android.annotation.NonNull;
-import android.annotation.SystemApi;
import android.compat.annotation.UnsupportedAppUsage;
import android.os.Build;
import android.os.Bundle;
@@ -95,8 +94,7 @@ public class SignalStrength implements Parcelable {
/**
* Create a new SignalStrength from a intent notifier Bundle
*
- * This method is used by PhoneStateIntentReceiver and maybe by
- * external applications.
+ * This method may be used by external applications.
*
* @param m Bundle from intent notifier
* @return newly created SignalStrength
@@ -295,7 +293,6 @@ public class SignalStrength implements Parcelable {
*
* @hide
*/
- @SystemApi
public SignalStrength(@NonNull SignalStrength s) {
copyFrom(s);
}
diff --git a/telephony/java/android/telephony/SmsCbMessage.java b/telephony/java/android/telephony/SmsCbMessage.java
index 752707e5a5dc..d366efe0d979 100644
--- a/telephony/java/android/telephony/SmsCbMessage.java
+++ b/telephony/java/android/telephony/SmsCbMessage.java
@@ -594,6 +594,7 @@ public final class SmsCbMessage implements Parcelable {
SmsCbEtwsInfo etwsInfo = getEtwsWarningInfo();
if (etwsInfo != null) {
cv.put(CellBroadcasts.ETWS_WARNING_TYPE, etwsInfo.getWarningType());
+ cv.put(CellBroadcasts.ETWS_IS_PRIMARY, etwsInfo.isPrimary());
}
SmsCbCmasInfo cmasInfo = getCmasWarningInfo();
@@ -667,9 +668,12 @@ public final class SmsCbMessage implements Parcelable {
SmsCbEtwsInfo etwsInfo;
int etwsWarningTypeColumn = cursor.getColumnIndex(CellBroadcasts.ETWS_WARNING_TYPE);
- if (etwsWarningTypeColumn != -1 && !cursor.isNull(etwsWarningTypeColumn)) {
+ int etwsIsPrimaryColumn = cursor.getColumnIndex(CellBroadcasts.ETWS_IS_PRIMARY);
+ if (etwsWarningTypeColumn != -1 && !cursor.isNull(etwsWarningTypeColumn)
+ && etwsIsPrimaryColumn != -1 && !cursor.isNull(etwsIsPrimaryColumn)) {
int warningType = cursor.getInt(etwsWarningTypeColumn);
- etwsInfo = new SmsCbEtwsInfo(warningType, false, false, false, null);
+ boolean isPrimary = cursor.getInt(etwsIsPrimaryColumn) != 0;
+ etwsInfo = new SmsCbEtwsInfo(warningType, false, false, isPrimary, null);
} else {
etwsInfo = null;
}
diff --git a/telephony/java/android/telephony/SmsManager.java b/telephony/java/android/telephony/SmsManager.java
index 1dbec2c0f443..d6ce40c24b78 100644
--- a/telephony/java/android/telephony/SmsManager.java
+++ b/telephony/java/android/telephony/SmsManager.java
@@ -36,7 +36,6 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.RemoteException;
-import android.os.ServiceManager;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Log;
@@ -283,6 +282,42 @@ public final class SmsManager {
*/
public static final int SMS_MESSAGE_PERIOD_NOT_SPECIFIED = -1;
+ /** @hide */
+ @IntDef(prefix = { "PREMIUM_SMS_CONSENT" }, value = {
+ SmsManager.PREMIUM_SMS_CONSENT_UNKNOWN,
+ SmsManager.PREMIUM_SMS_CONSENT_ASK_USER,
+ SmsManager.PREMIUM_SMS_CONSENT_NEVER_ALLOW,
+ SmsManager.PREMIUM_SMS_CONSENT_ALWAYS_ALLOW
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface PremiumSmsConsent {}
+
+ /** Premium SMS Consent for the package is unknown. This indicates that the user
+ * has not set a permission for this package, because this package has never tried
+ * to send a premium SMS.
+ * @hide
+ */
+ @SystemApi
+ public static final int PREMIUM_SMS_CONSENT_UNKNOWN = 0;
+
+ /** Default premium SMS Consent (ask user for each premium SMS sent).
+ * @hide
+ */
+ @SystemApi
+ public static final int PREMIUM_SMS_CONSENT_ASK_USER = 1;
+
+ /** Premium SMS Consent when the owner has denied the app from sending premium SMS.
+ * @hide
+ */
+ @SystemApi
+ public static final int PREMIUM_SMS_CONSENT_NEVER_ALLOW = 2;
+
+ /** Premium SMS Consent when the owner has allowed the app to send premium SMS.
+ * @hide
+ */
+ @SystemApi
+ public static final int PREMIUM_SMS_CONSENT_ALWAYS_ALLOW = 3;
+
// result of asking the user for a subscription to perform an operation.
private interface SubscriptionResolverResult {
void onSuccess(int subId);
@@ -389,7 +424,26 @@ public final class SmsManager {
String destinationAddress, String scAddress, String text,
PendingIntent sentIntent, PendingIntent deliveryIntent) {
sendTextMessageInternal(destinationAddress, scAddress, text, sentIntent, deliveryIntent,
- true /* persistMessage*/, null, null);
+ true /* persistMessage*/, null, null, 0L /* messageId */);
+ }
+
+
+ /**
+ * Send a text based SMS. Same as {@link #sendTextMessage( String destinationAddress,
+ * String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent)}, but
+ * adds an optional messageId.
+ * @param messageId An id that uniquely identifies the message requested to be sent.
+ * Used for logging and diagnostics purposes. The id may be 0.
+ *
+ * @throws IllegalArgumentException if destinationAddress or text are empty
+ *
+ */
+ public void sendTextMessage(
+ @NonNull String destinationAddress, @Nullable String scAddress, @NonNull String text,
+ @Nullable PendingIntent sentIntent, @Nullable PendingIntent deliveryIntent,
+ long messageId) {
+ sendTextMessageInternal(destinationAddress, scAddress, text, sentIntent, deliveryIntent,
+ true /* persistMessage*/, null, null, messageId);
}
/**
@@ -507,7 +561,7 @@ public final class SmsManager {
private void sendTextMessageInternal(String destinationAddress, String scAddress,
String text, PendingIntent sentIntent, PendingIntent deliveryIntent,
- boolean persistMessage, String packageName, String attributionTag) {
+ boolean persistMessage, String packageName, String attributionTag, long messageId) {
if (TextUtils.isEmpty(destinationAddress)) {
throw new IllegalArgumentException("Invalid destinationAddress");
}
@@ -534,10 +588,10 @@ public final class SmsManager {
try {
iSms.sendTextForSubscriber(subId, packageName, attributionTag,
destinationAddress, scAddress, text, sentIntent, deliveryIntent,
- persistMessage);
+ persistMessage, messageId);
} catch (RemoteException e) {
Log.e(TAG, "sendTextMessageInternal: Couldn't send SMS, exception - "
- + e.getMessage());
+ + e.getMessage() + " id: " + messageId);
notifySmsError(sentIntent, RESULT_REMOTE_EXCEPTION);
}
}
@@ -554,10 +608,10 @@ public final class SmsManager {
try {
iSms.sendTextForSubscriber(getSubscriptionId(), packageName, attributionTag,
destinationAddress, scAddress, text, sentIntent, deliveryIntent,
- persistMessage);
+ persistMessage, messageId);
} catch (RemoteException e) {
Log.e(TAG, "sendTextMessageInternal (no persist): Couldn't send SMS, exception - "
- + e.getMessage());
+ + e.getMessage() + " id: " + messageId);
notifySmsError(sentIntent, RESULT_REMOTE_EXCEPTION);
}
}
@@ -599,7 +653,8 @@ public final class SmsManager {
String destinationAddress, String scAddress, String text,
PendingIntent sentIntent, PendingIntent deliveryIntent) {
sendTextMessageInternal(destinationAddress, scAddress, text, sentIntent, deliveryIntent,
- false /* persistMessage */, null, null);
+ false /* persistMessage */, null, null,
+ 0L /* messageId */);
}
private void sendTextMessageInternal(
@@ -735,8 +790,8 @@ public final class SmsManager {
* android application framework, or failed. This intent is broadcasted at
* the same time an SMS received from radio is acknowledged back.
* The result code will be {@link android.provider.Telephony.Sms.Intents#RESULT_SMS_HANDLED}
- * for success, or {@link android.provider.Telephony.Sms.Intents#RESULT_SMS_GENERIC_ERROR} for
- * error.
+ * for success, or {@link android.provider.Telephony.Sms.Intents#RESULT_SMS_GENERIC_ERROR} or
+ * {@link #RESULT_REMOTE_EXCEPTION} for error.
*
* @throws IllegalArgumentException if the format is invalid.
*/
@@ -748,7 +803,7 @@ public final class SmsManager {
"Invalid pdu format. format must be either 3gpp or 3gpp2");
}
try {
- ISms iSms = ISms.Stub.asInterface(ServiceManager.getService("isms"));
+ ISms iSms = TelephonyManager.getSmsService();
if (iSms != null) {
iSms.injectSmsPduForSubscriber(
getSubscriptionId(), pdu, format, receivedIntent);
@@ -884,24 +939,26 @@ public final class SmsManager {
String destinationAddress, String scAddress, ArrayList<String> parts,
ArrayList<PendingIntent> sentIntents, ArrayList<PendingIntent> deliveryIntents) {
sendMultipartTextMessageInternal(destinationAddress, scAddress, parts, sentIntents,
- deliveryIntents, true /* persistMessage*/, null, null);
+ deliveryIntents, true /* persistMessage*/, null, null,
+ 0L /* messageId */);
}
/**
- * @deprecated Use {@link #sendMultipartTextMessage(String, String, List, List, List, String,
- * String)} instead.
+ * Send a multi-part text based SMS. Same as #sendMultipartTextMessage(String, String,
+ * ArrayList, ArrayList, ArrayList), but adds an optional messageId.
+ * @param messageId An id that uniquely identifies the message requested to be sent.
+ * Used for logging and diagnostics purposes. The id may be 0.
+ *
+ * @throws IllegalArgumentException if destinationAddress or data are empty
*
- * @hide
*/
- @Deprecated
- @SystemApi
- @TestApi
public void sendMultipartTextMessage(
- @NonNull String destinationAddress, @NonNull String scAddress,
+ @NonNull String destinationAddress, @Nullable String scAddress,
@NonNull List<String> parts, @Nullable List<PendingIntent> sentIntents,
- @Nullable List<PendingIntent> deliveryIntents, @NonNull String packageName) {
- sendMultipartTextMessage(destinationAddress, scAddress, parts, sentIntents, deliveryIntents,
- packageName, null);
+ @Nullable List<PendingIntent> deliveryIntents, long messageId) {
+ sendMultipartTextMessageInternal(destinationAddress, scAddress, parts, sentIntents,
+ deliveryIntents, true /* persistMessage*/, null, null,
+ messageId);
}
/**
@@ -920,24 +977,22 @@ public final class SmsManager {
*
* @param packageName serves as the default package name if the package name that is
* associated with the user id is null.
- *
- * @hide
*/
- @SystemApi
- @TestApi
public void sendMultipartTextMessage(
- @NonNull String destinationAddress, @NonNull String scAddress,
+ @NonNull String destinationAddress, @Nullable String scAddress,
@NonNull List<String> parts, @Nullable List<PendingIntent> sentIntents,
@Nullable List<PendingIntent> deliveryIntents, @NonNull String packageName,
@Nullable String attributionTag) {
sendMultipartTextMessageInternal(destinationAddress, scAddress, parts, sentIntents,
- deliveryIntents, true /* persistMessage*/, packageName, attributionTag);
+ deliveryIntents, true /* persistMessage*/, packageName, attributionTag,
+ 0L /* messageId */);
}
private void sendMultipartTextMessageInternal(
String destinationAddress, String scAddress, List<String> parts,
List<PendingIntent> sentIntents, List<PendingIntent> deliveryIntents,
- boolean persistMessage, String packageName, String attributionTag) {
+ boolean persistMessage, String packageName, @Nullable String attributionTag,
+ long messageId) {
if (TextUtils.isEmpty(destinationAddress)) {
throw new IllegalArgumentException("Invalid destinationAddress");
}
@@ -964,10 +1019,11 @@ public final class SmsManager {
ISms iSms = getISmsServiceOrThrow();
iSms.sendMultipartTextForSubscriber(subId, packageName, attributionTag,
destinationAddress, scAddress, parts, sentIntents,
- deliveryIntents, persistMessage);
+ deliveryIntents, persistMessage, messageId);
} catch (RemoteException e) {
Log.e(TAG, "sendMultipartTextMessageInternal: Couldn't send SMS - "
- + e.getMessage());
+ + e.getMessage() + " id: "
+ + messageId);
notifySmsError(sentIntents, RESULT_REMOTE_EXCEPTION);
}
}
@@ -984,11 +1040,11 @@ public final class SmsManager {
if (iSms != null) {
iSms.sendMultipartTextForSubscriber(getSubscriptionId(), packageName,
attributionTag, destinationAddress, scAddress, parts, sentIntents,
- deliveryIntents, persistMessage);
+ deliveryIntents, persistMessage, messageId);
}
} catch (RemoteException e) {
Log.e(TAG, "sendMultipartTextMessageInternal: Couldn't send SMS - "
- + e.getMessage());
+ + e.getMessage() + " id: " + messageId);
notifySmsError(sentIntents, RESULT_REMOTE_EXCEPTION);
}
}
@@ -1002,7 +1058,7 @@ public final class SmsManager {
deliveryIntent = deliveryIntents.get(0);
}
sendTextMessageInternal(destinationAddress, scAddress, parts.get(0),
- sentIntent, deliveryIntent, true, packageName, attributionTag);
+ sentIntent, deliveryIntent, true, packageName, attributionTag, messageId);
}
}
@@ -1032,7 +1088,8 @@ public final class SmsManager {
String destinationAddress, String scAddress, List<String> parts,
List<PendingIntent> sentIntents, List<PendingIntent> deliveryIntents) {
sendMultipartTextMessageInternal(destinationAddress, scAddress, parts, sentIntents,
- deliveryIntents, false /* persistMessage*/, null, null);
+ deliveryIntents, false /* persistMessage*/, null, null,
+ 0L /* messageId */);
}
/**
@@ -1550,7 +1607,10 @@ public final class SmsManager {
private static ITelephony getITelephony() {
ITelephony binder = ITelephony.Stub.asInterface(
- ServiceManager.getService(Context.TELEPHONY_SERVICE));
+ TelephonyFrameworkInitializer
+ .getTelephonyServiceManager()
+ .getTelephonyServiceRegisterer()
+ .get());
if (binder == null) {
throw new RuntimeException("Could not find Telephony Service.");
}
@@ -1580,7 +1640,7 @@ public final class SmsManager {
* the service does not exist.
*/
private static ISms getISmsServiceOrThrow() {
- ISms iSms = getISmsService();
+ ISms iSms = TelephonyManager.getSmsService();
if (iSms == null) {
throw new UnsupportedOperationException("Sms is not supported");
}
@@ -1588,7 +1648,7 @@ public final class SmsManager {
}
private static ISms getISmsService() {
- return ISms.Stub.asInterface(ServiceManager.getService("isms"));
+ return TelephonyManager.getSmsService();
}
/**
@@ -1618,7 +1678,6 @@ public final class SmsManager {
* @throws IllegalArgumentException if pdu is null.
* @hide
*/
- @SystemApi
@RequiresPermission(Manifest.permission.ACCESS_MESSAGES_ON_ICC)
public boolean copyMessageToIcc(
@Nullable byte[] smsc, @NonNull byte[] pdu, @StatusOnIcc int status) {
@@ -1662,7 +1721,6 @@ public final class SmsManager {
*
* {@hide}
*/
- @SystemApi
@RequiresPermission(Manifest.permission.ACCESS_MESSAGES_ON_ICC)
public boolean deleteMessageFromIcc(int messageIndex) {
boolean success = false;
@@ -1743,7 +1801,6 @@ public final class SmsManager {
*
* {@hide}
*/
- @SystemApi
@RequiresPermission(Manifest.permission.ACCESS_MESSAGES_ON_ICC)
public @NonNull List<SmsMessage> getMessagesFromIcc() {
return getAllMessagesFromIcc();
@@ -2024,7 +2081,7 @@ public final class SmsManager {
public boolean isSMSPromptEnabled() {
ISms iSms = null;
try {
- iSms = ISms.Stub.asInterface(ServiceManager.getService("isms"));
+ iSms = TelephonyManager.getSmsService();
return iSms.isSMSPromptEnabled();
} catch (RemoteException ex) {
return false;
@@ -2113,7 +2170,36 @@ public final class SmsManager {
RESULT_INTERNAL_ERROR,
RESULT_NO_RESOURCES,
RESULT_CANCELLED,
- RESULT_REQUEST_NOT_SUPPORTED
+ RESULT_REQUEST_NOT_SUPPORTED,
+ RESULT_NO_BLUETOOTH_SERVICE,
+ RESULT_INVALID_BLUETOOTH_ADDRESS,
+ RESULT_BLUETOOTH_DISCONNECTED,
+ RESULT_UNEXPECTED_EVENT_STOP_SENDING,
+ RESULT_SMS_BLOCKED_DURING_EMERGENCY,
+ RESULT_SMS_SEND_RETRY_FAILED,
+ RESULT_REMOTE_EXCEPTION,
+ RESULT_NO_DEFAULT_SMS_APP,
+ RESULT_RIL_RADIO_NOT_AVAILABLE,
+ RESULT_RIL_SMS_SEND_FAIL_RETRY,
+ RESULT_RIL_NETWORK_REJECT,
+ RESULT_RIL_INVALID_STATE,
+ RESULT_RIL_INVALID_ARGUMENTS,
+ RESULT_RIL_NO_MEMORY,
+ RESULT_RIL_REQUEST_RATE_LIMITED,
+ RESULT_RIL_INVALID_SMS_FORMAT,
+ RESULT_RIL_SYSTEM_ERR,
+ RESULT_RIL_ENCODING_ERR,
+ RESULT_RIL_INVALID_SMSC_ADDRESS,
+ RESULT_RIL_MODEM_ERR,
+ RESULT_RIL_NETWORK_ERR,
+ RESULT_RIL_INTERNAL_ERR,
+ RESULT_RIL_REQUEST_NOT_SUPPORTED,
+ RESULT_RIL_INVALID_MODEM_STATE,
+ RESULT_RIL_NETWORK_NOT_READY,
+ RESULT_RIL_OPERATION_NOT_ALLOWED,
+ RESULT_RIL_NO_RESOURCES,
+ RESULT_RIL_CANCELLED,
+ RESULT_RIL_SIM_ABSENT
})
@Retention(RetentionPolicy.SOURCE)
public @interface Result {}
@@ -2363,7 +2449,7 @@ public final class SmsManager {
public static final int RESULT_RIL_OPERATION_NOT_ALLOWED = 117;
/**
- * There are not sufficient resources to process the request.
+ * There are insufficient resources to process the request.
*/
public static final int RESULT_RIL_NO_RESOURCES = 118;
@@ -2378,6 +2464,45 @@ public final class SmsManager {
*/
public static final int RESULT_RIL_SIM_ABSENT = 120;
+ // SMS receiving results sent as a "result" extra in {@link Intents.SMS_REJECTED_ACTION}
+
+ /**
+ * SMS receive dispatch failure.
+ */
+ public static final int RESULT_RECEIVE_DISPATCH_FAILURE = 500;
+
+ /**
+ * SMS receive injected null PDU.
+ */
+ public static final int RESULT_RECEIVE_INJECTED_NULL_PDU = 501;
+
+ /**
+ * SMS receive encountered runtime exception.
+ */
+ public static final int RESULT_RECEIVE_RUNTIME_EXCEPTION = 502;
+
+ /**
+ * SMS received null message from the radio interface layer.
+ */
+ public static final int RESULT_RECEIVE_NULL_MESSAGE_FROM_RIL = 503;
+
+ /**
+ * SMS short code received while the phone is in encrypted state.
+ */
+ public static final int RESULT_RECEIVE_WHILE_ENCRYPTED = 504;
+
+ /**
+ * SMS receive encountered an SQL exception.
+ */
+ public static final int RESULT_RECEIVE_SQL_EXCEPTION = 505;
+
+ /**
+ * SMS receive an exception parsing a uri.
+ */
+ public static final int RESULT_RECEIVE_URI_EXCEPTION = 506;
+
+
+
/**
* Send an MMS message
*
@@ -2407,7 +2532,7 @@ public final class SmsManager {
MmsManager m = (MmsManager) context.getSystemService(Context.MMS_SERVICE);
if (m != null) {
m.sendMultimediaMessage(getSubscriptionId(), contentUri, locationUrl, configOverrides,
- sentIntent);
+ sentIntent, 0L /* messageId */);
}
}
@@ -2444,7 +2569,7 @@ public final class SmsManager {
MmsManager m = (MmsManager) context.getSystemService(Context.MMS_SERVICE);
if (m != null) {
m.downloadMultimediaMessage(getSubscriptionId(), locationUrl, contentUri,
- configOverrides, downloadedIntent);
+ configOverrides, downloadedIntent, 0L /* messageId */);
}
}
@@ -2807,4 +2932,78 @@ public final class SmsManager {
}
return false;
}
+
+ /**
+ * Gets the premium SMS permission for the specified package. If the package has never
+ * been seen before, the default {@link SmsManager#PREMIUM_SMS_CONSENT_UNKNOWN}
+ * will be returned.
+ * @param packageName the name of the package to query permission
+ * @return one of {@link SmsManager#PREMIUM_SMS_CONSENT_UNKNOWN},
+ * {@link SmsManager#PREMIUM_SMS_CONSENT_ASK_USER},
+ * {@link SmsManager#PREMIUM_SMS_CONSENT_NEVER_ALLOW}, or
+ * {@link SmsManager#PREMIUM_SMS_CONSENT_ALWAYS_ALLOW}
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
+ public @PremiumSmsConsent int getPremiumSmsConsent(@NonNull String packageName) {
+ int permission = 0;
+ try {
+ ISms iSms = getISmsService();
+ if (iSms != null) {
+ permission = iSms.getPremiumSmsPermission(packageName);
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "getPremiumSmsPermission() RemoteException", e);
+ }
+ return permission;
+ }
+
+ /**
+ * Sets the premium SMS permission for the specified package and save the value asynchronously
+ * to persistent storage.
+ * @param packageName the name of the package to set permission
+ * @param permission one of {@link SmsManager#PREMIUM_SMS_CONSENT_ASK_USER},
+ * {@link SmsManager#PREMIUM_SMS_CONSENT_NEVER_ALLOW}, or
+ * {@link SmsManager#PREMIUM_SMS_CONSENT_ALWAYS_ALLOW}
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
+ public void setPremiumSmsConsent(
+ @NonNull String packageName, @PremiumSmsConsent int permission) {
+ try {
+ ISms iSms = getISmsService();
+ if (iSms != null) {
+ iSms.setPremiumSmsPermission(packageName, permission);
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "setPremiumSmsPermission() RemoteException", e);
+ }
+ }
+
+ /**
+ * Reset all cell broadcast ranges. Previously enabled ranges will become invalid after this.
+ *
+ * @return {@code true} if succeeded, otherwise {@code false}.
+ *
+ * // TODO: Unhide the API in S.
+ * @hide
+ */
+ public boolean resetAllCellBroadcastRanges() {
+ boolean success = false;
+
+ try {
+ ISms iSms = getISmsService();
+ if (iSms != null) {
+ // If getSubscriptionId() returns INVALID or an inactive subscription, we will use
+ // the default phone internally.
+ success = iSms.resetAllCellBroadcastRanges(getSubscriptionId());
+ }
+ } catch (RemoteException ex) {
+ // ignore it
+ }
+
+ return success;
+ }
}
diff --git a/telephony/java/android/telephony/SmsMessage.java b/telephony/java/android/telephony/SmsMessage.java
index 392670ba992c..717a9b155cbf 100644
--- a/telephony/java/android/telephony/SmsMessage.java
+++ b/telephony/java/android/telephony/SmsMessage.java
@@ -317,6 +317,23 @@ public class SmsMessage {
}
/**
+ * Create an SmsMessage from a native SMS-Submit PDU, specified by Bluetooth Message Access
+ * Profile Specification v1.4.2 5.8.
+ * This is used by Bluetooth MAP profile to decode message when sending non UTF-8 SMS messages.
+ *
+ * @param data Message data.
+ * @param isCdma Indicates weather the type of the SMS is CDMA.
+ * @return An SmsMessage representing the message.
+ *
+ * @hide
+ */
+ @SystemApi
+ @Nullable
+ public static SmsMessage createFromNativeSmsSubmitPdu(@NonNull byte[] data, boolean isCdma) {
+ return null;
+ }
+
+ /**
* Get the TP-Layer-Length for the given SMS-SUBMIT PDU Basically, the
* length in bytes (not hex chars) less the SMSC header
*
@@ -744,9 +761,9 @@ public class SmsMessage {
if (isTypeGsm) {
data = com.android.internal.telephony.gsm.SmsMessage.getSubmitPdu(null,
- destinationAddress, message, false,
- SmsHeader.toByteArray(smsHeader), encoding, languageTable,
- languageShiftTable).encodedMessage;
+ destinationAddress, message, false,
+ SmsHeader.toByteArray(smsHeader), encoding, languageTable,
+ languageShiftTable).encodedMessage;
} else { // SMS_TYPE_CDMA
UserData uData = new UserData();
uData.payloadStr = message;
@@ -758,7 +775,7 @@ public class SmsMessage {
}
uData.msgEncodingSet = true;
data = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(
- destinationAddress, uData, false).encodedMessage;
+ destinationAddress, uData, false).encodedMessage;
}
if (data == null) {
return new byte[0];
@@ -1176,6 +1193,7 @@ public class SmsMessage {
/**
* Returns the recipient address(receiver) of this SMS message in String form or null if
* unavailable.
+ * {@hide}
*/
@Nullable
public String getRecipientAddress() {
diff --git a/telephony/java/android/telephony/SubscriptionInfo.java b/telephony/java/android/telephony/SubscriptionInfo.java
index dc75c58e9420..11667c83bc6a 100644
--- a/telephony/java/android/telephony/SubscriptionInfo.java
+++ b/telephony/java/android/telephony/SubscriptionInfo.java
@@ -217,6 +217,20 @@ public class SubscriptionInfo implements Parcelable {
private boolean mAreUiccApplicationsEnabled = true;
/**
+ * Public copy constructor.
+ * @hide
+ */
+ public SubscriptionInfo(SubscriptionInfo info) {
+ this(info.mId, info.mIccId, info.mSimSlotIndex, info.mDisplayName, info.mCarrierName,
+ info.mNameSource, info.mIconTint, info.mNumber, info.mDataRoaming, info.mIconBitmap,
+ info.mMcc, info.mMnc, info.mCountryIso, info.mIsEmbedded, info.mNativeAccessRules,
+ info.mCardString, info.mCardId, info.mIsOpportunistic,
+ info.mGroupUUID == null ? null : info.mGroupUUID.toString(), info.mIsGroupDisabled,
+ info.mCarrierId, info.mProfileClass, info.mSubscriptionType, info.mGroupOwner,
+ info.mCarrierConfigAccessRules, info.mAreUiccApplicationsEnabled);
+ }
+
+ /**
* @hide
*/
public SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName,
@@ -291,13 +305,30 @@ public class SubscriptionInfo implements Parcelable {
}
/**
- * @return the ICC ID.
+ * Returns the ICC ID.
+ *
+ * Starting with API level 30, returns the ICC ID if the calling app has been granted the
+ * READ_PRIVILEGED_PHONE_STATE permission, has carrier privileges (see
+ * {@link TelephonyManager#hasCarrierPrivileges}), or is a device owner or profile owner that
+ * has been granted the READ_PHONE_STATE permission. The profile owner is an app that owns a
+ * managed profile on the device; for more details see <a
+ * href="https://developer.android.com/work/managed-profiles">Work profiles</a>. Profile
+ * owner access is deprecated and will be removed in a future release.
+ *
+ * @return the ICC ID, or an empty string if one of these requirements is not met
*/
public String getIccId() {
return this.mIccId;
}
/**
+ * @hide
+ */
+ public void clearIccId() {
+ this.mIccId = "";
+ }
+
+ /**
* @return the slot index of this Subscription's SIM card.
*/
public int getSimSlotIndex() {
@@ -421,13 +452,35 @@ public class SubscriptionInfo implements Parcelable {
}
/**
- * @return the number of this subscription.
+ * Returns the number of this subscription.
+ *
+ * Starting with API level 30, returns the number of this subscription if the calling app meets
+ * one of the following requirements:
+ * <ul>
+ * <li>If the calling app's target SDK is API level 29 or lower and the app has been granted
+ * the READ_PHONE_STATE permission.
+ * <li>If the calling app has been granted any of READ_PRIVILEGED_PHONE_STATE,
+ * READ_PHONE_NUMBERS, or READ_SMS.
+ * <li>If the calling app has carrier privileges (see {@link
+ * TelephonyManager#hasCarrierPrivileges}).
+ * <li>If the calling app is the default SMS role holder.
+ * </ul>
+ *
+ * @return the number of this subscription, or an empty string if one of these requirements is
+ * not met
*/
public String getNumber() {
return mNumber;
}
/**
+ * @hide
+ */
+ public void clearNumber() {
+ mNumber = "";
+ }
+
+ /**
* @return the data roaming state for this subscription, either
* {@link SubscriptionManager#DATA_ROAMING_ENABLE} or {@link SubscriptionManager#DATA_ROAMING_DISABLE}.
*/
@@ -634,8 +687,19 @@ public class SubscriptionInfo implements Parcelable {
}
/**
- * @return the card string of the SIM card which contains the subscription. The card string is
- * the ICCID for UICCs or the EID for eUICCs.
+ * Returns the card string of the SIM card which contains the subscription.
+ *
+ * Starting with API level 30, returns the card string if the calling app has been granted the
+ * READ_PRIVILEGED_PHONE_STATE permission, has carrier privileges (see
+ * {@link TelephonyManager#hasCarrierPrivileges}), or is a device owner or profile owner that
+ * has been granted the READ_PHONE_STATE permission. The profile owner is an app that owns a
+ * managed profile on the device; for more details see <a
+ * href="https://developer.android.com/work/managed-profiles">Work profiles</a>. Profile
+ * owner access is deprecated and will be removed in a future release.
+ *
+ * @return the card string of the SIM card which contains the subscription or an empty string
+ * if these requirements are not met. The card string is the ICCID for UICCs or the EID for
+ * eUICCs.
* @hide
* //TODO rename usages in LPA: UiccSlotUtil.java, UiccSlotsManager.java, UiccSlotInfoTest.java
*/
@@ -644,6 +708,13 @@ public class SubscriptionInfo implements Parcelable {
}
/**
+ * @hide
+ */
+ public void clearCardString() {
+ this.mCardString = "";
+ }
+
+ /**
* Returns the card ID of the SIM card which contains the subscription (see
* {@link UiccCardInfo#getCardId()}.
* @return the cardId
@@ -786,20 +857,20 @@ public class SubscriptionInfo implements Parcelable {
+ " carrierId=" + mCarrierId + " displayName=" + mDisplayName
+ " carrierName=" + mCarrierName + " nameSource=" + mNameSource
+ " iconTint=" + mIconTint
- + " mNumber=" + Rlog.pii(TelephonyUtils.IS_DEBUGGABLE, mNumber)
- + " dataRoaming=" + mDataRoaming + " iconBitmap=" + mIconBitmap + " mcc " + mMcc
- + " mnc " + mMnc + "mCountryIso=" + mCountryIso + " isEmbedded " + mIsEmbedded
- + " nativeAccessRules " + Arrays.toString(mNativeAccessRules)
+ + " number=" + Rlog.pii(TelephonyUtils.IS_DEBUGGABLE, mNumber)
+ + " dataRoaming=" + mDataRoaming + " iconBitmap=" + mIconBitmap + " mcc=" + mMcc
+ + " mnc=" + mMnc + " countryIso=" + mCountryIso + " isEmbedded=" + mIsEmbedded
+ + " nativeAccessRules=" + Arrays.toString(mNativeAccessRules)
+ " cardString=" + cardStringToPrint + " cardId=" + mCardId
- + " isOpportunistic=" + mIsOpportunistic + " mGroupUUID=" + mGroupUUID
- + " mIsGroupDisabled=" + mIsGroupDisabled
+ + " isOpportunistic=" + mIsOpportunistic + " groupUUID=" + mGroupUUID
+ + " isGroupDisabled=" + mIsGroupDisabled
+ " profileClass=" + mProfileClass
+ " ehplmns=" + Arrays.toString(mEhplmns)
+ " hplmns=" + Arrays.toString(mHplmns)
+ " subscriptionType=" + mSubscriptionType
- + " mGroupOwner=" + mGroupOwner
+ + " groupOwner=" + mGroupOwner
+ " carrierConfigAccessRules=" + Arrays.toString(mCarrierConfigAccessRules)
- + " mAreUiccApplicationsEnabled=" + mAreUiccApplicationsEnabled + "}";
+ + " areUiccApplicationsEnabled=" + mAreUiccApplicationsEnabled + "}";
}
@Override
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index bcde7160c1c5..a71a965b1bdb 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -21,6 +21,7 @@ import static android.net.NetworkPolicyManager.SUBSCRIPTION_OVERRIDE_UNMETERED;
import android.Manifest;
import android.annotation.CallbackExecutor;
+import android.annotation.ColorInt;
import android.annotation.DurationMillisLong;
import android.annotation.IntDef;
import android.annotation.NonNull;
@@ -32,8 +33,8 @@ import android.annotation.SuppressAutoDoc;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.TestApi;
-import android.app.BroadcastOptions;
import android.app.PendingIntent;
+import android.app.PropertyInvalidatedCache;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.Intent;
@@ -42,7 +43,6 @@ import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.ContentObserver;
-import android.net.INetworkPolicyManager;
import android.net.NetworkCapabilities;
import android.net.NetworkPolicyManager;
import android.net.Uri;
@@ -53,7 +53,6 @@ import android.os.Looper;
import android.os.ParcelUuid;
import android.os.Process;
import android.os.RemoteException;
-import android.os.ServiceManager;
import android.provider.Telephony.SimInfo;
import android.telephony.euicc.EuiccManager;
import android.telephony.ims.ImsMmTelManager;
@@ -64,6 +63,7 @@ import com.android.internal.telephony.ISetOpportunisticDataCallback;
import com.android.internal.telephony.ISub;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.util.HandlerExecutor;
+import com.android.internal.util.FunctionalUtils;
import com.android.internal.util.Preconditions;
import com.android.telephony.Rlog;
@@ -78,7 +78,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
-import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.stream.Collectors;
@@ -132,6 +131,127 @@ public class SubscriptionManager {
@UnsupportedAppUsage
public static final Uri CONTENT_URI = SimInfo.CONTENT_URI;
+ /** @hide */
+ public static final String CACHE_KEY_DEFAULT_SUB_ID_PROPERTY =
+ "cache_key.telephony.get_default_sub_id";
+
+ /** @hide */
+ public static final String CACHE_KEY_DEFAULT_DATA_SUB_ID_PROPERTY =
+ "cache_key.telephony.get_default_data_sub_id";
+
+ /** @hide */
+ public static final String CACHE_KEY_DEFAULT_SMS_SUB_ID_PROPERTY =
+ "cache_key.telephony.get_default_sms_sub_id";
+
+ /** @hide */
+ public static final String CACHE_KEY_ACTIVE_DATA_SUB_ID_PROPERTY =
+ "cache_key.telephony.get_active_data_sub_id";
+
+ /** @hide */
+ public static final String CACHE_KEY_SLOT_INDEX_PROPERTY =
+ "cache_key.telephony.get_slot_index";
+
+ private static final int MAX_CACHE_SIZE = 4;
+
+ private static class VoidPropertyInvalidatedCache<T>
+ extends PropertyInvalidatedCache<Void, T> {
+ private final FunctionalUtils.ThrowingFunction<ISub, T> mInterfaceMethod;
+ private final String mCacheKeyProperty;
+ private final T mDefaultValue;
+
+ VoidPropertyInvalidatedCache(
+ FunctionalUtils.ThrowingFunction<ISub, T> subscriptionInterfaceMethod,
+ String cacheKeyProperty,
+ T defaultValue) {
+ super(MAX_CACHE_SIZE, cacheKeyProperty);
+ mInterfaceMethod = subscriptionInterfaceMethod;
+ mCacheKeyProperty = cacheKeyProperty;
+ mDefaultValue = defaultValue;
+ }
+
+ @Override
+ protected T recompute(Void aVoid) {
+ T result = mDefaultValue;
+
+ try {
+ ISub iSub = TelephonyManager.getSubscriptionService();
+ if (iSub != null) {
+ result = mInterfaceMethod.applyOrThrow(iSub);
+ }
+ } catch (Exception ex) {
+ Rlog.w(LOG_TAG, "Failed to recompute cache key for " + mCacheKeyProperty);
+ }
+
+ if (VDBG) logd("recomputing " + mCacheKeyProperty + ", result = " + result);
+ return result;
+ }
+ }
+
+ private static class IntegerPropertyInvalidatedCache<T>
+ extends PropertyInvalidatedCache<Integer, T> {
+ private final FunctionalUtils.ThrowingBiFunction<ISub, Integer, T> mInterfaceMethod;
+ private final String mCacheKeyProperty;
+ private final T mDefaultValue;
+
+ IntegerPropertyInvalidatedCache(
+ FunctionalUtils.ThrowingBiFunction<ISub, Integer, T> subscriptionInterfaceMethod,
+ String cacheKeyProperty,
+ T defaultValue) {
+ super(MAX_CACHE_SIZE, cacheKeyProperty);
+ mInterfaceMethod = subscriptionInterfaceMethod;
+ mCacheKeyProperty = cacheKeyProperty;
+ mDefaultValue = defaultValue;
+ }
+
+ @Override
+ protected T recompute(Integer query) {
+ T result = mDefaultValue;
+
+ try {
+ ISub iSub = TelephonyManager.getSubscriptionService();
+ if (iSub != null) {
+ result = mInterfaceMethod.applyOrThrow(iSub, query);
+ }
+ } catch (Exception ex) {
+ Rlog.w(LOG_TAG, "Failed to recompute cache key for " + mCacheKeyProperty);
+ }
+
+ if (VDBG) logd("recomputing " + mCacheKeyProperty + ", result = " + result);
+ return result;
+ }
+ }
+
+ private static VoidPropertyInvalidatedCache<Integer> sDefaultSubIdCache =
+ new VoidPropertyInvalidatedCache<>(ISub::getDefaultSubId,
+ CACHE_KEY_DEFAULT_SUB_ID_PROPERTY,
+ INVALID_SUBSCRIPTION_ID);
+
+ private static VoidPropertyInvalidatedCache<Integer> sDefaultDataSubIdCache =
+ new VoidPropertyInvalidatedCache<>(ISub::getDefaultDataSubId,
+ CACHE_KEY_DEFAULT_DATA_SUB_ID_PROPERTY,
+ INVALID_SUBSCRIPTION_ID);
+
+ private static VoidPropertyInvalidatedCache<Integer> sDefaultSmsSubIdCache =
+ new VoidPropertyInvalidatedCache<>(ISub::getDefaultSmsSubId,
+ CACHE_KEY_DEFAULT_SMS_SUB_ID_PROPERTY,
+ INVALID_SUBSCRIPTION_ID);
+
+ private static VoidPropertyInvalidatedCache<Integer> sActiveDataSubIdCache =
+ new VoidPropertyInvalidatedCache<>(ISub::getActiveDataSubscriptionId,
+ CACHE_KEY_ACTIVE_DATA_SUB_ID_PROPERTY,
+ INVALID_SUBSCRIPTION_ID);
+
+ private static IntegerPropertyInvalidatedCache<Integer> sSlotIndexCache =
+ new IntegerPropertyInvalidatedCache<>(ISub::getSlotIndex,
+ CACHE_KEY_SLOT_INDEX_PROPERTY,
+ INVALID_SIM_SLOT_INDEX);
+
+ /** Cache depends on getDefaultSubId, so we use the defaultSubId cache key */
+ private static IntegerPropertyInvalidatedCache<Integer> sPhoneIdCache =
+ new IntegerPropertyInvalidatedCache<>(ISub::getPhoneId,
+ CACHE_KEY_DEFAULT_SUB_ID_PROPERTY,
+ INVALID_PHONE_INDEX);
+
/**
* Generates a content {@link Uri} used to receive updates on simInfo change
* on the given subscriptionId
@@ -882,7 +1002,6 @@ public class SubscriptionManager {
public static final String EXTRA_SLOT_INDEX = "android.telephony.extra.SLOT_INDEX";
private final Context mContext;
- private volatile INetworkPolicyManager mNetworkPolicy;
// Cache of Resource that has been created in getResourcesForSubId. Key is a Pair containing
// the Context and subId.
@@ -986,14 +1105,6 @@ public class SubscriptionManager {
.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
}
- private INetworkPolicyManager getINetworkPolicyManager() {
- if (mNetworkPolicy == null) {
- mNetworkPolicy = INetworkPolicyManager.Stub
- .asInterface(ServiceManager.getService(Context.NETWORK_POLICY_SERVICE));
- }
- return mNetworkPolicy;
- }
-
/**
* Register for changes to the list of active {@link SubscriptionInfo} records or to the
* individual records themselves. When a change occurs the onSubscriptionsChanged method of
@@ -1177,17 +1288,16 @@ public class SubscriptionManager {
SubscriptionInfo subInfo = null;
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
subInfo = iSub.getActiveSubscriptionInfo(subId, mContext.getOpPackageName(),
- null);
+ mContext.getAttributionTag());
}
} catch (RemoteException ex) {
// ignore it
}
return subInfo;
-
}
/**
@@ -1211,10 +1321,10 @@ public class SubscriptionManager {
SubscriptionInfo result = null;
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
result = iSub.getActiveSubscriptionInfoForIccId(iccId, mContext.getOpPackageName(),
- null);
+ mContext.getAttributionTag());
}
} catch (RemoteException ex) {
// ignore it
@@ -1245,10 +1355,10 @@ public class SubscriptionManager {
SubscriptionInfo result = null;
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
result = iSub.getActiveSubscriptionInfoForSimSlotIndex(slotIndex,
- mContext.getOpPackageName(), null);
+ mContext.getOpPackageName(), mContext.getAttributionTag());
}
} catch (RemoteException ex) {
// ignore it
@@ -1269,10 +1379,10 @@ public class SubscriptionManager {
List<SubscriptionInfo> result = null;
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
result = iSub.getAllSubInfoList(mContext.getOpPackageName(),
- null);
+ mContext.getAttributionTag());
}
} catch (RemoteException ex) {
// ignore it
@@ -1336,8 +1446,13 @@ public class SubscriptionManager {
* both active and hidden SubscriptionInfos.
*
*/
- public @Nullable List<SubscriptionInfo> getActiveAndHiddenSubscriptionInfoList() {
- return getActiveSubscriptionInfoList(/* userVisibleonly */false);
+ public @NonNull List<SubscriptionInfo> getCompleteActiveSubscriptionInfoList() {
+ List<SubscriptionInfo> completeList = getActiveSubscriptionInfoList(
+ /* userVisibleonly */false);
+ if (completeList == null) {
+ completeList = new ArrayList<>();
+ }
+ return completeList;
}
/**
@@ -1350,10 +1465,10 @@ public class SubscriptionManager {
List<SubscriptionInfo> activeList = null;
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
activeList = iSub.getActiveSubscriptionInfoList(mContext.getOpPackageName(),
- null);
+ mContext.getAttributionTag());
}
} catch (RemoteException ex) {
// ignore it
@@ -1401,10 +1516,10 @@ public class SubscriptionManager {
List<SubscriptionInfo> result = null;
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
result = iSub.getAvailableSubscriptionInfoList(mContext.getOpPackageName(),
- null);
+ mContext.getAttributionTag());
}
} catch (RemoteException ex) {
// ignore it
@@ -1440,7 +1555,7 @@ public class SubscriptionManager {
List<SubscriptionInfo> result = null;
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
result = iSub.getAccessibleSubscriptionInfoList(mContext.getOpPackageName());
}
@@ -1469,7 +1584,7 @@ public class SubscriptionManager {
public void requestEmbeddedSubscriptionInfoListRefresh() {
int cardId = TelephonyManager.from(mContext).getCardIdForDefaultEuicc();
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
iSub.requestEmbeddedSubscriptionInfoListRefresh(cardId);
}
@@ -1498,7 +1613,7 @@ public class SubscriptionManager {
@SystemApi
public void requestEmbeddedSubscriptionInfoListRefresh(int cardId) {
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
iSub.requestEmbeddedSubscriptionInfoListRefresh(cardId);
}
@@ -1519,10 +1634,10 @@ public class SubscriptionManager {
int result = 0;
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
result = iSub.getAllSubInfoCount(mContext.getOpPackageName(),
- null);
+ mContext.getAttributionTag());
}
} catch (RemoteException ex) {
// ignore it
@@ -1548,10 +1663,10 @@ public class SubscriptionManager {
int result = 0;
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
result = iSub.getActiveSubInfoCount(mContext.getOpPackageName(),
- null);
+ mContext.getAttributionTag());
}
} catch (RemoteException ex) {
// ignore it
@@ -1569,7 +1684,7 @@ public class SubscriptionManager {
int result = 0;
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
result = iSub.getActiveSubInfoCountMax();
}
@@ -1626,7 +1741,7 @@ public class SubscriptionManager {
}
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub == null) {
Log.e(LOG_TAG, "[addSubscriptionInfoRecord]- ISub service is null");
return;
@@ -1660,7 +1775,7 @@ public class SubscriptionManager {
}
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub == null) {
Log.e(LOG_TAG, "[removeSubscriptionInfoRecord]- ISub service is null");
return;
@@ -1677,14 +1792,14 @@ public class SubscriptionManager {
}
/**
- * Set SIM icon tint color by simInfo index
+ * Set SIM icon tint color for subscription ID
* @param tint the RGB value of icon tint color of the SIM
- * @param subId the unique SubInfoRecord index in database
+ * @param subId the unique Subscritpion ID in database
* @return the number of records updated
* @hide
*/
- @UnsupportedAppUsage
- public int setIconTint(int tint, int subId) {
+ @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE)
+ public int setIconTint(@ColorInt int tint, int subId) {
if (VDBG) logd("[setIconTint]+ tint:" + tint + " subId:" + subId);
return setSubscriptionPropertyHelper(subId, "setIconTint",
(iSub)-> iSub.setIconTint(tint, subId)
@@ -1692,15 +1807,16 @@ public class SubscriptionManager {
}
/**
- * Set display name by simInfo index with name source
+ * Set the display name for a subscription ID
* @param displayName the display name of SIM card
- * @param subId the unique SubscriptionInfo index in database
+ * @param subId the unique Subscritpion ID in database
* @param nameSource SIM display name source
* @return the number of records updated or < 0 if invalid subId
* @hide
*/
- @UnsupportedAppUsage
- public int setDisplayName(String displayName, int subId, @SimDisplayNameSource int nameSource) {
+ @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE)
+ public int setDisplayName(@Nullable String displayName, int subId,
+ @SimDisplayNameSource int nameSource) {
if (VDBG) {
logd("[setDisplayName]+ displayName:" + displayName + " subId:" + subId
+ " nameSource:" + nameSource);
@@ -1751,25 +1867,7 @@ public class SubscriptionManager {
* subscriptionId doesn't have an associated slot index.
*/
public static int getSlotIndex(int subscriptionId) {
- if (!isValidSubscriptionId(subscriptionId)) {
- if (DBG) {
- logd("[getSlotIndex]- supplied subscriptionId is invalid.");
- }
- }
-
- int result = INVALID_SIM_SLOT_INDEX;
-
- try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
- if (iSub != null) {
- result = iSub.getSlotIndex(subscriptionId);
- }
- } catch (RemoteException ex) {
- // ignore it
- }
-
- return result;
-
+ return sSlotIndexCache.query(subscriptionId);
}
/**
@@ -1794,7 +1892,7 @@ public class SubscriptionManager {
int[] subId = null;
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
subId = iSub.getSubId(slotIndex);
}
@@ -1808,27 +1906,7 @@ public class SubscriptionManager {
/** @hide */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
public static int getPhoneId(int subId) {
- if (!isValidSubscriptionId(subId)) {
- if (DBG) {
- logd("[getPhoneId]- fail");
- }
- return INVALID_PHONE_INDEX;
- }
-
- int result = INVALID_PHONE_INDEX;
-
- try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
- if (iSub != null) {
- result = iSub.getPhoneId(subId);
- }
- } catch (RemoteException ex) {
- // ignore it
- }
-
- if (VDBG) logd("[getPhoneId]- phoneId=" + result);
- return result;
-
+ return sPhoneIdCache.query(subId);
}
private static void logd(String msg) {
@@ -1849,19 +1927,7 @@ public class SubscriptionManager {
* @return the "system" default subscription id.
*/
public static int getDefaultSubscriptionId() {
- int subId = INVALID_SUBSCRIPTION_ID;
-
- try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
- if (iSub != null) {
- subId = iSub.getDefaultSubId();
- }
- } catch (RemoteException ex) {
- // ignore it
- }
-
- if (VDBG) logd("getDefaultSubId=" + subId);
- return subId;
+ return sDefaultSubIdCache.query(null);
}
/**
@@ -1875,7 +1941,7 @@ public class SubscriptionManager {
int subId = INVALID_SUBSCRIPTION_ID;
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
subId = iSub.getDefaultVoiceSubId();
}
@@ -1905,7 +1971,7 @@ public class SubscriptionManager {
public void setDefaultVoiceSubscriptionId(int subscriptionId) {
if (VDBG) logd("setDefaultVoiceSubId sub id = " + subscriptionId);
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
iSub.setDefaultVoiceSubId(subscriptionId);
}
@@ -1950,19 +2016,7 @@ public class SubscriptionManager {
* @return the default SMS subscription Id.
*/
public static int getDefaultSmsSubscriptionId() {
- int subId = INVALID_SUBSCRIPTION_ID;
-
- try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
- if (iSub != null) {
- subId = iSub.getDefaultSmsSubId();
- }
- } catch (RemoteException ex) {
- // ignore it
- }
-
- if (VDBG) logd("getDefaultSmsSubscriptionId, sub id = " + subId);
- return subId;
+ return sDefaultSmsSubIdCache.query(null);
}
/**
@@ -1979,7 +2033,7 @@ public class SubscriptionManager {
public void setDefaultSmsSubId(int subscriptionId) {
if (VDBG) logd("setDefaultSmsSubId sub id = " + subscriptionId);
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
iSub.setDefaultSmsSubId(subscriptionId);
}
@@ -2014,19 +2068,7 @@ public class SubscriptionManager {
* @return the default data subscription Id.
*/
public static int getDefaultDataSubscriptionId() {
- int subId = INVALID_SUBSCRIPTION_ID;
-
- try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
- if (iSub != null) {
- subId = iSub.getDefaultDataSubId();
- }
- } catch (RemoteException ex) {
- // ignore it
- }
-
- if (VDBG) logd("getDefaultDataSubscriptionId, sub id = " + subId);
- return subId;
+ return sDefaultDataSubIdCache.query(null);
}
/**
@@ -2043,7 +2085,7 @@ public class SubscriptionManager {
public void setDefaultDataSubId(int subscriptionId) {
if (VDBG) logd("setDataSubscription sub id = " + subscriptionId);
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
iSub.setDefaultDataSubId(subscriptionId);
}
@@ -2074,7 +2116,7 @@ public class SubscriptionManager {
/** @hide */
public void clearSubscriptionInfo() {
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
iSub.clearSubInfo();
}
@@ -2212,7 +2254,7 @@ public class SubscriptionManager {
*/
public @NonNull int[] getActiveSubscriptionIdList(boolean visibleOnly) {
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
int[] subId = iSub.getActiveSubIdList(visibleOnly);
if (subId != null) return subId;
@@ -2263,7 +2305,7 @@ public class SubscriptionManager {
int simState = TelephonyManager.SIM_STATE_UNKNOWN;
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
simState = iSub.getSimStateForSlotIndex(slotIndex);
}
@@ -2282,7 +2324,7 @@ public class SubscriptionManager {
*/
public static void setSubscriptionProperty(int subId, String propKey, String propValue) {
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
iSub.setSubscriptionProperty(subId, propKey, propValue);
}
@@ -2302,10 +2344,10 @@ public class SubscriptionManager {
Context context) {
String resultValue = null;
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
resultValue = iSub.getSubscriptionProperty(subId, propKey,
- context.getOpPackageName(), null);
+ context.getOpPackageName(), context.getAttributionTag());
}
} catch (RemoteException ex) {
// ignore it
@@ -2466,10 +2508,10 @@ public class SubscriptionManager {
@UnsupportedAppUsage
public boolean isActiveSubId(int subId) {
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
return iSub.isActiveSubId(subId, mContext.getOpPackageName(),
- null);
+ mContext.getAttributionTag());
}
} catch (RemoteException ex) {
}
@@ -2526,15 +2568,6 @@ public class SubscriptionManager {
plans.toArray(new SubscriptionPlan[plans.size()]), mContext.getOpPackageName());
}
- /** @hide */
- private String getSubscriptionPlansOwner(int subId) {
- try {
- return getINetworkPolicyManager().getSubscriptionPlansOwner(subId);
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
- }
-
/**
* Temporarily override the billing relationship plan between a carrier and
* a specific subscriber to be considered unmetered. This will be reflected
@@ -2598,89 +2631,6 @@ public class SubscriptionManager {
}
/**
- * Create an {@link Intent} that can be launched towards the carrier app
- * that is currently defining the billing relationship plan through
- * {@link #setSubscriptionPlans(int, List)}.
- *
- * @return ready to launch Intent targeted towards the carrier app, or
- * {@code null} if no carrier app is defined, or if the defined
- * carrier app provides no management activity.
- * @hide
- */
- public @Nullable Intent createManageSubscriptionIntent(int subId) {
- // Bail if no owner
- final String owner = getSubscriptionPlansOwner(subId);
- if (owner == null) return null;
-
- // Bail if no plans
- final List<SubscriptionPlan> plans = getSubscriptionPlans(subId);
- if (plans.isEmpty()) return null;
-
- final Intent intent = new Intent(ACTION_MANAGE_SUBSCRIPTION_PLANS);
- intent.setPackage(owner);
- intent.putExtra(EXTRA_SUBSCRIPTION_INDEX, subId);
-
- // Bail if not implemented
- if (mContext.getPackageManager().queryIntentActivities(intent,
- PackageManager.MATCH_DEFAULT_ONLY).isEmpty()) {
- return null;
- }
-
- return intent;
- }
-
- /** @hide */
- private @Nullable Intent createRefreshSubscriptionIntent(int subId) {
- // Bail if no owner
- final String owner = getSubscriptionPlansOwner(subId);
- if (owner == null) return null;
-
- // Bail if no plans
- final List<SubscriptionPlan> plans = getSubscriptionPlans(subId);
- if (plans.isEmpty()) return null;
-
- final Intent intent = new Intent(ACTION_REFRESH_SUBSCRIPTION_PLANS);
- intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
- intent.setPackage(owner);
- intent.putExtra(EXTRA_SUBSCRIPTION_INDEX, subId);
-
- // Bail if not implemented
- if (mContext.getPackageManager().queryBroadcastReceivers(intent, 0).isEmpty()) {
- return null;
- }
-
- return intent;
- }
-
- /**
- * Check if there is a carrier app that is currently defining the billing
- * relationship plan through {@link #setSubscriptionPlans(int, List)} that
- * supports refreshing of subscription plans.
- *
- * @hide
- */
- public boolean isSubscriptionPlansRefreshSupported(int subId) {
- return createRefreshSubscriptionIntent(subId) != null;
- }
-
- /**
- * Request that the carrier app that is currently defining the billing
- * relationship plan through {@link #setSubscriptionPlans(int, List)}
- * refresh its subscription plans.
- * <p>
- * If the app is able to successfully update the plans, you'll expect to
- * receive the {@link #ACTION_SUBSCRIPTION_PLANS_CHANGED} broadcast.
- *
- * @hide
- */
- public void requestSubscriptionPlansRefresh(int subId) {
- final Intent intent = createRefreshSubscriptionIntent(subId);
- final BroadcastOptions options = BroadcastOptions.makeBasic();
- options.setTemporaryAppWhitelistDuration(TimeUnit.MINUTES.toMillis(1));
- mContext.sendBroadcast(intent, null, options.toBundle());
- }
-
- /**
* Checks whether the app with the given context is authorized to manage the given subscription
* according to its metadata.
*
@@ -2754,7 +2704,7 @@ public class SubscriptionManager {
@TelephonyManager.SetOpportunisticSubscriptionResult Consumer<Integer> callback) {
if (VDBG) logd("[setPreferredDataSubscriptionId]+ subId:" + subId);
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub == null) return;
ISetOpportunisticDataCallback callbackStub = new ISetOpportunisticDataCallback.Stub() {
@@ -2797,7 +2747,7 @@ public class SubscriptionManager {
public int getPreferredDataSubscriptionId() {
int preferredSubId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID;
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
preferredSubId = iSub.getPreferredDataSubscriptionId();
}
@@ -2824,13 +2774,14 @@ public class SubscriptionManager {
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
public @NonNull List<SubscriptionInfo> getOpportunisticSubscriptions() {
String contextPkg = mContext != null ? mContext.getOpPackageName() : "<unknown>";
- String contextFeature = null;
+ String contextAttributionTag = mContext != null ? mContext.getAttributionTag() : null;
List<SubscriptionInfo> subInfoList = null;
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
- subInfoList = iSub.getOpportunisticSubscriptions(contextPkg, contextFeature);
+ subInfoList = iSub.getOpportunisticSubscriptions(contextPkg,
+ contextAttributionTag);
}
} catch (RemoteException ex) {
// ignore it
@@ -2929,7 +2880,7 @@ public class SubscriptionManager {
ParcelUuid groupUuid = null;
int[] subIdArray = subIdList.stream().mapToInt(i->i).toArray();
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
groupUuid = iSub.createSubscriptionGroup(subIdArray, pkgForDebug);
} else {
@@ -2979,7 +2930,7 @@ public class SubscriptionManager {
int[] subIdArray = subIdList.stream().mapToInt(i->i).toArray();
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
iSub.addSubscriptionsIntoGroup(subIdArray, groupUuid, pkgForDebug);
} else {
@@ -3031,7 +2982,7 @@ public class SubscriptionManager {
int[] subIdArray = subIdList.stream().mapToInt(i->i).toArray();
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
iSub.removeSubscriptionsFromGroup(subIdArray, groupUuid, pkgForDebug);
} else {
@@ -3069,16 +3020,17 @@ public class SubscriptionManager {
public @NonNull List<SubscriptionInfo> getSubscriptionsInGroup(@NonNull ParcelUuid groupUuid) {
Preconditions.checkNotNull(groupUuid, "groupUuid can't be null");
String contextPkg = mContext != null ? mContext.getOpPackageName() : "<unknown>";
- String contextFeature = null;
+ String contextAttributionTag = mContext != null ? mContext.getAttributionTag() : null;
if (VDBG) {
logd("[getSubscriptionsInGroup]+ groupUuid:" + groupUuid);
}
List<SubscriptionInfo> result = null;
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
- result = iSub.getSubscriptionsInGroup(groupUuid, contextPkg, contextFeature);
+ result = iSub.getSubscriptionsInGroup(groupUuid, contextPkg,
+ contextAttributionTag);
} else {
if (!isSystemProcess()) {
throw new IllegalStateException("telephony service is null.");
@@ -3189,7 +3141,7 @@ public class SubscriptionManager {
logd("setSubscriptionActivated subId= " + subscriptionId + " enable " + enable);
}
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
return iSub.setSubscriptionEnabled(enable, subscriptionId);
}
@@ -3219,7 +3171,11 @@ public class SubscriptionManager {
logd("setUiccApplicationsEnabled subId= " + subscriptionId + " enable " + enabled);
}
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = ISub.Stub.asInterface(
+ TelephonyFrameworkInitializer
+ .getTelephonyServiceManager()
+ .getSubscriptionServiceRegisterer()
+ .get());
if (iSub != null) {
iSub.setUiccApplicationsEnabled(enabled, subscriptionId);
}
@@ -3249,7 +3205,11 @@ public class SubscriptionManager {
logd("canDisablePhysicalSubscription");
}
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = ISub.Stub.asInterface(
+ TelephonyFrameworkInitializer
+ .getTelephonyServiceManager()
+ .getSubscriptionServiceRegisterer()
+ .get());
if (iSub != null) {
return iSub.canDisablePhysicalSubscription();
}
@@ -3270,7 +3230,7 @@ public class SubscriptionManager {
@RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
public boolean isSubscriptionEnabled(int subscriptionId) {
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
return iSub.isSubscriptionEnabled(subscriptionId);
}
@@ -3293,7 +3253,7 @@ public class SubscriptionManager {
int subId = INVALID_SUBSCRIPTION_ID;
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
subId = iSub.getEnabledSubscriptionId(slotIndex);
}
@@ -3319,7 +3279,7 @@ public class SubscriptionManager {
int result = 0;
try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
+ ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
result = helper.callMethod(iSub);
}
@@ -3341,14 +3301,7 @@ public class SubscriptionManager {
* SubscriptionManager.INVALID_SUBSCRIPTION_ID if not.
*/
public static int getActiveDataSubscriptionId() {
- try {
- ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
- if (iSub != null) {
- return iSub.getActiveDataSubscriptionId();
- }
- } catch (RemoteException ex) {
- }
- return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+ return sActiveDataSubIdCache.query(null);
}
/**
@@ -3365,4 +3318,56 @@ public class SubscriptionManager {
intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, subId);
intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
}
+
+ /** @hide */
+ public static void invalidateDefaultSubIdCaches() {
+ PropertyInvalidatedCache.invalidateCache(CACHE_KEY_DEFAULT_SUB_ID_PROPERTY);
+ }
+
+ /** @hide */
+ public static void invalidateDefaultDataSubIdCaches() {
+ PropertyInvalidatedCache.invalidateCache(CACHE_KEY_DEFAULT_DATA_SUB_ID_PROPERTY);
+ }
+
+ /** @hide */
+ public static void invalidateDefaultSmsSubIdCaches() {
+ PropertyInvalidatedCache.invalidateCache(CACHE_KEY_DEFAULT_SMS_SUB_ID_PROPERTY);
+ }
+
+ /** @hide */
+ public static void invalidateActiveDataSubIdCaches() {
+ PropertyInvalidatedCache.invalidateCache(CACHE_KEY_ACTIVE_DATA_SUB_ID_PROPERTY);
+ }
+
+ /** @hide */
+ public static void invalidateSlotIndexCaches() {
+ PropertyInvalidatedCache.invalidateCache(CACHE_KEY_SLOT_INDEX_PROPERTY);
+ }
+
+ /**
+ * Allows a test process to disable client-side caching operations.
+ *
+ * @hide
+ */
+ public static void disableCaching() {
+ sDefaultSubIdCache.disableLocal();
+ sDefaultDataSubIdCache.disableLocal();
+ sActiveDataSubIdCache.disableLocal();
+ sDefaultSmsSubIdCache.disableLocal();
+ sSlotIndexCache.disableLocal();
+ sPhoneIdCache.disableLocal();
+ }
+
+ /**
+ * Clears all process-local binder caches.
+ *
+ * @hide */
+ public static void clearCaches() {
+ sDefaultSubIdCache.clear();
+ sDefaultDataSubIdCache.clear();
+ sActiveDataSubIdCache.clear();
+ sDefaultSmsSubIdCache.clear();
+ sSlotIndexCache.clear();
+ sPhoneIdCache.clear();
+ }
}
diff --git a/telephony/java/android/telephony/TelephonyFrameworkInitializer.java b/telephony/java/android/telephony/TelephonyFrameworkInitializer.java
new file mode 100644
index 000000000000..c9540fb5f467
--- /dev/null
+++ b/telephony/java/android/telephony/TelephonyFrameworkInitializer.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.telephony;
+
+import android.annotation.NonNull;
+import android.app.SystemServiceRegistry;
+import android.content.Context;
+import android.os.TelephonyServiceManager;
+import android.telephony.euicc.EuiccCardManager;
+import android.telephony.euicc.EuiccManager;
+import android.telephony.ims.ImsManager;
+
+import com.android.internal.util.Preconditions;
+
+
+/**
+ * Class for performing registration for all telephony services.
+ *
+ * @hide
+ */
+public class TelephonyFrameworkInitializer {
+
+ private TelephonyFrameworkInitializer() {
+ }
+
+ private static volatile TelephonyServiceManager sTelephonyServiceManager;
+
+ /**
+ * Sets an instance of {@link TelephonyServiceManager} that allows
+ * the telephony mainline module to register/obtain telephony binder services. This is called
+ * by the platform during the system initialization.
+ *
+ * @param telephonyServiceManager instance of {@link TelephonyServiceManager} that allows
+ * the telephony mainline module to register/obtain telephony binder services.
+ */
+ public static void setTelephonyServiceManager(
+ @NonNull TelephonyServiceManager telephonyServiceManager) {
+ Preconditions.checkState(sTelephonyServiceManager == null,
+ "setTelephonyServiceManager called twice!");
+ sTelephonyServiceManager = Preconditions.checkNotNull(telephonyServiceManager);
+ }
+
+ /**
+ * Called by {@link SystemServiceRegistry}'s static initializer and registers all telephony
+ * services to {@link Context}, so that {@link Context#getSystemService} can return them.
+ *
+ * @throws IllegalStateException if this is called from anywhere besides
+ * {@link SystemServiceRegistry}
+ */
+ public static void registerServiceWrappers() {
+ SystemServiceRegistry.registerContextAwareService(
+ Context.TELEPHONY_SERVICE,
+ TelephonyManager.class,
+ context -> new TelephonyManager(context)
+ );
+ SystemServiceRegistry.registerContextAwareService(
+ Context.TELEPHONY_SUBSCRIPTION_SERVICE,
+ SubscriptionManager.class,
+ context -> new SubscriptionManager(context)
+ );
+ SystemServiceRegistry.registerContextAwareService(
+ Context.CARRIER_CONFIG_SERVICE,
+ CarrierConfigManager.class,
+ context -> new CarrierConfigManager(context)
+ );
+ SystemServiceRegistry.registerContextAwareService(
+ Context.EUICC_SERVICE,
+ EuiccManager.class,
+ context -> new EuiccManager(context)
+ );
+ SystemServiceRegistry.registerContextAwareService(
+ Context.EUICC_CARD_SERVICE,
+ EuiccCardManager.class,
+ context -> new EuiccCardManager(context)
+ );
+ SystemServiceRegistry.registerContextAwareService(
+ Context.TELEPHONY_IMS_SERVICE,
+ ImsManager.class,
+ context -> new ImsManager(context)
+ );
+ }
+
+ /** @hide */
+ public static TelephonyServiceManager getTelephonyServiceManager() {
+ return sTelephonyServiceManager;
+ }
+}
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index c13d5d71baf2..4b5399e74abf 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -38,6 +38,7 @@ import android.annotation.SystemService;
import android.annotation.TestApi;
import android.annotation.WorkerThread;
import android.app.PendingIntent;
+import android.app.role.RoleManager;
import android.compat.Compatibility;
import android.compat.annotation.ChangeId;
import android.compat.annotation.EnabledAfter;
@@ -53,12 +54,12 @@ import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
+import android.os.IBinder;
import android.os.ParcelFileDescriptor;
import android.os.PersistableBundle;
import android.os.Process;
import android.os.RemoteException;
import android.os.ResultReceiver;
-import android.os.ServiceManager;
import android.os.SystemProperties;
import android.os.WorkSource;
import android.provider.Settings.SettingNotFoundException;
@@ -94,6 +95,7 @@ import android.util.Log;
import android.util.Pair;
import com.android.ims.internal.IImsServiceFeatureCallback;
+import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.CellNetworkScanResult;
import com.android.internal.telephony.IBooleanConsumer;
@@ -101,8 +103,9 @@ import com.android.internal.telephony.INumberVerificationCallback;
import com.android.internal.telephony.IOns;
import com.android.internal.telephony.IPhoneSubInfo;
import com.android.internal.telephony.ISetOpportunisticDataCallback;
+import com.android.internal.telephony.ISms;
+import com.android.internal.telephony.ISub;
import com.android.internal.telephony.ITelephony;
-import com.android.internal.telephony.ITelephonyRegistry;
import com.android.internal.telephony.IUpdateAvailableNetworksCallback;
import com.android.internal.telephony.OperatorInfo;
import com.android.internal.telephony.PhoneConstants;
@@ -141,6 +144,10 @@ import java.util.function.Consumer;
* information unless it has the appropriate permissions declared in
* its manifest file. Where permissions apply, they are noted in the
* the methods through which you access the protected information.
+ *
+ * <p>TelephonyManager is intended for use on devices that implement
+ * {@link android.content.pm.PackageManager#FEATURE_TELEPHONY FEATURE_TELEPHONY}. On devices
+ * that do not implement this feature, the behavior is not reliable.
*/
@SystemService(Context.TELEPHONY_SERVICE)
public class TelephonyManager {
@@ -152,7 +159,7 @@ public class TelephonyManager {
*/
@ChangeId
@EnabledAfter(targetSdkVersion = Build.VERSION_CODES.Q)
- public static final long CALLBACK_ON_MORE_ERROR_CODE_CHANGE = 130595455L;
+ private static final long CALLBACK_ON_MORE_ERROR_CODE_CHANGE = 130595455L;
/**
* The key to use when placing the result of {@link #requestModemActivityInfo(ResultReceiver)}
@@ -292,6 +299,21 @@ public class TelephonyManager {
private SubscriptionManager mSubscriptionManager;
private TelephonyScanManager mTelephonyScanManager;
+ /** Cached service handles, cleared by resetServiceHandles() at death */
+ private static final Object sCacheLock = new Object();
+
+ /** @hide */
+ private static boolean sServiceHandleCacheEnabled = true;
+
+ @GuardedBy("sCacheLock")
+ private static IPhoneSubInfo sIPhoneSubInfo;
+ @GuardedBy("sCacheLock")
+ private static ISub sISub;
+ @GuardedBy("sCacheLock")
+ private static ISms sISms;
+ @GuardedBy("sCacheLock")
+ private static final DeathRecipient sServiceDeath = new DeathRecipient();
+
/** Enum indicating multisim variants
* DSDS - Dual SIM Dual Standby
* DSDA - Dual SIM Dual Active
@@ -323,7 +345,11 @@ public class TelephonyManager {
mSubId = subId;
Context appContext = context.getApplicationContext();
if (appContext != null) {
- mContext = appContext;
+ if (Objects.equals(context.getAttributionTag(), appContext.getAttributionTag())) {
+ mContext = appContext;
+ } else {
+ mContext = appContext.createAttributionContext(context.getAttributionTag());
+ }
} else {
mContext = context;
}
@@ -367,7 +393,13 @@ public class TelephonyManager {
}
}
- private String getFeatureId() {
+ private String getAttributionTag() {
+ // For legacy reasons the TelephonyManager has API for getting
+ // a static instance with no context set preventing us from
+ // getting the attribution tag.
+ if (mContext != null) {
+ return mContext.getAttributionTag();
+ }
return null;
}
@@ -1519,6 +1551,7 @@ public class TelephonyManager {
* @hide
*/
@SystemApi
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
@SuppressLint("ActionValue")
public static final String ACTION_EMERGENCY_CALLBACK_MODE_CHANGED =
"android.intent.action.EMERGENCY_CALLBACK_MODE_CHANGED";
@@ -1547,7 +1580,6 @@ public class TelephonyManager {
* <p class="note">This is a protected intent that can only be sent by the system.</p>
* @hide
*/
- @SystemApi
@SuppressLint("ActionValue")
public static final String ACTION_CARRIER_SIGNAL_REDIRECTED =
"com.android.internal.telephony.CARRIER_SIGNAL_REDIRECTED";
@@ -1565,7 +1597,6 @@ public class TelephonyManager {
* <p class="note">This is a protected intent that can only be sent by the system. </p>
* @hide
*/
- @SystemApi
@SuppressLint("ActionValue")
public static final String ACTION_CARRIER_SIGNAL_REQUEST_NETWORK_FAILED =
"com.android.internal.telephony.CARRIER_SIGNAL_REQUEST_NETWORK_FAILED";
@@ -1588,7 +1619,6 @@ public class TelephonyManager {
* <p class="note">This is a protected intent that can only be sent by the system. </p>
* @hide
*/
- @SystemApi
@SuppressLint("ActionValue")
public static final String ACTION_CARRIER_SIGNAL_PCO_VALUE =
"com.android.internal.telephony.CARRIER_SIGNAL_PCO_VALUE";
@@ -1606,7 +1636,6 @@ public class TelephonyManager {
* <p class="note">This is a protected intent that can only be sent by the system. </p>
* @hide
*/
- @SystemApi
@SuppressLint("ActionValue")
public static final String ACTION_CARRIER_SIGNAL_DEFAULT_NETWORK_AVAILABLE =
"com.android.internal.telephony.CARRIER_SIGNAL_DEFAULT_NETWORK_AVAILABLE";
@@ -1621,7 +1650,6 @@ public class TelephonyManager {
* <p class="note">This is a protected intent that can only be sent by the system.</p>
* @hide
*/
- @SystemApi
@SuppressLint("ActionValue")
public static final String ACTION_CARRIER_SIGNAL_RESET =
"com.android.internal.telephony.CARRIER_SIGNAL_RESET";
@@ -1631,7 +1659,6 @@ public class TelephonyManager {
* An string extra of redirected url upon {@link #ACTION_CARRIER_SIGNAL_REDIRECTED}.
* @hide
*/
- @SystemApi
@SuppressLint("ActionValue")
public static final String EXTRA_REDIRECTION_URL = "redirectionUrl";
@@ -1640,7 +1667,6 @@ public class TelephonyManager {
* Check {@link DataFailCause} for all possible values.
* @hide
*/
- @SystemApi
@SuppressLint("ActionValue")
public static final String EXTRA_ERROR_CODE = "errorCode";
@@ -1654,7 +1680,6 @@ public class TelephonyManager {
*
* @hide
*/
- @SystemApi
@Deprecated
@SuppressLint("ActionValue")
public static final String EXTRA_APN_TYPE = "apnType";
@@ -1667,7 +1692,6 @@ public class TelephonyManager {
* Check {@link ApnSetting} TYPE_* for its values.
* @hide
*/
- @SystemApi
@SuppressLint("ActionValue")
public static final String EXTRA_APN_TYPE_INT = "apnTypeInt";
@@ -1679,7 +1703,6 @@ public class TelephonyManager {
*
* @hide
*/
- @SystemApi
@Deprecated
@SuppressLint("ActionValue")
public static final String EXTRA_APN_PROTOCOL = "apnProto";
@@ -1690,7 +1713,6 @@ public class TelephonyManager {
* Check {@link ApnSetting} PROTOCOL_* for its values.
* @hide
*/
- @SystemApi
@SuppressLint("ActionValue")
public static final String EXTRA_APN_PROTOCOL_INT = "apnProtoInt";
@@ -1699,7 +1721,6 @@ public class TelephonyManager {
* {@link #ACTION_CARRIER_SIGNAL_PCO_VALUE} broadcasts.
* @hide
*/
- @SystemApi
@SuppressLint("ActionValue")
public static final String EXTRA_PCO_ID = "pcoId";
@@ -1708,7 +1729,6 @@ public class TelephonyManager {
* {@link #ACTION_CARRIER_SIGNAL_PCO_VALUE} broadcasts.
* @hide
*/
- @SystemApi
@SuppressLint("ActionValue")
public static final String EXTRA_PCO_VALUE = "pcoValue";
@@ -1717,7 +1737,6 @@ public class TelephonyManager {
* {@link #ACTION_CARRIER_SIGNAL_DEFAULT_NETWORK_AVAILABLE} broadcasts.
* @hide
*/
- @SystemApi
@SuppressLint("ActionValue")
public static final String EXTRA_DEFAULT_NETWORK_AVAILABLE = "defaultNetworkAvailable";
@@ -1740,6 +1759,7 @@ public class TelephonyManager {
* @hide
*/
@SystemApi
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
@SuppressLint("ActionValue")
public static final String ACTION_EMERGENCY_CALL_STATE_CHANGED =
"android.intent.action.EMERGENCY_CALL_STATE_CHANGED";
@@ -1755,6 +1775,62 @@ public class TelephonyManager {
public static final String EXTRA_PHONE_IN_EMERGENCY_CALL =
"android.telephony.extra.PHONE_IN_EMERGENCY_CALL";
+ /**
+ * <p>Broadcast Action: It indicates the Emergency callback mode blocks datacall/sms
+ * <p class="note">.
+ * This is to pop up a notice to show user that the phone is in emergency callback mode
+ * and data calls and outgoing sms are blocked.
+ *
+ * <p class="note">This is a protected intent that can only be sent by the system.
+ *
+ * @hide
+ */
+ @SystemApi
+ public static final String ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS =
+ "android.telephony.action.SHOW_NOTICE_ECM_BLOCK_OTHERS";
+
+ /**
+ * Broadcast Action: The default data subscription has changed in a multi-SIM device.
+ * This has the following extra values:</p>
+ * <ul>
+ * <li><em>subscription</em> - A int, the current data default subscription.</li>
+ * </ul>
+ *
+ * @hide
+ */
+ @SystemApi
+ @SuppressLint("ActionValue")
+ public static final String ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED =
+ "android.intent.action.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED";
+
+ /**
+ * Broadcast Action: The default voice subscription has changed in a mult-SIm device.
+ * This has the following extra values:</p>
+ * <ul>
+ * <li><em>subscription</em> - A int, the current voice default subscription.</li>
+ * </ul>
+ *
+ * @hide
+ */
+ @SystemApi
+ @SuppressLint("ActionValue")
+ public static final String ACTION_DEFAULT_VOICE_SUBSCRIPTION_CHANGED =
+ "android.intent.action.ACTION_DEFAULT_VOICE_SUBSCRIPTION_CHANGED";
+
+ /**
+ * Broadcast Action: This triggers a client initiated OMA-DM session to the OMA server.
+ * <p class="note">
+ * Open Mobile Alliance (OMA) Device Management (DM).
+ *
+ * This intent is used by the system components to trigger OMA-DM
+ *
+ * @hide
+ */
+ @SystemApi
+ @SuppressLint("ActionValue")
+ public static final String ACTION_REQUEST_OMADM_CONFIGURATION_UPDATE =
+ "com.android.omadm.service.CONFIGURATION_UPDATE";
+
//
//
// Device Info
@@ -1794,7 +1870,7 @@ public class TelephonyManager {
try {
return telephony.getDeviceSoftwareVersionForSlot(slotIndex, getOpPackageName(),
- getFeatureId());
+ getAttributionTag());
} catch (RemoteException ex) {
return null;
} catch (NullPointerException ex) {
@@ -1806,12 +1882,23 @@ public class TelephonyManager {
* Returns the unique device ID, for example, the IMEI for GSM and the MEID
* or ESN for CDMA phones. Return null if device ID is not available.
*
- * <p>Requires Permission: READ_PRIVILEGED_PHONE_STATE, for the calling app to be the device or
- * profile owner and have the READ_PHONE_STATE permission, or that the calling app has carrier
- * privileges (see {@link #hasCarrierPrivileges}) on any active subscription. The profile owner
- * is an app that owns a managed profile on the device; for more details see <a
- * href="https://developer.android.com/work/managed-profiles">Work profiles</a>. Profile owner
- * access is deprecated and will be removed in a future release.
+ * <p>Starting with API level 29, persistent device identifiers are guarded behind additional
+ * restrictions, and apps are recommended to use resettable identifiers (see <a
+ * href="c"> Best practices for unique identifiers</a>). This method can be invoked if one of
+ * the following requirements is met:
+ * <ul>
+ * <li>If the calling app has been granted the READ_PRIVILEGED_PHONE_STATE permission; this
+ * is a privileged permission that can only be granted to apps preloaded on the device.
+ * <li>If the calling app is the device or profile owner and has been granted the
+ * {@link Manifest.permission#READ_PHONE_STATE} permission. The profile owner is an app that
+ * owns a managed profile on the device; for more details see <a
+ * href="https://developer.android.com/work/managed-profiles">Work profiles</a>.
+ * Profile owner access is deprecated and will be removed in a future release.
+ * <li>If the calling app has carrier privileges (see {@link #hasCarrierPrivileges}) on any
+ * active subscription.
+ * <li>If the calling app is the default SMS role holder (see {@link
+ * RoleManager#isRoleHeld(String)}).
+ * </ul>
*
* <p>If the calling app does not meet one of these requirements then this method will behave
* as follows:
@@ -1836,7 +1923,7 @@ public class TelephonyManager {
if (telephony == null)
return null;
return telephony.getDeviceIdWithFeature(mContext.getOpPackageName(),
- null);
+ mContext.getAttributionTag());
} catch (RemoteException ex) {
return null;
} catch (NullPointerException ex) {
@@ -1848,12 +1935,23 @@ public class TelephonyManager {
* Returns the unique device ID of a subscription, for example, the IMEI for
* GSM and the MEID for CDMA phones. Return null if device ID is not available.
*
- * <p>Requires Permission: READ_PRIVILEGED_PHONE_STATE, for the calling app to be the device or
- * profile owner and have the READ_PHONE_STATE permission, or that the calling app has carrier
- * privileges (see {@link #hasCarrierPrivileges}) on any active subscription. The profile owner
- * is an app that owns a managed profile on the device; for more details see <a
- * href="https://developer.android.com/work/managed-profiles">Work profiles</a>. Profile owner
- * access is deprecated and will be removed in a future release.
+ * <p>Starting with API level 29, persistent device identifiers are guarded behind additional
+ * restrictions, and apps are recommended to use resettable identifiers (see <a
+ * href="c"> Best practices for unique identifiers</a>). This method can be invoked if one of
+ * the following requirements is met:
+ * <ul>
+ * <li>If the calling app has been granted the READ_PRIVILEGED_PHONE_STATE permission; this
+ * is a privileged permission that can only be granted to apps preloaded on the device.
+ * <li>If the calling app is the device or profile owner and has been granted the
+ * {@link Manifest.permission#READ_PHONE_STATE} permission. The profile owner is an app that
+ * owns a managed profile on the device; for more details see <a
+ * href="https://developer.android.com/work/managed-profiles">Work profiles</a>.
+ * Profile owner access is deprecated and will be removed in a future release.
+ * <li>If the calling app has carrier privileges (see {@link #hasCarrierPrivileges}) on any
+ * active subscription.
+ * <li>If the calling app is the default SMS role holder (see {@link
+ * RoleManager#isRoleHeld(String)}).
+ * </ul>
*
* <p>If the calling app does not meet one of these requirements then this method will behave
* as follows:
@@ -1877,11 +1975,11 @@ public class TelephonyManager {
public String getDeviceId(int slotIndex) {
// FIXME this assumes phoneId == slotIndex
try {
- IPhoneSubInfo info = getSubscriberInfo();
+ IPhoneSubInfo info = getSubscriberInfoService();
if (info == null)
return null;
return info.getDeviceIdForPhone(slotIndex, mContext.getOpPackageName(),
- null);
+ mContext.getAttributionTag());
} catch (RemoteException ex) {
return null;
} catch (NullPointerException ex) {
@@ -1906,18 +2004,23 @@ public class TelephonyManager {
* Returns the IMEI (International Mobile Equipment Identity). Return null if IMEI is not
* available.
*
- * <p>This API requires one of the following:
+ * <p>Starting with API level 29, persistent device identifiers are guarded behind additional
+ * restrictions, and apps are recommended to use resettable identifiers (see <a
+ * href="c"> Best practices for unique identifiers</a>). This method can be invoked if one of
+ * the following requirements is met:
* <ul>
- * <li>The caller holds the READ_PRIVILEGED_PHONE_STATE permission.</li>
- * <li>If the caller is the device or profile owner, the caller holds the
- * {@link Manifest.permission#READ_PHONE_STATE} permission.</li>
- * <li>The caller has carrier privileges (see {@link #hasCarrierPrivileges()} on any
- * active subscription.</li>
- * <li>The caller is the default SMS app for the device.</li>
+ * <li>If the calling app has been granted the READ_PRIVILEGED_PHONE_STATE permission; this
+ * is a privileged permission that can only be granted to apps preloaded on the device.
+ * <li>If the calling app is the device or profile owner and has been granted the
+ * {@link Manifest.permission#READ_PHONE_STATE} permission. The profile owner is an app that
+ * owns a managed profile on the device; for more details see <a
+ * href="https://developer.android.com/work/managed-profiles">Work profiles</a>.
+ * Profile owner access is deprecated and will be removed in a future release.
+ * <li>If the calling app has carrier privileges (see {@link #hasCarrierPrivileges}) on any
+ * active subscription.
+ * <li>If the calling app is the default SMS role holder (see {@link
+ * RoleManager#isRoleHeld(String)}).
* </ul>
- * <p>The profile owner is an app that owns a managed profile on the device; for more details
- * see <a href="https://developer.android.com/work/managed-profiles">Work profiles</a>.
- * Access by profile owners is deprecated and will be removed in a future release.
*
* <p>If the calling app does not meet one of these requirements then this method will behave
* as follows:
@@ -1939,7 +2042,7 @@ public class TelephonyManager {
if (telephony == null) return null;
try {
- return telephony.getImeiForSlot(slotIndex, getOpPackageName(), getFeatureId());
+ return telephony.getImeiForSlot(slotIndex, getOpPackageName(), getAttributionTag());
} catch (RemoteException ex) {
return null;
} catch (NullPointerException ex) {
@@ -1979,12 +2082,23 @@ public class TelephonyManager {
/**
* Returns the MEID (Mobile Equipment Identifier). Return null if MEID is not available.
*
- * <p>Requires Permission: READ_PRIVILEGED_PHONE_STATE, for the calling app to be the device or
- * profile owner and have the READ_PHONE_STATE permission, or that the calling app has carrier
- * privileges (see {@link #hasCarrierPrivileges}) on any active subscription. The profile owner
- * is an app that owns a managed profile on the device; for more details see <a
- * href="https://developer.android.com/work/managed-profiles">Work profiles</a>. Profile owner
- * access is deprecated and will be removed in a future release.
+ * <p>Starting with API level 29, persistent device identifiers are guarded behind additional
+ * restrictions, and apps are recommended to use resettable identifiers (see <a
+ * href="c"> Best practices for unique identifiers</a>). This method can be invoked if one of
+ * the following requirements is met:
+ * <ul>
+ * <li>If the calling app has been granted the READ_PRIVILEGED_PHONE_STATE permission; this
+ * is a privileged permission that can only be granted to apps preloaded on the device.
+ * <li>If the calling app is the device or profile owner and has been granted the
+ * {@link Manifest.permission#READ_PHONE_STATE} permission. The profile owner is an app that
+ * owns a managed profile on the device; for more details see <a
+ * href="https://developer.android.com/work/managed-profiles">Work profiles</a>.
+ * Profile owner access is deprecated and will be removed in a future release.
+ * <li>If the calling app has carrier privileges (see {@link #hasCarrierPrivileges}) on any
+ * active subscription.
+ * <li>If the calling app is the default SMS role holder (see {@link
+ * RoleManager#isRoleHeld(String)}).
+ * </ul>
*
* <p>If the calling app does not meet one of these requirements then this method will behave
* as follows:
@@ -2006,12 +2120,23 @@ public class TelephonyManager {
/**
* Returns the MEID (Mobile Equipment Identifier). Return null if MEID is not available.
*
- * <p>Requires Permission: READ_PRIVILEGED_PHONE_STATE, for the calling app to be the device or
- * profile owner and have the READ_PHONE_STATE permission, or that the calling app has carrier
- * privileges (see {@link #hasCarrierPrivileges}) on any active subscription. The profile owner
- * is an app that owns a managed profile on the device; for more details see <a
- * href="https://developer.android.com/work/managed-profiles">Work profiles</a>. Profile owner
- * access is deprecated and will be removed in a future release.
+ * <p>Starting with API level 29, persistent device identifiers are guarded behind additional
+ * restrictions, and apps are recommended to use resettable identifiers (see <a
+ * href="c"> Best practices for unique identifiers</a>). This method can be invoked if one of
+ * the following requirements is met:
+ * <ul>
+ * <li>If the calling app has been granted the READ_PRIVILEGED_PHONE_STATE permission; this
+ * is a privileged permission that can only be granted to apps preloaded on the device.
+ * <li>If the calling app is the device or profile owner and has been granted the
+ * {@link Manifest.permission#READ_PHONE_STATE} permission. The profile owner is an app that
+ * owns a managed profile on the device; for more details see <a
+ * href="https://developer.android.com/work/managed-profiles">Work profiles</a>.
+ * Profile owner access is deprecated and will be removed in a future release.
+ * <li>If the calling app has carrier privileges (see {@link #hasCarrierPrivileges}) on any
+ * active subscription.
+ * <li>If the calling app is the default SMS role holder (see {@link
+ * RoleManager#isRoleHeld(String)}).
+ * </ul>
*
* <p>If the calling app does not meet one of these requirements then this method will behave
* as follows:
@@ -2033,7 +2158,8 @@ public class TelephonyManager {
if (telephony == null) return null;
try {
- String meid = telephony.getMeidForSlot(slotIndex, getOpPackageName(), getFeatureId());
+ String meid = telephony.getMeidForSlot(slotIndex, getOpPackageName(),
+ getAttributionTag());
if (TextUtils.isEmpty(meid)) {
Log.d(TAG, "getMeid: return null because MEID is not available");
return null;
@@ -2078,12 +2204,25 @@ public class TelephonyManager {
/**
* Returns the Network Access Identifier (NAI). Return null if NAI is not available.
*
- * <p>Requires Permission: READ_PRIVILEGED_PHONE_STATE, for the calling app to be the device or
- * profile owner and have the READ_PHONE_STATE permission, or that the calling app has carrier
- * privileges (see {@link #hasCarrierPrivileges}). The profile owner is an app that owns a
- * managed profile on the device; for more details see <a
- * href="https://developer.android.com/work/managed-profiles">Work profiles</a>. Profile owner
- * access is deprecated and will be removed in a future release.
+ * <p>Starting with API level 29, persistent device identifiers are guarded behind additional
+ * restrictions, and apps are recommended to use resettable identifiers (see <a
+ * href="c"> Best practices for unique identifiers</a>). This method can be invoked if one of
+ * the following requirements is met:
+ * <ul>
+ * <li>If the calling app has been granted the READ_PRIVILEGED_PHONE_STATE permission; this
+ * is a privileged permission that can only be granted to apps preloaded on the device.
+ * <li>If the calling app is the device or profile owner and has been granted the
+ * {@link Manifest.permission#READ_PHONE_STATE} permission. The profile owner is an app that
+ * owns a managed profile on the device; for more details see <a
+ * href="https://developer.android.com/work/managed-profiles">Work profiles</a>.
+ * Profile owner access is deprecated and will be removed in a future release.
+ * <li>If the calling app has carrier privileges (see {@link #hasCarrierPrivileges}).
+ * <li>If the calling app is the default SMS role holder (see {@link
+ * RoleManager#isRoleHeld(String)}).
+ * </ul>
+ *
+ * <p>If the calling app does not meet one of these requirements then this method will behave
+ * as follows:
*
* <ul>
* <li>If the calling app's target SDK is API level 28 or lower and the app has the
@@ -2102,12 +2241,25 @@ public class TelephonyManager {
/**
* Returns the NAI. Return null if NAI is not available.
*
- * <p>Requires Permission: READ_PRIVILEGED_PHONE_STATE, for the calling app to be the device or
- * profile owner and have the READ_PHONE_STATE permission, or that the calling app has carrier
- * privileges (see {@link #hasCarrierPrivileges}). The profile owner is an app that owns a
- * managed profile on the device; for more details see <a
- * href="https://developer.android.com/work/managed-profiles">Work profiles</a>. Profile owner
- * access is deprecated and will be removed in a future release.
+ * <p>Starting with API level 29, persistent device identifiers are guarded behind additional
+ * restrictions, and apps are recommended to use resettable identifiers (see <a
+ * href="c"> Best practices for unique identifiers</a>). This method can be invoked if one of
+ * the following requirements is met:
+ * <ul>
+ * <li>If the calling app has been granted the READ_PRIVILEGED_PHONE_STATE permission; this
+ * is a privileged permission that can only be granted to apps preloaded on the device.
+ * <li>If the calling app is the device or profile owner and has been granted the
+ * {@link Manifest.permission#READ_PHONE_STATE} permission. The profile owner is an app that
+ * owns a managed profile on the device; for more details see <a
+ * href="https://developer.android.com/work/managed-profiles">Work profiles</a>.
+ * Profile owner access is deprecated and will be removed in a future release.
+ * <li>If the calling app has carrier privileges (see {@link #hasCarrierPrivileges}).
+ * <li>If the calling app is the default SMS role holder (see {@link
+ * RoleManager#isRoleHeld(String)}).
+ * </ul>
+ *
+ * <p>If the calling app does not meet one of these requirements then this method will behave
+ * as follows:
*
* <ul>
* <li>If the calling app's target SDK is API level 28 or lower and the app has the
@@ -2131,11 +2283,11 @@ public class TelephonyManager {
private String getNaiBySubscriberId(int subId) {
try {
- IPhoneSubInfo info = getSubscriberInfo();
+ IPhoneSubInfo info = getSubscriberInfoService();
if (info == null)
return null;
String nai = info.getNaiForSubscriber(subId, mContext.getOpPackageName(),
- null);
+ mContext.getAttributionTag());
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Rlog.v(TAG, "Nai = " + nai);
}
@@ -2169,7 +2321,7 @@ public class TelephonyManager {
}
CellIdentity cellIdentity = telephony.getCellLocation(mContext.getOpPackageName(),
- null);
+ mContext.getAttributionTag());
CellLocation cl = cellIdentity.asCellLocation();
if (cl == null || cl.isEmpty()) {
Rlog.d(TAG, "getCellLocation returning null because CellLocation is empty or"
@@ -2201,7 +2353,7 @@ public class TelephonyManager {
if (telephony == null)
return null;
return telephony.getNeighboringCellInfo(mContext.getOpPackageName(),
- null);
+ mContext.getAttributionTag());
} catch (RemoteException ex) {
return null;
} catch (NullPointerException ex) {
@@ -2546,21 +2698,22 @@ public class TelephonyManager {
}
/**
- * Returns the ISO-3166 country code equivalent of the MCC (Mobile Country Code) of the current
- * registered operator or the cell nearby, if available.
+ * Returns the ISO-3166-1 alpha-2 country code equivalent of the MCC (Mobile Country Code) of
+ * the current registered operator or the cell nearby, if available.
*
* Note: Result may be unreliable on CDMA networks (use {@link #getPhoneType()} to determine
* if on a CDMA network).
* <p>
- * @return the lowercase 2 character ISO-3166 country code, or empty string if not available.
+ * @return the lowercase 2 character ISO-3166-1 alpha-2 country code, or empty string if not
+ * available.
*/
public String getNetworkCountryIso() {
return getNetworkCountryIso(getSlotIndex());
}
/**
- * Returns the ISO-3166 country code equivalent of the MCC (Mobile Country Code) of the current
- * registered operator or the cell nearby, if available. This is same as
+ * Returns the ISO-3166-1 alpha-2 country code equivalent of the MCC (Mobile Country Code) of
+ * the current registered operator or the cell nearby, if available. This is same as
* {@link #getNetworkCountryIso()} but allowing specifying the SIM slot index. This is used for
* accessing network country info from the SIM slot that does not have SIM inserted.
*
@@ -2570,7 +2723,8 @@ public class TelephonyManager {
*
* @param slotIndex the SIM slot index to get network country ISO.
*
- * @return the lowercase 2 character ISO-3166 country code, or empty string if not available.
+ * @return the lowercase 2 character ISO-3166-1 alpha-2 country code, or empty string if not
+ * available.
*
* @throws IllegalArgumentException when the slotIndex is invalid.
*
@@ -2678,6 +2832,8 @@ public class TelephonyManager {
/**
* Return a collection of all network types
* @return network types
+ *
+ * @hide
*/
public static @NonNull @NetworkType int[] getAllNetworkTypes() {
return NETWORK_TYPES;
@@ -2729,7 +2885,7 @@ public class TelephonyManager {
ITelephony telephony = getITelephony();
if (telephony != null) {
return telephony.getNetworkTypeForSubscriber(subId, getOpPackageName(),
- getFeatureId());
+ getAttributionTag());
} else {
// This can happen when the ITelephony interface is not up yet.
return NETWORK_TYPE_UNKNOWN;
@@ -2794,7 +2950,7 @@ public class TelephonyManager {
ITelephony telephony = getITelephony();
if (telephony != null) {
return telephony.getDataNetworkTypeForSubscriber(subId, getOpPackageName(),
- getFeatureId());
+ getAttributionTag());
} else {
// This can happen when the ITelephony interface is not up yet.
return NETWORK_TYPE_UNKNOWN;
@@ -2831,7 +2987,7 @@ public class TelephonyManager {
ITelephony telephony = getITelephony();
if (telephony != null) {
return telephony.getVoiceNetworkTypeForSubscriber(subId, getOpPackageName(),
- getFeatureId());
+ getAttributionTag());
} else {
// This can happen when the ITelephony interface is not up yet.
return NETWORK_TYPE_UNKNOWN;
@@ -3525,10 +3681,11 @@ public class TelephonyManager {
}
/**
- * Returns the ISO-3166 country code equivalent for the SIM provider's country code.
+ * Returns the ISO-3166-1 alpha-2 country code equivalent for the SIM provider's country code.
* <p>
- * The ISO-3166 country code is provided in lowercase 2 character format.
- * @return the lowercase 2 character ISO-3166 country code, or empty string is not available.
+ * The ISO-3166-1 alpha-2 country code is provided in lowercase 2 character format.
+ * @return the lowercase 2 character ISO-3166-1 alpha-2 country code, or empty string is not
+ * available.
*/
public String getSimCountryIso() {
return getSimCountryIsoForPhone(getPhoneId());
@@ -3541,7 +3698,7 @@ public class TelephonyManager {
* @hide
*/
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
- public String getSimCountryIso(int subId) {
+ public static String getSimCountryIso(int subId) {
int phoneId = SubscriptionManager.getPhoneId(subId);
return getSimCountryIsoForPhone(phoneId);
}
@@ -3552,7 +3709,7 @@ public class TelephonyManager {
* @hide
*/
@UnsupportedAppUsage
- public String getSimCountryIsoForPhone(int phoneId) {
+ public static String getSimCountryIsoForPhone(int phoneId) {
return getTelephonyProperty(phoneId, TelephonyProperties.icc_operator_iso_country(), "");
}
@@ -3560,12 +3717,22 @@ public class TelephonyManager {
* Returns the serial number of the SIM, if applicable. Return null if it is
* unavailable.
*
- * <p>Requires Permission: READ_PRIVILEGED_PHONE_STATE, for the calling app to be the device or
- * profile owner and have the READ_PHONE_STATE permission, or that the calling app has carrier
- * privileges (see {@link #hasCarrierPrivileges}). The profile owner is an app that owns a
- * managed profile on the device; for more details see <a
- * href="https://developer.android.com/work/managed-profiles">Work profiles</a>. Profile owner
- * access is deprecated and will be removed in a future release.
+ * <p>Starting with API level 29, persistent device identifiers are guarded behind additional
+ * restrictions, and apps are recommended to use resettable identifiers (see <a
+ * href="c"> Best practices for unique identifiers</a>). This method can be invoked if one of
+ * the following requirements is met:
+ * <ul>
+ * <li>If the calling app has been granted the READ_PRIVILEGED_PHONE_STATE permission; this
+ * is a privileged permission that can only be granted to apps preloaded on the device.
+ * <li>If the calling app is the device or profile owner and has been granted the
+ * {@link Manifest.permission#READ_PHONE_STATE} permission. The profile owner is an app that
+ * owns a managed profile on the device; for more details see <a
+ * href="https://developer.android.com/work/managed-profiles">Work profiles</a>.
+ * Profile owner access is deprecated and will be removed in a future release.
+ * <li>If the calling app has carrier privileges (see {@link #hasCarrierPrivileges}).
+ * <li>If the calling app is the default SMS role holder (see {@link
+ * RoleManager#isRoleHeld(String)}).
+ * </ul>
*
* <p>If the calling app does not meet one of these requirements then this method will behave
* as follows:
@@ -3588,12 +3755,22 @@ public class TelephonyManager {
* Returns the serial number for the given subscription, if applicable. Return null if it is
* unavailable.
*
- * <p>Requires Permission: READ_PRIVILEGED_PHONE_STATE, for the calling app to be the device or
- * profile owner and have the READ_PHONE_STATE permission, or that the calling app has carrier
- * privileges (see {@link #hasCarrierPrivileges}). The profile owner is an app that owns a
- * managed profile on the device; for more details see <a
- * href="https://developer.android.com/work/managed-profiles">Work profiles</a>. Profile owner
- * access is deprecated and will be removed in a future release.
+ * <p>Starting with API level 29, persistent device identifiers are guarded behind additional
+ * restrictions, and apps are recommended to use resettable identifiers (see <a
+ * href="c"> Best practices for unique identifiers</a>). This method can be invoked if one of
+ * the following requirements is met:
+ * <ul>
+ * <li>If the calling app has been granted the READ_PRIVILEGED_PHONE_STATE permission; this
+ * is a privileged permission that can only be granted to apps preloaded on the device.
+ * <li>If the calling app is the device or profile owner and has been granted the
+ * {@link Manifest.permission#READ_PHONE_STATE} permission. The profile owner is an app that
+ * owns a managed profile on the device; for more details see <a
+ * href="https://developer.android.com/work/managed-profiles">Work profiles</a>.
+ * Profile owner access is deprecated and will be removed in a future release.
+ * <li>If the calling app has carrier privileges (see {@link #hasCarrierPrivileges}).
+ * <li>If the calling app is the default SMS role holder (see {@link
+ * RoleManager#isRoleHeld(String)}).
+ * </ul>
*
* <p>If the calling app does not meet one of these requirements then this method will behave
* as follows:
@@ -3613,11 +3790,11 @@ public class TelephonyManager {
@UnsupportedAppUsage
public String getSimSerialNumber(int subId) {
try {
- IPhoneSubInfo info = getSubscriberInfo();
+ IPhoneSubInfo info = getSubscriberInfoService();
if (info == null)
return null;
return info.getIccSerialNumberForSubscriber(subId, mContext.getOpPackageName(),
- null);
+ mContext.getAttributionTag());
} catch (RemoteException ex) {
return null;
} catch (NullPointerException ex) {
@@ -3661,7 +3838,7 @@ public class TelephonyManager {
if (telephony == null)
return PhoneConstants.LTE_ON_CDMA_UNKNOWN;
return telephony.getLteOnCdmaModeForSubscriber(subId, getOpPackageName(),
- getFeatureId());
+ getAttributionTag());
} catch (RemoteException ex) {
// Assume no ICC card if remote exception which shouldn't happen
return PhoneConstants.LTE_ON_CDMA_UNKNOWN;
@@ -3832,12 +4009,22 @@ public class TelephonyManager {
* Returns the unique subscriber ID, for example, the IMSI for a GSM phone.
* Return null if it is unavailable.
*
- * <p>Requires Permission: READ_PRIVILEGED_PHONE_STATE, for the calling app to be the device or
- * profile owner and have the READ_PHONE_STATE permission, or that the calling app has carrier
- * privileges (see {@link #hasCarrierPrivileges}). The profile owner is an app that owns a
- * managed profile on the device; for more details see <a
- * href="https://developer.android.com/work/managed-profiles">Work profiles</a>. Profile owner
- * access is deprecated and will be removed in a future release.
+ * <p>Starting with API level 29, persistent device identifiers are guarded behind additional
+ * restrictions, and apps are recommended to use resettable identifiers (see <a
+ * href="c"> Best practices for unique identifiers</a>). This method can be invoked if one of
+ * the following requirements is met:
+ * <ul>
+ * <li>If the calling app has been granted the READ_PRIVILEGED_PHONE_STATE permission; this
+ * is a privileged permission that can only be granted to apps preloaded on the device.
+ * <li>If the calling app is the device or profile owner and has been granted the
+ * {@link Manifest.permission#READ_PHONE_STATE} permission. The profile owner is an app that
+ * owns a managed profile on the device; for more details see <a
+ * href="https://developer.android.com/work/managed-profiles">Work profiles</a>.
+ * Profile owner access is deprecated and will be removed in a future release.
+ * <li>If the calling app has carrier privileges (see {@link #hasCarrierPrivileges}).
+ * <li>If the calling app is the default SMS role holder (see {@link
+ * RoleManager#isRoleHeld(String)}).
+ * </ul>
*
* <p>If the calling app does not meet one of these requirements then this method will behave
* as follows:
@@ -3861,12 +4048,22 @@ public class TelephonyManager {
* for a subscription.
* Return null if it is unavailable.
*
- * <p>Requires Permission: READ_PRIVILEGED_PHONE_STATE, for the calling app to be the device or
- * profile owner and have the READ_PHONE_STATE permission, or that the calling app has carrier
- * privileges (see {@link #hasCarrierPrivileges}). The profile owner is an app that owns a
- * managed profile on the device; for more details see <a
- * href="https://developer.android.com/work/managed-profiles">Work profiles</a>. Profile owner
- * access is deprecated and will be removed in a future release.
+ * <p>Starting with API level 29, persistent device identifiers are guarded behind additional
+ * restrictions, and apps are recommended to use resettable identifiers (see <a
+ * href="c"> Best practices for unique identifiers</a>). This method can be invoked if one of
+ * the following requirements is met:
+ * <ul>
+ * <li>If the calling app has been granted the READ_PRIVILEGED_PHONE_STATE permission; this
+ * is a privileged permission that can only be granted to apps preloaded on the device.
+ * <li>If the calling app is the device or profile owner and has been granted the
+ * {@link Manifest.permission#READ_PHONE_STATE} permission. The profile owner is an app that
+ * owns a managed profile on the device; for more details see <a
+ * href="https://developer.android.com/work/managed-profiles">Work profiles</a>.
+ * Profile owner access is deprecated and will be removed in a future release.
+ * <li>If the calling app has carrier privileges (see {@link #hasCarrierPrivileges}).
+ * <li>If the calling app is the default SMS role holder (see {@link
+ * RoleManager#isRoleHeld(String)}).
+ * </ul>
*
* <p>If the calling app does not meet one of these requirements then this method will behave
* as follows:
@@ -3886,11 +4083,11 @@ public class TelephonyManager {
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
public String getSubscriberId(int subId) {
try {
- IPhoneSubInfo info = getSubscriberInfo();
+ IPhoneSubInfo info = getSubscriberInfoService();
if (info == null)
return null;
return info.getSubscriberIdForSubscriber(subId, mContext.getOpPackageName(),
- null);
+ mContext.getAttributionTag());
} catch (RemoteException ex) {
return null;
} catch (NullPointerException ex) {
@@ -3922,7 +4119,7 @@ public class TelephonyManager {
@Nullable
public ImsiEncryptionInfo getCarrierInfoForImsiEncryption(@KeyType int keyType) {
try {
- IPhoneSubInfo info = getSubscriberInfo();
+ IPhoneSubInfo info = getSubscriberInfoService();
if (info == null) {
Rlog.e(TAG,"IMSI error: Subscriber Info is null");
return null;
@@ -3965,7 +4162,7 @@ public class TelephonyManager {
@SystemApi
public void resetCarrierKeysForImsiEncryption() {
try {
- IPhoneSubInfo info = getSubscriberInfo();
+ IPhoneSubInfo info = getSubscriberInfoService();
if (info == null) {
Rlog.e(TAG, "IMSI error: Subscriber Info is null");
if (!isSystemProcess()) {
@@ -4030,7 +4227,7 @@ public class TelephonyManager {
*/
public void setCarrierInfoForImsiEncryption(ImsiEncryptionInfo imsiEncryptionInfo) {
try {
- IPhoneSubInfo info = getSubscriberInfo();
+ IPhoneSubInfo info = getSubscriberInfoService();
if (info == null) return;
info.setCarrierInfoForImsiEncryption(mSubId, mContext.getOpPackageName(),
imsiEncryptionInfo);
@@ -4054,11 +4251,11 @@ public class TelephonyManager {
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
public String getGroupIdLevel1() {
try {
- IPhoneSubInfo info = getSubscriberInfo();
+ IPhoneSubInfo info = getSubscriberInfoService();
if (info == null)
return null;
return info.getGroupIdLevel1ForSubscriber(getSubId(), mContext.getOpPackageName(),
- null);
+ mContext.getAttributionTag());
} catch (RemoteException ex) {
return null;
} catch (NullPointerException ex) {
@@ -4078,11 +4275,11 @@ public class TelephonyManager {
@UnsupportedAppUsage
public String getGroupIdLevel1(int subId) {
try {
- IPhoneSubInfo info = getSubscriberInfo();
+ IPhoneSubInfo info = getSubscriberInfoService();
if (info == null)
return null;
return info.getGroupIdLevel1ForSubscriber(subId, mContext.getOpPackageName(),
- null);
+ mContext.getAttributionTag());
} catch (RemoteException ex) {
return null;
} catch (NullPointerException ex) {
@@ -4146,7 +4343,7 @@ public class TelephonyManager {
ITelephony telephony = getITelephony();
if (telephony != null)
number = telephony.getLine1NumberForDisplay(subId, mContext.getOpPackageName(),
- null);
+ mContext.getAttributionTag());
} catch (RemoteException ex) {
} catch (NullPointerException ex) {
}
@@ -4154,11 +4351,11 @@ public class TelephonyManager {
return number;
}
try {
- IPhoneSubInfo info = getSubscriberInfo();
+ IPhoneSubInfo info = getSubscriberInfoService();
if (info == null)
return null;
return info.getLine1NumberForSubscriber(subId, mContext.getOpPackageName(),
- null);
+ mContext.getAttributionTag());
} catch (RemoteException ex) {
return null;
} catch (NullPointerException ex) {
@@ -4237,7 +4434,7 @@ public class TelephonyManager {
ITelephony telephony = getITelephony();
if (telephony != null)
alphaTag = telephony.getLine1AlphaTagForDisplay(subId,
- getOpPackageName(), getFeatureId());
+ getOpPackageName(), getAttributionTag());
} catch (RemoteException ex) {
} catch (NullPointerException ex) {
}
@@ -4245,11 +4442,11 @@ public class TelephonyManager {
return alphaTag;
}
try {
- IPhoneSubInfo info = getSubscriberInfo();
+ IPhoneSubInfo info = getSubscriberInfoService();
if (info == null)
return null;
return info.getLine1AlphaTagForSubscriber(subId, getOpPackageName(),
- getFeatureId());
+ getAttributionTag());
} catch (RemoteException ex) {
return null;
} catch (NullPointerException ex) {
@@ -4279,7 +4476,7 @@ public class TelephonyManager {
ITelephony telephony = getITelephony();
if (telephony != null)
return telephony.getMergedSubscriberIds(getSubId(), getOpPackageName(),
- getFeatureId());
+ getAttributionTag());
} catch (RemoteException ex) {
} catch (NullPointerException ex) {
}
@@ -4358,10 +4555,10 @@ public class TelephonyManager {
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
public String getMsisdn(int subId) {
try {
- IPhoneSubInfo info = getSubscriberInfo();
+ IPhoneSubInfo info = getSubscriberInfoService();
if (info == null)
return null;
- return info.getMsisdnForSubscriber(subId, getOpPackageName(), getFeatureId());
+ return info.getMsisdnForSubscriber(subId, getOpPackageName(), getAttributionTag());
} catch (RemoteException ex) {
return null;
} catch (NullPointerException ex) {
@@ -4392,11 +4589,11 @@ public class TelephonyManager {
@UnsupportedAppUsage
public String getVoiceMailNumber(int subId) {
try {
- IPhoneSubInfo info = getSubscriberInfo();
+ IPhoneSubInfo info = getSubscriberInfoService();
if (info == null)
return null;
return info.getVoiceMailNumberForSubscriber(subId, getOpPackageName(),
- getFeatureId());
+ getAttributionTag());
} catch (RemoteException ex) {
return null;
} catch (NullPointerException ex) {
@@ -4521,7 +4718,7 @@ public class TelephonyManager {
ITelephony telephony = getITelephony();
if (telephony != null) {
return telephony.getVisualVoicemailPackageName(mContext.getOpPackageName(),
- getFeatureId(), getSubId());
+ getAttributionTag(), getSubId());
}
} catch (RemoteException ex) {
} catch (NullPointerException ex) {
@@ -4692,7 +4889,8 @@ public class TelephonyManager {
ITelephony telephony = getITelephony();
if (telephony != null) {
telephony.sendVisualVoicemailSmsForSubscriber(
- mContext.getOpPackageName(), null, subId, number, port, text, sentIntent);
+ mContext.getOpPackageName(), mContext.getAttributionTag(), subId, number,
+ port, text, sentIntent);
}
} catch (RemoteException ex) {
}
@@ -4958,7 +5156,7 @@ public class TelephonyManager {
if (telephony == null)
return 0;
return telephony.getVoiceMessageCountForSubscriber(subId, getOpPackageName(),
- getFeatureId());
+ getAttributionTag());
} catch (RemoteException ex) {
return 0;
} catch (NullPointerException ex) {
@@ -4991,11 +5189,11 @@ public class TelephonyManager {
@UnsupportedAppUsage
public String getVoiceMailAlphaTag(int subId) {
try {
- IPhoneSubInfo info = getSubscriberInfo();
+ IPhoneSubInfo info = getSubscriberInfoService();
if (info == null)
return null;
return info.getVoiceMailAlphaTagForSubscriber(subId, getOpPackageName(),
- getFeatureId());
+ getAttributionTag());
} catch (RemoteException ex) {
return null;
} catch (NullPointerException ex) {
@@ -5039,7 +5237,7 @@ public class TelephonyManager {
@UnsupportedAppUsage
public String getIsimImpi() {
try {
- IPhoneSubInfo info = getSubscriberInfo();
+ IPhoneSubInfo info = getSubscriberInfoService();
if (info == null)
return null;
//get the Isim Impi based on subId
@@ -5066,7 +5264,7 @@ public class TelephonyManager {
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
public String getIsimDomain() {
try {
- IPhoneSubInfo info = getSubscriberInfo();
+ IPhoneSubInfo info = getSubscriberInfoService();
if (info == null)
return null;
//get the Isim Domain based on subId
@@ -5090,7 +5288,7 @@ public class TelephonyManager {
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
public String[] getIsimImpu() {
try {
- IPhoneSubInfo info = getSubscriberInfo();
+ IPhoneSubInfo info = getSubscriberInfoService();
if (info == null)
return null;
//get the Isim Impu based on subId
@@ -5103,15 +5301,6 @@ public class TelephonyManager {
}
}
- /**
- * @hide
- */
- @UnsupportedAppUsage
- private IPhoneSubInfo getSubscriberInfo() {
- // get it each time because that process crashes a lot
- return IPhoneSubInfo.Stub.asInterface(ServiceManager.getService("iphonesubinfo"));
- }
-
/**
* Device call state: No activity.
*/
@@ -5168,6 +5357,14 @@ public class TelephonyManager {
}
/**
+ * @hide
+ */
+ @UnsupportedAppUsage
+ private IPhoneSubInfo getSubscriberInfo() {
+ return getSubscriberInfoService();
+ }
+
+ /**
* Returns the Telephony call state for calls on a specific SIM slot.
* <p>
* Note: This method considers ONLY telephony/mobile calls, where {@link #getCallState()}
@@ -5207,17 +5404,6 @@ public class TelephonyManager {
*/
public static final int DATA_ACTIVITY_DORMANT = 0x00000004;
- /** @hide */
- @IntDef(prefix = {"DATA_"}, value = {
- DATA_ACTIVITY_NONE,
- DATA_ACTIVITY_IN,
- DATA_ACTIVITY_OUT,
- DATA_ACTIVITY_INOUT,
- DATA_ACTIVITY_DORMANT,
- })
- @Retention(RetentionPolicy.SOURCE)
- public @interface DataActivityType{}
-
/**
* Returns a constant indicating the type of activity on a data connection
* (cellular).
@@ -5335,15 +5521,16 @@ public class TelephonyManager {
*/
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
private ITelephony getITelephony() {
- return ITelephony.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_SERVICE));
- }
-
- private ITelephonyRegistry getTelephonyRegistry() {
- return ITelephonyRegistry.Stub.asInterface(ServiceManager.getService("telephony.registry"));
+ return ITelephony.Stub.asInterface(TelephonyFrameworkInitializer
+ .getTelephonyServiceManager().getTelephonyServiceRegisterer().get());
}
private IOns getIOns() {
- return IOns.Stub.asInterface(ServiceManager.getService("ions"));
+ return IOns.Stub.asInterface(
+ TelephonyFrameworkInitializer
+ .getTelephonyServiceManager()
+ .getOpportunisticNetworkServiceRegisterer()
+ .get());
}
//
@@ -5353,13 +5540,6 @@ public class TelephonyManager {
//
/**
- * To check the SDK version for {@link TelephonyManager#listen}.
- */
- @ChangeId
- @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.P)
- private static final long LISTEN_CODE_CHANGE = 147600208L;
-
- /**
* Registers a listener object to receive notification of changes
* in specified telephony states.
* <p>
@@ -5395,46 +5575,37 @@ public class TelephonyManager {
*/
public void listen(PhoneStateListener listener, int events) {
if (mContext == null) return;
- try {
- boolean notifyNow = (getITelephony() != null);
- ITelephonyRegistry registry = getTelephonyRegistry();
- if (registry != null) {
- // subId from PhoneStateListener is deprecated Q on forward, use the subId from
- // TelephonyManager instance. keep using subId from PhoneStateListener for pre-Q.
- int subId = mSubId;
- if (Compatibility.isChangeEnabled(LISTEN_CODE_CHANGE)) {
- // since mSubId in PhoneStateListener is deprecated from Q on forward, this is
- // the only place to set mSubId and its for "informational" only.
- // TODO: remove this once we completely get rid of mSubId in PhoneStateListener
- listener.mSubId = (events == PhoneStateListener.LISTEN_NONE)
- ? SubscriptionManager.INVALID_SUBSCRIPTION_ID : subId;
- } else if (listener.mSubId != null) {
- subId = listener.mSubId;
- }
- registry.listenForSubscriber(subId, getOpPackageName(), getFeatureId(),
- listener.callback, events, notifyNow);
- } else {
- Rlog.w(TAG, "telephony registry not ready.");
- }
- } catch (RemoteException ex) {
- // system process dead
+ boolean notifyNow = (getITelephony() != null);
+ TelephonyRegistryManager telephonyRegistry =
+ (TelephonyRegistryManager)
+ mContext.getSystemService(Context.TELEPHONY_REGISTRY_SERVICE);
+ if (telephonyRegistry != null) {
+ telephonyRegistry.listenForSubscriber(mSubId, getOpPackageName(), getAttributionTag(),
+ listener, events, notifyNow);
+ } else {
+ Rlog.w(TAG, "telephony registry not ready.");
}
}
/**
- * Returns the CDMA ERI icon index to display
+ * Get the CDMA ERI (Enhanced Roaming Indicator) information
+ *
+ * Returns {@link android.telephony#CdmaEriInformation}
+ *
* @hide
*/
- @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
- public int getCdmaEriIconIndex() {
- return getCdmaEriIconIndex(getSubId());
+ @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
+ @NonNull
+ public CdmaEriInformation getCdmaEriInformation() {
+ return new CdmaEriInformation(
+ getCdmaEriIconIndex(getSubId()), getCdmaEriIconMode(getSubId()));
}
/**
* Returns the CDMA ERI icon index to display for a subscription
* @hide
*/
- @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
+ @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
@UnsupportedAppUsage
public int getCdmaEriIconIndex(int subId) {
try {
@@ -5442,7 +5613,7 @@ public class TelephonyManager {
if (telephony == null)
return -1;
return telephony.getCdmaEriIconIndexForSubscriber(subId, getOpPackageName(),
- getFeatureId());
+ getAttributionTag());
} catch (RemoteException ex) {
// the phone process is restarting.
return -1;
@@ -5452,25 +5623,13 @@ public class TelephonyManager {
}
/**
- * Returns the CDMA ERI icon mode,
- * 0 - ON
- * 1 - FLASHING
- *
- * @hide
- */
- @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
- public int getCdmaEriIconMode() {
- return getCdmaEriIconMode(getSubId());
- }
-
- /**
* Returns the CDMA ERI icon mode for a subscription.
* 0 - ON
* 1 - FLASHING
*
* @hide
*/
- @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
+ @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
@UnsupportedAppUsage
public int getCdmaEriIconMode(int subId) {
try {
@@ -5478,7 +5637,7 @@ public class TelephonyManager {
if (telephony == null)
return -1;
return telephony.getCdmaEriIconModeForSubscriber(subId, getOpPackageName(),
- getFeatureId());
+ getAttributionTag());
} catch (RemoteException ex) {
// the phone process is restarting.
return -1;
@@ -5510,7 +5669,7 @@ public class TelephonyManager {
if (telephony == null)
return null;
return telephony.getCdmaEriTextForSubscriber(subId, getOpPackageName(),
- getFeatureId());
+ getAttributionTag());
} catch (RemoteException ex) {
// the phone process is restarting.
return null;
@@ -5602,7 +5761,7 @@ public class TelephonyManager {
ITelephony telephony = getITelephony();
if (telephony == null)
return null;
- return telephony.getAllCellInfo(getOpPackageName(), getFeatureId());
+ return telephony.getAllCellInfo(getOpPackageName(), getAttributionTag());
} catch (RemoteException ex) {
} catch (NullPointerException ex) {
}
@@ -5669,6 +5828,10 @@ public class TelephonyManager {
* {@link android.telephony.PhoneStateListener#onCellInfoChanged onCellInfoChanged()}
* for each active subscription.
*
+ * <p>This method returns valid data for devices with
+ * {@link android.content.pm.PackageManager#FEATURE_TELEPHONY FEATURE_TELEPHONY}. On devices
+ * that do not implement this feature, the behavior is not reliable.
+ *
* @param executor the executor on which callback will be invoked.
* @param callback a callback to receive CellInfo.
*/
@@ -5702,7 +5865,7 @@ public class TelephonyManager {
Binder.restoreCallingIdentity(identity);
}
}
- }, getOpPackageName(), getFeatureId());
+ }, getOpPackageName(), getAttributionTag());
} catch (RemoteException ex) {
}
}
@@ -5715,6 +5878,10 @@ public class TelephonyManager {
* {@link android.telephony.PhoneStateListener#onCellInfoChanged onCellInfoChanged()}
* for each active subscription.
*
+ * <p>This method returns valid data for devices with
+ * {@link android.content.pm.PackageManager#FEATURE_TELEPHONY FEATURE_TELEPHONY}. On devices
+ * that do not implement this feature, the behavior is not reliable.
+ *
* @param workSource the requestor to whom the power consumption for this should be attributed.
* @param executor the executor on which callback will be invoked.
* @param callback a callback to receive CellInfo.
@@ -5753,7 +5920,7 @@ public class TelephonyManager {
Binder.restoreCallingIdentity(identity);
}
}
- }, getOpPackageName(), getFeatureId(), workSource);
+ }, getOpPackageName(), getAttributionTag(), workSource);
} catch (RemoteException ex) {
}
}
@@ -6572,7 +6739,19 @@ public class TelephonyManager {
* Return an appropriate subscription ID for any situation.
*
* If this object has been created with {@link #createForSubscriptionId}, then the provided
- * subId is returned. Otherwise, the default subId will be returned.
+ * subscription ID is returned. Otherwise, the default subscription ID will be returned.
+ *
+ */
+ public int getSubscriptionId() {
+ return getSubId();
+ }
+
+ /**
+ * Return an appropriate subscription ID for any situation.
+ *
+ * If this object has been created with {@link #createForSubscriptionId}, then the provided
+ * subscription ID is returned. Otherwise, the default subscription ID will be returned.
+ *
*/
private int getSubId() {
if (SubscriptionManager.isUsableSubIdValue(mSubId)) {
@@ -6881,7 +7060,7 @@ public class TelephonyManager {
@RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
public String getIsimIst() {
try {
- IPhoneSubInfo info = getSubscriberInfo();
+ IPhoneSubInfo info = getSubscriberInfoService();
if (info == null)
return null;
//get the Isim Ist based on subId
@@ -6903,7 +7082,7 @@ public class TelephonyManager {
@UnsupportedAppUsage
public String[] getIsimPcscf() {
try {
- IPhoneSubInfo info = getSubscriberInfo();
+ IPhoneSubInfo info = getSubscriberInfoService();
if (info == null)
return null;
//get the Isim Pcscf based on subId
@@ -6984,7 +7163,7 @@ public class TelephonyManager {
@UnsupportedAppUsage
public String getIccAuthentication(int subId, int appType, int authType, String data) {
try {
- IPhoneSubInfo info = getSubscriberInfo();
+ IPhoneSubInfo info = getSubscriberInfoService();
if (info == null)
return null;
return info.getIccSimChallengeResponse(subId, appType, authType, data);
@@ -7027,7 +7206,7 @@ public class TelephonyManager {
if (telephony == null)
return null;
return telephony.getForbiddenPlmns(subId, appType, mContext.getOpPackageName(),
- getFeatureId());
+ getAttributionTag());
} catch (RemoteException ex) {
return null;
} catch (NullPointerException ex) {
@@ -7061,7 +7240,7 @@ public class TelephonyManager {
ITelephony telephony = getITelephony();
if (telephony == null) return -1;
return telephony.setForbiddenPlmns(
- getSubId(), APPTYPE_USIM, fplmns, getOpPackageName(), getFeatureId());
+ getSubId(), APPTYPE_USIM, fplmns, getOpPackageName(), getAttributionTag());
} catch (RemoteException ex) {
Rlog.e(TAG, "setForbiddenPlmns RemoteException: " + ex.getMessage());
} catch (NullPointerException ex) {
@@ -7082,7 +7261,7 @@ public class TelephonyManager {
ITelephony telephony = getITelephony();
if (telephony == null)
return new String[0];
- return telephony.getPcscfAddress(apnType, getOpPackageName(), getFeatureId());
+ return telephony.getPcscfAddress(apnType, getOpPackageName(), getAttributionTag());
} catch (RemoteException e) {
return new String[0];
}
@@ -7678,7 +7857,7 @@ public class TelephonyManager {
ITelephony telephony = getITelephony();
if (telephony != null) {
return telephony.getCellNetworkScanResults(getSubId(), getOpPackageName(),
- getFeatureId());
+ getAttributionTag());
}
} catch (RemoteException ex) {
Rlog.e(TAG, "getAvailableNetworks RemoteException", ex);
@@ -7733,7 +7912,7 @@ public class TelephonyManager {
}
}
return mTelephonyScanManager.requestNetworkScan(getSubId(), request, executor, callback,
- getOpPackageName(), getFeatureId());
+ getOpPackageName(), getAttributionTag());
}
/**
@@ -7868,6 +8047,30 @@ public class TelephonyManager {
}
/**
+ * Get the PLMN chosen for Manual Network Selection if active.
+ * Return empty string if in automatic selection.
+ *
+ * <p>Requires Permission: {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE
+ * READ_PRECISE_PHONE_STATE} or that the calling app has carrier privileges
+ * (see {@link #hasCarrierPrivileges})
+ *
+ * @return manually selected network info on success or empty string on failure
+ */
+ @SuppressAutoDoc // No support carrier privileges (b/72967236).
+ @RequiresPermission(android.Manifest.permission.READ_PRECISE_PHONE_STATE)
+ public @NonNull String getManualNetworkSelectionPlmn() {
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony != null && isManualNetworkSelectionAllowed()) {
+ return telephony.getManualNetworkSelectionPlmn(getSubId());
+ }
+ } catch (RemoteException ex) {
+ Rlog.e(TAG, "getManualNetworkSelectionPlmn RemoteException", ex);
+ }
+ return "";
+ }
+
+ /**
* Query Telephony to see if there has recently been an emergency SMS sent to the network by the
* user and we are still within the time interval after the emergency SMS was sent that we are
* considered in Emergency SMS mode.
@@ -7882,7 +8085,6 @@ public class TelephonyManager {
*
* @hide
*/
- @SystemApi
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
public boolean isInEmergencySmsMode() {
try {
@@ -8597,7 +8799,7 @@ public class TelephonyManager {
try {
ITelephony telephony = getITelephony();
if (telephony != null)
- return telephony.isRadioOnWithFeature(getOpPackageName(), getFeatureId());
+ return telephony.isRadioOnWithFeature(getOpPackageName(), getAttributionTag());
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#isRadioOn", e);
}
@@ -8963,7 +9165,7 @@ public class TelephonyManager {
ITelephony telephony = getITelephony();
if (telephony != null) {
return telephony.getRadioPowerState(getSlotIndex(), mContext.getOpPackageName(),
- null);
+ mContext.getAttributionTag());
}
} catch (RemoteException ex) {
// This could happen if binder process crashes.
@@ -9345,7 +9547,7 @@ public class TelephonyManager {
try {
ITelephony telephony = getITelephony();
if (telephony != null)
- return telephony.isVideoCallingEnabled(getOpPackageName(), getFeatureId());
+ return telephony.isVideoCallingEnabled(getOpPackageName(), getAttributionTag());
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#isVideoCallingEnabled", e);
}
@@ -9362,7 +9564,7 @@ public class TelephonyManager {
ITelephony telephony = getITelephony();
if (telephony != null) {
return telephony.canChangeDtmfToneLength(mSubId, getOpPackageName(),
- getFeatureId());
+ getAttributionTag());
}
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#canChangeDtmfToneLength", e);
@@ -9381,7 +9583,7 @@ public class TelephonyManager {
try {
ITelephony telephony = getITelephony();
if (telephony != null) {
- return telephony.isWorldPhone(mSubId, getOpPackageName(), getFeatureId());
+ return telephony.isWorldPhone(mSubId, getOpPackageName(), getAttributionTag());
}
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#isWorldPhone", e);
@@ -9912,18 +10114,30 @@ public class TelephonyManager {
}
/**
- * Gets the default Respond Via Message application
- * @param context context from the calling app
- * @param updateIfNeeded update the default app if there is no valid default app configured.
+ * Gets the default Respond Via Message application, updating the cache if there is no
+ * respond-via-message application currently configured.
* @return component name of the app and class to direct Respond Via Message intent to, or
* {@code null} if the functionality is not supported.
* @hide
*/
@SystemApi
@TestApi
- public static @Nullable ComponentName getDefaultRespondViaMessageApplication(
- @NonNull Context context, boolean updateIfNeeded) {
- return SmsApplication.getDefaultRespondViaMessageApplication(context, updateIfNeeded);
+ @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
+ public @Nullable ComponentName getAndUpdateDefaultRespondViaMessageApplication() {
+ return SmsApplication.getDefaultRespondViaMessageApplication(mContext, true);
+ }
+
+ /**
+ * Gets the default Respond Via Message application.
+ * @return component name of the app and class to direct Respond Via Message intent to, or
+ * {@code null} if the functionality is not supported.
+ * @hide
+ */
+ @SystemApi
+ @TestApi
+ @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
+ public @Nullable ComponentName getDefaultRespondViaMessageApplication() {
+ return SmsApplication.getDefaultRespondViaMessageApplication(mContext, false);
}
/**
@@ -10086,7 +10300,8 @@ public class TelephonyManager {
ITelephony service = getITelephony();
if (service != null) {
retval = service.getSubIdForPhoneAccountHandle(
- phoneAccountHandle, mContext.getOpPackageName(), null);
+ phoneAccountHandle, mContext.getOpPackageName(),
+ mContext.getAttributionTag());
}
} catch (RemoteException ex) {
Log.e(TAG, "getSubscriptionId RemoteException", ex);
@@ -10226,7 +10441,7 @@ public class TelephonyManager {
ITelephony service = getITelephony();
if (service != null) {
return service.getServiceStateForSubscriber(subId, getOpPackageName(),
- getFeatureId());
+ getAttributionTag());
}
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#getServiceStateForSubscriber", e);
@@ -10920,14 +11135,14 @@ public class TelephonyManager {
/**
* Policy control of data connection. Usually used when data limit is passed.
* @param enabled True if enabling the data, otherwise disabling.
- * @param subId sub id
* @hide
*/
- public void setPolicyDataEnabled(boolean enabled, int subId) {
+ @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE)
+ public void setPolicyDataEnabled(boolean enabled) {
try {
ITelephony service = getITelephony();
if (service != null) {
- service.setPolicyDataEnabled(enabled, subId);
+ service.setPolicyDataEnabled(enabled, getSubId());
}
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#setPolicyDataEnabled", e);
@@ -10947,7 +11162,8 @@ public class TelephonyManager {
try {
ITelephony service = getITelephony();
if (service != null) {
- return service.getClientRequestStats(getOpPackageName(), getFeatureId(), subId);
+ return service.getClientRequestStats(getOpPackageName(), getAttributionTag(),
+ subId);
}
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#getClientRequestStats", e);
@@ -10993,15 +11209,18 @@ public class TelephonyManager {
/**
* Checks if manual network selection is allowed.
*
+ * <p>Requires Permission: {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE
+ * READ_PRECISE_PHONE_STATE} or that the calling app has carrier privileges
+ * (see {@link #hasCarrierPrivileges})
+ *
* <p>If this object has been created with {@link #createForSubscriptionId}, applies to the
* given subId. Otherwise, applies to {@link SubscriptionManager#getDefaultSubscriptionId()}.
*
* @return {@code true} if manual network selection is allowed, otherwise return {@code false}.
- *
- * @hide
*/
- @SystemApi
- @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
+ @SuppressAutoDoc // No support carrier privileges (b/72967236).
+ @RequiresPermission(anyOf = {android.Manifest.permission.READ_PRECISE_PHONE_STATE,
+ android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE})
public boolean isManualNetworkSelectionAllowed() {
try {
ITelephony telephony = getITelephony();
@@ -11230,7 +11449,7 @@ public class TelephonyManager {
ITelephony telephony = getITelephony();
if (telephony != null) {
return telephony.getNumberOfModemsWithSimultaneousDataConnections(
- getSubId(), getOpPackageName(), getFeatureId());
+ getSubId(), getOpPackageName(), getAttributionTag());
}
} catch (RemoteException ex) {
// This could happen if binder process crashes.
@@ -11660,7 +11879,7 @@ public class TelephonyManager {
ITelephony telephony = getITelephony();
if (telephony != null) {
return telephony.getEmergencyNumberList(mContext.getOpPackageName(),
- null);
+ mContext.getAttributionTag());
} else {
throw new IllegalStateException("telephony service is null.");
}
@@ -11716,7 +11935,7 @@ public class TelephonyManager {
ITelephony telephony = getITelephony();
if (telephony != null) {
emergencyNumberList = telephony.getEmergencyNumberList(
- mContext.getOpPackageName(), null);
+ mContext.getOpPackageName(), mContext.getAttributionTag());
if (emergencyNumberList != null) {
for (Integer subscriptionId : emergencyNumberList.keySet()) {
List<EmergencyNumber> numberList = emergencyNumberList.get(subscriptionId);
@@ -11868,6 +12087,7 @@ public class TelephonyManager {
*/
public static final int SET_OPPORTUNISTIC_SUB_REMOTE_SERVICE_EXCEPTION = 4;
+
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef(prefix = {"UPDATE_AVAILABLE_NETWORKS"}, value = {
@@ -12025,13 +12245,13 @@ public class TelephonyManager {
})
public int getPreferredOpportunisticDataSubscription() {
String packageName = mContext != null ? mContext.getOpPackageName() : "<unknown>";
- String featureId = null;
+ String attributionTag = mContext != null ? mContext.getAttributionTag() : null;
int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
try {
IOns iOpportunisticNetworkService = getIOns();
if (iOpportunisticNetworkService != null) {
subId = iOpportunisticNetworkService.getPreferredDataSubscriptionId(
- packageName, featureId);
+ packageName, attributionTag);
}
} catch (RemoteException ex) {
Rlog.e(TAG, "getPreferredDataSubscriptionId RemoteException", ex);
@@ -12148,18 +12368,20 @@ public class TelephonyManager {
/**
* It indicates whether modem is enabled or not per slot.
- * It's the corresponding status of {@link #enableModemForSlot}.
+ * It's the corresponding status of TelephonyManager.enableModemForSlot.
*
+ * <p>Requires Permission:
+ * READ_PRIVILEGED_PHONE_STATE or
+ * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
* @param slotIndex which slot it's checking.
- * @hide
*/
- @SystemApi
+ @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
public boolean isModemEnabledForSlot(int slotIndex) {
try {
ITelephony telephony = getITelephony();
if (telephony != null) {
return telephony.isModemEnabledForSlot(slotIndex, mContext.getOpPackageName(),
- null);
+ mContext.getAttributionTag());
}
} catch (RemoteException ex) {
Log.e(TAG, "enableModem RemoteException", ex);
@@ -12184,7 +12406,7 @@ public class TelephonyManager {
/**
* The extra used with an {@link #ACTION_NETWORK_COUNTRY_CHANGED} to specify the
- * the country code in ISO 3166 format.
+ * the country code in ISO-3166-1 alpha-2 format.
* <p class="note">
* Retrieve with {@link android.content.Intent#getStringExtra(String)}.
*/
@@ -12278,7 +12500,7 @@ public class TelephonyManager {
try {
ITelephony service = getITelephony();
if (service != null) {
- return service.isMultiSimSupported(getOpPackageName(), getFeatureId());
+ return service.isMultiSimSupported(getOpPackageName(), getAttributionTag());
}
} catch (RemoteException e) {
Log.e(TAG, "isMultiSimSupported RemoteException", e);
@@ -12330,7 +12552,7 @@ public class TelephonyManager {
ITelephony service = getITelephony();
if (service != null) {
return service.doesSwitchMultiSimConfigTriggerReboot(getSubId(),
- getOpPackageName(), getFeatureId());
+ getOpPackageName(), getAttributionTag());
}
} catch (RemoteException e) {
Log.e(TAG, "doesSwitchMultiSimConfigTriggerReboot RemoteException", e);
@@ -12399,7 +12621,6 @@ public class TelephonyManager {
* @throws {@link SecurityException} if the caller is not the system or phone process.
* @hide
*/
- @SystemApi
@TestApi
// TODO: add new permission tag indicating that this is system-only.
public @NonNull List<ApnSetting> getDevicePolicyOverrideApns(@NonNull Context context) {
@@ -12430,7 +12651,6 @@ public class TelephonyManager {
* @throws {@link SecurityException} if the caller is not the system or phone process.
* @hide
*/
- @SystemApi
@TestApi
// TODO: add new permission tag indicating that this is system-only.
public int addDevicePolicyOverrideApn(@NonNull Context context,
@@ -12461,7 +12681,6 @@ public class TelephonyManager {
* @throws {@link SecurityException} if the caller is not the system or phone process.
* @hide
*/
- @SystemApi
@TestApi
// TODO: add new permission tag indicating that this is system-only.
public boolean modifyDevicePolicyOverrideApn(@NonNull Context context, int apnId,
@@ -12514,6 +12733,8 @@ public class TelephonyManager {
*
* @hide
*/
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
public boolean isApnMetered(@ApnType int apnType) {
try {
ITelephony service = getITelephony();
@@ -12603,7 +12824,8 @@ public class TelephonyManager {
* {@hide}
*/
@SystemApi
- public boolean isCurrentSimOperator(@NonNull String mccmnc, @MvnoType int mvnoType,
+ @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
+ public boolean matchesCurrentSimOperator(@NonNull String mccmnc, @MvnoType int mvnoType,
@Nullable String mvnoMatchData) {
try {
if (!mccmnc.equals(getSimOperator())) {
@@ -12882,7 +13104,6 @@ public class TelephonyManager {
*
* @hide
*/
- @SystemApi
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public boolean setAlwaysAllowMmsData(boolean alwaysAllow) {
try {
@@ -13000,6 +13221,175 @@ public class TelephonyManager {
}
/**
+ * Called when userActivity is signalled in the power manager.
+ * This should only be called from system Uid.
+ * @hide
+ */
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
+ public void notifyUserActivity() {
+ try {
+ ITelephony service = getITelephony();
+ if (service != null) {
+ service.userActivity();
+ }
+ } catch (RemoteException e) {
+ // one-way notification, if telephony is not available, it is okay to not throw
+ // exception here.
+ Log.w(TAG, "notifyUserActivity exception: " + e.getMessage());
+ }
+ }
+
+ private static class DeathRecipient implements IBinder.DeathRecipient {
+ @Override
+ public void binderDied() {
+ resetServiceCache();
+ }
+ }
+
+ /**
+ * Reset everything in the service cache; if one handle died then they are
+ * all probably broken.
+ * @hide
+ */
+ private static void resetServiceCache() {
+ synchronized (sCacheLock) {
+ if (sISub != null) {
+ sISub.asBinder().unlinkToDeath(sServiceDeath, 0);
+ sISub = null;
+ SubscriptionManager.clearCaches();
+ }
+ if (sISms != null) {
+ sISms.asBinder().unlinkToDeath(sServiceDeath, 0);
+ sISms = null;
+ }
+ if (sIPhoneSubInfo != null) {
+ sIPhoneSubInfo.asBinder().unlinkToDeath(sServiceDeath, 0);
+ sIPhoneSubInfo = null;
+ }
+ }
+ }
+
+ /**
+ * @hide
+ */
+ static IPhoneSubInfo getSubscriberInfoService() {
+ // Keeps cache disabled until test fixes are checked into AOSP.
+ if (!sServiceHandleCacheEnabled) {
+ return IPhoneSubInfo.Stub.asInterface(
+ TelephonyFrameworkInitializer
+ .getTelephonyServiceManager()
+ .getPhoneSubServiceRegisterer()
+ .get());
+ }
+
+ if (sIPhoneSubInfo == null) {
+ IPhoneSubInfo temp = IPhoneSubInfo.Stub.asInterface(
+ TelephonyFrameworkInitializer
+ .getTelephonyServiceManager()
+ .getPhoneSubServiceRegisterer()
+ .get());
+ synchronized (sCacheLock) {
+ if (sIPhoneSubInfo == null && temp != null) {
+ try {
+ sIPhoneSubInfo = temp;
+ sIPhoneSubInfo.asBinder().linkToDeath(sServiceDeath, 0);
+ } catch (Exception e) {
+ // something has gone horribly wrong
+ sIPhoneSubInfo = null;
+ }
+ }
+ }
+ }
+ return sIPhoneSubInfo;
+ }
+
+ /**
+ * @hide
+ */
+ static ISub getSubscriptionService() {
+ // Keeps cache disabled until test fixes are checked into AOSP.
+ if (!sServiceHandleCacheEnabled) {
+ return ISub.Stub.asInterface(
+ TelephonyFrameworkInitializer
+ .getTelephonyServiceManager()
+ .getSubscriptionServiceRegisterer()
+ .get());
+ }
+
+ if (sISub == null) {
+ ISub temp = ISub.Stub.asInterface(
+ TelephonyFrameworkInitializer
+ .getTelephonyServiceManager()
+ .getSubscriptionServiceRegisterer()
+ .get());
+ synchronized (sCacheLock) {
+ if (sISub == null && temp != null) {
+ try {
+ sISub = temp;
+ sISub.asBinder().linkToDeath(sServiceDeath, 0);
+ } catch (Exception e) {
+ // something has gone horribly wrong
+ sISub = null;
+ }
+ }
+ }
+ }
+ return sISub;
+ }
+
+ /**
+ * @hide
+ */
+ static ISms getSmsService() {
+ // Keeps cache disabled until test fixes are checked into AOSP.
+ if (!sServiceHandleCacheEnabled) {
+ return ISms.Stub.asInterface(
+ TelephonyFrameworkInitializer
+ .getTelephonyServiceManager()
+ .getSmsServiceRegisterer()
+ .get());
+ }
+
+ if (sISms == null) {
+ ISms temp = ISms.Stub.asInterface(
+ TelephonyFrameworkInitializer
+ .getTelephonyServiceManager()
+ .getSmsServiceRegisterer()
+ .get());
+ synchronized (sCacheLock) {
+ if (sISms == null && temp != null) {
+ try {
+ sISms = temp;
+ sISms.asBinder().linkToDeath(sServiceDeath, 0);
+ } catch (Exception e) {
+ // something has gone horribly wrong
+ sISms = null;
+ }
+ }
+ }
+ }
+ return sISms;
+ }
+
+ /**
+ * Disables service handle caching for tests that utilize mock services.
+ * @hide
+ */
+ @VisibleForTesting
+ public static void disableServiceHandleCaching() {
+ sServiceHandleCacheEnabled = false;
+ }
+
+ /**
+ * Reenables service handle caching.
+ * @hide
+ */
+ @VisibleForTesting
+ public static void enableServiceHandleCaching() {
+ sServiceHandleCacheEnabled = true;
+ }
+
+ /**
* Whether device can connect to 5G network when two SIMs are active.
* @hide
* TODO b/153669716: remove or make system API.
diff --git a/telephony/java/android/telephony/TelephonyScanManager.java b/telephony/java/android/telephony/TelephonyScanManager.java
index 3f8fd9d68a4f..e890acb36b48 100644
--- a/telephony/java/android/telephony/TelephonyScanManager.java
+++ b/telephony/java/android/telephony/TelephonyScanManager.java
@@ -18,7 +18,7 @@ package android.telephony;
import static com.android.internal.util.Preconditions.checkNotNull;
-import android.content.Context;
+import android.annotation.Nullable;
import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
@@ -28,7 +28,6 @@ import android.os.Message;
import android.os.Messenger;
import android.os.Parcelable;
import android.os.RemoteException;
-import android.os.ServiceManager;
import android.util.SparseArray;
import com.android.internal.annotations.GuardedBy;
@@ -238,12 +237,14 @@ public final class TelephonyScanManager {
*
* @param request Contains all the RAT with bands/channels that need to be scanned.
* @param callback Returns network scan results or errors.
+ * @param callingPackage The package name of the caller
+ * @param callingFeatureId The feature id inside of the calling package
* @return A NetworkScan obj which contains a callback which can stop the scan.
* @hide
*/
public NetworkScan requestNetworkScan(int subId,
NetworkScanRequest request, Executor executor, NetworkScanCallback callback,
- String callingPackage, String callingFeatureId) {
+ String callingPackage, @Nullable String callingFeatureId) {
try {
final ITelephony telephony = getITelephony();
if (telephony == null) return null;
@@ -282,6 +283,9 @@ public final class TelephonyScanManager {
private ITelephony getITelephony() {
return ITelephony.Stub.asInterface(
- ServiceManager.getService(Context.TELEPHONY_SERVICE));
+ TelephonyFrameworkInitializer
+ .getTelephonyServiceManager()
+ .getTelephonyServiceRegisterer()
+ .get());
}
}
diff --git a/telephony/java/android/telephony/VoLteServiceState.java b/telephony/java/android/telephony/VoLteServiceState.java
index 078059e3dc64..27187e68d5cc 100644
--- a/telephony/java/android/telephony/VoLteServiceState.java
+++ b/telephony/java/android/telephony/VoLteServiceState.java
@@ -53,8 +53,7 @@ public final class VoLteServiceState implements Parcelable {
/**
* Create a new VoLteServiceState from a intent notifier Bundle
*
- * This method is used by PhoneStateIntentReceiver and maybe by
- * external applications.
+ * This method is maybe used by external applications.
*
* @param m Bundle from intent notifier
* @return newly created VoLteServiceState
diff --git a/telephony/java/android/telephony/data/ApnSetting.java b/telephony/java/android/telephony/data/ApnSetting.java
index d44d29f3aefb..e60ae896f9f8 100644
--- a/telephony/java/android/telephony/data/ApnSetting.java
+++ b/telephony/java/android/telephony/data/ApnSetting.java
@@ -300,42 +300,44 @@ public class ApnSetting implements Parcelable {
private static final Map<Integer, String> MVNO_TYPE_INT_MAP;
static {
- APN_TYPE_STRING_MAP = new ArrayMap<String, Integer>();
- APN_TYPE_STRING_MAP.put("*", TYPE_ALL);
- APN_TYPE_STRING_MAP.put("default", TYPE_DEFAULT);
- APN_TYPE_STRING_MAP.put("mms", TYPE_MMS);
- APN_TYPE_STRING_MAP.put("supl", TYPE_SUPL);
- APN_TYPE_STRING_MAP.put("dun", TYPE_DUN);
- APN_TYPE_STRING_MAP.put("hipri", TYPE_HIPRI);
- APN_TYPE_STRING_MAP.put("fota", TYPE_FOTA);
- APN_TYPE_STRING_MAP.put("ims", TYPE_IMS);
- APN_TYPE_STRING_MAP.put("cbs", TYPE_CBS);
- APN_TYPE_STRING_MAP.put("ia", TYPE_IA);
- APN_TYPE_STRING_MAP.put("emergency", TYPE_EMERGENCY);
- APN_TYPE_STRING_MAP.put("mcx", TYPE_MCX);
- APN_TYPE_STRING_MAP.put("xcap", TYPE_XCAP);
- APN_TYPE_INT_MAP = new ArrayMap<Integer, String>();
- APN_TYPE_INT_MAP.put(TYPE_DEFAULT, "default");
- APN_TYPE_INT_MAP.put(TYPE_MMS, "mms");
- APN_TYPE_INT_MAP.put(TYPE_SUPL, "supl");
- APN_TYPE_INT_MAP.put(TYPE_DUN, "dun");
- APN_TYPE_INT_MAP.put(TYPE_HIPRI, "hipri");
- APN_TYPE_INT_MAP.put(TYPE_FOTA, "fota");
- APN_TYPE_INT_MAP.put(TYPE_IMS, "ims");
- APN_TYPE_INT_MAP.put(TYPE_CBS, "cbs");
- APN_TYPE_INT_MAP.put(TYPE_IA, "ia");
- APN_TYPE_INT_MAP.put(TYPE_EMERGENCY, "emergency");
- APN_TYPE_INT_MAP.put(TYPE_MCX, "mcx");
- APN_TYPE_INT_MAP.put(TYPE_XCAP, "xcap");
-
- PROTOCOL_STRING_MAP = new ArrayMap<String, Integer>();
+ APN_TYPE_STRING_MAP = new ArrayMap<>();
+ APN_TYPE_STRING_MAP.put(TYPE_ALL_STRING, TYPE_ALL);
+ APN_TYPE_STRING_MAP.put(TYPE_DEFAULT_STRING, TYPE_DEFAULT);
+ APN_TYPE_STRING_MAP.put(TYPE_MMS_STRING, TYPE_MMS);
+ APN_TYPE_STRING_MAP.put(TYPE_SUPL_STRING, TYPE_SUPL);
+ APN_TYPE_STRING_MAP.put(TYPE_DUN_STRING, TYPE_DUN);
+ APN_TYPE_STRING_MAP.put(TYPE_HIPRI_STRING, TYPE_HIPRI);
+ APN_TYPE_STRING_MAP.put(TYPE_FOTA_STRING, TYPE_FOTA);
+ APN_TYPE_STRING_MAP.put(TYPE_IMS_STRING, TYPE_IMS);
+ APN_TYPE_STRING_MAP.put(TYPE_CBS_STRING, TYPE_CBS);
+ APN_TYPE_STRING_MAP.put(TYPE_IA_STRING, TYPE_IA);
+ APN_TYPE_STRING_MAP.put(TYPE_EMERGENCY_STRING, TYPE_EMERGENCY);
+ APN_TYPE_STRING_MAP.put(TYPE_MCX_STRING, TYPE_MCX);
+ APN_TYPE_STRING_MAP.put(TYPE_XCAP_STRING, TYPE_XCAP);
+
+ APN_TYPE_INT_MAP = new ArrayMap<>();
+ APN_TYPE_INT_MAP.put(TYPE_DEFAULT, TYPE_DEFAULT_STRING);
+ APN_TYPE_INT_MAP.put(TYPE_MMS, TYPE_MMS_STRING);
+ APN_TYPE_INT_MAP.put(TYPE_SUPL, TYPE_SUPL_STRING);
+ APN_TYPE_INT_MAP.put(TYPE_DUN, TYPE_DUN_STRING);
+ APN_TYPE_INT_MAP.put(TYPE_HIPRI, TYPE_HIPRI_STRING);
+ APN_TYPE_INT_MAP.put(TYPE_FOTA, TYPE_FOTA_STRING);
+ APN_TYPE_INT_MAP.put(TYPE_IMS, TYPE_IMS_STRING);
+ APN_TYPE_INT_MAP.put(TYPE_CBS, TYPE_CBS_STRING);
+ APN_TYPE_INT_MAP.put(TYPE_IA, TYPE_IA_STRING);
+ APN_TYPE_INT_MAP.put(TYPE_EMERGENCY, TYPE_EMERGENCY_STRING);
+ APN_TYPE_INT_MAP.put(TYPE_MCX, TYPE_MCX_STRING);
+ APN_TYPE_INT_MAP.put(TYPE_XCAP, TYPE_XCAP_STRING);
+
+ PROTOCOL_STRING_MAP = new ArrayMap<>();
PROTOCOL_STRING_MAP.put("IP", PROTOCOL_IP);
PROTOCOL_STRING_MAP.put("IPV6", PROTOCOL_IPV6);
PROTOCOL_STRING_MAP.put("IPV4V6", PROTOCOL_IPV4V6);
PROTOCOL_STRING_MAP.put("PPP", PROTOCOL_PPP);
PROTOCOL_STRING_MAP.put("NON-IP", PROTOCOL_NON_IP);
PROTOCOL_STRING_MAP.put("UNSTRUCTURED", PROTOCOL_UNSTRUCTURED);
- PROTOCOL_INT_MAP = new ArrayMap<Integer, String>();
+
+ PROTOCOL_INT_MAP = new ArrayMap<>();
PROTOCOL_INT_MAP.put(PROTOCOL_IP, "IP");
PROTOCOL_INT_MAP.put(PROTOCOL_IPV6, "IPV6");
PROTOCOL_INT_MAP.put(PROTOCOL_IPV4V6, "IPV4V6");
@@ -343,12 +345,13 @@ public class ApnSetting implements Parcelable {
PROTOCOL_INT_MAP.put(PROTOCOL_NON_IP, "NON-IP");
PROTOCOL_INT_MAP.put(PROTOCOL_UNSTRUCTURED, "UNSTRUCTURED");
- MVNO_TYPE_STRING_MAP = new ArrayMap<String, Integer>();
+ MVNO_TYPE_STRING_MAP = new ArrayMap<>();
MVNO_TYPE_STRING_MAP.put("spn", MVNO_TYPE_SPN);
MVNO_TYPE_STRING_MAP.put("imsi", MVNO_TYPE_IMSI);
MVNO_TYPE_STRING_MAP.put("gid", MVNO_TYPE_GID);
MVNO_TYPE_STRING_MAP.put("iccid", MVNO_TYPE_ICCID);
- MVNO_TYPE_INT_MAP = new ArrayMap<Integer, String>();
+
+ MVNO_TYPE_INT_MAP = new ArrayMap<>();
MVNO_TYPE_INT_MAP.put(MVNO_TYPE_SPN, "spn");
MVNO_TYPE_INT_MAP.put(MVNO_TYPE_IMSI, "imsi");
MVNO_TYPE_INT_MAP.put(MVNO_TYPE_GID, "gid");
@@ -2054,7 +2057,7 @@ public class ApnSetting implements Parcelable {
/**
* Sets skip464xlat flag for this APN.
*
- * @param skip464xlat skip464xlat for this APN
+ * @param skip464xlat skip464xlat for this APN.
* @hide
*/
public Builder setSkip464Xlat(@Skip464XlatStatus int skip464xlat) {
diff --git a/telephony/java/android/telephony/euicc/EuiccCardManager.java b/telephony/java/android/telephony/euicc/EuiccCardManager.java
index e52be44d9797..e1aec0a593b4 100644
--- a/telephony/java/android/telephony/euicc/EuiccCardManager.java
+++ b/telephony/java/android/telephony/euicc/EuiccCardManager.java
@@ -22,8 +22,8 @@ import android.annotation.SystemApi;
import android.content.Context;
import android.os.Binder;
import android.os.RemoteException;
-import android.os.ServiceManager;
import android.service.euicc.EuiccProfileInfo;
+import android.telephony.TelephonyFrameworkInitializer;
import android.util.Log;
import com.android.internal.telephony.euicc.IAuthenticateServerCallback;
@@ -149,7 +149,10 @@ public class EuiccCardManager {
private IEuiccCardController getIEuiccCardController() {
return IEuiccCardController.Stub.asInterface(
- ServiceManager.getService("euicc_card_controller"));
+ TelephonyFrameworkInitializer
+ .getTelephonyServiceManager()
+ .getEuiccCardControllerServiceRegisterer()
+ .get());
}
/**
diff --git a/telephony/java/android/telephony/euicc/EuiccManager.java b/telephony/java/android/telephony/euicc/EuiccManager.java
index 5500d635d2ff..2edb564cc950 100644
--- a/telephony/java/android/telephony/euicc/EuiccManager.java
+++ b/telephony/java/android/telephony/euicc/EuiccManager.java
@@ -30,7 +30,7 @@ import android.content.IntentSender;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.RemoteException;
-import android.os.ServiceManager;
+import android.telephony.TelephonyFrameworkInitializer;
import android.telephony.TelephonyManager;
import android.telephony.euicc.EuiccCardManager.ResetOption;
@@ -552,7 +552,7 @@ public class EuiccManager {
/**
* List of OperationCode corresponding to {@link #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE}'s
- * value, an integer. @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * value, an integer. @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*
* @hide
*/
@@ -575,44 +575,44 @@ public class EuiccManager {
/**
* Internal system error.
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int OPERATION_SYSTEM = 1;
/**
* SIM slot error. Failed to switch slot, failed to access the physical slot etc.
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int OPERATION_SIM_SLOT = 2;
/**
* eUICC card error.
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int OPERATION_EUICC_CARD = 3;
/**
* Generic switching profile error
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int OPERATION_SWITCH = 4;
/**
* Download profile error.
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int OPERATION_DOWNLOAD = 5;
/**
* Subscription's metadata error
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int OPERATION_METADATA = 6;
/**
* eUICC returned an error defined in GSMA (SGP.22 v2.2) while running one of the ES10x
* functions.
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int OPERATION_EUICC_GSMA = 7;
@@ -620,13 +620,13 @@ public class EuiccManager {
* The exception of failing to execute an APDU command. It can be caused by an error
* happening on opening the basic or logical channel, or the response of the APDU command is
* not success (0x9000).
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int OPERATION_APDU = 8;
/**
* SMDX(SMDP/SMDS) error
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int OPERATION_SMDX = 9;
@@ -655,19 +655,19 @@ public class EuiccManager {
* Thus the integer stored in {@link #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE} is
* 0xA8B1051(176885841)
*
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int OPERATION_SMDX_SUBJECT_REASON_CODE = 10;
/**
* HTTP error
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int OPERATION_HTTP = 11;
/**
* List of ErrorCode corresponding to {@link #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE}
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
* @hide
*/
@Retention(RetentionPolicy.SOURCE)
@@ -695,56 +695,56 @@ public class EuiccManager {
/**
* Operation such as downloading/switching to another profile failed due to device being
* carrier locked.
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int ERROR_CARRIER_LOCKED = 10000;
/**
* The activation code(SGP.22 v2.2 section[4.1]) is invalid.
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int ERROR_INVALID_ACTIVATION_CODE = 10001;
/**
* The confirmation code(SGP.22 v2.2 section[4.7]) is invalid.
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int ERROR_INVALID_CONFIRMATION_CODE = 10002;
/**
* The profile's carrier is incompatible with the LPA.
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int ERROR_INCOMPATIBLE_CARRIER = 10003;
/**
* There is no more space available on the eUICC for new profiles.
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int ERROR_EUICC_INSUFFICIENT_MEMORY = 10004;
/**
* Timed out while waiting for an operation to complete. i.e restart, disable,
* switch reset etc.
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int ERROR_TIME_OUT = 10005;
/**
* eUICC is missing or defective on the device.
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int ERROR_EUICC_MISSING = 10006;
/**
* The eUICC card(hardware) version is incompatible with the software
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int ERROR_UNSUPPORTED_VERSION = 10007;
/**
* No SIM card is available in the device.
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int ERROR_SIM_MISSING = 10008;
@@ -754,52 +754,52 @@ public class EuiccManager {
* 2. GSMA(.22 v2.2) Profile Install Result - installFailedDueToDataMismatch
* 3. operation was interrupted
* 4. SIMalliance error in PEStatus(SGP.22 v2.2 section 2.5.6.1)
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int ERROR_INSTALL_PROFILE = 10009;
/**
* Failed to load profile onto eUICC due to Profile Poicly Rules.
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int ERROR_DISALLOWED_BY_PPR = 10010;
/**
* Address is missing e.g SMDS/SMDP address is missing.
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int ERROR_ADDRESS_MISSING = 10011;
/**
* Certificate needed for authentication is not valid or missing. E.g SMDP/SMDS authentication
* failed.
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int ERROR_CERTIFICATE_ERROR = 10012;
/**
* No profiles available.
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int ERROR_NO_PROFILES_AVAILABLE = 10013;
/**
* Failure to create a connection.
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int ERROR_CONNECTION_ERROR = 10014;
/**
* Response format is invalid. e.g SMDP/SMDS response contains invalid json, header or/and ASN1.
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int ERROR_INVALID_RESPONSE = 10015;
/**
* The operation is currently busy, try again later.
- * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE
+ * @see #EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE for details
*/
public static final int ERROR_OPERATION_BUSY = 10016;
@@ -1412,6 +1412,10 @@ public class EuiccManager {
}
private static IEuiccController getIEuiccController() {
- return IEuiccController.Stub.asInterface(ServiceManager.getService("econtroller"));
+ return IEuiccController.Stub.asInterface(
+ TelephonyFrameworkInitializer
+ .getTelephonyServiceManager()
+ .getEuiccControllerService()
+ .get());
}
}
diff --git a/telephony/java/android/telephony/ims/ImsCallProfile.java b/telephony/java/android/telephony/ims/ImsCallProfile.java
index 1e8fdceac1e6..f31fcf4050ea 100644
--- a/telephony/java/android/telephony/ims/ImsCallProfile.java
+++ b/telephony/java/android/telephony/ims/ImsCallProfile.java
@@ -300,6 +300,14 @@ public final class ImsCallProfile implements Parcelable {
"android.telephony.ims.extra.ADDITIONAL_SIP_INVITE_FIELDS";
/**
+ * CallDisconnectCause: Specify call disconnect cause. This extra should be a code
+ * corresponding to ImsReasonInfo and should only be populated in the case that the
+ * call has already been missed
+ */
+ public static final String EXTRA_CALL_DISCONNECT_CAUSE =
+ "android.telephony.ims.extra.CALL_DISCONNECT_CAUSE";
+
+ /**
* Extra key which the RIL can use to indicate the radio technology used for a call.
* Valid values are:
* {@link android.telephony.ServiceState#RIL_RADIO_TECHNOLOGY_LTE},
@@ -338,6 +346,14 @@ public final class ImsCallProfile implements Parcelable {
@Deprecated
public static final String EXTRA_CALL_RAT_TYPE_ALT = "callRadioTech";
+ /**
+ * String extra property containing forwarded numbers associated with the current connection
+ * for an IMS call. The value is string array, and it can include multiple numbers, and
+ * the array values are expected E164 (e.g. +1 (650) 253-0000) format.
+ */
+ public static final String EXTRA_FORWARDED_NUMBER =
+ "android.telephony.ims.extra.FORWARDED_NUMBER";
+
/** @hide */
public int mServiceType;
/** @hide */
@@ -638,7 +654,7 @@ public final class ImsCallProfile implements Parcelable {
return "{ serviceType=" + mServiceType
+ ", callType=" + mCallType
+ ", restrictCause=" + mRestrictCause
- + ", mediaProfile=" + mMediaProfile.toString()
+ + ", mediaProfile=" + (mMediaProfile != null ? mMediaProfile.toString() : "null")
+ ", emergencyServiceCategories=" + mEmergencyServiceCategories
+ ", emergencyUrns=" + mEmergencyUrns
+ ", emergencyCallRouting=" + mEmergencyCallRouting
diff --git a/telephony/java/android/telephony/ims/ImsMmTelManager.java b/telephony/java/android/telephony/ims/ImsMmTelManager.java
index c274ec49cb2e..f6c14e67306b 100644
--- a/telephony/java/android/telephony/ims/ImsMmTelManager.java
+++ b/telephony/java/android/telephony/ims/ImsMmTelManager.java
@@ -26,14 +26,13 @@ import android.annotation.SuppressAutoDoc;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.annotation.TestApi;
-import android.content.Context;
import android.os.Binder;
import android.os.RemoteException;
-import android.os.ServiceManager;
import android.os.ServiceSpecificException;
import android.telephony.AccessNetworkConstants;
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyFrameworkInitializer;
import android.telephony.ims.aidl.IImsCapabilityCallback;
import android.telephony.ims.feature.ImsFeature;
import android.telephony.ims.feature.MmTelFeature;
@@ -1371,7 +1370,10 @@ public class ImsMmTelManager implements RegistrationManager {
private static ITelephony getITelephony() {
ITelephony binder = ITelephony.Stub.asInterface(
- ServiceManager.getService(Context.TELEPHONY_SERVICE));
+ TelephonyFrameworkInitializer
+ .getTelephonyServiceManager()
+ .getTelephonyServiceRegisterer()
+ .get());
return binder;
}
}
diff --git a/telephony/java/android/telephony/ims/ImsRcsManager.java b/telephony/java/android/telephony/ims/ImsRcsManager.java
index 16e54833abdf..94407f1dcd3a 100644
--- a/telephony/java/android/telephony/ims/ImsRcsManager.java
+++ b/telephony/java/android/telephony/ims/ImsRcsManager.java
@@ -26,11 +26,11 @@ import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.os.RemoteException;
-import android.os.ServiceManager;
import android.provider.Settings;
import android.telephony.AccessNetworkConstants;
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyFrameworkInitializer;
import android.telephony.ims.aidl.IImsCapabilityCallback;
import android.telephony.ims.aidl.IImsRcsController;
import android.telephony.ims.feature.ImsFeature;
@@ -447,7 +447,10 @@ public class ImsRcsManager {
}
private IImsRcsController getIImsRcsController() {
- IBinder binder = ServiceManager.getService(Context.TELEPHONY_IMS_SERVICE);
+ IBinder binder = TelephonyFrameworkInitializer
+ .getTelephonyServiceManager()
+ .getTelephonyImsServiceRegisterer()
+ .get();
return IImsRcsController.Stub.asInterface(binder);
}
}
diff --git a/telephony/java/android/telephony/ims/ProvisioningManager.java b/telephony/java/android/telephony/ims/ProvisioningManager.java
index ff79dfa8099a..2a073a1f1d81 100644
--- a/telephony/java/android/telephony/ims/ProvisioningManager.java
+++ b/telephony/java/android/telephony/ims/ProvisioningManager.java
@@ -25,13 +25,12 @@ import android.annotation.StringDef;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.annotation.WorkerThread;
-import android.content.Context;
import android.os.Binder;
import android.os.RemoteException;
-import android.os.ServiceManager;
import android.os.ServiceSpecificException;
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyFrameworkInitializer;
import android.telephony.ims.aidl.IImsConfigCallback;
import android.telephony.ims.feature.MmTelFeature;
import android.telephony.ims.feature.RcsFeature;
@@ -1212,7 +1211,10 @@ public class ProvisioningManager {
private static ITelephony getITelephony() {
ITelephony binder = ITelephony.Stub.asInterface(
- ServiceManager.getService(Context.TELEPHONY_SERVICE));
+ TelephonyFrameworkInitializer
+ .getTelephonyServiceManager()
+ .getTelephonyServiceRegisterer()
+ .get());
if (binder == null) {
throw new RuntimeException("Could not find Telephony Service.");
}
diff --git a/telephony/java/android/telephony/ims/RcsUceAdapter.java b/telephony/java/android/telephony/ims/RcsUceAdapter.java
index 27456f12302a..a427d056f915 100644
--- a/telephony/java/android/telephony/ims/RcsUceAdapter.java
+++ b/telephony/java/android/telephony/ims/RcsUceAdapter.java
@@ -28,7 +28,7 @@ import android.net.Uri;
import android.os.Binder;
import android.os.IBinder;
import android.os.RemoteException;
-import android.os.ServiceManager;
+import android.telephony.TelephonyFrameworkInitializer;
import android.telephony.ims.aidl.IImsRcsController;
import android.telephony.ims.aidl.IRcsUceControllerCallback;
import android.telephony.ims.aidl.IRcsUcePublishStateCallback;
@@ -343,7 +343,7 @@ public class RcsUceAdapter {
try {
imsRcsController.requestCapabilities(mSubId, mContext.getOpPackageName(),
- null /*featureId*/, contactNumbers, internalCallback);
+ mContext.getAttributionTag(), contactNumbers, internalCallback);
} catch (RemoteException e) {
Log.e(TAG, "Error calling IImsRcsController#requestCapabilities", e);
throw new ImsException("Remote IMS Service is not available",
@@ -491,7 +491,7 @@ public class RcsUceAdapter {
try {
// Telephony.SimInfo#IMS_RCS_UCE_ENABLED can also be used to listen to changes to this.
return imsRcsController.isUceSettingEnabled(mSubId, mContext.getOpPackageName(),
- null /*featureId*/);
+ mContext.getAttributionTag());
} catch (RemoteException e) {
Log.e(TAG, "Error calling IImsRcsController#isUceSettingEnabled", e);
throw new ImsException("Remote IMS Service is not available",
@@ -539,7 +539,10 @@ public class RcsUceAdapter {
}
private IImsRcsController getIImsRcsController() {
- IBinder binder = ServiceManager.getService(Context.TELEPHONY_IMS_SERVICE);
+ IBinder binder = TelephonyFrameworkInitializer
+ .getTelephonyServiceManager()
+ .getTelephonyImsServiceRegisterer()
+ .get();
return IImsRcsController.Stub.asInterface(binder);
}
}
diff --git a/telephony/java/android/telephony/ims/feature/MmTelFeature.java b/telephony/java/android/telephony/ims/feature/MmTelFeature.java
index 5ee6ec957b50..01d468cb53f6 100644
--- a/telephony/java/android/telephony/ims/feature/MmTelFeature.java
+++ b/telephony/java/android/telephony/ims/feature/MmTelFeature.java
@@ -253,10 +253,7 @@ public class MmTelFeature extends ImsFeature {
super(capabilities);
}
- /**
- * @hide
- */
- @SystemApi @TestApi
+ /** @hide */
@IntDef(flag = true,
value = {
CAPABILITY_TYPE_VOICE,
@@ -387,10 +384,7 @@ public class MmTelFeature extends ImsFeature {
@SystemApi @TestApi
public static final int PROCESS_CALL_CSFB = 1;
- /**
- * @hide
- */
- @SystemApi @TestApi
+ /** @hide */
@IntDef(flag = true,
value = {
PROCESS_CALL_IMS,
diff --git a/telephony/java/android/telephony/ims/stub/ImsUtImplBase.java b/telephony/java/android/telephony/ims/stub/ImsUtImplBase.java
index 5e0a3d83ffb7..8564f7affd6d 100644
--- a/telephony/java/android/telephony/ims/stub/ImsUtImplBase.java
+++ b/telephony/java/android/telephony/ims/stub/ImsUtImplBase.java
@@ -44,52 +44,62 @@ import java.lang.annotation.RetentionPolicy;
public class ImsUtImplBase {
/**
* Bar all incoming calls. (See 3GPP TS 24.611)
+ * @hide
*/
public static final int CALL_BARRING_ALL_INCOMING = 1;
/**
* Bar all outgoing calls. (See 3GPP TS 24.611)
+ * @hide
*/
public static final int CALL_BARRING_ALL_OUTGOING = 2;
/**
* Bar all outgoing international calls. (See 3GPP TS 24.611)
+ * @hide
*/
public static final int CALL_BARRING_OUTGOING_INTL = 3;
/**
* Bar all outgoing international calls, excluding those to the home PLMN country
* (See 3GPP TS 24.611)
+ * @hide
*/
public static final int CALL_BARRING_OUTGOING_INTL_EXCL_HOME = 4;
/**
* Bar all incoming calls when roaming (See 3GPP TS 24.611)
+ * @hide
*/
public static final int CALL_BLOCKING_INCOMING_WHEN_ROAMING = 5;
/**
* Enable Anonymous Communication Rejection (See 3GPP TS 24.611)
+ * @hide
*/
public static final int CALL_BARRING_ANONYMOUS_INCOMING = 6;
/**
* Bar all incoming and outgoing calls. (See 3GPP TS 24.611)
+ * @hide
*/
public static final int CALL_BARRING_ALL = 7;
/**
* Bar all outgoing service requests, including calls. (See 3GPP TS 24.611)
+ * @hide
*/
public static final int CALL_BARRING_OUTGOING_ALL_SERVICES = 8;
/**
* Bar all incoming service requests, including calls. (See 3GPP TS 24.611)
+ * @hide
*/
public static final int CALL_BARRING_INCOMING_ALL_SERVICES = 9;
/**
* Bar specific incoming calls. (See 3GPP TS 24.611)
+ * @hide
*/
public static final int CALL_BARRING_SPECIFIC_INCOMING_CALLS = 10;
@@ -104,6 +114,7 @@ public class ImsUtImplBase {
/**
* Constant used to denote an invalid return value.
+ * @hide
*/
public static final int INVALID_RESULT = -1;
diff --git a/telephony/java/com/android/internal/telephony/ISms.aidl b/telephony/java/com/android/internal/telephony/ISms.aidl
index 88da3c94748b..9ec3c6716a29 100644
--- a/telephony/java/com/android/internal/telephony/ISms.aidl
+++ b/telephony/java/com/android/internal/telephony/ISms.aidl
@@ -117,10 +117,13 @@ interface ISms {
* be automatically persisted in the SMS db. It only affects messages sent
* by a non-default SMS app. Currently only the carrier app can set this
* parameter to false to skip auto message persistence.
+ * @param messageId An id that uniquely identifies the message requested to be sent.
+ * Used for logging and diagnostics purposes. The id may be 0.
*/
void sendTextForSubscriber(in int subId, String callingPkg, String callingAttributionTag,
in String destAddr, in String scAddr, in String text, in PendingIntent sentIntent,
- in PendingIntent deliveryIntent, in boolean persistMessageForNonDefaultSmsApp);
+ in PendingIntent deliveryIntent, in boolean persistMessageForNonDefaultSmsApp,
+ in long messageId);
/**
* Send an SMS with options using Subscription Id.
@@ -215,11 +218,14 @@ interface ISms {
* be automatically persisted in the SMS db. It only affects messages sent
* by a non-default SMS app. Currently only the carrier app can set this
* parameter to false to skip auto message persistence.
+ * @param messageId An id that uniquely identifies the message requested to be sent.
+ * Used for logging and diagnostics purposes. The id may be 0.
*/
void sendMultipartTextForSubscriber(in int subId, String callingPkg,
String callingAttributionTag, in String destinationAddress, in String scAddress,
in List<String> parts, in List<PendingIntent> sentIntents,
- in List<PendingIntent> deliveryIntents, in boolean persistMessageForNonDefaultSmsApp);
+ in List<PendingIntent> deliveryIntents, in boolean persistMessageForNonDefaultSmsApp,
+ in long messageId);
/**
* Send a multi-part text based SMS with options using Subscription Id.
@@ -557,4 +563,14 @@ interface ISms {
* @return capacity of ICC
*/
int getSmsCapacityOnIccForSubscriber(int subId);
+
+ /**
+ * Reset all cell broadcast ranges. Previously enabled ranges will become invalid after this.
+ *
+ * @param subId Subscription index
+ * @return {@code true} if succeeded, otherwise {@code false}.
+ *
+ * @hide
+ */
+ boolean resetAllCellBroadcastRanges(int subId);
}
diff --git a/telephony/java/com/android/internal/telephony/ISmsImplBase.java b/telephony/java/com/android/internal/telephony/ISmsImplBase.java
index 51af6de78627..c361d5bec097 100644
--- a/telephony/java/com/android/internal/telephony/ISmsImplBase.java
+++ b/telephony/java/com/android/internal/telephony/ISmsImplBase.java
@@ -54,7 +54,8 @@ public class ISmsImplBase extends ISms.Stub {
@Override
public void sendTextForSubscriber(int subId, String callingPkg, String callingAttributionTag,
String destAddr, String scAddr, String text, PendingIntent sentIntent,
- PendingIntent deliveryIntent, boolean persistMessageForNonDefaultSmsApp) {
+ PendingIntent deliveryIntent, boolean persistMessageForNonDefaultSmsApp,
+ long messageId) {
throw new UnsupportedOperationException();
}
@@ -77,7 +78,8 @@ public class ISmsImplBase extends ISms.Stub {
public void sendMultipartTextForSubscriber(int subId, String callingPkg,
String callingAttributionTag, String destinationAddress, String scAddress,
List<String> parts, List<PendingIntent> sentIntents,
- List<PendingIntent> deliveryIntents, boolean persistMessageForNonDefaultSmsApp) {
+ List<PendingIntent> deliveryIntents, boolean persistMessageForNonDefaultSmsApp,
+ long messageId) {
throw new UnsupportedOperationException();
}
@@ -210,4 +212,9 @@ public class ISmsImplBase extends ISms.Stub {
public int getSmsCapacityOnIccForSubscriber(int subId) {
throw new UnsupportedOperationException();
}
+
+ @Override
+ public boolean resetAllCellBroadcastRanges(int subId) {
+ throw new UnsupportedOperationException();
+ }
}
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index 99144ca8cb5b..ae1b5c1b50bd 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -2274,6 +2274,26 @@ interface ITelephony {
int changeIccLockPassword(int subId, String oldPassword, String newPassword);
/**
+ * Request for receiving user activity notification
+ */
+ oneway void requestUserActivityNotification();
+
+ /**
+ * Called when userActivity is signalled in the power manager.
+ * This is safe to call from any thread, with any window manager locks held or not.
+ */
+ oneway void userActivity();
+
+ /**
+ * Get the user manual network selection.
+ * Return empty string if in automatic selection.
+ *
+ * @param subId the id of the subscription
+ * @return operatorinfo on success
+ */
+ String getManualNetworkSelectionPlmn(int subId);
+
+ /**
* Whether device can connect to 5G network when two SIMs are active.
*/
boolean canConnectTo5GInDsdsMode();
diff --git a/telephony/java/com/android/internal/telephony/PhoneConstants.java b/telephony/java/com/android/internal/telephony/PhoneConstants.java
index db9fdf54852d..151187c5071f 100644
--- a/telephony/java/com/android/internal/telephony/PhoneConstants.java
+++ b/telephony/java/com/android/internal/telephony/PhoneConstants.java
@@ -37,12 +37,9 @@ public class PhoneConstants {
@UnsupportedAppUsage(implicitMember =
"values()[Lcom/android/internal/telephony/PhoneConstants$State;")
public enum State {
- @UnsupportedAppUsage
- IDLE,
- @UnsupportedAppUsage
- RINGING,
- @UnsupportedAppUsage
- OFFHOOK;
+ @UnsupportedAppUsage IDLE,
+ @UnsupportedAppUsage RINGING,
+ @UnsupportedAppUsage OFFHOOK;
};
/**
diff --git a/telephony/java/com/android/internal/telephony/SmsMessageBase.java b/telephony/java/com/android/internal/telephony/SmsMessageBase.java
index f21f8889fedb..084882b10c9b 100644
--- a/telephony/java/com/android/internal/telephony/SmsMessageBase.java
+++ b/telephony/java/com/android/internal/telephony/SmsMessageBase.java
@@ -34,15 +34,10 @@ import java.util.regex.Pattern;
* {@hide}
*/
public abstract class SmsMessageBase {
-
// Copied from Telephony.Mms.NAME_ADDR_EMAIL_PATTERN
public static final Pattern NAME_ADDR_EMAIL_PATTERN =
Pattern.compile("\\s*(\"[^\"]*\"|[^<>\"]+)\\s*<([^<>]+)>\\s*");
- @UnsupportedAppUsage
- public SmsMessageBase() {
- }
-
/** {@hide} The address of the SMSC. May be null */
@UnsupportedAppUsage
protected String mScAddress;
@@ -112,6 +107,10 @@ public abstract class SmsMessageBase {
@UnsupportedAppUsage
public int mMessageRef;
+ @UnsupportedAppUsage
+ public SmsMessageBase() {
+ }
+
// TODO(): This class is duplicated in SmsMessage.java. Refactor accordingly.
public static abstract class SubmitPduBase {
@UnsupportedAppUsage
diff --git a/telephony/java/com/android/internal/telephony/TelephonyIntents.java b/telephony/java/com/android/internal/telephony/TelephonyIntents.java
index 4dda066b4d18..d41a6c889afb 100644
--- a/telephony/java/com/android/internal/telephony/TelephonyIntents.java
+++ b/telephony/java/com/android/internal/telephony/TelephonyIntents.java
@@ -18,6 +18,7 @@ package com.android.internal.telephony;
import android.content.Intent;
import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
import android.telephony.ims.ImsManager;
/**
@@ -100,7 +101,7 @@ public class TelephonyIntents {
* by the system.
*/
public static final String ACTION_EMERGENCY_CALLBACK_MODE_CHANGED
- = "android.intent.action.EMERGENCY_CALLBACK_MODE_CHANGED";
+ = TelephonyManager.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED;
/**
* <p>Broadcast Action: The emergency call state is changed.
@@ -121,33 +122,7 @@ public class TelephonyIntents {
* by the system.
*/
public static final String ACTION_EMERGENCY_CALL_STATE_CHANGED
- = "android.intent.action.EMERGENCY_CALL_STATE_CHANGED";
-
- /**
- * Broadcast Action: The phone's signal strength has changed. The intent will have the
- * following extra values:</p>
- * <ul>
- * <li><em>phoneName</em> - A string version of the phone name.</li>
- * <li><em>asu</em> - A numeric value for the signal strength.
- * An ASU is 0-31 or -1 if unknown (for GSM, dBm = -113 - 2 * asu).
- * The following special values are defined:
- * <ul><li>0 means "-113 dBm or less".</li><li>31 means "-51 dBm or greater".</li></ul>
- * </li>
- * </ul>
- *
- * <p class="note">
- * You can <em>not</em> receive this through components declared
- * in manifests, only by exlicitly registering for it with
- * {@link android.content.Context#registerReceiver(android.content.BroadcastReceiver,
- * android.content.IntentFilter) Context.registerReceiver()}.
- *
- * <p class="note">
- * Requires the READ_PHONE_STATE permission.
- *
- * <p class="note">This is a protected intent that can only be sent
- * by the system.
- */
- public static final String ACTION_SIGNAL_STRENGTH_CHANGED = "android.intent.action.SIG_STR";
+ = TelephonyManager.ACTION_EMERGENCY_CALL_STATE_CHANGED;
/**
@@ -215,7 +190,7 @@ public class TelephonyIntents {
* by the system.
*/
public static final String ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS
- = "com.android.internal.intent.action.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS";
+ = TelephonyManager.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS;
/**
* <p>Broadcast Action: Indicates that the action is forbidden by network.
@@ -237,37 +212,6 @@ public class TelephonyIntents {
public static final String SECRET_CODE_ACTION = "android.provider.Telephony.SECRET_CODE";
/**
- * Broadcast Action: The Service Provider string(s) have been updated. Activities or
- * services that use these strings should update their display.
- * The intent will have the following extra values:</p>
- *
- * <dl>
- * <dt>showPlmn</dt><dd>Boolean that indicates whether the PLMN should be shown.</dd>
- * <dt>plmn</dt><dd>The operator name of the registered network, as a string.</dd>
- * <dt>showSpn</dt><dd>Boolean that indicates whether the SPN should be shown.</dd>
- * <dt>spn</dt><dd>The service provider name, as a string.</dd>
- * </dl>
- *
- * Note that <em>showPlmn</em> may indicate that <em>plmn</em> should be displayed, even
- * though the value for <em>plmn</em> is null. This can happen, for example, if the phone
- * has not registered to a network yet. In this case the receiver may substitute an
- * appropriate placeholder string (eg, "No service").
- *
- * It is recommended to display <em>plmn</em> before / above <em>spn</em> if
- * both are displayed.
- *
- * <p>Note: this is a protected intent that can only be sent by the system.
- */
- public static final String SPN_STRINGS_UPDATED_ACTION =
- "android.provider.Telephony.SPN_STRINGS_UPDATED";
-
- public static final String EXTRA_SHOW_PLMN = "showPlmn";
- public static final String EXTRA_PLMN = "plmn";
- public static final String EXTRA_SHOW_SPN = "showSpn";
- public static final String EXTRA_SPN = "spn";
- public static final String EXTRA_DATA_SPN = "spnData";
-
- /**
* <p>Broadcast Action: It indicates one column of a subinfo record has been changed
* <p class="note">This is a protected intent that can only be sent
* by the system.
@@ -304,7 +248,7 @@ public class TelephonyIntents {
* </ul>
*/
public static final String ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED
- = "android.intent.action.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED";
+ = TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED;
/**
* Broadcast Action: The default voice subscription has changed. This has the following
@@ -314,7 +258,7 @@ public class TelephonyIntents {
* </ul>
*/
public static final String ACTION_DEFAULT_VOICE_SUBSCRIPTION_CHANGED
- = "android.intent.action.ACTION_DEFAULT_VOICE_SUBSCRIPTION_CHANGED";
+ = TelephonyManager.ACTION_DEFAULT_VOICE_SUBSCRIPTION_CHANGED;
/**
* Broadcast Action: The default sms subscription has changed. This has the following
@@ -354,7 +298,7 @@ public class TelephonyIntents {
* Broadcast action to trigger CI OMA-DM Session.
*/
public static final String ACTION_REQUEST_OMADM_CONFIGURATION_UPDATE =
- "com.android.omadm.service.CONFIGURATION_UPDATE";
+ TelephonyManager.ACTION_REQUEST_OMADM_CONFIGURATION_UPDATE;
/**
* Broadcast action to trigger the Carrier Certificate download.
@@ -373,16 +317,8 @@ public class TelephonyIntents {
"com.android.internal.telephony.ACTION_LINE1_NUMBER_ERROR_DETECTED";
/**
- * Broadcast action to notify radio bug.
- *
- * Requires the READ_PRIVILEGED_PHONE_STATE permission.
- *
- * @hide
+ * Broadcast sent when a user activity is detected.
*/
- public static final String ACTION_REPORT_RADIO_BUG =
- "com.android.internal.telephony.ACTION_REPORT_RADIO_BUG";
-
- // ACTION_REPORT_RADIO_BUG extra keys
- public static final String EXTRA_SLOT_ID = "slotId";
- public static final String EXTRA_RADIO_BUG_TYPE = "radioBugType";
+ public static final String ACTION_USER_ACTIVITY_NOTIFICATION =
+ "android.intent.action.USER_ACTIVITY_NOTIFICATION";
}
diff --git a/telephony/java/com/android/internal/telephony/cdma/UserData.java b/telephony/java/com/android/internal/telephony/cdma/UserData.java
index d7e296800a62..524cb0ceadd2 100644
--- a/telephony/java/com/android/internal/telephony/cdma/UserData.java
+++ b/telephony/java/com/android/internal/telephony/cdma/UserData.java
@@ -24,10 +24,6 @@ import com.android.internal.util.HexDump;
public class UserData {
- @UnsupportedAppUsage
- public UserData() {
- }
-
/**
* User data encoding types.
* (See 3GPP2 C.R1001-F, v1.0, table 9.1-1)
@@ -107,6 +103,10 @@ public class UserData {
charToAscii.put('\r', ASCII_CR_INDEX);
}
+ @UnsupportedAppUsage
+ public UserData() {
+ }
+
/*
* TODO(cleanup): Move this very generic functionality somewhere
* more general.
diff --git a/telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java b/telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java
index 109dd3b30827..d186fcf63cfe 100644
--- a/telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java
+++ b/telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java
@@ -47,10 +47,6 @@ import java.util.ArrayList;
public final class BearerData {
private final static String LOG_TAG = "BearerData";
- @UnsupportedAppUsage
- public BearerData() {
- }
-
/**
* Bearer Data Subparameter Identifiers
* (See 3GPP2 C.S0015-B, v2.0, table 4.5-1)
@@ -241,6 +237,10 @@ public final class BearerData {
public boolean userResponseCodeSet = false;
public int userResponseCode;
+ @UnsupportedAppUsage
+ public BearerData() {
+ }
+
/**
* 6-byte-field, see 3GPP2 C.S0015-B, v2, 4.5.4
*/
diff --git a/telephony/java/com/android/internal/telephony/cdma/sms/CdmaSmsAddress.java b/telephony/java/com/android/internal/telephony/cdma/sms/CdmaSmsAddress.java
index 039b1769b487..6f0de340d2b8 100644
--- a/telephony/java/com/android/internal/telephony/cdma/sms/CdmaSmsAddress.java
+++ b/telephony/java/com/android/internal/telephony/cdma/sms/CdmaSmsAddress.java
@@ -94,6 +94,7 @@ public class CdmaSmsAddress extends SmsAddress {
* are stored in the parent class address and origBytes fields,
* respectively.
*/
+
@UnsupportedAppUsage
public CdmaSmsAddress(){
}
diff --git a/telephony/java/com/android/internal/telephony/cdma/sms/SmsEnvelope.java b/telephony/java/com/android/internal/telephony/cdma/sms/SmsEnvelope.java
index 964e2fb32689..9e2d29cd12e9 100644
--- a/telephony/java/com/android/internal/telephony/cdma/sms/SmsEnvelope.java
+++ b/telephony/java/com/android/internal/telephony/cdma/sms/SmsEnvelope.java
@@ -16,7 +16,6 @@
package com.android.internal.telephony.cdma.sms;
-
import android.compat.annotation.UnsupportedAppUsage;
import android.telephony.cdma.CdmaSmsCbProgramData;
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmSmsAddress.java b/telephony/java/com/android/internal/telephony/gsm/GsmSmsAddress.java
index c2adbc214a79..5409c094c80f 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmSmsAddress.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmSmsAddress.java
@@ -40,7 +40,6 @@ public class GsmSmsAddress extends SmsAddress {
* (addressLength + 1) / 2"
* @throws ParseException
*/
-
@UnsupportedAppUsage
public GsmSmsAddress(byte[] data, int offset, int length) throws ParseException {
origBytes = new byte[length];
diff --git a/telephony/java/com/android/internal/telephony/gsm/SmsCbHeader.java b/telephony/java/com/android/internal/telephony/gsm/SmsCbHeader.java
index f29410d9fca3..d1903450261b 100644
--- a/telephony/java/com/android/internal/telephony/gsm/SmsCbHeader.java
+++ b/telephony/java/com/android/internal/telephony/gsm/SmsCbHeader.java
@@ -229,17 +229,17 @@ public class SmsCbHeader {
}
@UnsupportedAppUsage
- int getGeographicalScope() {
+ public int getGeographicalScope() {
return mGeographicalScope;
}
@UnsupportedAppUsage
- int getSerialNumber() {
+ public int getSerialNumber() {
return mSerialNumber;
}
@UnsupportedAppUsage
- int getServiceCategory() {
+ public int getServiceCategory() {
return mMessageIdentifier;
}
@@ -252,12 +252,12 @@ public class SmsCbHeader {
}
@UnsupportedAppUsage
- int getPageIndex() {
+ public int getPageIndex() {
return mPageIndex;
}
@UnsupportedAppUsage
- int getNumberOfPages() {
+ public int getNumberOfPages() {
return mNrOfPages;
}
diff --git a/telephony/java/com/android/internal/telephony/gsm/SmsMessage.java b/telephony/java/com/android/internal/telephony/gsm/SmsMessage.java
index 7dd2f6dd8e32..e3df903b7f4f 100644
--- a/telephony/java/com/android/internal/telephony/gsm/SmsMessage.java
+++ b/telephony/java/com/android/internal/telephony/gsm/SmsMessage.java
@@ -105,14 +105,13 @@ public class SmsMessage extends SmsMessageBase {
private static final int INVALID_VALIDITY_PERIOD = -1;
- @UnsupportedAppUsage
- public SmsMessage() {
- }
-
public static class SubmitPdu extends SubmitPduBase {
@UnsupportedAppUsage
- public SubmitPdu() {
- }
+ public SubmitPdu() {}
+ }
+
+ @UnsupportedAppUsage
+ public SmsMessage() {
}
/**