diff options
Diffstat (limited to 'telephony/java')
70 files changed, 2767 insertions, 1188 deletions
diff --git a/telephony/java/android/service/carrier/CarrierService.java b/telephony/java/android/service/carrier/CarrierService.java index eefc1b70bac9..d06ec11f3e61 100644 --- a/telephony/java/android/service/carrier/CarrierService.java +++ b/telephony/java/android/service/carrier/CarrierService.java @@ -25,6 +25,9 @@ import android.os.ResultReceiver; import android.telephony.TelephonyRegistryManager; import android.util.Log; +import java.io.FileDescriptor; +import java.io.PrintWriter; + /** * A service that exposes carrier-specific functionality to the system. * <p> @@ -156,5 +159,10 @@ public abstract class CarrierService extends Service { result.send(RESULT_ERROR, null); } } + + @Override + protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { + CarrierService.this.dump(fd, pw, args); + } } } diff --git a/telephony/java/android/telephony/AccessNetworkConstants.java b/telephony/java/android/telephony/AccessNetworkConstants.java index 01abb2661f39..558f4cd24471 100644 --- a/telephony/java/android/telephony/AccessNetworkConstants.java +++ b/telephony/java/android/telephony/AccessNetworkConstants.java @@ -19,6 +19,10 @@ package android.telephony; import android.annotation.IntDef; import android.annotation.SystemApi; import android.annotation.TestApi; +import android.hardware.radio.V1_1.EutranBands; +import android.hardware.radio.V1_1.GeranBands; +import android.hardware.radio.V1_5.AccessNetwork; +import android.hardware.radio.V1_5.UtranBands; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -84,13 +88,13 @@ public final class AccessNetworkConstants { public @interface RadioAccessNetworkType {} public static final class AccessNetworkType { - public static final int UNKNOWN = 0; - public static final int GERAN = 1; - public static final int UTRAN = 2; - public static final int EUTRAN = 3; - public static final int CDMA2000 = 4; - public static final int IWLAN = 5; - public static final int NGRAN = 6; + public static final int UNKNOWN = AccessNetwork.UNKNOWN; + public static final int GERAN = AccessNetwork.GERAN; + public static final int UTRAN = AccessNetwork.UTRAN; + public static final int EUTRAN = AccessNetwork.EUTRAN; + public static final int CDMA2000 = AccessNetwork.CDMA2000; + public static final int IWLAN = AccessNetwork.IWLAN; + public static final int NGRAN = AccessNetwork.NGRAN; /** @hide */ private AccessNetworkType() {} @@ -115,20 +119,20 @@ public final class AccessNetworkConstants { * http://www.etsi.org/deliver/etsi_ts/145000_145099/145005/14.00.00_60/ts_145005v140000p.pdf */ public static final class GeranBand { - public static final int BAND_T380 = 1; - public static final int BAND_T410 = 2; - public static final int BAND_450 = 3; - public static final int BAND_480 = 4; - public static final int BAND_710 = 5; - public static final int BAND_750 = 6; - public static final int BAND_T810 = 7; - public static final int BAND_850 = 8; - public static final int BAND_P900 = 9; - public static final int BAND_E900 = 10; - public static final int BAND_R900 = 11; - public static final int BAND_DCS1800 = 12; - public static final int BAND_PCS1900 = 13; - public static final int BAND_ER900 = 14; + public static final int BAND_T380 = GeranBands.BAND_T380; + public static final int BAND_T410 = GeranBands.BAND_T410; + public static final int BAND_450 = GeranBands.BAND_450; + public static final int BAND_480 = GeranBands.BAND_480; + public static final int BAND_710 = GeranBands.BAND_710; + public static final int BAND_750 = GeranBands.BAND_750; + public static final int BAND_T810 = GeranBands.BAND_T810; + public static final int BAND_850 = GeranBands.BAND_850; + public static final int BAND_P900 = GeranBands.BAND_P900; + public static final int BAND_E900 = GeranBands.BAND_E900; + public static final int BAND_R900 = GeranBands.BAND_R900; + public static final int BAND_DCS1800 = GeranBands.BAND_DCS1800; + public static final int BAND_PCS1900 = GeranBands.BAND_PCS1900; + public static final int BAND_ER900 = GeranBands.BAND_ER900; /** @hide */ private GeranBand() {} @@ -139,28 +143,28 @@ public final class AccessNetworkConstants { * http://www.etsi.org/deliver/etsi_ts/125100_125199/125104/13.03.00_60/ts_125104v130p.pdf */ public static final class UtranBand { - public static final int BAND_1 = 1; - public static final int BAND_2 = 2; - public static final int BAND_3 = 3; - public static final int BAND_4 = 4; - public static final int BAND_5 = 5; - public static final int BAND_6 = 6; - public static final int BAND_7 = 7; - public static final int BAND_8 = 8; - public static final int BAND_9 = 9; - public static final int BAND_10 = 10; - public static final int BAND_11 = 11; - public static final int BAND_12 = 12; - public static final int BAND_13 = 13; - public static final int BAND_14 = 14; + public static final int BAND_1 = UtranBands.BAND_1; + public static final int BAND_2 = UtranBands.BAND_2; + public static final int BAND_3 = UtranBands.BAND_3; + public static final int BAND_4 = UtranBands.BAND_4; + public static final int BAND_5 = UtranBands.BAND_5; + public static final int BAND_6 = UtranBands.BAND_6; + public static final int BAND_7 = UtranBands.BAND_7; + public static final int BAND_8 = UtranBands.BAND_8; + public static final int BAND_9 = UtranBands.BAND_9; + public static final int BAND_10 = UtranBands.BAND_10; + public static final int BAND_11 = UtranBands.BAND_11; + public static final int BAND_12 = UtranBands.BAND_12; + public static final int BAND_13 = UtranBands.BAND_13; + public static final int BAND_14 = UtranBands.BAND_14; // band 15, 16, 17, 18 are reserved - public static final int BAND_19 = 19; - public static final int BAND_20 = 20; - public static final int BAND_21 = 21; - public static final int BAND_22 = 22; + public static final int BAND_19 = UtranBands.BAND_19; + public static final int BAND_20 = UtranBands.BAND_20; + public static final int BAND_21 = UtranBands.BAND_21; + public static final int BAND_22 = UtranBands.BAND_22; // band 23, 24 are reserved - public static final int BAND_25 = 25; - public static final int BAND_26 = 26; + public static final int BAND_25 = UtranBands.BAND_25; + public static final int BAND_26 = UtranBands.BAND_26; // Frequency bands for TD-SCDMA. Defined in 3GPP TS 25.102, Table 5.2. @@ -169,38 +173,38 @@ public final class AccessNetworkConstants { * 1900 - 1920 MHz: Uplink and downlink transmission * 2010 - 2025 MHz: Uplink and downlink transmission */ - public static final int BAND_A = 101; + public static final int BAND_A = UtranBands.BAND_A; /** * Band B * 1850 - 1910 MHz: Uplink and downlink transmission * 1930 - 1990 MHz: Uplink and downlink transmission */ - public static final int BAND_B = 102; + public static final int BAND_B = UtranBands.BAND_B; /** * Band C * 1910 - 1930 MHz: Uplink and downlink transmission */ - public static final int BAND_C = 103; + public static final int BAND_C = UtranBands.BAND_C; /** * Band D * 2570 - 2620 MHz: Uplink and downlink transmission */ - public static final int BAND_D = 104; + public static final int BAND_D = UtranBands.BAND_D; /** * Band E * 2300—2400 MHz: Uplink and downlink transmission */ - public static final int BAND_E = 105; + public static final int BAND_E = UtranBands.BAND_E; /** * Band F * 1880 - 1920 MHz: Uplink and downlink transmission */ - public static final int BAND_F = 106; + public static final int BAND_F = UtranBands.BAND_F; /** @hide */ private UtranBand() {} @@ -211,54 +215,54 @@ public final class AccessNetworkConstants { * http://www.etsi.org/deliver/etsi_ts/136100_136199/136101/14.03.00_60/ts_136101v140p.pdf */ public static final class EutranBand { - public static final int BAND_1 = 1; - public static final int BAND_2 = 2; - public static final int BAND_3 = 3; - public static final int BAND_4 = 4; - public static final int BAND_5 = 5; - public static final int BAND_6 = 6; - public static final int BAND_7 = 7; - public static final int BAND_8 = 8; - public static final int BAND_9 = 9; - public static final int BAND_10 = 10; - public static final int BAND_11 = 11; - public static final int BAND_12 = 12; - public static final int BAND_13 = 13; - public static final int BAND_14 = 14; - public static final int BAND_17 = 17; - public static final int BAND_18 = 18; - public static final int BAND_19 = 19; - public static final int BAND_20 = 20; - public static final int BAND_21 = 21; - public static final int BAND_22 = 22; - public static final int BAND_23 = 23; - public static final int BAND_24 = 24; - public static final int BAND_25 = 25; - public static final int BAND_26 = 26; - public static final int BAND_27 = 27; - public static final int BAND_28 = 28; - public static final int BAND_30 = 30; - public static final int BAND_31 = 31; - public static final int BAND_33 = 33; - public static final int BAND_34 = 34; - public static final int BAND_35 = 35; - public static final int BAND_36 = 36; - public static final int BAND_37 = 37; - public static final int BAND_38 = 38; - public static final int BAND_39 = 39; - public static final int BAND_40 = 40; - public static final int BAND_41 = 41; - public static final int BAND_42 = 42; - public static final int BAND_43 = 43; - public static final int BAND_44 = 44; - public static final int BAND_45 = 45; - public static final int BAND_46 = 46; - public static final int BAND_47 = 47; - public static final int BAND_48 = 48; - public static final int BAND_65 = 65; - public static final int BAND_66 = 66; - public static final int BAND_68 = 68; - public static final int BAND_70 = 70; + public static final int BAND_1 = EutranBands.BAND_1; + public static final int BAND_2 = EutranBands.BAND_2; + public static final int BAND_3 = EutranBands.BAND_3; + public static final int BAND_4 = EutranBands.BAND_4; + public static final int BAND_5 = EutranBands.BAND_5; + public static final int BAND_6 = EutranBands.BAND_6; + public static final int BAND_7 = EutranBands.BAND_7; + public static final int BAND_8 = EutranBands.BAND_8; + public static final int BAND_9 = EutranBands.BAND_9; + public static final int BAND_10 = EutranBands.BAND_10; + public static final int BAND_11 = EutranBands.BAND_11; + public static final int BAND_12 = EutranBands.BAND_12; + public static final int BAND_13 = EutranBands.BAND_13; + public static final int BAND_14 = EutranBands.BAND_14; + public static final int BAND_17 = EutranBands.BAND_17; + public static final int BAND_18 = EutranBands.BAND_18; + public static final int BAND_19 = EutranBands.BAND_19; + public static final int BAND_20 = EutranBands.BAND_20; + public static final int BAND_21 = EutranBands.BAND_21; + public static final int BAND_22 = EutranBands.BAND_22; + public static final int BAND_23 = EutranBands.BAND_23; + public static final int BAND_24 = EutranBands.BAND_24; + public static final int BAND_25 = EutranBands.BAND_25; + public static final int BAND_26 = EutranBands.BAND_26; + public static final int BAND_27 = EutranBands.BAND_27; + public static final int BAND_28 = EutranBands.BAND_28; + public static final int BAND_30 = EutranBands.BAND_30; + public static final int BAND_31 = EutranBands.BAND_31; + public static final int BAND_33 = EutranBands.BAND_33; + public static final int BAND_34 = EutranBands.BAND_34; + public static final int BAND_35 = EutranBands.BAND_35; + public static final int BAND_36 = EutranBands.BAND_36; + public static final int BAND_37 = EutranBands.BAND_37; + public static final int BAND_38 = EutranBands.BAND_38; + public static final int BAND_39 = EutranBands.BAND_39; + public static final int BAND_40 = EutranBands.BAND_40; + public static final int BAND_41 = EutranBands.BAND_41; + public static final int BAND_42 = EutranBands.BAND_42; + public static final int BAND_43 = EutranBands.BAND_43; + public static final int BAND_44 = EutranBands.BAND_44; + public static final int BAND_45 = EutranBands.BAND_45; + public static final int BAND_46 = EutranBands.BAND_46; + public static final int BAND_47 = EutranBands.BAND_47; + public static final int BAND_48 = EutranBands.BAND_48; + public static final int BAND_65 = EutranBands.BAND_65; + public static final int BAND_66 = EutranBands.BAND_66; + public static final int BAND_68 = EutranBands.BAND_68; + public static final int BAND_70 = EutranBands.BAND_70; /** @hide */ private EutranBand() {}; @@ -304,51 +308,51 @@ public final class AccessNetworkConstants { */ public static final class NgranBands { /** FR1 bands */ - public static final int BAND_1 = 1; - public static final int BAND_2 = 2; - public static final int BAND_3 = 3; - public static final int BAND_5 = 5; - public static final int BAND_7 = 7; - public static final int BAND_8 = 8; - public static final int BAND_12 = 12; - public static final int BAND_14 = 14; - public static final int BAND_18 = 18; - public static final int BAND_20 = 20; - public static final int BAND_25 = 25; - public static final int BAND_28 = 28; - public static final int BAND_29 = 29; - public static final int BAND_30 = 30; - public static final int BAND_34 = 34; - public static final int BAND_38 = 38; - public static final int BAND_39 = 39; - public static final int BAND_40 = 40; - public static final int BAND_41 = 41; - public static final int BAND_48 = 48; - public static final int BAND_50 = 50; - public static final int BAND_51 = 51; - public static final int BAND_65 = 65; - public static final int BAND_66 = 66; - public static final int BAND_70 = 70; - public static final int BAND_71 = 71; - public static final int BAND_74 = 74; - public static final int BAND_75 = 75; - public static final int BAND_76 = 76; - public static final int BAND_77 = 77; - public static final int BAND_78 = 78; - public static final int BAND_79 = 79; - public static final int BAND_80 = 80; - public static final int BAND_81 = 81; - public static final int BAND_82 = 82; - public static final int BAND_83 = 83; - public static final int BAND_84 = 84; - public static final int BAND_86 = 86; - public static final int BAND_90 = 90; + public static final int BAND_1 = android.hardware.radio.V1_5.NgranBands.BAND_1; + public static final int BAND_2 = android.hardware.radio.V1_5.NgranBands.BAND_2; + public static final int BAND_3 = android.hardware.radio.V1_5.NgranBands.BAND_3; + public static final int BAND_5 = android.hardware.radio.V1_5.NgranBands.BAND_5; + public static final int BAND_7 = android.hardware.radio.V1_5.NgranBands.BAND_7; + public static final int BAND_8 = android.hardware.radio.V1_5.NgranBands.BAND_8; + public static final int BAND_12 = android.hardware.radio.V1_5.NgranBands.BAND_12; + public static final int BAND_14 = android.hardware.radio.V1_5.NgranBands.BAND_14; + public static final int BAND_18 = android.hardware.radio.V1_5.NgranBands.BAND_18; + public static final int BAND_20 = android.hardware.radio.V1_5.NgranBands.BAND_20; + public static final int BAND_25 = android.hardware.radio.V1_5.NgranBands.BAND_25; + public static final int BAND_28 = android.hardware.radio.V1_5.NgranBands.BAND_28; + public static final int BAND_29 = android.hardware.radio.V1_5.NgranBands.BAND_29; + public static final int BAND_30 = android.hardware.radio.V1_5.NgranBands.BAND_30; + public static final int BAND_34 = android.hardware.radio.V1_5.NgranBands.BAND_34; + public static final int BAND_38 = android.hardware.radio.V1_5.NgranBands.BAND_38; + public static final int BAND_39 = android.hardware.radio.V1_5.NgranBands.BAND_39; + public static final int BAND_40 = android.hardware.radio.V1_5.NgranBands.BAND_40; + public static final int BAND_41 = android.hardware.radio.V1_5.NgranBands.BAND_41; + public static final int BAND_48 = android.hardware.radio.V1_5.NgranBands.BAND_48; + public static final int BAND_50 = android.hardware.radio.V1_5.NgranBands.BAND_50; + public static final int BAND_51 = android.hardware.radio.V1_5.NgranBands.BAND_51; + public static final int BAND_65 = android.hardware.radio.V1_5.NgranBands.BAND_65; + public static final int BAND_66 = android.hardware.radio.V1_5.NgranBands.BAND_66; + public static final int BAND_70 = android.hardware.radio.V1_5.NgranBands.BAND_70; + public static final int BAND_71 = android.hardware.radio.V1_5.NgranBands.BAND_71; + public static final int BAND_74 = android.hardware.radio.V1_5.NgranBands.BAND_74; + public static final int BAND_75 = android.hardware.radio.V1_5.NgranBands.BAND_75; + public static final int BAND_76 = android.hardware.radio.V1_5.NgranBands.BAND_76; + public static final int BAND_77 = android.hardware.radio.V1_5.NgranBands.BAND_77; + public static final int BAND_78 = android.hardware.radio.V1_5.NgranBands.BAND_78; + public static final int BAND_79 = android.hardware.radio.V1_5.NgranBands.BAND_79; + public static final int BAND_80 = android.hardware.radio.V1_5.NgranBands.BAND_80; + public static final int BAND_81 = android.hardware.radio.V1_5.NgranBands.BAND_81; + public static final int BAND_82 = android.hardware.radio.V1_5.NgranBands.BAND_82; + public static final int BAND_83 = android.hardware.radio.V1_5.NgranBands.BAND_83; + public static final int BAND_84 = android.hardware.radio.V1_5.NgranBands.BAND_84; + public static final int BAND_86 = android.hardware.radio.V1_5.NgranBands.BAND_86; + public static final int BAND_90 = android.hardware.radio.V1_5.NgranBands.BAND_90; /** FR2 bands */ - public static final int BAND_257 = 257; - public static final int BAND_258 = 258; - public static final int BAND_260 = 260; - public static final int BAND_261 = 261; + public static final int BAND_257 = android.hardware.radio.V1_5.NgranBands.BAND_257; + public static final int BAND_258 = android.hardware.radio.V1_5.NgranBands.BAND_258; + public static final int BAND_260 = android.hardware.radio.V1_5.NgranBands.BAND_260; + public static final int BAND_261 = android.hardware.radio.V1_5.NgranBands.BAND_261; /** * NR Bands diff --git a/telephony/java/android/telephony/Annotation.java b/telephony/java/android/telephony/Annotation.java index 0325c36e227e..28cc7d0378a1 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, @@ -598,48 +598,6 @@ public class Annotation { } /** - * Call forwarding function status - */ - @IntDef(prefix = { "STATUS_" }, value = { - CallForwardingInfo.STATUS_ACTIVE, - CallForwardingInfo.STATUS_INACTIVE, - CallForwardingInfo.STATUS_UNKNOWN_ERROR, - CallForwardingInfo.STATUS_NOT_SUPPORTED, - CallForwardingInfo.STATUS_FDN_CHECK_FAILURE - }) - @Retention(RetentionPolicy.SOURCE) - public @interface CallForwardingStatus { - } - - /** - * Call forwarding reason types - */ - @IntDef(flag = true, prefix = { "REASON_" }, value = { - CallForwardingInfo.REASON_UNCONDITIONAL, - CallForwardingInfo.REASON_BUSY, - CallForwardingInfo.REASON_NO_REPLY, - CallForwardingInfo.REASON_NOT_REACHABLE, - CallForwardingInfo.REASON_ALL, - CallForwardingInfo.REASON_ALL_CONDITIONAL - }) - @Retention(RetentionPolicy.SOURCE) - public @interface CallForwardingReason { - } - - /** - * Call waiting function status - */ - @IntDef(prefix = { "CALL_WAITING_STATUS_" }, value = { - TelephonyManager.CALL_WAITING_STATUS_ACTIVE, - TelephonyManager.CALL_WAITING_STATUS_INACTIVE, - TelephonyManager.CALL_WAITING_STATUS_NOT_SUPPORTED, - TelephonyManager.CALL_WAITING_STATUS_UNKNOWN_ERROR - }) - @Retention(RetentionPolicy.SOURCE) - public @interface CallWaitingStatus { - } - - /** * UICC SIM Application Types */ @IntDef(prefix = { "APPTYPE_" }, value = { diff --git a/telephony/java/android/telephony/BarringInfo.aidl b/telephony/java/android/telephony/BarringInfo.aidl new file mode 100644 index 000000000000..50ddf6b31919 --- /dev/null +++ b/telephony/java/android/telephony/BarringInfo.aidl @@ -0,0 +1,20 @@ +/* + * Copyright 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. + */ + +/** @hide */ +package android.telephony; + +parcelable BarringInfo; diff --git a/telephony/java/android/telephony/BarringInfo.java b/telephony/java/android/telephony/BarringInfo.java new file mode 100644 index 000000000000..92423a2f2218 --- /dev/null +++ b/telephony/java/android/telephony/BarringInfo.java @@ -0,0 +1,398 @@ +/* + * Copyright 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.IntDef; +import android.annotation.NonNull; +import android.annotation.Nullable; +import android.annotation.SuppressLint; +import android.annotation.SystemApi; +import android.annotation.TestApi; +import android.os.Parcel; +import android.os.Parcelable; +import android.util.SparseArray; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.util.List; +import java.util.Objects; + +/** + * Provides the barring configuration for a particular service type. + * + * Provides indication about the barring of a particular service for use. Certain barring types + * are only valid for certain technology families. Any service that does not have a barring + * configuration is unbarred by default. + */ +public final class BarringInfo implements Parcelable { + + /** + * Barring Service Type + * + * @hide + */ + @Retention(RetentionPolicy.SOURCE) + @IntDef(prefix = "BARRING_SERVICE_TYPE_", value = { + BARRING_SERVICE_TYPE_CS_SERVICE, + BARRING_SERVICE_TYPE_PS_SERVICE, + BARRING_SERVICE_TYPE_CS_VOICE, + BARRING_SERVICE_TYPE_MO_SIGNALLING, + BARRING_SERVICE_TYPE_MO_DATA, + BARRING_SERVICE_TYPE_CS_FALLBACK, + BARRING_SERVICE_TYPE_MMTEL_VOICE, + BARRING_SERVICE_TYPE_MMTEL_VIDEO, + BARRING_SERVICE_TYPE_EMERGENCY, + BARRING_SERVICE_TYPE_SMS}) + public @interface BarringServiceType {} + + /* Applicabe to UTRAN */ + /** Barring indicator for circuit-switched service; applicable to UTRAN */ + public static final int BARRING_SERVICE_TYPE_CS_SERVICE = + android.hardware.radio.V1_5.BarringInfo.ServiceType.CS_SERVICE; + /** Barring indicator for packet-switched service; applicable to UTRAN */ + public static final int BARRING_SERVICE_TYPE_PS_SERVICE = + android.hardware.radio.V1_5.BarringInfo.ServiceType.PS_SERVICE; + /** Barring indicator for circuit-switched voice service; applicable to UTRAN */ + public static final int BARRING_SERVICE_TYPE_CS_VOICE = + android.hardware.radio.V1_5.BarringInfo.ServiceType.CS_VOICE; + + /* Applicable to EUTRAN, NGRAN */ + /** Barring indicator for mobile-originated signalling; applicable to EUTRAN and NGRAN */ + public static final int BARRING_SERVICE_TYPE_MO_SIGNALLING = + android.hardware.radio.V1_5.BarringInfo.ServiceType.MO_SIGNALLING; + /** Barring indicator for mobile-originated data traffic; applicable to EUTRAN and NGRAN */ + public static final int BARRING_SERVICE_TYPE_MO_DATA = + android.hardware.radio.V1_5.BarringInfo.ServiceType.MO_DATA; + /** Barring indicator for circuit-switched fallback for voice; applicable to EUTRAN and NGRAN */ + public static final int BARRING_SERVICE_TYPE_CS_FALLBACK = + android.hardware.radio.V1_5.BarringInfo.ServiceType.CS_FALLBACK; + /** Barring indicator for MMTEL (IMS) voice; applicable to EUTRAN and NGRAN */ + public static final int BARRING_SERVICE_TYPE_MMTEL_VOICE = + android.hardware.radio.V1_5.BarringInfo.ServiceType.MMTEL_VOICE; + /** Barring indicator for MMTEL (IMS) video; applicable to EUTRAN and NGRAN */ + public static final int BARRING_SERVICE_TYPE_MMTEL_VIDEO = + android.hardware.radio.V1_5.BarringInfo.ServiceType.MMTEL_VIDEO; + + /* Applicable to UTRAN, EUTRAN, NGRAN */ + /** Barring indicator for emergency services; applicable to UTRAN, EUTRAN, and NGRAN */ + public static final int BARRING_SERVICE_TYPE_EMERGENCY = + android.hardware.radio.V1_5.BarringInfo.ServiceType.EMERGENCY; + /** Barring indicator for SMS sending; applicable to UTRAN, EUTRAN, and NGRAN */ + public static final int BARRING_SERVICE_TYPE_SMS = + android.hardware.radio.V1_5.BarringInfo.ServiceType.SMS; + + //TODO: add barring constants for Operator-Specific barring codes + + /** Describe the current barring configuration of a cell */ + public static final class BarringServiceInfo implements Parcelable { + /** + * Barring Type + * @hide + */ + @Retention(RetentionPolicy.SOURCE) + @IntDef(prefix = "BARRING_TYPE_", value = + {BARRING_TYPE_NONE, + BARRING_TYPE_UNCONDITIONAL, + BARRING_TYPE_CONDITIONAL, + BARRING_TYPE_UNKNOWN}) + public @interface BarringType {} + + /** Barring is inactive */ + public static final int BARRING_TYPE_NONE = + android.hardware.radio.V1_5.BarringInfo.BarringType.NONE; + /** The service is barred */ + public static final int BARRING_TYPE_UNCONDITIONAL = + android.hardware.radio.V1_5.BarringInfo.BarringType.UNCONDITIONAL; + /** The service may be barred based on additional factors */ + public static final int BARRING_TYPE_CONDITIONAL = + android.hardware.radio.V1_5.BarringInfo.BarringType.CONDITIONAL; + + /** If a modem does not report barring info, then the barring type will be UNKNOWN */ + public static final int BARRING_TYPE_UNKNOWN = -1; + + private final @BarringType int mBarringType; + + private final boolean mIsConditionallyBarred; + private final int mConditionalBarringFactor; + private final int mConditionalBarringTimeSeconds; + + /** @hide */ + public BarringServiceInfo(@BarringType int type) { + this(type, false, 0, 0); + } + + /** @hide */ + @TestApi + public BarringServiceInfo(@BarringType int barringType, boolean isConditionallyBarred, + int conditionalBarringFactor, int conditionalBarringTimeSeconds) { + mBarringType = barringType; + mIsConditionallyBarred = isConditionallyBarred; + mConditionalBarringFactor = conditionalBarringFactor; + mConditionalBarringTimeSeconds = conditionalBarringTimeSeconds; + } + + public @BarringType int getBarringType() { + return mBarringType; + } + + /** + * @return true if the conditional barring parameters have resulted in the service being + * barred; false if the service has either not been evaluated for conditional + * barring or has been evaluated and isn't barred. + */ + public boolean isConditionallyBarred() { + return mIsConditionallyBarred; + } + + /** + * @return the conditional barring factor as a percentage 0-100, which is the probability of + * a random device being barred for the service type. + */ + public int getConditionalBarringFactor() { + return mConditionalBarringFactor; + } + + /** + * @return the conditional barring time seconds, which is the interval between successive + * evaluations for conditional barring based on the barring factor. + */ + @SuppressLint("MethodNameUnits") + public int getConditionalBarringTimeSeconds() { + return mConditionalBarringTimeSeconds; + } + + /** + * Return whether a service is currently barred based on the BarringInfo + * + * @return true if the service is currently being barred, otherwise false + */ + public boolean isBarred() { + return mBarringType == BarringServiceInfo.BARRING_TYPE_UNCONDITIONAL + || (mBarringType == BarringServiceInfo.BARRING_TYPE_CONDITIONAL + && mIsConditionallyBarred); + } + + @Override + public int hashCode() { + return Objects.hash(mBarringType, mIsConditionallyBarred, + mConditionalBarringFactor, mConditionalBarringTimeSeconds); + } + + @Override + public boolean equals(Object rhs) { + if (!(rhs instanceof BarringServiceInfo)) return false; + + BarringServiceInfo other = (BarringServiceInfo) rhs; + return mBarringType == other.mBarringType + && mIsConditionallyBarred == other.mIsConditionallyBarred + && mConditionalBarringFactor == other.mConditionalBarringFactor + && mConditionalBarringTimeSeconds == other.mConditionalBarringTimeSeconds; + } + + /** @hide */ + public BarringServiceInfo(Parcel p) { + mBarringType = p.readInt(); + mIsConditionallyBarred = p.readBoolean(); + mConditionalBarringFactor = p.readInt(); + mConditionalBarringTimeSeconds = p.readInt(); + } + + @Override + public void writeToParcel(@NonNull Parcel dest, int flags) { + dest.writeInt(mBarringType); + dest.writeBoolean(mIsConditionallyBarred); + dest.writeInt(mConditionalBarringFactor); + dest.writeInt(mConditionalBarringTimeSeconds); + } + + /* @inheritDoc */ + public static final @NonNull Parcelable.Creator<BarringServiceInfo> CREATOR = + new Parcelable.Creator<BarringServiceInfo>() { + @Override + public BarringServiceInfo createFromParcel(Parcel source) { + return new BarringServiceInfo(source); + } + + @Override + public BarringServiceInfo[] newArray(int size) { + return new BarringServiceInfo[size]; + } + }; + + @Override + public int describeContents() { + return 0; + } + } + + private static final BarringServiceInfo BARRING_SERVICE_INFO_UNKNOWN = + new BarringServiceInfo(BarringServiceInfo.BARRING_TYPE_UNKNOWN); + + private static final BarringServiceInfo BARRING_SERVICE_INFO_UNBARRED = + new BarringServiceInfo(BarringServiceInfo.BARRING_TYPE_NONE); + + private CellIdentity mCellIdentity; + + // A SparseArray potentially mapping each BarringService type to a BarringServiceInfo config + // that describes the current barring status of that particular service. + private SparseArray<BarringServiceInfo> mBarringServiceInfos; + + /** @hide */ + @TestApi + @SystemApi + public BarringInfo() { + mBarringServiceInfos = new SparseArray<>(); + } + + /** + * Constructor for new BarringInfo instances. + * + * @hide + */ + @TestApi + public BarringInfo(@Nullable CellIdentity barringCellId, + @NonNull SparseArray<BarringServiceInfo> barringServiceInfos) { + mCellIdentity = barringCellId; + mBarringServiceInfos = barringServiceInfos; + } + + /** @hide */ + public static BarringInfo create( + @NonNull android.hardware.radio.V1_5.CellIdentity halBarringCellId, + @NonNull List<android.hardware.radio.V1_5.BarringInfo> halBarringInfos) { + CellIdentity ci = CellIdentity.create(halBarringCellId); + SparseArray<BarringServiceInfo> serviceInfos = new SparseArray<>(); + + for (android.hardware.radio.V1_5.BarringInfo halBarringInfo : halBarringInfos) { + if (halBarringInfo.barringType + == android.hardware.radio.V1_5.BarringInfo.BarringType.CONDITIONAL) { + if (halBarringInfo.barringTypeSpecificInfo.getDiscriminator() + != android.hardware.radio.V1_5.BarringInfo.BarringTypeSpecificInfo + .hidl_discriminator.conditional) { + // this is an error case where the barring info is conditional but the + // conditional barring fields weren't included + continue; + } + android.hardware.radio.V1_5.BarringInfo.BarringTypeSpecificInfo + .Conditional conditionalInfo = + halBarringInfo.barringTypeSpecificInfo.conditional(); + serviceInfos.put( + halBarringInfo.serviceType, new BarringServiceInfo( + halBarringInfo.barringType, // will always be CONDITIONAL here + conditionalInfo.isBarred, + conditionalInfo.factor, + conditionalInfo.timeSeconds)); + } else { + // Barring type is either NONE or UNCONDITIONAL + serviceInfos.put( + halBarringInfo.serviceType, new BarringServiceInfo( + halBarringInfo.barringType, false, 0, 0)); + } + } + return new BarringInfo(ci, serviceInfos); + } + + /** + * Get the BarringServiceInfo for a specified service. + * + * @return a BarringServiceInfo struct describing the current barring status for a service + */ + public @NonNull BarringServiceInfo getBarringServiceInfo(@BarringServiceType int service) { + BarringServiceInfo bsi = mBarringServiceInfos.get(service); + // If barring is reported but not for a particular service, then we report the barring + // type as UNKNOWN; if the modem reports barring info but doesn't report for a particular + // service then we can safely assume that the service isn't barred (for instance because + // that particular service isn't applicable to the current RAN). + return (bsi != null) ? bsi : mBarringServiceInfos.size() > 0 + ? BARRING_SERVICE_INFO_UNBARRED : BARRING_SERVICE_INFO_UNKNOWN; + } + + /** @hide */ + @SystemApi + public @NonNull BarringInfo createLocationInfoSanitizedCopy() { + // The only thing that would need sanitizing is the CellIdentity + if (mCellIdentity == null) return this; + + return new BarringInfo(mCellIdentity.sanitizeLocationInfo(), mBarringServiceInfos); + } + + /** @hide */ + public BarringInfo(Parcel p) { + mCellIdentity = p.readParcelable(CellIdentity.class.getClassLoader()); + mBarringServiceInfos = p.readSparseArray(BarringServiceInfo.class.getClassLoader()); + } + + @Override + public void writeToParcel(@NonNull Parcel dest, int flags) { + dest.writeParcelable(mCellIdentity, flags); + dest.writeSparseArray(mBarringServiceInfos); + } + + public static final @NonNull Parcelable.Creator<BarringInfo> CREATOR = + new Parcelable.Creator<BarringInfo>() { + @Override + public BarringInfo createFromParcel(Parcel source) { + return new BarringInfo(source); + } + + @Override + public BarringInfo[] newArray(int size) { + return new BarringInfo[size]; + } + }; + + @Override + public int describeContents() { + return 0; + } + + @Override + public int hashCode() { + int hash = mCellIdentity != null ? mCellIdentity.hashCode() : 7; + for (int i = 0; i < mBarringServiceInfos.size(); i++) { + hash = hash + 15 * mBarringServiceInfos.keyAt(i); + hash = hash + 31 * mBarringServiceInfos.valueAt(i).hashCode(); + } + return hash; + } + + @Override + public boolean equals(Object rhs) { + if (!(rhs instanceof BarringInfo)) return false; + + BarringInfo bi = (BarringInfo) rhs; + + if (hashCode() != bi.hashCode()) return false; + + if (mBarringServiceInfos.size() != bi.mBarringServiceInfos.size()) return false; + + for (int i = 0; i < mBarringServiceInfos.size(); i++) { + if (mBarringServiceInfos.keyAt(i) != bi.mBarringServiceInfos.keyAt(i)) return false; + if (!Objects.equals(mBarringServiceInfos.valueAt(i), + bi.mBarringServiceInfos.valueAt(i))) { + return false; + } + } + return true; + } + + @Override + public String toString() { + return "BarringInfo {mCellIdentity=" + mCellIdentity + + ", mBarringServiceInfos=" + mBarringServiceInfos + "}"; + } +} 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/CallForwardingInfo.java b/telephony/java/android/telephony/CallForwardingInfo.java index 1dd7539420ac..7e777fae46eb 100644 --- a/telephony/java/android/telephony/CallForwardingInfo.java +++ b/telephony/java/android/telephony/CallForwardingInfo.java @@ -15,24 +15,24 @@ */ package android.telephony; + +import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SuppressLint; -import android.annotation.SystemApi; import android.os.Parcel; import android.os.Parcelable; -import android.telephony.Annotation.CallForwardingReason; -import android.telephony.Annotation.CallForwardingStatus; import com.android.telephony.Rlog; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.util.Objects; /** * Defines the call forwarding information. * @hide */ -@SystemApi public final class CallForwardingInfo implements Parcelable { private static final String TAG = "CallForwardingInfo"; @@ -41,7 +41,6 @@ public final class CallForwardingInfo implements Parcelable { * * @hide */ - @SystemApi public static final int STATUS_INACTIVE = 0; /** @@ -49,7 +48,6 @@ public final class CallForwardingInfo implements Parcelable { * * @hide */ - @SystemApi public static final int STATUS_ACTIVE = 1; /** @@ -58,7 +56,6 @@ public final class CallForwardingInfo implements Parcelable { * * @hide */ - @SystemApi public static final int STATUS_FDN_CHECK_FAILURE = 2; /** @@ -66,7 +63,6 @@ public final class CallForwardingInfo implements Parcelable { * * @hide */ - @SystemApi public static final int STATUS_UNKNOWN_ERROR = 3; /** @@ -74,7 +70,6 @@ public final class CallForwardingInfo implements Parcelable { * * @hide */ - @SystemApi public static final int STATUS_NOT_SUPPORTED = 4; /** @@ -83,7 +78,6 @@ public final class CallForwardingInfo implements Parcelable { * and conditions +CCFC * @hide */ - @SystemApi public static final int REASON_UNCONDITIONAL = 0; /** @@ -92,7 +86,6 @@ public final class CallForwardingInfo implements Parcelable { * and conditions +CCFC * @hide */ - @SystemApi public static final int REASON_BUSY = 1; /** @@ -101,7 +94,6 @@ public final class CallForwardingInfo implements Parcelable { * and conditions +CCFC * @hide */ - @SystemApi public static final int REASON_NO_REPLY = 2; /** @@ -110,7 +102,6 @@ public final class CallForwardingInfo implements Parcelable { * and conditions +CCFC * @hide */ - @SystemApi public static final int REASON_NOT_REACHABLE = 3; /** @@ -120,7 +111,6 @@ public final class CallForwardingInfo implements Parcelable { * and conditions +CCFC * @hide */ - @SystemApi public static final int REASON_ALL = 4; /** @@ -130,20 +120,48 @@ public final class CallForwardingInfo implements Parcelable { * and conditions +CCFC * @hide */ - @SystemApi public static final int REASON_ALL_CONDITIONAL = 5; /** + * Call forwarding function status + */ + @IntDef(prefix = { "STATUS_" }, value = { + STATUS_ACTIVE, + STATUS_INACTIVE, + STATUS_UNKNOWN_ERROR, + STATUS_NOT_SUPPORTED, + STATUS_FDN_CHECK_FAILURE + }) + @Retention(RetentionPolicy.SOURCE) + public @interface CallForwardingStatus { + } + + /** + * Call forwarding reason types + */ + @IntDef(flag = true, prefix = { "REASON_" }, value = { + REASON_UNCONDITIONAL, + REASON_BUSY, + REASON_NO_REPLY, + REASON_NOT_REACHABLE, + REASON_ALL, + REASON_ALL_CONDITIONAL + }) + @Retention(RetentionPolicy.SOURCE) + public @interface CallForwardingReason { + } + + /** * The call forwarding status. */ - private @CallForwardingStatus int mStatus; + private int mStatus; /** * The call forwarding reason indicates the condition under which calls will be forwarded. * Reference: 3GPP TS 27.007 version 10.3.0 Release 10 - 7.11 Call forwarding number * and conditions +CCFC */ - private @CallForwardingReason int mReason; + private int mReason; /** * The phone number to which calls will be forwarded. @@ -166,7 +184,6 @@ public final class CallForwardingInfo implements Parcelable { * @param timeSeconds the timeout (in seconds) before the forwarding is attempted * @hide */ - @SystemApi public CallForwardingInfo(@CallForwardingStatus int status, @CallForwardingReason int reason, @Nullable String number, int timeSeconds) { mStatus = status; @@ -182,7 +199,6 @@ public final class CallForwardingInfo implements Parcelable { * * @hide */ - @SystemApi public @CallForwardingStatus int getStatus() { return mStatus; } @@ -196,7 +212,6 @@ public final class CallForwardingInfo implements Parcelable { * * @hide */ - @SystemApi public @CallForwardingReason int getReason() { return mReason; } @@ -209,7 +224,6 @@ public final class CallForwardingInfo implements Parcelable { * * @hide */ - @SystemApi @Nullable public String getNumber() { return mNumber; @@ -227,7 +241,6 @@ public final class CallForwardingInfo implements Parcelable { * * @hide */ - @SystemApi @SuppressLint("MethodNameUnits") public int getTimeoutSeconds() { return mTimeSeconds; diff --git a/telephony/java/android/telephony/CallQuality.java b/telephony/java/android/telephony/CallQuality.java index 1e1cdba70ad0..428a515844e6 100644 --- a/telephony/java/android/telephony/CallQuality.java +++ b/telephony/java/android/telephony/CallQuality.java @@ -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 de35c00c8059..13c53235f746 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; @@ -1493,6 +1492,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 */ @@ -1553,6 +1596,7 @@ public class CarrierConfigManager { /** * The string is used to compare with operator name. * If it matches the pattern then show specific data icon. + * @hide */ public static final String KEY_SHOW_CARRIER_DATA_ICON_PATTERN_STRING = "show_carrier_data_icon_pattern_string"; @@ -1885,6 +1929,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. @@ -2151,12 +2203,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 @@ -2531,7 +2577,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 @@ -2967,9 +3012,9 @@ public class CarrierConfigManager { * UE wants to display 5G_Plus icon for scenario#1, and 5G icon for scenario#2; otherwise not * define. * The configuration is: "connected_mmwave:5G_Plus,connected:5G" + * @hide */ - public static final String KEY_5G_ICON_CONFIGURATION_STRING = - "5g_icon_configuration_string"; + public static final String KEY_5G_ICON_CONFIGURATION_STRING = "5g_icon_configuration_string"; /** * Timeout in seconds for displaying 5G icon, default value is 0 which means the timer is @@ -2981,12 +3026,14 @@ public class CarrierConfigManager { * * If 5G is reacquired during this timer, the timer is canceled and restarted when 5G is next * lost. Allows us to momentarily lose 5G without blinking the icon. + * @hide */ public static final String KEY_5G_ICON_DISPLAY_GRACE_PERIOD_SEC_INT = "5g_icon_display_grace_period_sec_int"; /** * Controls time in milliseconds until DcTracker reevaluates 5G connection state. + * @hide */ public static final String KEY_5G_WATCHDOG_TIME_MS_LONG = "5g_watchdog_time_long"; @@ -3181,6 +3228,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 { @@ -3353,7 +3409,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"); @@ -3444,7 +3500,7 @@ public class CarrierConfigManager { * @hide */ public static final String KEY_DATA_SWITCH_VALIDATION_MIN_GAP_LONG = - "data_switch_validation_min_gap_LONG"; + "data_switch_validation_min_gap_long"; /** * A boolean property indicating whether this subscription should be managed as an opportunistic @@ -3468,12 +3524,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; } } @@ -3502,6 +3563,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. */ @@ -3533,6 +3603,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. @@ -3680,6 +3758,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[]{ @@ -3723,7 +3803,7 @@ public class CarrierConfigManager { sDefaults.putInt(KEY_IMS_DTMF_TONE_DELAY_INT, 0); sDefaults.putInt(KEY_CDMA_DTMF_TONE_DELAY_INT, 100); sDefaults.putBoolean(KEY_CALL_FORWARDING_MAP_NON_NUMBER_TO_VOICEMAIL_BOOL, false); - sDefaults.putBoolean(KEY_IGNORE_RTT_MODE_SETTING_BOOL, false); + sDefaults.putBoolean(KEY_IGNORE_RTT_MODE_SETTING_BOOL, true); sDefaults.putInt(KEY_CDMA_3WAYCALL_FLASH_DELAY_INT , 0); sDefaults.putBoolean(KEY_SUPPORT_ADHOC_CONFERENCE_CALLS_BOOL, false); sDefaults.putBoolean(KEY_SUPPORT_ADD_CONFERENCE_PARTICIPANTS_BOOL, false); @@ -3811,6 +3891,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 @@ -3877,7 +3958,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); @@ -4060,8 +4140,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]); @@ -4069,6 +4154,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, @@ -4092,7 +4202,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()); @@ -4304,8 +4414,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/CellIdentityGsm.java b/telephony/java/android/telephony/CellIdentityGsm.java index 9f2537c7ed10..203047fb111d 100644 --- a/telephony/java/android/telephony/CellIdentityGsm.java +++ b/telephony/java/android/telephony/CellIdentityGsm.java @@ -22,11 +22,12 @@ import android.compat.annotation.UnsupportedAppUsage; import android.os.Parcel; import android.telephony.gsm.GsmCellLocation; import android.text.TextUtils; +import android.util.ArraySet; -import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; -import java.util.List; import java.util.Objects; +import java.util.Set; /** * CellIdentity to represent a unique GSM cell @@ -50,7 +51,7 @@ public final class CellIdentityGsm extends CellIdentity { private final int mBsic; // a list of additional PLMN-IDs reported for this cell - private final List<String> mAdditionalPlmns; + private final ArraySet<String> mAdditionalPlmns; /** * @hide @@ -62,7 +63,7 @@ public final class CellIdentityGsm extends CellIdentity { mCid = CellInfo.UNAVAILABLE; mArfcn = CellInfo.UNAVAILABLE; mBsic = CellInfo.UNAVAILABLE; - mAdditionalPlmns = Collections.emptyList(); + mAdditionalPlmns = new ArraySet<>(); } /** @@ -81,13 +82,13 @@ public final class CellIdentityGsm extends CellIdentity { */ public CellIdentityGsm(int lac, int cid, int arfcn, int bsic, @Nullable String mccStr, @Nullable String mncStr, @Nullable String alphal, @Nullable String alphas, - @NonNull List<String> additionalPlmns) { + @NonNull Collection<String> additionalPlmns) { super(TAG, CellInfo.TYPE_GSM, mccStr, mncStr, alphal, alphas); mLac = inRangeOrUnavailable(lac, 0, MAX_LAC); mCid = inRangeOrUnavailable(cid, 0, MAX_CID); mArfcn = inRangeOrUnavailable(arfcn, 0, MAX_ARFCN); mBsic = inRangeOrUnavailable(bsic, 0, MAX_BSIC); - mAdditionalPlmns = new ArrayList<>(additionalPlmns.size()); + mAdditionalPlmns = new ArraySet<>(additionalPlmns.size()); for (String plmn : additionalPlmns) { if (isValidPlmn(plmn)) { mAdditionalPlmns.add(plmn); @@ -99,7 +100,7 @@ public final class CellIdentityGsm extends CellIdentity { public CellIdentityGsm(@NonNull android.hardware.radio.V1_0.CellIdentityGsm cid) { this(cid.lac, cid.cid, cid.arfcn, cid.bsic == (byte) 0xFF ? CellInfo.UNAVAILABLE : cid.bsic, - cid.mcc, cid.mnc, "", "", Collections.emptyList()); + cid.mcc, cid.mnc, "", "", new ArraySet<>()); } /** @hide */ @@ -107,7 +108,7 @@ public final class CellIdentityGsm extends CellIdentity { this(cid.base.lac, cid.base.cid, cid.base.arfcn, cid.base.bsic == (byte) 0xFF ? CellInfo.UNAVAILABLE : cid.base.bsic, cid.base.mcc, cid.base.mnc, cid.operatorNames.alphaLong, cid.operatorNames.alphaShort, - Collections.emptyList()); + new ArraySet<>()); } /** @hide */ @@ -221,8 +222,8 @@ public final class CellIdentityGsm extends CellIdentity { * @return a list of additional PLMN IDs supported by this cell. */ @NonNull - public List<String> getAdditionalPlmns() { - return mAdditionalPlmns; + public Set<String> getAdditionalPlmns() { + return Collections.unmodifiableSet(mAdditionalPlmns); } /** @@ -296,7 +297,7 @@ public final class CellIdentityGsm extends CellIdentity { dest.writeInt(mCid); dest.writeInt(mArfcn); dest.writeInt(mBsic); - dest.writeList(mAdditionalPlmns); + dest.writeArraySet(mAdditionalPlmns); } /** Construct from Parcel, type has already been processed */ @@ -306,7 +307,7 @@ public final class CellIdentityGsm extends CellIdentity { mCid = in.readInt(); mArfcn = in.readInt(); mBsic = in.readInt(); - mAdditionalPlmns = in.readArrayList(null); + mAdditionalPlmns = (ArraySet<String>) in.readArraySet(null); if (DBG) log(toString()); } diff --git a/telephony/java/android/telephony/CellIdentityLte.java b/telephony/java/android/telephony/CellIdentityLte.java index a194ae35216c..b4ce162274fb 100644 --- a/telephony/java/android/telephony/CellIdentityLte.java +++ b/telephony/java/android/telephony/CellIdentityLte.java @@ -23,11 +23,13 @@ import android.os.Build; import android.os.Parcel; import android.telephony.gsm.GsmCellLocation; import android.text.TextUtils; +import android.util.ArraySet; -import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; import java.util.Collections; -import java.util.List; import java.util.Objects; +import java.util.Set; /** * CellIdentity is to represent a unique LTE cell @@ -52,9 +54,11 @@ public final class CellIdentityLte extends CellIdentity { private final int mEarfcn; // cell bandwidth, in kHz private final int mBandwidth; + // cell bands + private final int[] mBands; // a list of additional PLMN-IDs reported for this cell - private final List<String> mAdditionalPlmns; + private final ArraySet<String> mAdditionalPlmns; private ClosedSubscriberGroupInfo mCsgInfo; @@ -68,8 +72,9 @@ public final class CellIdentityLte extends CellIdentity { mPci = CellInfo.UNAVAILABLE; mTac = CellInfo.UNAVAILABLE; mEarfcn = CellInfo.UNAVAILABLE; + mBands = new int[] {}; mBandwidth = CellInfo.UNAVAILABLE; - mAdditionalPlmns = Collections.emptyList(); + mAdditionalPlmns = new ArraySet<>(); mCsgInfo = null; } @@ -85,8 +90,9 @@ public final class CellIdentityLte extends CellIdentity { */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) public CellIdentityLte(int mcc, int mnc, int ci, int pci, int tac) { - this(ci, pci, tac, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, String.valueOf(mcc), - String.valueOf(mnc), null, null, Collections.emptyList(), null); + this(ci, pci, tac, CellInfo.UNAVAILABLE, new int[] {}, CellInfo.UNAVAILABLE, + String.valueOf(mcc), String.valueOf(mnc), null, null, new ArraySet<>(), + null); } /** @@ -105,17 +111,19 @@ public final class CellIdentityLte extends CellIdentity { * * @hide */ - public CellIdentityLte(int ci, int pci, int tac, int earfcn, int bandwidth, - @Nullable String mccStr, @Nullable String mncStr, @Nullable String alphal, - @Nullable String alphas, @NonNull List<String> additionalPlmns, + public CellIdentityLte(int ci, int pci, int tac, int earfcn, @NonNull int[] bands, + int bandwidth, @Nullable String mccStr, @Nullable String mncStr, + @Nullable String alphal, @Nullable String alphas, + @NonNull Collection<String> additionalPlmns, @Nullable ClosedSubscriberGroupInfo csgInfo) { super(TAG, CellInfo.TYPE_LTE, mccStr, mncStr, alphal, alphas); mCi = inRangeOrUnavailable(ci, 0, MAX_CI); mPci = inRangeOrUnavailable(pci, 0, MAX_PCI); mTac = inRangeOrUnavailable(tac, 0, MAX_TAC); mEarfcn = inRangeOrUnavailable(earfcn, 0, MAX_EARFCN); + mBands = bands; mBandwidth = inRangeOrUnavailable(bandwidth, 0, MAX_BANDWIDTH); - mAdditionalPlmns = new ArrayList<>(additionalPlmns.size()); + mAdditionalPlmns = new ArraySet<>(additionalPlmns.size()); for (String plmn : additionalPlmns) { if (isValidPlmn(plmn)) { mAdditionalPlmns.add(plmn); @@ -126,28 +134,29 @@ public final class CellIdentityLte extends CellIdentity { /** @hide */ public CellIdentityLte(@NonNull android.hardware.radio.V1_0.CellIdentityLte cid) { - this(cid.ci, cid.pci, cid.tac, cid.earfcn, - CellInfo.UNAVAILABLE, cid.mcc, cid.mnc, "", "", Collections.emptyList(), null); + this(cid.ci, cid.pci, cid.tac, cid.earfcn, new int[] {}, + CellInfo.UNAVAILABLE, cid.mcc, cid.mnc, "", "", new ArraySet<>(), null); } /** @hide */ public CellIdentityLte(@NonNull android.hardware.radio.V1_2.CellIdentityLte cid) { - this(cid.base.ci, cid.base.pci, cid.base.tac, cid.base.earfcn, cid.bandwidth, - cid.base.mcc, cid.base.mnc, cid.operatorNames.alphaLong, - cid.operatorNames.alphaShort, Collections.emptyList(), null); + this(cid.base.ci, cid.base.pci, cid.base.tac, cid.base.earfcn, new int[] {}, + cid.bandwidth, cid.base.mcc, cid.base.mnc, cid.operatorNames.alphaLong, + cid.operatorNames.alphaShort, new ArraySet<>(), null); } /** @hide */ public CellIdentityLte(@NonNull android.hardware.radio.V1_5.CellIdentityLte cid) { this(cid.base.base.ci, cid.base.base.pci, cid.base.base.tac, cid.base.base.earfcn, - cid.base.bandwidth, cid.base.base.mcc, cid.base.base.mnc, - cid.base.operatorNames.alphaLong, cid.base.operatorNames.alphaShort, - cid.additionalPlmns, cid.optionalCsgInfo.csgInfo() != null + cid.bands.stream().mapToInt(Integer::intValue).toArray(), cid.base.bandwidth, + cid.base.base.mcc, cid.base.base.mnc, cid.base.operatorNames.alphaLong, + cid.base.operatorNames.alphaShort, cid.additionalPlmns, + cid.optionalCsgInfo.csgInfo() != null ? new ClosedSubscriberGroupInfo(cid.optionalCsgInfo.csgInfo()) : null); } private CellIdentityLte(@NonNull CellIdentityLte cid) { - this(cid.mCi, cid.mPci, cid.mTac, cid.mEarfcn, cid.mBandwidth, cid.mMccStr, + this(cid.mCi, cid.mPci, cid.mTac, cid.mEarfcn, cid.mBands, cid.mBandwidth, cid.mMccStr, cid.mMncStr, cid.mAlphaLong, cid.mAlphaShort, cid.mAdditionalPlmns, cid.mCsgInfo); } @@ -155,7 +164,7 @@ public final class CellIdentityLte extends CellIdentity { @Override public @NonNull CellIdentityLte sanitizeLocationInfo() { return new CellIdentityLte(CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, - CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, + CellInfo.UNAVAILABLE, mBands, CellInfo.UNAVAILABLE, mMccStr, mMncStr, mAlphaLong, mAlphaShort, mAdditionalPlmns, null); } @@ -220,12 +229,11 @@ public final class CellIdentityLte extends CellIdentity { * * Reference: 3GPP TS 36.101 section 5.5 * - * @return List of band number or empty list if not available. + * @return Array of band number or empty array if not available. */ @NonNull - public List<Integer> getBands() { - // Todo: Add actual support - return Collections.emptyList(); + public int[] getBands() { + return Arrays.copyOf(mBands, mBands.length); } /** @@ -270,8 +278,8 @@ public final class CellIdentityLte extends CellIdentity { * @return a list of additional PLMN IDs supported by this cell. */ @NonNull - public List<String> getAdditionalPlmns() { - return mAdditionalPlmns; + public Set<String> getAdditionalPlmns() { + return Collections.unmodifiableSet(mAdditionalPlmns); } /** @@ -307,8 +315,8 @@ public final class CellIdentityLte extends CellIdentity { @Override public int hashCode() { - return Objects.hash(mCi, mPci, mTac, - mAdditionalPlmns.hashCode(), mCsgInfo, super.hashCode()); + return Objects.hash(mCi, mPci, mTac, mEarfcn, Arrays.hashCode(mBands), + mBandwidth, mAdditionalPlmns.hashCode(), mCsgInfo, super.hashCode()); } @Override @@ -326,6 +334,7 @@ public final class CellIdentityLte extends CellIdentity { && mPci == o.mPci && mTac == o.mTac && mEarfcn == o.mEarfcn + && Arrays.equals(mBands, o.mBands) && mBandwidth == o.mBandwidth && TextUtils.equals(mMccStr, o.mMccStr) && TextUtils.equals(mMncStr, o.mMncStr) @@ -341,6 +350,7 @@ public final class CellIdentityLte extends CellIdentity { .append(" mPci=").append(mPci) .append(" mTac=").append(mTac) .append(" mEarfcn=").append(mEarfcn) + .append(" mBands=").append(mBands) .append(" mBandwidth=").append(mBandwidth) .append(" mMcc=").append(mMccStr) .append(" mMnc=").append(mMncStr) @@ -360,8 +370,9 @@ public final class CellIdentityLte extends CellIdentity { dest.writeInt(mPci); dest.writeInt(mTac); dest.writeInt(mEarfcn); + dest.writeIntArray(mBands); dest.writeInt(mBandwidth); - dest.writeList(mAdditionalPlmns); + dest.writeArraySet(mAdditionalPlmns); dest.writeParcelable(mCsgInfo, flags); } @@ -372,8 +383,9 @@ public final class CellIdentityLte extends CellIdentity { mPci = in.readInt(); mTac = in.readInt(); mEarfcn = in.readInt(); + mBands = in.createIntArray(); mBandwidth = in.readInt(); - mAdditionalPlmns = in.readArrayList(null); + mAdditionalPlmns = (ArraySet<String>) in.readArraySet(null); mCsgInfo = in.readParcelable(null); if (DBG) log(toString()); } diff --git a/telephony/java/android/telephony/CellIdentityNr.java b/telephony/java/android/telephony/CellIdentityNr.java index a0ef5aa2feae..69cf7e7d4814 100644 --- a/telephony/java/android/telephony/CellIdentityNr.java +++ b/telephony/java/android/telephony/CellIdentityNr.java @@ -22,11 +22,13 @@ import android.annotation.Nullable; import android.os.Parcel; import android.telephony.AccessNetworkConstants.NgranBands.NgranBand; import android.telephony.gsm.GsmCellLocation; +import android.util.ArraySet; -import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; import java.util.Collections; -import java.util.List; import java.util.Objects; +import java.util.Set; /** * Information to represent a unique NR(New Radio 5G) cell. @@ -43,10 +45,10 @@ public final class CellIdentityNr extends CellIdentity { private final int mPci; private final int mTac; private final long mNci; - private final List<Integer> mBands; + private final int[] mBands; // a list of additional PLMN-IDs reported for this cell - private final List<String> mAdditionalPlmns; + private final ArraySet<String> mAdditionalPlmns; /** * @@ -63,17 +65,18 @@ public final class CellIdentityNr extends CellIdentity { * * @hide */ - public CellIdentityNr(int pci, int tac, int nrArfcn, @NgranBand List<Integer> bands, + public CellIdentityNr(int pci, int tac, int nrArfcn, @NonNull @NgranBand int[] bands, @Nullable String mccStr, @Nullable String mncStr, long nci, @Nullable String alphal, @Nullable String alphas, - @NonNull List<String> additionalPlmns) { + @NonNull Collection<String> additionalPlmns) { super(TAG, CellInfo.TYPE_NR, mccStr, mncStr, alphal, alphas); mPci = inRangeOrUnavailable(pci, 0, MAX_PCI); mTac = inRangeOrUnavailable(tac, 0, MAX_TAC); mNrArfcn = inRangeOrUnavailable(nrArfcn, 0, MAX_NRARFCN); - mBands = new ArrayList<>(bands); + // TODO: input validation for bands + mBands = bands; mNci = inRangeOrUnavailable(nci, 0, MAX_NCI); - mAdditionalPlmns = new ArrayList<>(additionalPlmns.size()); + mAdditionalPlmns = new ArraySet<>(additionalPlmns.size()); for (String plmn : additionalPlmns) { if (isValidPlmn(plmn)) { mAdditionalPlmns.add(plmn); @@ -83,15 +86,16 @@ public final class CellIdentityNr extends CellIdentity { /** @hide */ public CellIdentityNr(@NonNull android.hardware.radio.V1_4.CellIdentityNr cid) { - this(cid.pci, cid.tac, cid.nrarfcn, Collections.emptyList(), cid.mcc, cid.mnc, cid.nci, + this(cid.pci, cid.tac, cid.nrarfcn, new int[] {}, cid.mcc, cid.mnc, cid.nci, cid.operatorNames.alphaLong, cid.operatorNames.alphaShort, - Collections.emptyList()); + new ArraySet<>()); } /** @hide */ public CellIdentityNr(@NonNull android.hardware.radio.V1_5.CellIdentityNr cid) { - this(cid.base.pci, cid.base.tac, cid.base.nrarfcn, cid.bands, cid.base.mcc, cid.base.mnc, - cid.base.nci, cid.base.operatorNames.alphaLong, + this(cid.base.pci, cid.base.tac, cid.base.nrarfcn, + cid.bands.stream().mapToInt(Integer::intValue).toArray(), cid.base.mcc, + cid.base.mnc, cid.base.nci, cid.base.operatorNames.alphaLong, cid.base.operatorNames.alphaShort, cid.additionalPlmns); } @@ -116,18 +120,22 @@ public final class CellIdentityNr extends CellIdentity { @Override public int hashCode() { return Objects.hash(super.hashCode(), mPci, mTac, - mNrArfcn, mBands.hashCode(), mNci, mAdditionalPlmns.hashCode()); + mNrArfcn, Arrays.hashCode(mBands), mNci, mAdditionalPlmns.hashCode()); } @Override public boolean equals(Object other) { + if (this == other) { + return true; + } + if (!(other instanceof CellIdentityNr)) { return false; } CellIdentityNr o = (CellIdentityNr) other; return super.equals(o) && mPci == o.mPci && mTac == o.mTac && mNrArfcn == o.mNrArfcn - && mBands.equals(o.mBands) && mNci == o.mNci + && Arrays.equals(mBands, o.mBands) && mNci == o.mNci && mAdditionalPlmns.equals(o.mAdditionalPlmns); } @@ -160,12 +168,12 @@ public final class CellIdentityNr extends CellIdentity { * Reference: TS 38.101-1 table 5.2-1 * Reference: TS 38.101-2 table 5.2-1 * - * @return List of band number or empty list if not available. + * @return Array of band number or empty array if not available. */ @NgranBand @NonNull - public List<Integer> getBands() { - return Collections.unmodifiableList(mBands); + public int[] getBands() { + return Arrays.copyOf(mBands, mBands.length); } /** @@ -212,8 +220,8 @@ public final class CellIdentityNr extends CellIdentity { * @return a list of additional PLMN IDs supported by this cell. */ @NonNull - public List<String> getAdditionalPlmns() { - return Collections.unmodifiableList(mAdditionalPlmns); + public Set<String> getAdditionalPlmns() { + return Collections.unmodifiableSet(mAdditionalPlmns); } @Override @@ -239,9 +247,9 @@ public final class CellIdentityNr extends CellIdentity { dest.writeInt(mPci); dest.writeInt(mTac); dest.writeInt(mNrArfcn); - dest.writeList(mBands); + dest.writeIntArray(mBands); dest.writeLong(mNci); - dest.writeList(mAdditionalPlmns); + dest.writeArraySet(mAdditionalPlmns); } /** Construct from Parcel, type has already been processed */ @@ -250,9 +258,9 @@ public final class CellIdentityNr extends CellIdentity { mPci = in.readInt(); mTac = in.readInt(); mNrArfcn = in.readInt(); - mBands = in.readArrayList(null); + mBands = in.createIntArray(); mNci = in.readLong(); - mAdditionalPlmns = in.readArrayList(null); + mAdditionalPlmns = (ArraySet<String>) in.readArraySet(null); } /** Implement the Parcelable interface */ diff --git a/telephony/java/android/telephony/CellIdentityTdscdma.java b/telephony/java/android/telephony/CellIdentityTdscdma.java index 531487a313d9..30f98bc57458 100644 --- a/telephony/java/android/telephony/CellIdentityTdscdma.java +++ b/telephony/java/android/telephony/CellIdentityTdscdma.java @@ -20,11 +20,12 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.os.Parcel; import android.telephony.gsm.GsmCellLocation; +import android.util.ArraySet; -import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; -import java.util.List; import java.util.Objects; +import java.util.Set; /** * CellIdentity is to represent a unique TD-SCDMA cell @@ -50,7 +51,7 @@ public final class CellIdentityTdscdma extends CellIdentity { private final int mUarfcn; // a list of additional PLMN-IDs reported for this cell - private final List<String> mAdditionalPlmns; + private final ArraySet<String> mAdditionalPlmns; private ClosedSubscriberGroupInfo mCsgInfo; @@ -63,7 +64,7 @@ public final class CellIdentityTdscdma extends CellIdentity { mCid = CellInfo.UNAVAILABLE; mCpid = CellInfo.UNAVAILABLE; mUarfcn = CellInfo.UNAVAILABLE; - mAdditionalPlmns = Collections.emptyList(); + mAdditionalPlmns = new ArraySet<>(); mCsgInfo = null; } @@ -85,13 +86,14 @@ public final class CellIdentityTdscdma extends CellIdentity { */ public CellIdentityTdscdma(@Nullable String mcc, @Nullable String mnc, int lac, int cid, int cpid, int uarfcn, @Nullable String alphal, @Nullable String alphas, - @NonNull List<String> additionalPlmns, @Nullable ClosedSubscriberGroupInfo csgInfo) { + @NonNull Collection<String> additionalPlmns, + @Nullable ClosedSubscriberGroupInfo csgInfo) { super(TAG, CellInfo.TYPE_TDSCDMA, mcc, mnc, alphal, alphas); mLac = inRangeOrUnavailable(lac, 0, MAX_LAC); mCid = inRangeOrUnavailable(cid, 0, MAX_CID); mCpid = inRangeOrUnavailable(cpid, 0, MAX_CPID); mUarfcn = inRangeOrUnavailable(uarfcn, 0, MAX_UARFCN); - mAdditionalPlmns = new ArrayList<>(additionalPlmns.size()); + mAdditionalPlmns = new ArraySet<>(additionalPlmns.size()); for (String plmn : additionalPlmns) { if (isValidPlmn(plmn)) { mAdditionalPlmns.add(plmn); @@ -208,8 +210,8 @@ public final class CellIdentityTdscdma extends CellIdentity { * @return a list of additional PLMN IDs supported by this cell. */ @NonNull - public List<String> getAdditionalPlmns() { - return mAdditionalPlmns; + public Set<String> getAdditionalPlmns() { + return Collections.unmodifiableSet(mAdditionalPlmns); } /** @@ -289,7 +291,7 @@ public final class CellIdentityTdscdma extends CellIdentity { dest.writeInt(mCid); dest.writeInt(mCpid); dest.writeInt(mUarfcn); - dest.writeList(mAdditionalPlmns); + dest.writeArraySet(mAdditionalPlmns); dest.writeParcelable(mCsgInfo, flags); } @@ -300,7 +302,7 @@ public final class CellIdentityTdscdma extends CellIdentity { mCid = in.readInt(); mCpid = in.readInt(); mUarfcn = in.readInt(); - mAdditionalPlmns = in.readArrayList(null); + mAdditionalPlmns = (ArraySet<String>) in.readArraySet(null); mCsgInfo = in.readParcelable(null); if (DBG) log(toString()); } diff --git a/telephony/java/android/telephony/CellIdentityWcdma.java b/telephony/java/android/telephony/CellIdentityWcdma.java index 15e491b66575..9d2cb74bac23 100644 --- a/telephony/java/android/telephony/CellIdentityWcdma.java +++ b/telephony/java/android/telephony/CellIdentityWcdma.java @@ -22,11 +22,12 @@ import android.compat.annotation.UnsupportedAppUsage; import android.os.Parcel; import android.telephony.gsm.GsmCellLocation; import android.text.TextUtils; +import android.util.ArraySet; -import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; -import java.util.List; import java.util.Objects; +import java.util.Set; /** * CellIdentity to represent a unique UMTS cell @@ -51,7 +52,7 @@ public final class CellIdentityWcdma extends CellIdentity { private final int mUarfcn; // a list of additional PLMN-IDs reported for this cell - private final List<String> mAdditionalPlmns; + private final ArraySet<String> mAdditionalPlmns; @Nullable private final ClosedSubscriberGroupInfo mCsgInfo; @@ -65,7 +66,7 @@ public final class CellIdentityWcdma extends CellIdentity { mCid = CellInfo.UNAVAILABLE; mPsc = CellInfo.UNAVAILABLE; mUarfcn = CellInfo.UNAVAILABLE; - mAdditionalPlmns = Collections.emptyList(); + mAdditionalPlmns = new ArraySet<>(); mCsgInfo = null; } @@ -86,13 +87,14 @@ public final class CellIdentityWcdma extends CellIdentity { */ public CellIdentityWcdma(int lac, int cid, int psc, int uarfcn, @Nullable String mccStr, @Nullable String mncStr, @Nullable String alphal, @Nullable String alphas, - @NonNull List<String> additionalPlmns, @Nullable ClosedSubscriberGroupInfo csgInfo) { + @NonNull Collection<String> additionalPlmns, + @Nullable ClosedSubscriberGroupInfo csgInfo) { super(TAG, CellInfo.TYPE_WCDMA, mccStr, mncStr, alphal, alphas); mLac = inRangeOrUnavailable(lac, 0, MAX_LAC); mCid = inRangeOrUnavailable(cid, 0, MAX_CID); mPsc = inRangeOrUnavailable(psc, 0, MAX_PSC); mUarfcn = inRangeOrUnavailable(uarfcn, 0, MAX_UARFCN); - mAdditionalPlmns = new ArrayList<>(additionalPlmns.size()); + mAdditionalPlmns = new ArraySet<>(additionalPlmns.size()); for (String plmn : additionalPlmns) { if (isValidPlmn(plmn)) { mAdditionalPlmns.add(plmn); @@ -104,14 +106,14 @@ public final class CellIdentityWcdma extends CellIdentity { /** @hide */ public CellIdentityWcdma(@NonNull android.hardware.radio.V1_0.CellIdentityWcdma cid) { this(cid.lac, cid.cid, cid.psc, cid.uarfcn, cid.mcc, cid.mnc, "", "", - Collections.emptyList(), null); + new ArraySet<>(), null); } /** @hide */ public CellIdentityWcdma(@NonNull android.hardware.radio.V1_2.CellIdentityWcdma cid) { this(cid.base.lac, cid.base.cid, cid.base.psc, cid.base.uarfcn, cid.base.mcc, cid.base.mnc, cid.operatorNames.alphaLong, - cid.operatorNames.alphaShort, Collections.emptyList(), null); + cid.operatorNames.alphaShort, new ArraySet<>(), null); } /** @hide */ @@ -232,8 +234,8 @@ public final class CellIdentityWcdma extends CellIdentity { * @return a list of additional PLMN IDs supported by this cell. */ @NonNull - public List<String> getAdditionalPlmns() { - return mAdditionalPlmns; + public Set<String> getAdditionalPlmns() { + return Collections.unmodifiableSet(mAdditionalPlmns); } /** @@ -305,7 +307,7 @@ public final class CellIdentityWcdma extends CellIdentity { dest.writeInt(mCid); dest.writeInt(mPsc); dest.writeInt(mUarfcn); - dest.writeList(mAdditionalPlmns); + dest.writeArraySet(mAdditionalPlmns); dest.writeParcelable(mCsgInfo, flags); } @@ -316,7 +318,7 @@ public final class CellIdentityWcdma extends CellIdentity { mCid = in.readInt(); mPsc = in.readInt(); mUarfcn = in.readInt(); - mAdditionalPlmns = in.readArrayList(null); + mAdditionalPlmns = (ArraySet<String>) in.readArraySet(null); mCsgInfo = in.readParcelable(null); if (DBG) log(toString()); } diff --git a/telephony/java/android/telephony/CellLocation.java b/telephony/java/android/telephony/CellLocation.java index 64776e377fa4..2d0bd52f84ee 100644 --- a/telephony/java/android/telephony/CellLocation.java +++ b/telephony/java/android/telephony/CellLocation.java @@ -19,7 +19,6 @@ package android.telephony; import android.compat.annotation.UnsupportedAppUsage; import android.os.Bundle; import android.os.RemoteException; -import android.os.ServiceManager; import android.telephony.cdma.CdmaCellLocation; import android.telephony.gsm.GsmCellLocation; @@ -38,7 +37,11 @@ public abstract class CellLocation { */ public static void requestLocationUpdate() { try { - ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.getService("phone")); + ITelephony phone = ITelephony.Stub.asInterface( + TelephonyFrameworkInitializer + .getTelephonyServiceManager() + .getTelephonyServiceRegisterer() + .get()); if (phone != null) { phone.updateServiceLocation(); } @@ -50,8 +53,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/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/DataSpecificRegistrationInfo.java b/telephony/java/android/telephony/DataSpecificRegistrationInfo.java index 270eafe642b7..c667165e7a0e 100644 --- a/telephony/java/android/telephony/DataSpecificRegistrationInfo.java +++ b/telephony/java/android/telephony/DataSpecificRegistrationInfo.java @@ -208,7 +208,6 @@ public final class DataSpecificRegistrationInfo implements Parcelable { * @return {@code true} if using carrier aggregation. * @hide */ - @SystemApi public boolean isUsingCarrierAggregation() { return mIsUsingCarrierAggregation; } diff --git a/telephony/java/android/telephony/DisconnectCause.java b/telephony/java/android/telephony/DisconnectCause.java index aff1391fc080..be85b30f272b 100644 --- a/telephony/java/android/telephony/DisconnectCause.java +++ b/telephony/java/android/telephony/DisconnectCause.java @@ -360,6 +360,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. @@ -536,6 +542,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/ImsManager.java b/telephony/java/android/telephony/ImsManager.java index 704e5aa78188..3984bd769edd 100644 --- a/telephony/java/android/telephony/ImsManager.java +++ b/telephony/java/android/telephony/ImsManager.java @@ -19,9 +19,7 @@ package android.telephony.ims; import android.annotation.NonNull; import android.annotation.SdkConstant; import android.annotation.SuppressLint; -import android.annotation.SystemApi; import android.annotation.SystemService; -import android.annotation.TestApi; import android.content.Context; import android.telephony.SubscriptionManager; @@ -34,8 +32,9 @@ public class ImsManager { private Context mContext; /** - * <p>Broadcast Action: Indicates that an IMS operation was rejected by the network due to it - * not being authorized on the network. + * <p>Broadcast Action: Indicates that a previously allowed IMS operation was rejected by the + * network due to the network returning a "forbidden" response. This may be due to a + * provisioning change from the network. * May include the {@link SubscriptionManager#EXTRA_SUBSCRIPTION_INDEX} extra to also specify * which subscription the operation was rejected for. * <p class="note"> @@ -43,8 +42,6 @@ public class ImsManager { * issues. * @hide */ - @SystemApi - @TestApi // Moved from TelephonyIntents, need to keep backwards compatibility with OEM apps that have // this value hard-coded in BroadcastReceiver. @SuppressLint("ActionValue") @@ -74,17 +71,17 @@ public class ImsManager { "android.telephony.ims.action.WFC_IMS_REGISTRATION_ERROR"; /** - * An extra key corresponding to a String value which contains the carrier specific title to be - * displayed as part of the message shown to the user when there is an error registering for - * WiFi calling. + * An extra key corresponding to a {@link CharSequence} value which contains the carrier + * specific title to be displayed as part of the message shown to the user when there is an + * error registering for WiFi calling. */ public static final String EXTRA_WFC_REGISTRATION_FAILURE_TITLE = "android.telephony.ims.extra.WFC_REGISTRATION_FAILURE_TITLE"; /** - * An extra key corresponding to a String value which contains the carrier specific message to - * be displayed as part of the message shown to the user when there is an error registering for - * WiFi calling. + * An extra key corresponding to a {@link CharSequence} value which contains the carrier + * specific message to be displayed as part of the message shown to the user when there is an + * error registering for WiFi calling. */ public static final String EXTRA_WFC_REGISTRATION_FAILURE_MESSAGE = "android.telephony.ims.extra.WFC_REGISTRATION_FAILURE_MESSAGE"; @@ -103,10 +100,7 @@ public class ImsManager { * @param subscriptionId The ID of the subscription that this ImsRcsManager will use. * @throws IllegalArgumentException if the subscription is invalid. * @return a ImsRcsManager instance with the specific subscription ID. - * @hide */ - @SystemApi - @TestApi @NonNull public ImsRcsManager getImsRcsManager(int subscriptionId) { if (!SubscriptionManager.isValidSubscriptionId(subscriptionId)) { diff --git a/telephony/java/android/telephony/ModemActivityInfo.java b/telephony/java/android/telephony/ModemActivityInfo.java index 47a9d779fdd5..e2f604c153ba 100644 --- a/telephony/java/android/telephony/ModemActivityInfo.java +++ b/telephony/java/android/telephony/ModemActivityInfo.java @@ -16,6 +16,7 @@ package android.telephony; +import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.SystemApi; import android.os.Parcel; @@ -23,6 +24,8 @@ 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; @@ -43,6 +46,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 +149,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/NetworkRegistrationInfo.java b/telephony/java/android/telephony/NetworkRegistrationInfo.java index d8a65517c90f..4940cb2b143e 100644 --- a/telephony/java/android/telephony/NetworkRegistrationInfo.java +++ b/telephony/java/android/telephony/NetworkRegistrationInfo.java @@ -25,6 +25,7 @@ import android.os.Parcel; import android.os.Parcelable; import android.telephony.AccessNetworkConstants.TransportType; import android.telephony.Annotation.NetworkType; +import android.text.TextUtils; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -214,6 +215,9 @@ public final class NetworkRegistrationInfo implements Parcelable { @Nullable private DataSpecificRegistrationInfo mDataSpecificInfo; + @NonNull + private String mRplmn; + /** * @param domain Network domain. Must be a {@link Domain}. For transport type * {@link AccessNetworkConstants#TRANSPORT_TYPE_WLAN}, this must set to {@link #DOMAIN_PS}. @@ -234,13 +238,14 @@ public final class NetworkRegistrationInfo implements Parcelable { * @param availableServices The list of the supported services. * @param cellIdentity The identity representing a unique cell or wifi AP. Set to null if the * information is not available. + * @param rplmn the registered plmn or the last plmn for attempted registration if reg failed. */ private NetworkRegistrationInfo(@Domain int domain, @TransportType int transportType, @RegistrationState int registrationState, @NetworkType int accessNetworkTechnology, int rejectCause, boolean emergencyOnly, @Nullable @ServiceType List<Integer> availableServices, - @Nullable CellIdentity cellIdentity) { + @Nullable CellIdentity cellIdentity, @Nullable String rplmn) { mDomain = domain; mTransportType = transportType; mRegistrationState = registrationState; @@ -253,6 +258,7 @@ public final class NetworkRegistrationInfo implements Parcelable { mCellIdentity = cellIdentity; mEmergencyOnly = emergencyOnly; mNrState = NR_STATE_NONE; + mRplmn = rplmn; } /** @@ -263,11 +269,11 @@ public final class NetworkRegistrationInfo implements Parcelable { int registrationState, int accessNetworkTechnology, int rejectCause, boolean emergencyOnly, @Nullable List<Integer> availableServices, - @Nullable CellIdentity cellIdentity, boolean cssSupported, - int roamingIndicator, int systemIsInPrl, + @Nullable CellIdentity cellIdentity, @Nullable String rplmn, + boolean cssSupported, int roamingIndicator, int systemIsInPrl, int defaultRoamingIndicator) { this(domain, transportType, registrationState, accessNetworkTechnology, rejectCause, - emergencyOnly, availableServices, cellIdentity); + emergencyOnly, availableServices, cellIdentity, rplmn); mVoiceSpecificInfo = new VoiceSpecificRegistrationInfo(cssSupported, roamingIndicator, systemIsInPrl, defaultRoamingIndicator); @@ -281,13 +287,13 @@ public final class NetworkRegistrationInfo implements Parcelable { int registrationState, int accessNetworkTechnology, int rejectCause, boolean emergencyOnly, @Nullable List<Integer> availableServices, - @Nullable CellIdentity cellIdentity, int maxDataCalls, - boolean isDcNrRestricted, boolean isNrAvailable, - boolean isEndcAvailable, + @Nullable CellIdentity cellIdentity, @Nullable String rplmn, + int maxDataCalls, boolean isDcNrRestricted, + boolean isNrAvailable, boolean isEndcAvailable, LteVopsSupportInfo lteVopsSupportInfo, boolean isUsingCarrierAggregation) { this(domain, transportType, registrationState, accessNetworkTechnology, rejectCause, - emergencyOnly, availableServices, cellIdentity); + emergencyOnly, availableServices, cellIdentity, rplmn); mDataSpecificInfo = new DataSpecificRegistrationInfo( maxDataCalls, isDcNrRestricted, isNrAvailable, isEndcAvailable, lteVopsSupportInfo, isUsingCarrierAggregation); @@ -310,6 +316,7 @@ public final class NetworkRegistrationInfo implements Parcelable { mDataSpecificInfo = source.readParcelable( DataSpecificRegistrationInfo.class.getClassLoader()); mNrState = source.readInt(); + mRplmn = source.readString(); } /** @@ -343,6 +350,7 @@ public final class NetworkRegistrationInfo implements Parcelable { mDataSpecificInfo = new DataSpecificRegistrationInfo(nri.mDataSpecificInfo); } mNrState = nri.mNrState; + mRplmn = nri.mRplmn; } /** @@ -359,6 +367,7 @@ public final class NetworkRegistrationInfo implements Parcelable { * Get the 5G NR connection state. * * @return the 5G NR connection state. + * @hide */ public @NRState int getNrState() { return mNrState; @@ -395,6 +404,22 @@ public final class NetworkRegistrationInfo implements Parcelable { } /** + * Get the PLMN-ID for this Network Registration, also known as the RPLMN. + * + * <p>If the device is registered, this will return the registered PLMN-ID. If registration + * has failed, then this will return the PLMN ID of the last attempted registration. If the + * device is not registered, or if is registered to a non-3GPP radio technology, then this + * will return null. + * + * <p>See 3GPP TS 23.122 for further information about the Registered PLMN. + * + * @return the registered PLMN-ID or null. + */ + @Nullable public String getRegisteredPlmn() { + return mRplmn; + } + + /** * @return {@code true} if registered on roaming network, {@code false} otherwise. */ public boolean isRoaming() { @@ -590,6 +615,7 @@ public final class NetworkRegistrationInfo implements Parcelable { .append(" voiceSpecificInfo=").append(mVoiceSpecificInfo) .append(" dataSpecificInfo=").append(mDataSpecificInfo) .append(" nrState=").append(nrStateToString(mNrState)) + .append(" rRplmn=").append(mRplmn) .append("}").toString(); } @@ -597,7 +623,7 @@ public final class NetworkRegistrationInfo implements Parcelable { public int hashCode() { return Objects.hash(mDomain, mTransportType, mRegistrationState, mRoamingType, mAccessNetworkTechnology, mRejectCause, mEmergencyOnly, mAvailableServices, - mCellIdentity, mVoiceSpecificInfo, mDataSpecificInfo, mNrState); + mCellIdentity, mVoiceSpecificInfo, mDataSpecificInfo, mNrState, mRplmn); } @Override @@ -620,6 +646,7 @@ public final class NetworkRegistrationInfo implements Parcelable { && Objects.equals(mCellIdentity, other.mCellIdentity) && Objects.equals(mVoiceSpecificInfo, other.mVoiceSpecificInfo) && Objects.equals(mDataSpecificInfo, other.mDataSpecificInfo) + && TextUtils.equals(mRplmn, other.mRplmn) && mNrState == other.mNrState; } @@ -641,6 +668,7 @@ public final class NetworkRegistrationInfo implements Parcelable { dest.writeParcelable(mVoiceSpecificInfo, 0); dest.writeParcelable(mDataSpecificInfo, 0); dest.writeInt(mNrState); + dest.writeString(mRplmn); } /** @@ -741,6 +769,9 @@ public final class NetworkRegistrationInfo implements Parcelable { @Nullable private CellIdentity mCellIdentity; + @NonNull + private String mRplmn = ""; + /** * Default constructor for Builder. */ @@ -855,6 +886,18 @@ public final class NetworkRegistrationInfo implements Parcelable { } /** + * Set the registered PLMN. + * + * @param rplmn the registered plmn. + * + * @return The same instance of the builder. + */ + public @NonNull Builder setRegisteredPlmn(@Nullable String rplmn) { + mRplmn = rplmn; + return this; + } + + /** * Build the NetworkRegistrationInfo. * @return the NetworkRegistrationInfo object. * @hide @@ -863,7 +906,7 @@ public final class NetworkRegistrationInfo implements Parcelable { public @NonNull NetworkRegistrationInfo build() { return new NetworkRegistrationInfo(mDomain, mTransportType, mRegistrationState, mAccessNetworkTechnology, mRejectCause, mEmergencyOnly, mAvailableServices, - mCellIdentity); + mCellIdentity, mRplmn); } } } 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..6571858fc4ae 100644 --- a/telephony/java/android/telephony/PhoneCapability.java +++ b/telephony/java/android/telephony/PhoneCapability.java @@ -50,6 +50,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 +117,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 68c9d998ba92..98d6448e77ea 100644 --- a/telephony/java/android/telephony/PinResult.java +++ b/telephony/java/android/telephony/PinResult.java @@ -65,9 +65,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() { @@ -92,9 +92,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 54c22ae282fb..c2cfbef98740 100644 --- a/telephony/java/android/telephony/PreciseDataConnectionState.java +++ b/telephony/java/android/telephony/PreciseDataConnectionState.java @@ -95,7 +95,6 @@ public final class PreciseDataConnectionState implements Parcelable { * if there is no valid APN setting for the specific type, then this will be null * @hide */ - @SystemApi public PreciseDataConnectionState(@DataState int state, @NetworkType int networkType, @ApnType int apnTypes, @NonNull String apn, @@ -257,18 +256,17 @@ 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; } /** * Return the APN Settings for this data connection. * - * Returns the ApnSetting that was used to configure this data connection. + * @return the ApnSetting that was used to configure this data connection. */ // FIXME: This shouldn't be nullable; update once the ApnSetting is supplied correctly - @Nullable ApnSetting getApnSetting() { + public @Nullable ApnSetting getApnSetting() { return mApnSetting; } diff --git a/telephony/java/android/telephony/RadioAccessFamily.java b/telephony/java/android/telephony/RadioAccessFamily.java index bc8473865466..90ddf2cd4730 100644 --- a/telephony/java/android/telephony/RadioAccessFamily.java +++ b/telephony/java/android/telephony/RadioAccessFamily.java @@ -260,24 +260,6 @@ public class RadioAccessFamily implements Parcelable { return raf; } - /** - * Returns the highest capability of the RadioAccessFamily (4G > 3G > 2G). - * @param raf The RadioAccessFamily that we wish to filter - * @return The highest radio capability - */ - public static int getHighestRafCapability(int raf) { - if ((LTE & raf) > 0) { - return TelephonyManager.NETWORK_CLASS_4_G; - } - if ((EVDO|HS|WCDMA & raf) > 0) { - return TelephonyManager.NETWORK_CLASS_3_G; - } - if((GSM|CDMA & raf) > 0) { - return TelephonyManager.NETWORK_CLASS_2_G; - } - return TelephonyManager.NETWORK_CLASS_UNKNOWN; - } - @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) @PrefNetworkMode public static int getNetworkTypeFromRaf(int raf) { @@ -395,4 +377,34 @@ public class RadioAccessFamily implements Parcelable { } return result; } + + /** + * Compare two sets of network types to see which is more capable. + * + * This algorithm first tries to see see if a set has a strict superset of RAT support for + * each generation, from newest to oldest; if that results in a tie, then it returns the set + * that supports the most RAT types. + */ + public static int compare(long networkTypeBitmaskL, long networkTypeBitmaskR) { + final long[] prioritizedNetworkClassBitmasks = new long[] { + TelephonyManager.NETWORK_CLASS_BITMASK_5G, + TelephonyManager.NETWORK_CLASS_BITMASK_4G, + TelephonyManager.NETWORK_CLASS_BITMASK_3G, + TelephonyManager.NETWORK_CLASS_BITMASK_2G, + }; + + long lhsUnique = networkTypeBitmaskL & ~networkTypeBitmaskR; + long rhsUnique = networkTypeBitmaskR & ~networkTypeBitmaskL; + + // See if one has a strict super-set of capabilities, generation by generation. + for (long classBitmask : prioritizedNetworkClassBitmasks) { + int result = 0; + if ((lhsUnique & classBitmask) != 0) ++result; + if ((rhsUnique & classBitmask) != 0) --result; + if (result != 0) return result; + } + + // Without a clear winner, return the one that supports the most types. + return Long.bitCount(networkTypeBitmaskL) - Long.bitCount(networkTypeBitmaskR); + } } diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java index 5cf33dec25ea..deba5519ce22 100644 --- a/telephony/java/android/telephony/ServiceState.java +++ b/telephony/java/android/telephony/ServiceState.java @@ -688,8 +688,9 @@ public class ServiceState implements Parcelable { * @return true if registration indicates roaming, false otherwise * @hide */ - @SystemApi public boolean getDataRoamingFromRegistration() { + // TODO: all callers should refactor to get roaming state directly from modem + // this should not be exposed as a public API return mIsDataRoamingFromRegistration; } @@ -1421,7 +1422,6 @@ public class ServiceState implements Parcelable { * @return the frequency range of 5G NR. * @hide */ - @SystemApi public @FrequencyRange int getNrFrequencyRange() { return mNrFrequencyRange; } @@ -1650,7 +1650,6 @@ public class ServiceState implements Parcelable { * @return Current data network type * @hide */ - @SystemApi @TestApi public @NetworkType int getDataNetworkType() { final NetworkRegistrationInfo iwlanRegInfo = getNetworkRegistrationInfo( @@ -2022,11 +2021,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; } @@ -2041,11 +2041,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 16fbd07f9495..ad58c54054a3 100644 --- a/telephony/java/android/telephony/SignalStrength.java +++ b/telephony/java/android/telephony/SignalStrength.java @@ -93,8 +93,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 diff --git a/telephony/java/android/telephony/SmsManager.java b/telephony/java/android/telephony/SmsManager.java index 2714facc7a7f..f6a305f4bf2b 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); + true /* persistMessage*/, 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, 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) { + boolean persistMessage, String packageName, long messageId) { if (TextUtils.isEmpty(destinationAddress)) { throw new IllegalArgumentException("Invalid destinationAddress"); } @@ -534,10 +588,10 @@ public final class SmsManager { try { iSms.sendTextForSubscriber(subId, packageName, 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, 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); + false /* persistMessage */, null, + 0L /* messageId */); } private void sendTextMessageInternal( @@ -733,8 +788,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. */ @@ -746,7 +801,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); @@ -882,7 +937,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); + deliveryIntents, true /* persistMessage*/, null, + 0L /* messageId */); + } + + /** + * 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 + * + */ + public void sendMultipartTextMessage( + @NonNull String destinationAddress, @Nullable String scAddress, + @NonNull List<String> parts, @Nullable List<PendingIntent> sentIntents, + @Nullable List<PendingIntent> deliveryIntents, long messageId) { + sendMultipartTextMessageInternal(destinationAddress, scAddress, parts, sentIntents, + deliveryIntents, true /* persistMessage*/, null, + messageId); } /** @@ -901,23 +975,19 @@ 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) { sendMultipartTextMessageInternal(destinationAddress, scAddress, parts, sentIntents, - deliveryIntents, true /* persistMessage*/, packageName); + deliveryIntents, true /* persistMessage*/, packageName, 0L /* messageId */); } private void sendMultipartTextMessageInternal( String destinationAddress, String scAddress, List<String> parts, List<PendingIntent> sentIntents, List<PendingIntent> deliveryIntents, - boolean persistMessage, String packageName) { + boolean persistMessage, String packageName, long messageId) { if (TextUtils.isEmpty(destinationAddress)) { throw new IllegalArgumentException("Invalid destinationAddress"); } @@ -944,10 +1014,11 @@ public final class SmsManager { ISms iSms = getISmsServiceOrThrow(); iSms.sendMultipartTextForSubscriber(subId, packageName, 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); } } @@ -964,11 +1035,11 @@ public final class SmsManager { if (iSms != null) { iSms.sendMultipartTextForSubscriber(getSubscriptionId(), packageName, destinationAddress, scAddress, parts, sentIntents, deliveryIntents, - persistMessage); + persistMessage, messageId); } } catch (RemoteException e) { Log.e(TAG, "sendMultipartTextMessageInternal: Couldn't send SMS - " - + e.getMessage()); + + e.getMessage() + " id: " + messageId); notifySmsError(sentIntents, RESULT_REMOTE_EXCEPTION); } } @@ -982,7 +1053,7 @@ public final class SmsManager { deliveryIntent = deliveryIntents.get(0); } sendTextMessageInternal(destinationAddress, scAddress, parts.get(0), - sentIntent, deliveryIntent, true, packageName); + sentIntent, deliveryIntent, true, packageName, messageId); } } @@ -1012,7 +1083,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); + deliveryIntents, false /* persistMessage*/, null, + 0L /* messageId */); } /** @@ -1529,7 +1601,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."); } @@ -1559,7 +1634,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"); } @@ -1567,7 +1642,7 @@ public final class SmsManager { } private static ISms getISmsService() { - return ISms.Stub.asInterface(ServiceManager.getService("isms")); + return TelephonyManager.getSmsService(); } /** @@ -2004,7 +2079,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; @@ -2093,7 +2168,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 {} @@ -2343,7 +2447,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; @@ -2358,6 +2462,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 * @@ -2388,7 +2531,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 */); } } @@ -2426,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 */); } } @@ -2789,4 +2932,53 @@ 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); + } + } } diff --git a/telephony/java/android/telephony/SmsMessage.java b/telephony/java/android/telephony/SmsMessage.java index 52f089894b30..ad13ae19e3ce 100644 --- a/telephony/java/android/telephony/SmsMessage.java +++ b/telephony/java/android/telephony/SmsMessage.java @@ -763,9 +763,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; @@ -777,7 +777,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]; diff --git a/telephony/java/android/telephony/SubscriptionInfo.java b/telephony/java/android/telephony/SubscriptionInfo.java index 67eab0e1ff8c..0ec3d55efe3b 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,27 @@ public class SubscriptionInfo implements Parcelable { } /** - * @return the ICC ID. + * 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() { diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index d87df08ffc80..0b39c63cc5a4 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,7 +33,6 @@ 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.compat.annotation.UnsupportedAppUsage; import android.content.Context; @@ -42,7 +42,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 +52,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; @@ -78,7 +76,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; @@ -880,7 +877,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. @@ -972,14 +968,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 @@ -1157,10 +1145,10 @@ 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 @@ -1191,10 +1179,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 @@ -1225,10 +1213,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 @@ -1249,10 +1237,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 @@ -1316,8 +1304,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; } /** @@ -1330,10 +1323,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 @@ -1381,10 +1374,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 @@ -1420,7 +1413,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()); } @@ -1449,7 +1442,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); } @@ -1478,7 +1471,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); } @@ -1499,10 +1492,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 @@ -1528,10 +1521,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 @@ -1549,7 +1542,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(); } @@ -1606,7 +1599,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; @@ -1640,7 +1633,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; @@ -1657,14 +1650,15 @@ 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) { + @SystemApi + @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) @@ -1672,15 +1666,17 @@ 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) { + @SystemApi + @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); @@ -1740,7 +1736,7 @@ public class SubscriptionManager { int result = INVALID_SIM_SLOT_INDEX; try { - ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); + ISub iSub = TelephonyManager.getSubscriptionService(); if (iSub != null) { result = iSub.getSlotIndex(subscriptionId); } @@ -1774,7 +1770,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); } @@ -1798,7 +1794,7 @@ public class SubscriptionManager { int result = INVALID_PHONE_INDEX; try { - ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); + ISub iSub = TelephonyManager.getSubscriptionService(); if (iSub != null) { result = iSub.getPhoneId(subId); } @@ -1832,7 +1828,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.getDefaultSubId(); } @@ -1855,7 +1851,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(); } @@ -1885,7 +1881,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); } @@ -1933,7 +1929,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.getDefaultSmsSubId(); } @@ -1959,7 +1955,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); } @@ -1997,7 +1993,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.getDefaultDataSubId(); } @@ -2023,7 +2019,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); } @@ -2054,7 +2050,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(); } @@ -2190,7 +2186,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; @@ -2241,7 +2237,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); } @@ -2260,7 +2256,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); } @@ -2280,10 +2276,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 @@ -2444,10 +2440,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) { } @@ -2504,15 +2500,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 @@ -2576,89 +2563,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. * @@ -2732,7 +2636,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() { @@ -2775,7 +2679,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(); } @@ -2802,13 +2706,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 @@ -2907,7 +2812,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 { @@ -2957,7 +2862,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 { @@ -3009,7 +2914,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 { @@ -3047,16 +2952,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."); @@ -3167,7 +3073,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); } @@ -3197,7 +3103,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); } @@ -3227,7 +3137,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(); } @@ -3248,7 +3162,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); } @@ -3271,7 +3185,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); } @@ -3297,7 +3211,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); } @@ -3320,7 +3234,7 @@ public class SubscriptionManager { */ public static int getActiveDataSubscriptionId() { try { - ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); + ISub iSub = TelephonyManager.getSubscriptionService(); if (iSub != null) { return iSub.getActiveDataSubscriptionId(); } diff --git a/telephony/java/android/telephony/TelephonyFrameworkInitializer.java b/telephony/java/android/telephony/TelephonyFrameworkInitializer.java new file mode 100644 index 000000000000..0d2a8bc14bcb --- /dev/null +++ b/telephony/java/android/telephony/TelephonyFrameworkInitializer.java @@ -0,0 +1,103 @@ +/* + * 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.annotation.SystemApi; +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 + */ +@SystemApi +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 86b061512f1f..b9d87c44d528 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -53,12 +53,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; @@ -70,13 +70,12 @@ import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; import android.telephony.Annotation.ApnType; -import android.telephony.Annotation.CallForwardingReason; import android.telephony.Annotation.CallState; -import android.telephony.Annotation.CallWaitingStatus; import android.telephony.Annotation.NetworkType; import android.telephony.Annotation.RadioPowerState; import android.telephony.Annotation.SimActivationState; import android.telephony.Annotation.UiccAppType; +import android.telephony.CallForwardingInfo.CallForwardingReason; import android.telephony.VisualVoicemailService.VisualVoicemailTask; import android.telephony.data.ApnSetting; import android.telephony.data.ApnSetting.MvnoType; @@ -94,6 +93,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 +101,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; @@ -156,7 +157,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)} @@ -297,6 +298,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 @@ -317,21 +333,6 @@ public class TelephonyManager { }; /** @hide */ - @IntDef(prefix = {"MODEM_COUNT_"}, - value = { - MODEM_COUNT_NO_MODEM, - MODEM_COUNT_SINGLE_MODEM, - MODEM_COUNT_DUAL_MODEM, - MODEM_COUNT_TRI_MODEM - }) - public @interface ModemCount {} - - public static final int MODEM_COUNT_NO_MODEM = 0; - public static final int MODEM_COUNT_SINGLE_MODEM = 1; - public static final int MODEM_COUNT_DUAL_MODEM = 2; - public static final int MODEM_COUNT_TRI_MODEM = 3; - - /** @hide */ @UnsupportedAppUsage public TelephonyManager(Context context) { this(context, SubscriptionManager.DEFAULT_SUBSCRIPTION_ID); @@ -343,7 +344,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; } @@ -387,7 +392,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; } @@ -439,22 +450,22 @@ public class TelephonyManager { * Returns 2 for Dual standby mode (Dual SIM functionality). * Returns 3 for Tri standby mode (Tri SIM functionality). */ - public @ModemCount int getActiveModemCount() { + public int getActiveModemCount() { int modemCount = 1; switch (getMultiSimConfiguration()) { case UNKNOWN: - modemCount = MODEM_COUNT_SINGLE_MODEM; + modemCount = 1; // check for voice and data support, 0 if not supported if (!isVoiceCapable() && !isSmsCapable() && !isDataCapable()) { - modemCount = MODEM_COUNT_NO_MODEM; + modemCount = 0; } break; case DSDS: case DSDA: - modemCount = MODEM_COUNT_DUAL_MODEM; + modemCount = 2; break; case TSTS: - modemCount = MODEM_COUNT_TRI_MODEM; + modemCount = 3; break; } return modemCount; @@ -467,7 +478,7 @@ public class TelephonyManager { * dual-SIM capable device operating in single SIM mode (only one logical modem is turned on), * {@link #getActiveModemCount} returns 1 while this API returns 2. */ - public @ModemCount int getSupportedModemCount() { + public int getSupportedModemCount() { return TelephonyProperties.max_active_modems().orElse(getActiveModemCount()); } @@ -1553,6 +1564,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"; @@ -1774,6 +1786,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"; @@ -1789,6 +1802,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 @@ -1828,7 +1897,7 @@ public class TelephonyManager { try { return telephony.getDeviceSoftwareVersionForSlot(slotIndex, getOpPackageName(), - getFeatureId()); + getAttributionTag()); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -1870,7 +1939,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) { @@ -1911,11 +1980,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) { @@ -1973,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) { @@ -2067,7 +2136,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; @@ -2165,11 +2235,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); } @@ -2203,7 +2273,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" @@ -2287,7 +2357,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) { @@ -2755,6 +2825,17 @@ public class TelephonyManager { } } + /** + * @hide + * @deprecated Use {@link #getNetworkCountryIso(int)} instead. + */ + @Deprecated + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, + publicAlternatives = "Use {@link #getNetworkCountryIso(int)} instead.") + public String getNetworkCountryIsoForPhone(int phoneId) { + return getNetworkCountryIso(phoneId); + } + /* * When adding a network type to the list below, make sure to add the correct icon to * MobileSignalController.mapIconSets() as well as NETWORK_TYPES @@ -2882,7 +2963,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; @@ -2947,7 +3028,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; @@ -2984,7 +3065,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; @@ -2999,64 +3080,6 @@ public class TelephonyManager { } /** - * Network Class Definitions. - * Do not change this order, it is used for sorting during emergency calling in - * {@link TelephonyConnectionService#getFirstPhoneForEmergencyCall()}. Any newer technologies - * should be added after the current definitions. - */ - /** Unknown network class. {@hide} */ - public static final int NETWORK_CLASS_UNKNOWN = 0; - /** Class of broadly defined "2G" networks. {@hide} */ - @UnsupportedAppUsage - public static final int NETWORK_CLASS_2_G = 1; - /** Class of broadly defined "3G" networks. {@hide} */ - @UnsupportedAppUsage - public static final int NETWORK_CLASS_3_G = 2; - /** Class of broadly defined "4G" networks. {@hide} */ - @UnsupportedAppUsage - public static final int NETWORK_CLASS_4_G = 3; - /** Class of broadly defined "5G" networks. {@hide} */ - public static final int NETWORK_CLASS_5_G = 4; - - /** - * Return general class of network type, such as "3G" or "4G". In cases - * where classification is contentious, this method is conservative. - * - * @hide - */ - @UnsupportedAppUsage - public static int getNetworkClass(int networkType) { - switch (networkType) { - case NETWORK_TYPE_GPRS: - case NETWORK_TYPE_GSM: - case NETWORK_TYPE_EDGE: - case NETWORK_TYPE_CDMA: - case NETWORK_TYPE_1xRTT: - case NETWORK_TYPE_IDEN: - return NETWORK_CLASS_2_G; - case NETWORK_TYPE_UMTS: - case NETWORK_TYPE_EVDO_0: - case NETWORK_TYPE_EVDO_A: - case NETWORK_TYPE_HSDPA: - case NETWORK_TYPE_HSUPA: - case NETWORK_TYPE_HSPA: - case NETWORK_TYPE_EVDO_B: - case NETWORK_TYPE_EHRPD: - case NETWORK_TYPE_HSPAP: - case NETWORK_TYPE_TD_SCDMA: - return NETWORK_CLASS_3_G; - case NETWORK_TYPE_LTE: - case NETWORK_TYPE_IWLAN: - case NETWORK_TYPE_LTE_CA: - return NETWORK_CLASS_4_G; - case NETWORK_TYPE_NR: - return NETWORK_CLASS_5_G; - default: - return NETWORK_CLASS_UNKNOWN; - } - } - - /** * Returns a string representation of the radio technology (network type) * currently in use on the device. * @return the name of the radio technology @@ -3752,7 +3775,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); } @@ -3763,7 +3786,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(), ""); } @@ -3824,11 +3847,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) { @@ -3838,19 +3861,19 @@ public class TelephonyManager { } /** - * Return if the current radio has global mode enabled, meaning it supports - * both 3GPP and 3GPP2 radio technologies at the same time. + * Return if the current radio can support both 3GPP and 3GPP2 radio technologies at the same + * time. This is also known as global mode, which includes LTE, CDMA, EvDo and GSM/WCDMA. * * <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 global mode is enabled - * {@code false} if global mode is not enabled or unknown + * @return {@code true} if 3GPP and 3GPP2 radio technologies can be supported at the same time + * {@code false} if not supported or unknown * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) - public boolean isGlobalModeEnabled() { + public boolean isLteCdmaEvdoGsmWcdmaEnabled() { return getLteOnCdmaMode(getSubId()) == PhoneConstants.LTE_ON_CDMA_TRUE; } @@ -3872,7 +3895,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; @@ -4097,11 +4120,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) { @@ -4133,7 +4156,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; @@ -4176,7 +4199,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()) { @@ -4241,7 +4264,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); @@ -4265,11 +4288,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) { @@ -4289,11 +4312,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) { @@ -4344,7 +4367,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) { } @@ -4352,11 +4375,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) { @@ -4435,7 +4458,7 @@ public class TelephonyManager { ITelephony telephony = getITelephony(); if (telephony != null) alphaTag = telephony.getLine1AlphaTagForDisplay(subId, - getOpPackageName(), getFeatureId()); + getOpPackageName(), getAttributionTag()); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -4443,11 +4466,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) { @@ -4464,7 +4487,7 @@ public class TelephonyManager { * The returned set of subscriber IDs will include the subscriber ID corresponding to this * TelephonyManager's subId. * - * This is deprecated and {@link #getMergedSubscriberIdsFromGroup()} should be used for data + * This is deprecated and {@link #getMergedImsisFromGroup()} should be used for data * usage merging purpose. * TODO: remove this API. * @@ -4477,7 +4500,7 @@ public class TelephonyManager { ITelephony telephony = getITelephony(); if (telephony != null) return telephony.getMergedSubscriberIds(getSubId(), getOpPackageName(), - getFeatureId()); + getAttributionTag()); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -4485,25 +4508,27 @@ public class TelephonyManager { } /** - * Return the set of subscriber IDs that should be considered "merged together" for data usage - * purposes. Unlike {@link #getMergedSubscriberIds()} this API merge subscriberIds based on - * subscription grouping: subscriberId of those in the same group will all be returned. + * Return the set of IMSIs that should be considered "merged together" for data usage + * purposes. Unlike {@link #getMergedSubscriberIds()} this API merge IMSIs based on + * subscription grouping: IMSI of those in the same group will all be returned. + * Return the current IMSI if there is no subscription group. * * <p>Requires the calling app to have READ_PRIVILEGED_PHONE_STATE permission. * * @hide */ + @SystemApi @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) - public @Nullable String[] getMergedSubscriberIdsFromGroup() { + public @NonNull String[] getMergedImsisFromGroup() { try { ITelephony telephony = getITelephony(); if (telephony != null) { - return telephony.getMergedSubscriberIdsFromGroup(getSubId(), getOpPackageName()); + return telephony.getMergedImsisFromGroup(getSubId(), getOpPackageName()); } } catch (RemoteException ex) { } catch (NullPointerException ex) { } - return null; + return new String[0]; } /** @@ -4529,10 +4554,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) { @@ -4563,11 +4588,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) { @@ -4692,7 +4717,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) { @@ -5129,7 +5154,7 @@ public class TelephonyManager { if (telephony == null) return 0; return telephony.getVoiceMessageCountForSubscriber(subId, getOpPackageName(), - getFeatureId()); + getAttributionTag()); } catch (RemoteException ex) { return 0; } catch (NullPointerException ex) { @@ -5162,11 +5187,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) { @@ -5210,7 +5235,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 @@ -5237,7 +5262,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 @@ -5256,12 +5281,12 @@ public class TelephonyManager { * not present or not loaded * @hide */ + @UnsupportedAppUsage @Nullable - @SystemApi @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 @@ -5274,15 +5299,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. */ @@ -5339,6 +5355,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()} @@ -5378,17 +5402,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). @@ -5506,15 +5519,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()); } // @@ -5524,13 +5538,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> @@ -5562,46 +5569,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 { @@ -5609,7 +5607,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; @@ -5619,25 +5617,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 { @@ -5645,7 +5631,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; @@ -5677,7 +5663,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; @@ -5769,7 +5755,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) { } @@ -5869,7 +5855,7 @@ public class TelephonyManager { Binder.restoreCallingIdentity(identity); } } - }, getOpPackageName(), getFeatureId()); + }, getOpPackageName(), getAttributionTag()); } catch (RemoteException ex) { } } @@ -5920,7 +5906,7 @@ public class TelephonyManager { Binder.restoreCallingIdentity(identity); } } - }, getOpPackageName(), getFeatureId(), workSource); + }, getOpPackageName(), getAttributionTag(), workSource); } catch (RemoteException ex) { } } @@ -6739,7 +6725,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)) { @@ -7048,7 +7046,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 @@ -7070,7 +7068,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 @@ -7151,7 +7149,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); @@ -7194,7 +7192,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) { @@ -7228,7 +7226,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) { @@ -7249,7 +7247,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,6 +7676,17 @@ public class TelephonyManager { RILConstants.NETWORK_MODE_NR_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA; /** + * The default preferred network mode constant. + * + * <p> This constant is used in case of nothing is set in + * TelephonyProperties#default_network(). + * + * @hide + */ + public static final int DEFAULT_PREFERRED_NETWORK_MODE = + RILConstants.PREFERRED_NETWORK_MODE; + + /** * Get the preferred network type. * Used for device configuration by some CDMA operators. * @@ -7811,7 +7820,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); @@ -7866,7 +7875,7 @@ public class TelephonyManager { } } return mTelephonyScanManager.requestNetworkScan(getSubId(), request, executor, callback, - getOpPackageName(), getFeatureId()); + getOpPackageName(), getAttributionTag()); } /** @@ -7921,21 +7930,19 @@ public class TelephonyManager { * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @param operatorNumeric the PLMN ID of the network to select. + * @param persistSelection whether the selection will persist until reboot. + * If true, only allows attaching to the selected PLMN until reboot; otherwise, + * attach to the chosen PLMN and resume normal network selection next time. * @param ran the initial suggested radio access network type. * If registration fails, the RAN is not available after, the RAN is not within the - * network types specified by {@link #setPreferredNetworkTypeBitmask}, or the value is + * network types specified by the preferred network types, or the value is * {@link AccessNetworkConstants.AccessNetworkType#UNKNOWN}, modem will select * the next best RAN for network registration. - * @param persistSelection whether the selection will persist until reboot. - * If true, only allows attaching to the selected PLMN until reboot; otherwise, - * attach to the chosen PLMN and resume normal network selection next time. * @return {@code true} on success; {@code false} on any failure. - * @hide */ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) - @SystemApi public boolean setNetworkSelectionModeManual(@NonNull String operatorNumeric, - @AccessNetworkConstants.RadioAccessNetworkType int ran, boolean persistSelection) { + boolean persistSelection, @AccessNetworkConstants.RadioAccessNetworkType int ran) { return setNetworkSelectionModeManual(new OperatorInfo("" /* operatorAlphaLong */, "" /* operatorAlphaShort */, operatorNumeric, ran), persistSelection); } @@ -8003,6 +8010,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. @@ -8598,7 +8629,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); } @@ -8972,7 +9003,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. @@ -9357,7 +9388,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); } @@ -9374,7 +9405,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); @@ -9393,7 +9424,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); @@ -9947,18 +9978,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); } /** @@ -10121,7 +10164,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); @@ -10262,7 +10306,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); @@ -10956,14 +11000,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); @@ -10983,7 +11027,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); @@ -11029,15 +11074,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(); @@ -11057,7 +11105,6 @@ public class TelephonyManager { * @param isEnabled {@code true} for enabling; {@code false} for disabling. * @hide */ - @SystemApi @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setAlwaysReportSignalStrength(boolean isEnabled) { try { @@ -11131,6 +11178,8 @@ public class TelephonyManager { * PackageManager.FEATURE_TELEPHONY system feature, which is available * on any device with a telephony radio, even if the device is * voice-only. + * + * @hide */ public boolean isDataCapable() { if (mContext == null) return true; @@ -11267,7 +11316,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. @@ -11486,6 +11535,55 @@ public class TelephonyManager { @SystemApi public static final long NETWORK_TYPE_BITMASK_IWLAN = (1 << (NETWORK_TYPE_IWLAN -1)); + /** @hide */ + public static final long NETWORK_CLASS_BITMASK_2G = NETWORK_TYPE_BITMASK_GSM + | NETWORK_TYPE_BITMASK_GPRS + | NETWORK_TYPE_BITMASK_EDGE + | NETWORK_TYPE_BITMASK_CDMA + | NETWORK_TYPE_BITMASK_1xRTT; + + /** @hide */ + public static final long NETWORK_CLASS_BITMASK_3G = NETWORK_TYPE_BITMASK_EVDO_0 + | NETWORK_TYPE_BITMASK_EVDO_A + | NETWORK_TYPE_BITMASK_EVDO_B + | NETWORK_TYPE_BITMASK_EHRPD + | NETWORK_TYPE_BITMASK_HSUPA + | NETWORK_TYPE_BITMASK_HSDPA + | NETWORK_TYPE_BITMASK_HSPA + | NETWORK_TYPE_BITMASK_HSPAP + | NETWORK_TYPE_BITMASK_UMTS + | NETWORK_TYPE_BITMASK_TD_SCDMA; + + /** @hide */ + public static final long NETWORK_CLASS_BITMASK_4G = NETWORK_TYPE_BITMASK_LTE + | NETWORK_TYPE_BITMASK_LTE_CA + | NETWORK_TYPE_BITMASK_IWLAN; + + /** @hide */ + public static final long NETWORK_CLASS_BITMASK_5G = NETWORK_TYPE_BITMASK_NR; + + /** @hide */ + public static final long NETWORK_STANDARDS_FAMILY_BITMASK_3GPP = NETWORK_TYPE_BITMASK_GSM + | NETWORK_TYPE_BITMASK_GPRS + | NETWORK_TYPE_BITMASK_EDGE + | NETWORK_TYPE_BITMASK_HSUPA + | NETWORK_TYPE_BITMASK_HSDPA + | NETWORK_TYPE_BITMASK_HSPA + | NETWORK_TYPE_BITMASK_HSPAP + | NETWORK_TYPE_BITMASK_UMTS + | NETWORK_TYPE_BITMASK_TD_SCDMA + | NETWORK_TYPE_BITMASK_LTE + | NETWORK_TYPE_BITMASK_LTE_CA + | NETWORK_TYPE_BITMASK_NR; + + /** @hide */ + public static final long NETWORK_STANDARDS_FAMILY_BITMASK_3GPP2 = NETWORK_TYPE_BITMASK_CDMA + | NETWORK_TYPE_BITMASK_1xRTT + | NETWORK_TYPE_BITMASK_EVDO_0 + | NETWORK_TYPE_BITMASK_EVDO_A + | NETWORK_TYPE_BITMASK_EVDO_B + | NETWORK_TYPE_BITMASK_EHRPD; + /** * @return Modem supported radio access family bitmask * @@ -11648,7 +11746,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."); } @@ -11704,7 +11802,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); @@ -11856,6 +11954,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 = { @@ -12013,13 +12112,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); @@ -12136,18 +12235,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); @@ -12252,7 +12353,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); @@ -12304,7 +12405,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); @@ -12373,7 +12474,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) { @@ -12404,7 +12504,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, @@ -12435,7 +12534,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, @@ -12488,6 +12586,8 @@ public class TelephonyManager { * * @hide */ + @SystemApi + @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isApnMetered(@ApnType int apnType) { try { ITelephony service = getITelephony(); @@ -12577,7 +12677,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())) { @@ -12616,7 +12717,6 @@ public class TelephonyManager { * * @hide */ - @SystemApi @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) @NonNull public CallForwardingInfo getCallForwarding(@CallForwardingReason int callForwardingReason) { @@ -12663,7 +12763,6 @@ public class TelephonyManager { * * @hide */ - @SystemApi @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setCallForwarding(@NonNull CallForwardingInfo callForwardingInfo) { if (callForwardingInfo == null) { @@ -12704,7 +12803,6 @@ public class TelephonyManager { * * @hide */ - @SystemApi public static final int CALL_WAITING_STATUS_ACTIVE = 1; /** @@ -12712,7 +12810,6 @@ public class TelephonyManager { * * @hide */ - @SystemApi public static final int CALL_WAITING_STATUS_INACTIVE = 2; /** @@ -12720,7 +12817,6 @@ public class TelephonyManager { * * @hide */ - @SystemApi public static final int CALL_WAITING_STATUS_UNKNOWN_ERROR = 3; /** @@ -12728,10 +12824,24 @@ public class TelephonyManager { * * @hide */ - @SystemApi public static final int CALL_WAITING_STATUS_NOT_SUPPORTED = 4; /** + * Call waiting function status + * + * @hide + */ + @IntDef(prefix = { "CALL_WAITING_STATUS_" }, value = { + CALL_WAITING_STATUS_ACTIVE, + CALL_WAITING_STATUS_INACTIVE, + CALL_WAITING_STATUS_NOT_SUPPORTED, + CALL_WAITING_STATUS_UNKNOWN_ERROR + }) + @Retention(RetentionPolicy.SOURCE) + public @interface CallWaitingStatus { + } + + /** * Gets the status of voice call waiting function. Call waiting function enables the waiting * for the incoming call when it reaches the user who is busy to make another call and allows * users to decide whether to switch to the incoming call. @@ -12739,7 +12849,6 @@ public class TelephonyManager { * @return the status of call waiting function. * @hide */ - @SystemApi @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public @CallWaitingStatus int getCallWaitingStatus() { try { @@ -12765,7 +12874,6 @@ public class TelephonyManager { * * @hide */ - @SystemApi @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setCallWaitingStatus(boolean isEnable) { try { @@ -12870,7 +12978,6 @@ public class TelephonyManager { * The IccLock state or password was changed successfully. * @hide */ - @SystemApi public static final int CHANGE_ICC_LOCK_SUCCESS = Integer.MAX_VALUE; /** @@ -12883,7 +12990,6 @@ public class TelephonyManager { * * @hide */ - @SystemApi @WorkerThread @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isIccLockEnabled() { @@ -12920,7 +13026,6 @@ public class TelephonyManager { * * @hide */ - @SystemApi @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setIccLockEnabled(boolean enabled, @NonNull String password) { checkNotNull(password, "setIccLockEnabled password can't be null."); @@ -12954,7 +13059,6 @@ public class TelephonyManager { * * @hide */ - @SystemApi @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int changeIccLockPassword(@NonNull String oldPassword, @NonNull String newPassword) { checkNotNull(oldPassword, "changeIccLockPassword oldPassword can't be null."); @@ -12969,4 +13073,171 @@ public class TelephonyManager { } return 0; } + + /** + * Called when userActivity is signalled in the power manager. + * This should only be called from system Uid. + * @hide + */ + @SystemApi + @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) + public void notifyUserActivity() { + try { + ITelephony service = getITelephony(); + if (service != null) { + service.userActivity(); + } + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + 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; + } + 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; + } } diff --git a/telephony/java/android/telephony/TelephonyScanManager.java b/telephony/java/android/telephony/TelephonyScanManager.java index 359d08d294c3..cdff651c9c3d 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.telephony.ITelephony; @@ -196,12 +195,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 { ITelephony telephony = getITelephony(); if (telephony != null) { @@ -232,6 +233,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 158ada94e3c6..bfb54b008cd8 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"); @@ -2052,7 +2055,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 44b0968eaa90..7488a1aec0e5 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; @@ -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 a7d553b60abf..1597cd5a2f89 100644 --- a/telephony/java/android/telephony/ims/ImsCallProfile.java +++ b/telephony/java/android/telephony/ims/ImsCallProfile.java @@ -18,7 +18,6 @@ package android.telephony.ims; import android.annotation.IntDef; import android.annotation.NonNull; -import android.annotation.Nullable; import android.annotation.SystemApi; import android.annotation.TestApi; import android.compat.annotation.UnsupportedAppUsage; @@ -282,6 +281,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}, @@ -320,6 +327,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 */ @@ -702,11 +717,16 @@ public final class ImsCallProfile implements Parcelable { * @return A {@link Bundle} containing proprietary call extras that were not set by the * platform. */ - public @Nullable Bundle getProprietaryCallExtras() { + public @NonNull Bundle getProprietaryCallExtras() { if (mCallExtras == null) { - return null; + return new Bundle(); + } + Bundle proprietaryExtras = mCallExtras.getBundle(EXTRA_OEM_EXTRAS); + if (proprietaryExtras == null) { + return new Bundle(); } - return mCallExtras.getBundle(EXTRA_OEM_EXTRAS); + // Make a copy so users do not accidentally change this copy of the extras. + return new Bundle(proprietaryExtras); } public ImsStreamMediaProfile getMediaProfile() { diff --git a/telephony/java/android/telephony/ims/ImsCallSessionListener.java b/telephony/java/android/telephony/ims/ImsCallSessionListener.java index 025721c89f70..81af99fb40b7 100644 --- a/telephony/java/android/telephony/ims/ImsCallSessionListener.java +++ b/telephony/java/android/telephony/ims/ImsCallSessionListener.java @@ -58,7 +58,7 @@ public class ImsCallSessionListener { try { mListener.callSessionProgressing(profile); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -71,7 +71,7 @@ public class ImsCallSessionListener { try { mListener.callSessionInitiated(profile); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -85,7 +85,7 @@ public class ImsCallSessionListener { try { mListener.callSessionInitiatedFailed(reasonInfo); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -98,7 +98,7 @@ public class ImsCallSessionListener { try { mListener.callSessionTerminated(reasonInfo); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -115,7 +115,7 @@ public class ImsCallSessionListener { try { mListener.callSessionHeld(profile); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -128,7 +128,7 @@ public class ImsCallSessionListener { try { mListener.callSessionHoldFailed(reasonInfo); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -141,7 +141,7 @@ public class ImsCallSessionListener { try { mListener.callSessionHoldReceived(profile); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -155,7 +155,7 @@ public class ImsCallSessionListener { try { mListener.callSessionResumed(profile); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -169,7 +169,7 @@ public class ImsCallSessionListener { try { mListener.callSessionResumeFailed(reasonInfo); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -182,7 +182,7 @@ public class ImsCallSessionListener { try { mListener.callSessionResumeReceived(profile); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -201,7 +201,7 @@ public class ImsCallSessionListener { mListener.callSessionMergeStarted(newSession != null ? newSession.getServiceImpl() : null, profile); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -216,7 +216,7 @@ public class ImsCallSessionListener { try { mListener.callSessionMergeStarted(newSession, profile); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -232,7 +232,7 @@ public class ImsCallSessionListener { mListener.callSessionMergeComplete(newSession != null ? newSession.getServiceImpl() : null); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -247,7 +247,7 @@ public class ImsCallSessionListener { try { mListener.callSessionMergeComplete(newSession); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -260,7 +260,7 @@ public class ImsCallSessionListener { try { mListener.callSessionMergeFailed(reasonInfo); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -273,7 +273,7 @@ public class ImsCallSessionListener { try { mListener.callSessionUpdated(profile); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -286,7 +286,7 @@ public class ImsCallSessionListener { try { mListener.callSessionUpdateFailed(reasonInfo); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -299,7 +299,7 @@ public class ImsCallSessionListener { try { mListener.callSessionUpdateReceived(profile); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -319,7 +319,7 @@ public class ImsCallSessionListener { mListener.callSessionConferenceExtended( newSession != null ? newSession.getServiceImpl() : null, profile); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -333,7 +333,7 @@ public class ImsCallSessionListener { try { mListener.callSessionConferenceExtended(newSession, profile); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -347,7 +347,7 @@ public class ImsCallSessionListener { try { mListener.callSessionConferenceExtendFailed(reasonInfo); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -364,7 +364,7 @@ public class ImsCallSessionListener { mListener.callSessionConferenceExtendReceived(newSession != null ? newSession.getServiceImpl() : null, profile); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -379,7 +379,7 @@ public class ImsCallSessionListener { try { mListener.callSessionConferenceExtendReceived(newSession, profile); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -391,7 +391,7 @@ public class ImsCallSessionListener { try { mListener.callSessionInviteParticipantsRequestDelivered(); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -407,7 +407,7 @@ public class ImsCallSessionListener { try { mListener.callSessionInviteParticipantsRequestFailed(reasonInfo); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -419,7 +419,7 @@ public class ImsCallSessionListener { try { mListener.callSessionRemoveParticipantsRequestDelivered(); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -435,7 +435,7 @@ public class ImsCallSessionListener { try { mListener.callSessionInviteParticipantsRequestFailed(reasonInfo); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -448,7 +448,7 @@ public class ImsCallSessionListener { try { mListener.callSessionConferenceStateUpdated(state); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -465,7 +465,7 @@ public class ImsCallSessionListener { try { mListener.callSessionUssdMessageReceived(mode, ussdMessage); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -501,7 +501,7 @@ public class ImsCallSessionListener { try { mListener.callSessionMayHandover(srcNetworkType, targetNetworkType); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -537,7 +537,7 @@ public class ImsCallSessionListener { try { mListener.callSessionHandover(srcNetworkType, targetNetworkType, reasonInfo); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -570,7 +570,7 @@ public class ImsCallSessionListener { try { mListener.callSessionHandoverFailed(srcNetworkType, targetNetworkType, reasonInfo); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -587,7 +587,7 @@ public class ImsCallSessionListener { try { mListener.callSessionTtyModeReceived(mode); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -600,7 +600,7 @@ public class ImsCallSessionListener { try { mListener.callSessionMultipartyStateChanged(isMultiParty); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -614,7 +614,7 @@ public class ImsCallSessionListener { try { mListener.callSessionSuppServiceReceived(suppSrvNotification); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -628,7 +628,7 @@ public class ImsCallSessionListener { try { mListener.callSessionRttModifyRequestReceived(callProfile); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -641,7 +641,7 @@ public class ImsCallSessionListener { try { mListener.callSessionRttModifyResponseReceived(status); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -654,7 +654,7 @@ public class ImsCallSessionListener { try { mListener.callSessionRttMessageReceived(rttMessage); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -667,7 +667,7 @@ public class ImsCallSessionListener { try { mListener.callSessionRttAudioIndicatorChanged(profile); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } @@ -680,7 +680,7 @@ public class ImsCallSessionListener { try { mListener.callQualityChanged(callQuality); } catch (RemoteException e) { - throw new RuntimeException(e); + e.rethrowFromSystemServer(); } } } diff --git a/telephony/java/android/telephony/ims/ImsException.java b/telephony/java/android/telephony/ims/ImsException.java index 643f452d2e75..1c3d58d98b4a 100644 --- a/telephony/java/android/telephony/ims/ImsException.java +++ b/telephony/java/android/telephony/ims/ImsException.java @@ -47,11 +47,12 @@ public final class ImsException extends Exception { public static final int CODE_ERROR_SERVICE_UNAVAILABLE = 1; /** - * This device or carrier configuration does not support IMS for this subscription. + * This device or carrier configuration does not support this feature for this subscription. * <p> - * This is a permanent configuration error and there should be no retry. Usually this is - * because {@link PackageManager#FEATURE_TELEPHONY_IMS} is not available - * or the device has no ImsService implementation to service this request. + * This is a permanent configuration error and there should be no retry until the subscription + * changes if this operation is denied due to a carrier configuration. If this is due to a + * device configuration, the feature {@link PackageManager#FEATURE_TELEPHONY_IMS} is not + * available or the device has no ImsService implementation to service this request. */ public static final int CODE_ERROR_UNSUPPORTED_OPERATION = 2; diff --git a/telephony/java/android/telephony/ims/ImsMmTelManager.java b/telephony/java/android/telephony/ims/ImsMmTelManager.java index 494009f35dba..bd531daff6b9 100644 --- a/telephony/java/android/telephony/ims/ImsMmTelManager.java +++ b/telephony/java/android/telephony/ims/ImsMmTelManager.java @@ -21,20 +21,18 @@ import android.Manifest; import android.annotation.CallbackExecutor; import android.annotation.IntDef; import android.annotation.NonNull; -import android.annotation.Nullable; import android.annotation.RequiresPermission; 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; @@ -125,7 +123,7 @@ public class ImsMmTelManager implements RegistrationManager { * @param info the {@link ImsReasonInfo} associated with why registration was disconnected. */ @Override - public void onUnregistered(@Nullable ImsReasonInfo info) { + public void onUnregistered(@NonNull ImsReasonInfo info) { } /** @@ -137,7 +135,7 @@ public class ImsMmTelManager implements RegistrationManager { @Override public void onTechnologyChangeFailed( @AccessNetworkConstants.TransportType int imsTransportType, - @Nullable ImsReasonInfo info) { + @NonNull ImsReasonInfo info) { } } @@ -295,8 +293,15 @@ public class ImsMmTelManager implements RegistrationManager { throw new IllegalArgumentException("Must include a non-null Executor."); } c.setExecutor(executor); + + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new ImsException("Could not find Telephony Service.", + ImsException.CODE_ERROR_SERVICE_UNAVAILABLE); + } + try { - getITelephony().registerImsRegistrationCallback(mSubId, c.getBinder()); + iTelephony.registerImsRegistrationCallback(mSubId, c.getBinder()); } catch (ServiceSpecificException e) { if (e.errorCode == ImsException.CODE_ERROR_INVALID_SUBSCRIPTION) { // Rethrow as runtime error to keep API compatible. @@ -332,8 +337,15 @@ public class ImsMmTelManager implements RegistrationManager { throw new IllegalArgumentException("Must include a non-null Executor."); } c.setExecutor(executor); + + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new ImsException("Could not find Telephony Service.", + ImsException.CODE_ERROR_SERVICE_UNAVAILABLE); + } + try { - getITelephony().registerImsRegistrationCallback(mSubId, c.getBinder()); + iTelephony.registerImsRegistrationCallback(mSubId, c.getBinder()); } catch (ServiceSpecificException e) { throw new ImsException(e.getMessage(), e.errorCode); } catch (RemoteException | IllegalStateException e) { @@ -362,8 +374,14 @@ public class ImsMmTelManager implements RegistrationManager { if (c == null) { throw new IllegalArgumentException("Must include a non-null RegistrationCallback."); } + + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new RuntimeException("Could not find Telephony Service."); + } + try { - getITelephony().unregisterImsRegistrationCallback(mSubId, c.getBinder()); + iTelephony.unregisterImsRegistrationCallback(mSubId, c.getBinder()); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } @@ -388,8 +406,14 @@ public class ImsMmTelManager implements RegistrationManager { if (c == null) { throw new IllegalArgumentException("Must include a non-null RegistrationCallback."); } + + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new RuntimeException("Could not find Telephony Service."); + } + try { - getITelephony().unregisterImsRegistrationCallback(mSubId, c.getBinder()); + iTelephony.unregisterImsRegistrationCallback(mSubId, c.getBinder()); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } @@ -410,8 +434,14 @@ public class ImsMmTelManager implements RegistrationManager { if (executor == null) { throw new IllegalArgumentException("Must include a non-null Executor."); } + + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new RuntimeException("Could not find Telephony Service."); + } + try { - getITelephony().getImsMmTelRegistrationState(mSubId, new IIntegerConsumer.Stub() { + iTelephony.getImsMmTelRegistrationState(mSubId, new IIntegerConsumer.Stub() { @Override public void accept(int result) { executor.execute(() -> stateCallback.accept(result)); @@ -444,8 +474,14 @@ public class ImsMmTelManager implements RegistrationManager { if (executor == null) { throw new IllegalArgumentException("Must include a non-null Executor."); } + + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new RuntimeException("Could not find Telephony Service."); + } + try { - getITelephony().getImsMmTelRegistrationTransportType(mSubId, + iTelephony.getImsMmTelRegistrationTransportType(mSubId, new IIntegerConsumer.Stub() { @Override public void accept(int result) { @@ -507,8 +543,15 @@ public class ImsMmTelManager implements RegistrationManager { throw new IllegalArgumentException("Must include a non-null Executor."); } c.setExecutor(executor); + + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new ImsException("Could not find Telephony Service.", + ImsException.CODE_ERROR_INVALID_SUBSCRIPTION); + } + try { - getITelephony().registerMmTelCapabilityCallback(mSubId, c.getBinder()); + iTelephony.registerMmTelCapabilityCallback(mSubId, c.getBinder()); } catch (ServiceSpecificException e) { if (e.errorCode == ImsException.CODE_ERROR_INVALID_SUBSCRIPTION) { // Rethrow as runtime error to keep API compatible. @@ -554,8 +597,14 @@ public class ImsMmTelManager implements RegistrationManager { if (c == null) { throw new IllegalArgumentException("Must include a non-null RegistrationCallback."); } + + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new RuntimeException("Could not find Telephony Service."); + } + try { - getITelephony().unregisterMmTelCapabilityCallback(mSubId, c.getBinder()); + iTelephony.unregisterMmTelCapabilityCallback(mSubId, c.getBinder()); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } @@ -600,8 +649,13 @@ public class ImsMmTelManager implements RegistrationManager { android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PRECISE_PHONE_STATE}) public boolean isAdvancedCallingSettingEnabled() { + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new RuntimeException("Could not find Telephony Service."); + } + try { - return getITelephony().isAdvancedCallingSettingEnabled(mSubId); + return iTelephony.isAdvancedCallingSettingEnabled(mSubId); } catch (ServiceSpecificException e) { if (e.errorCode == ImsException.CODE_ERROR_INVALID_SUBSCRIPTION) { // Rethrow as runtime error to keep API compatible. @@ -641,8 +695,13 @@ public class ImsMmTelManager implements RegistrationManager { @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) @SystemApi @TestApi public void setAdvancedCallingSettingEnabled(boolean isEnabled) { + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new RuntimeException("Could not find Telephony Service."); + } + try { - getITelephony().setAdvancedCallingSettingEnabled(mSubId, isEnabled); + iTelephony.setAdvancedCallingSettingEnabled(mSubId, isEnabled); } catch (ServiceSpecificException e) { if (e.errorCode == ImsException.CODE_ERROR_INVALID_SUBSCRIPTION) { // Rethrow as runtime error to keep API compatible. @@ -681,8 +740,13 @@ public class ImsMmTelManager implements RegistrationManager { @SystemApi @TestApi public boolean isCapable(@MmTelFeature.MmTelCapabilities.MmTelCapability int capability, @ImsRegistrationImplBase.ImsRegistrationTech int imsRegTech) { + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new RuntimeException("Could not find Telephony Service."); + } + try { - return getITelephony().isCapable(mSubId, capability, imsRegTech); + return iTelephony.isCapable(mSubId, capability, imsRegTech); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } @@ -710,8 +774,13 @@ public class ImsMmTelManager implements RegistrationManager { @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isAvailable(@MmTelFeature.MmTelCapabilities.MmTelCapability int capability, @ImsRegistrationImplBase.ImsRegistrationTech int imsRegTech) { + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new RuntimeException("Could not find Telephony Service."); + } + try { - return getITelephony().isAvailable(mSubId, capability, imsRegTech); + return iTelephony.isAvailable(mSubId, capability, imsRegTech); } catch (RemoteException e) { throw e.rethrowAsRuntimeException(); } @@ -745,6 +814,13 @@ public class ImsMmTelManager implements RegistrationManager { if (executor == null) { throw new IllegalArgumentException("Must include a non-null Executor."); } + + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new ImsException("Could not find Telephony Service.", + ImsException.CODE_ERROR_SERVICE_UNAVAILABLE); + } + try { getITelephony().isMmTelCapabilitySupported(mSubId, new IIntegerConsumer.Stub() { @Override @@ -789,8 +865,13 @@ public class ImsMmTelManager implements RegistrationManager { android.Manifest.permission.READ_PRECISE_PHONE_STATE}) @SuppressAutoDoc // No support for device / profile owner or carrier privileges (b/72967236). public boolean isVtSettingEnabled() { + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new RuntimeException("Could not find Telephony Service."); + } + try { - return getITelephony().isVtSettingEnabled(mSubId); + return iTelephony.isVtSettingEnabled(mSubId); } catch (ServiceSpecificException e) { if (e.errorCode == ImsException.CODE_ERROR_INVALID_SUBSCRIPTION) { // Rethrow as runtime error to keep API compatible. @@ -814,8 +895,13 @@ public class ImsMmTelManager implements RegistrationManager { @SystemApi @TestApi @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) public void setVtSettingEnabled(boolean isEnabled) { + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new RuntimeException("Could not find Telephony Service."); + } + try { - getITelephony().setVtSettingEnabled(mSubId, isEnabled); + iTelephony.setVtSettingEnabled(mSubId, isEnabled); } catch (ServiceSpecificException e) { if (e.errorCode == ImsException.CODE_ERROR_INVALID_SUBSCRIPTION) { // Rethrow as runtime error to keep API compatible. @@ -854,8 +940,13 @@ public class ImsMmTelManager implements RegistrationManager { android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PRECISE_PHONE_STATE}) public boolean isVoWiFiSettingEnabled() { + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new RuntimeException("Could not find Telephony Service."); + } + try { - return getITelephony().isVoWiFiSettingEnabled(mSubId); + return iTelephony.isVoWiFiSettingEnabled(mSubId); } catch (ServiceSpecificException e) { if (e.errorCode == ImsException.CODE_ERROR_INVALID_SUBSCRIPTION) { // Rethrow as runtime error to keep API compatible. @@ -880,8 +971,13 @@ public class ImsMmTelManager implements RegistrationManager { @SystemApi @TestApi @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) public void setVoWiFiSettingEnabled(boolean isEnabled) { + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new RuntimeException("Could not find Telephony Service."); + } + try { - getITelephony().setVoWiFiSettingEnabled(mSubId, isEnabled); + iTelephony.setVoWiFiSettingEnabled(mSubId, isEnabled); } catch (ServiceSpecificException e) { if (e.errorCode == ImsException.CODE_ERROR_INVALID_SUBSCRIPTION) { // Rethrow as runtime error to keep API compatible. @@ -922,8 +1018,13 @@ public class ImsMmTelManager implements RegistrationManager { android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PRECISE_PHONE_STATE}) public boolean isVoWiFiRoamingSettingEnabled() { + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new RuntimeException("Could not find Telephony Service."); + } + try { - return getITelephony().isVoWiFiRoamingSettingEnabled(mSubId); + return iTelephony.isVoWiFiRoamingSettingEnabled(mSubId); } catch (ServiceSpecificException e) { if (e.errorCode == ImsException.CODE_ERROR_INVALID_SUBSCRIPTION) { // Rethrow as runtime error to keep API compatible. @@ -949,8 +1050,13 @@ public class ImsMmTelManager implements RegistrationManager { @SystemApi @TestApi @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) public void setVoWiFiRoamingSettingEnabled(boolean isEnabled) { + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new RuntimeException("Could not find Telephony Service."); + } + try { - getITelephony().setVoWiFiRoamingSettingEnabled(mSubId, isEnabled); + iTelephony.setVoWiFiRoamingSettingEnabled(mSubId, isEnabled); } catch (ServiceSpecificException e) { if (e.errorCode == ImsException.CODE_ERROR_INVALID_SUBSCRIPTION) { // Rethrow as runtime error to keep API compatible. @@ -981,8 +1087,13 @@ public class ImsMmTelManager implements RegistrationManager { @SystemApi @TestApi @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) public void setVoWiFiNonPersistent(boolean isCapable, int mode) { + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new RuntimeException("Could not find Telephony Service."); + } + try { - getITelephony().setVoWiFiNonPersistent(mSubId, isCapable, mode); + iTelephony.setVoWiFiNonPersistent(mSubId, isCapable, mode); } catch (ServiceSpecificException e) { if (e.errorCode == ImsException.CODE_ERROR_INVALID_SUBSCRIPTION) { // Rethrow as runtime error to keep API compatible. @@ -1026,8 +1137,13 @@ public class ImsMmTelManager implements RegistrationManager { android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PRECISE_PHONE_STATE}) public @WiFiCallingMode int getVoWiFiModeSetting() { + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new RuntimeException("Could not find Telephony Service."); + } + try { - return getITelephony().getVoWiFiModeSetting(mSubId); + return iTelephony.getVoWiFiModeSetting(mSubId); } catch (ServiceSpecificException e) { if (e.errorCode == ImsException.CODE_ERROR_INVALID_SUBSCRIPTION) { // Rethrow as runtime error to keep API compatible. @@ -1055,8 +1171,13 @@ public class ImsMmTelManager implements RegistrationManager { @SystemApi @TestApi @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) public void setVoWiFiModeSetting(@WiFiCallingMode int mode) { + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new RuntimeException("Could not find Telephony Service."); + } + try { - getITelephony().setVoWiFiModeSetting(mSubId, mode); + iTelephony.setVoWiFiModeSetting(mSubId, mode); } catch (ServiceSpecificException e) { if (e.errorCode == ImsException.CODE_ERROR_INVALID_SUBSCRIPTION) { // Rethrow as runtime error to keep API compatible. @@ -1086,8 +1207,13 @@ public class ImsMmTelManager implements RegistrationManager { @SystemApi @TestApi @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public @WiFiCallingMode int getVoWiFiRoamingModeSetting() { + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new RuntimeException("Could not find Telephony Service."); + } + try { - return getITelephony().getVoWiFiRoamingModeSetting(mSubId); + return iTelephony.getVoWiFiRoamingModeSetting(mSubId); } catch (ServiceSpecificException e) { if (e.errorCode == ImsException.CODE_ERROR_INVALID_SUBSCRIPTION) { // Rethrow as runtime error to keep API compatible. @@ -1117,8 +1243,13 @@ public class ImsMmTelManager implements RegistrationManager { @SystemApi @TestApi @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) public void setVoWiFiRoamingModeSetting(@WiFiCallingMode int mode) { + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new RuntimeException("Could not find Telephony Service."); + } + try { - getITelephony().setVoWiFiRoamingModeSetting(mSubId, mode); + iTelephony.setVoWiFiRoamingModeSetting(mSubId, mode); } catch (ServiceSpecificException e) { if (e.errorCode == ImsException.CODE_ERROR_INVALID_SUBSCRIPTION) { // Rethrow as runtime error to keep API compatible. @@ -1146,8 +1277,13 @@ public class ImsMmTelManager implements RegistrationManager { @SystemApi @TestApi @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) public void setRttCapabilitySetting(boolean isEnabled) { + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new RuntimeException("Could not find Telephony Service."); + } + try { - getITelephony().setRttCapabilitySetting(mSubId, isEnabled); + iTelephony.setRttCapabilitySetting(mSubId, isEnabled); } catch (ServiceSpecificException e) { if (e.errorCode == ImsException.CODE_ERROR_INVALID_SUBSCRIPTION) { // Rethrow as runtime error to keep API compatible. @@ -1187,8 +1323,13 @@ public class ImsMmTelManager implements RegistrationManager { android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PRECISE_PHONE_STATE}) public boolean isTtyOverVolteEnabled() { + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new RuntimeException("Could not find Telephony Service."); + } + try { - return getITelephony().isTtyOverVolteEnabled(mSubId); + return iTelephony.isTtyOverVolteEnabled(mSubId); } catch (ServiceSpecificException e) { if (e.errorCode == ImsException.CODE_ERROR_INVALID_SUBSCRIPTION) { // Rethrow as runtime error to keep API compatible. @@ -1224,8 +1365,15 @@ public class ImsMmTelManager implements RegistrationManager { if (callback == null) { throw new IllegalArgumentException("Must include a non-null Consumer."); } + + ITelephony iTelephony = getITelephony(); + if (iTelephony == null) { + throw new ImsException("Could not find Telephony Service.", + ImsException.CODE_ERROR_SERVICE_UNAVAILABLE); + } + try { - getITelephony().getImsMmTelFeatureState(mSubId, new IIntegerConsumer.Stub() { + iTelephony.getImsMmTelFeatureState(mSubId, new IIntegerConsumer.Stub() { @Override public void accept(int result) { executor.execute(() -> callback.accept(result)); @@ -1240,10 +1388,10 @@ public class ImsMmTelManager implements RegistrationManager { private static ITelephony getITelephony() { ITelephony binder = ITelephony.Stub.asInterface( - ServiceManager.getService(Context.TELEPHONY_SERVICE)); - if (binder == null) { - throw new RuntimeException("Could not find 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 a2ad21c03f98..151fb59b7550 100644 --- a/telephony/java/android/telephony/ims/ImsRcsManager.java +++ b/telephony/java/android/telephony/ims/ImsRcsManager.java @@ -20,15 +20,17 @@ import android.Manifest; import android.annotation.CallbackExecutor; import android.annotation.NonNull; import android.annotation.RequiresPermission; -import android.annotation.SystemApi; -import android.annotation.TestApi; +import android.annotation.SdkConstant; import android.content.Context; +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; @@ -46,14 +48,34 @@ import java.util.function.Consumer; * (UCE) service, as well as managing user settings. * * Use {@link ImsManager#getImsRcsManager(int)} to create an instance of this manager. - * @hide */ -@SystemApi -@TestApi public class ImsRcsManager implements RegistrationManager { private static final String TAG = "ImsRcsManager"; /** + * Activity Action: Show the opt-in dialog for enabling or disabling RCS contact discovery + * using User Capability Exchange (UCE). + * <p> + * An application that depends on contact discovery being enabled may send this intent + * using {@link Context#startActivity(Intent)} to ask the user to opt-in for contacts upload for + * capability exchange if it is currently disabled. Whether or not this setting has been enabled + * can be queried using {@link RcsUceAdapter#isUceSettingEnabled()}. + * <p> + * This intent should only be sent if the carrier supports RCS capability exchange, which can be + * queried using the key {@link CarrierConfigManager#KEY_USE_RCS_PRESENCE_BOOL}. Otherwise, the + * setting will not be present. + * <p> + * Input: A mandatory {@link Settings#EXTRA_SUB_ID} extra containing the subscription that the + * setting will be be shown for. + * <p> + * Output: Nothing + * @see RcsUceAdapter + */ + @SdkConstant(SdkConstant.SdkConstantType.ACTIVITY_INTENT_ACTION) + public static final String ACTION_SHOW_CAPABILITY_DISCOVERY_OPT_IN = + "android.telephony.ims.action.SHOW_CAPABILITY_DISCOVERY_OPT_IN"; + + /** * Receives RCS availability status updates from the ImsService. * * @see #isAvailable(int) @@ -145,11 +167,10 @@ public class ImsRcsManager implements RegistrationManager { */ @NonNull public RcsUceAdapter getUceAdapter() { - return new RcsUceAdapter(mSubId); + return new RcsUceAdapter(mContext, mSubId); } /** - * {@inheritDoc} * @hide */ @Override @@ -181,7 +202,6 @@ public class ImsRcsManager implements RegistrationManager { } /** - * {@inheritDoc * @hide */ @Override @@ -206,7 +226,6 @@ public class ImsRcsManager implements RegistrationManager { } /** - * {@inheritDoc} * @hide */ @Override @@ -239,7 +258,6 @@ public class ImsRcsManager implements RegistrationManager { } /** - * {@inheritDoc} * @hide */ @Override @@ -432,7 +450,10 @@ public class ImsRcsManager implements RegistrationManager { } 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/ImsUtListener.java b/telephony/java/android/telephony/ims/ImsUtListener.java index bc12404461c7..460a032ce7e0 100644 --- a/telephony/java/android/telephony/ims/ImsUtListener.java +++ b/telephony/java/android/telephony/ims/ImsUtListener.java @@ -49,7 +49,8 @@ public class ImsUtListener { * {@link ImsSsInfo#CLIR_STATUS_TEMPORARILY_RESTRICTED}, and * {@link ImsSsInfo#CLIR_STATUS_TEMPORARILY_ALLOWED}. * @deprecated Use {@link #onLineIdentificationSupplementaryServiceResponse(int, ImsSsInfo)} - * instead. + * instead, this key has been added for backwards compatibility with older proprietary + * implementations only and is being phased out. */ @Deprecated public static final String BUNDLE_KEY_CLIR = "queryClir"; @@ -60,7 +61,8 @@ public class ImsUtListener { * response. The value will be an instance of {@link ImsSsInfo}, which contains the response to * the query. * @deprecated Use {@link #onLineIdentificationSupplementaryServiceResponse(int, ImsSsInfo)} - * instead. + * instead, this key has been added for backwards compatibility with older proprietary + * implementations only and is being phased out. */ @Deprecated public static final String BUNDLE_KEY_SSINFO = "imsSsInfo"; @@ -123,7 +125,7 @@ public class ImsUtListener { try { mServiceInterface.lineIdentificationSupplementaryServiceResponse(id, configuration); } catch (RemoteException e) { - Log.w(LOG_TAG, "onLineIdentificationSupplementaryServicesResponse: remote exception"); + e.rethrowFromSystemServer(); } } diff --git a/telephony/java/android/telephony/ims/ProvisioningManager.java b/telephony/java/android/telephony/ims/ProvisioningManager.java index 6125001850db..1a606b7ae6a7 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; @@ -86,6 +85,7 @@ public class ProvisioningManager { /** * There is no existing configuration for the queried provisioning key. + * @hide */ public static final int PROVISIONING_RESULT_UNKNOWN = -1; @@ -121,6 +121,7 @@ public class ProvisioningManager { * Value is in String format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_AMR_CODEC_MODE_SET_VALUES = 0; @@ -144,6 +145,7 @@ public class ProvisioningManager { * Value is in String format. * @see #setProvisioningStringValue(int, String) * @see #getProvisioningStringValue(int) + * @hide */ public static final int KEY_AMR_WB_CODEC_MODE_SET_VALUES = 1; @@ -155,6 +157,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_SIP_SESSION_TIMER_SEC = 2; @@ -166,6 +169,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_MINIMUM_SIP_SESSION_EXPIRATION_TIMER_SEC = 3; @@ -177,6 +181,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_SIP_INVITE_CANCELLATION_TIMER_MS = 4; @@ -185,6 +190,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_TRANSITION_TO_LTE_DELAY_MS = 5; @@ -193,6 +199,7 @@ public class ProvisioningManager { * Value is in boolean format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_ENABLE_SILENT_REDIAL = 6; @@ -208,6 +215,7 @@ public class ProvisioningManager { * The value is an integer. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_T1_TIMER_VALUE_MS = 7; @@ -219,6 +227,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_T2_TIMER_VALUE_MS = 8; @@ -230,6 +239,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_TF_TIMER_VALUE_MS = 9; @@ -242,6 +252,7 @@ public class ProvisioningManager { * {@link #PROVISIONING_VALUE_DISABLED} to disable VoLTE provisioning. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_VOLTE_PROVISIONING_STATUS = 10; @@ -254,6 +265,7 @@ public class ProvisioningManager { * {@link #PROVISIONING_VALUE_DISABLED} to disable VT provisioning. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_VT_PROVISIONING_STATUS = 11; @@ -262,6 +274,7 @@ public class ProvisioningManager { * Value is in String format. * @see #setProvisioningStringValue(int, String) * @see #getProvisioningStringValue(int) + * @hide */ public static final int KEY_REGISTRATION_DOMAIN_NAME = 12; @@ -271,18 +284,21 @@ public class ProvisioningManager { * Valid values are {@link #SMS_FORMAT_3GPP} and {@link #SMS_FORMAT_3GPP2}. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_SMS_FORMAT = 13; /** * Value used with {@link #KEY_SMS_FORMAT} to indicate 3GPP2 SMS format is used. * See {@link android.telephony.SmsMessage#FORMAT_3GPP2} for more information. + * @hide */ public static final int SMS_FORMAT_3GPP2 = 0; /** * Value used with {@link #KEY_SMS_FORMAT} to indicate 3GPP SMS format is used. * See {@link android.telephony.SmsMessage#FORMAT_3GPP} for more information. + * @hide */ public static final int SMS_FORMAT_3GPP = 1; @@ -291,6 +307,7 @@ public class ProvisioningManager { * Value is in Integer format. ON (1), OFF(0). * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_SMS_OVER_IP_ENABLED = 14; @@ -301,18 +318,20 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_RCS_PUBLISH_TIMER_SEC = 15; /** * An integer key associated with the carrier configured expiration time in seconds for - * RCS presence published offline availability in RCS presence. + * published offline availability in RCS presence provided, which is provided to the network. * <p> * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ - public static final int KEY_RCS_PUBLISH_TIMER_EXTENDED_SEC = 16; + public static final int KEY_RCS_PUBLISH_OFFLINE_AVAILABILITY_TIMER_SEC = 16; /** * An integer key associated with whether or not capability discovery is provisioned for this @@ -323,46 +342,55 @@ public class ProvisioningManager { * enabled. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_RCS_CAPABILITY_DISCOVERY_ENABLED = 17; /** - * An integer key associated with the period of time the capability information of each contact - * is cached on the device. + * An integer key associated with the period of time in seconds the capability information of + * each contact is cached on the device. + * <p> + * Seconds are used because this is usually measured in the span of days. * <p> * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_RCS_CAPABILITIES_CACHE_EXPIRATION_SEC = 18; /** * An integer key associated with the period of time in seconds that the availability - * information of a contact is cached on the device. + * information of a contact is cached on the device, which is based on the carrier provisioning + * configuration from the network. * <p> * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_RCS_AVAILABILITY_CACHE_EXPIRATION_SEC = 19; /** * An integer key associated with the carrier configured interval in seconds expected between - * successive capability polling attempts. + * successive capability polling attempts, which is based on the carrier provisioning + * configuration from the network. * <p> * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_RCS_CAPABILITIES_POLL_INTERVAL_SEC = 20; /** * An integer key representing the minimum time allowed between two consecutive presence publish - * messages from the device. + * messages from the device in milliseconds. * <p> * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_RCS_PUBLISH_SOURCE_THROTTLE_MS = 21; @@ -373,17 +401,19 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_RCS_MAX_NUM_ENTRIES_IN_RCL = 22; /** * An integer associated with the expiration timer used during the SIP subscription of a * Request Contained List (RCL), which is used to retrieve the RCS capabilities of the contact - * book. + * book. This timer value is sent in seconds to the network. * <p> * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_RCS_CAPABILITY_POLL_LIST_SUB_EXP_SEC = 23; @@ -392,6 +422,7 @@ public class ProvisioningManager { * Value is in Integer format. Enable (1), Disable(0). * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_USE_GZIP_FOR_LIST_SUBSCRIPTION = 24; @@ -404,6 +435,7 @@ public class ProvisioningManager { * {@link #PROVISIONING_VALUE_DISABLED} to disable EAB provisioning. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_EAB_PROVISIONING_STATUS = 25; @@ -437,6 +469,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_VOICE_OVER_WIFI_ENABLED_OVERRIDE = 28; @@ -445,6 +478,7 @@ public class ProvisioningManager { * Value is in Integer format. On (1), OFF(0). * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_MOBILE_DATA_ENABLED = 29; @@ -453,12 +487,14 @@ public class ProvisioningManager { * Value is in Integer format. Opted-in (1) Opted-out (0). * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_VOLTE_USER_OPT_IN_STATUS = 30; /** * Proxy for Call Session Control Function(P-CSCF) address for Local-BreakOut(LBO). * Value is in String format. + * @hide */ public static final int KEY_LOCAL_BREAKOUT_PCSCF_ADDRESS = 31; @@ -467,22 +503,27 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_SIP_KEEP_ALIVE_ENABLED = 32; /** - * Registration retry Base Time value in seconds. + * Registration retry Base Time value in seconds, which is based off of the carrier + * configuration. * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_REGISTRATION_RETRY_BASE_TIME_SEC = 33; /** - * Registration retry Max Time value in seconds. + * Registration retry Max Time value in seconds, which is based off of the carrier + * configuration. * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_REGISTRATION_RETRY_MAX_TIME_SEC = 34; @@ -491,6 +532,7 @@ public class ProvisioningManager { * Value is in integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_RTP_SPEECH_START_PORT = 35; @@ -500,6 +542,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_RTP_SPEECH_END_PORT = 36; @@ -509,6 +552,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_SIP_INVITE_REQUEST_TRANSMIT_INTERVAL_MS = 37; @@ -518,6 +562,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_SIP_INVITE_ACK_WAIT_TIME_MS = 38; @@ -527,6 +572,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_SIP_INVITE_RESPONSE_RETRANSMIT_WAIT_TIME_MS = 39; @@ -536,6 +582,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_SIP_NON_INVITE_REQUEST_RETRANSMIT_INTERVAL_MS = 40; @@ -545,6 +592,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_SIP_NON_INVITE_TRANSACTION_TIMEOUT_TIMER_MS = 41; @@ -554,6 +602,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_SIP_INVITE_RESPONSE_RETRANSMIT_INTERVAL_MS = 42; @@ -563,6 +612,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_SIP_ACK_RECEIPT_WAIT_TIME_MS = 43; @@ -572,6 +622,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_SIP_ACK_RETRANSMIT_WAIT_TIME_MS = 44; @@ -581,6 +632,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_SIP_NON_INVITE_REQUEST_RETRANSMISSION_WAIT_TIME_MS = 45; @@ -590,6 +642,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_SIP_NON_INVITE_RESPONSE_RETRANSMISSION_WAIT_TIME_MS = 46; @@ -598,6 +651,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_AMR_WB_OCTET_ALIGNED_PAYLOAD_TYPE = 47; @@ -606,6 +660,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_AMR_WB_BANDWIDTH_EFFICIENT_PAYLOAD_TYPE = 48; @@ -614,6 +669,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_AMR_OCTET_ALIGNED_PAYLOAD_TYPE = 49; @@ -622,6 +678,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_AMR_BANDWIDTH_EFFICIENT_PAYLOAD_TYPE = 50; @@ -630,6 +687,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_DTMF_WB_PAYLOAD_TYPE = 51; @@ -638,6 +696,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_DTMF_NB_PAYLOAD_TYPE = 52; @@ -646,12 +705,14 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_AMR_DEFAULT_ENCODING_MODE = 53; /** * SMS Public Service Identity. * Value is in String format. + * @hide */ public static final int KEY_SMS_PUBLIC_SERVICE_IDENTITY = 54; @@ -661,16 +722,19 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_VIDEO_QUALITY = 55; /** * Used with {@link #KEY_VIDEO_QUALITY} to indicate low video quality. + * @hide */ public static final int VIDEO_QUALITY_LOW = 0; /** * Used with {@link #KEY_VIDEO_QUALITY} to indicate high video quality. + * @hide */ public static final int VIDEO_QUALITY_HIGH = 1; @@ -680,6 +744,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_LTE_THRESHOLD_1 = 56; @@ -691,6 +756,7 @@ public class ProvisioningManager { * * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_LTE_THRESHOLD_2 = 57; @@ -702,6 +768,7 @@ public class ProvisioningManager { * * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_LTE_THRESHOLD_3 = 58; @@ -711,6 +778,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_1X_THRESHOLD = 59; @@ -722,6 +790,7 @@ public class ProvisioningManager { * * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_WIFI_THRESHOLD_A = 60; @@ -732,6 +801,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_WIFI_THRESHOLD_B = 61; @@ -741,6 +811,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_LTE_EPDG_TIMER_SEC = 62; @@ -750,12 +821,14 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_WIFI_EPDG_TIMER_SEC = 63; /** * 1x ePDG timer (in seconds). * Device shall not re-register on 1x until the T_ePDG_1x timer expires. + * @hide */ public static final int KEY_1X_EPDG_TIMER_SEC = 64; @@ -764,6 +837,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_MULTIENDPOINT_ENABLED = 65; @@ -772,6 +846,7 @@ public class ProvisioningManager { * Value is in Integer format. * @see #setProvisioningIntValue(int, int) * @see #getProvisioningIntValue(int) + * @hide */ public static final int KEY_RTT_ENABLED = 66; @@ -923,7 +998,7 @@ public class ProvisioningManager { * * @param key An integer that represents the provisioning key, which is defined by the OEM. * @return an integer value for the provided key, or - * {@link #PROVISIONING_RESULT_UNKNOWN} if the key doesn't exist. + * {@link ImsConfigImplBase#CONFIG_RESULT_UNKNOWN} if the key doesn't exist. * @throws IllegalArgumentException if the key provided was invalid. */ @WorkerThread @@ -1123,7 +1198,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/RcsContactUceCapability.java b/telephony/java/android/telephony/ims/RcsContactUceCapability.java index 57b9b7a30f8c..dc36edf5aad9 100644 --- a/telephony/java/android/telephony/ims/RcsContactUceCapability.java +++ b/telephony/java/android/telephony/ims/RcsContactUceCapability.java @@ -19,8 +19,6 @@ package android.telephony.ims; import android.annotation.LongDef; import android.annotation.NonNull; import android.annotation.Nullable; -import android.annotation.SystemApi; -import android.annotation.TestApi; import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; @@ -37,8 +35,6 @@ import java.util.Map; * Contains the User Capability Exchange capabilities corresponding to a contact's URI. * @hide */ -@SystemApi -@TestApi public final class RcsContactUceCapability implements Parcelable { /** Supports 1-to-1 chat */ diff --git a/telephony/java/android/telephony/ims/RcsUceAdapter.java b/telephony/java/android/telephony/ims/RcsUceAdapter.java index 32fd8638f761..05ab6bd75878 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.feature.RcsFeature; @@ -43,10 +43,7 @@ import java.util.concurrent.Executor; * Manages RCS User Capability Exchange for the subscription specified. * * @see ImsRcsManager#getUceAdapter() for information on creating an instance of this class. - * @hide */ -@SystemApi -@TestApi public class RcsUceAdapter { private static final String TAG = "RcsUceAdapter"; @@ -216,6 +213,7 @@ public class RcsUceAdapter { } } + private final Context mContext; private final int mSubId; /** @@ -223,7 +221,8 @@ public class RcsUceAdapter { * {@link ImsRcsManager#getUceAdapter()} to instantiate this manager class. * @hide */ - RcsUceAdapter(int subId) { + RcsUceAdapter(Context context, int subId) { + mContext = context; mSubId = subId; } @@ -291,7 +290,8 @@ public class RcsUceAdapter { }; try { - imsRcsController.requestCapabilities(mSubId, contactNumbers, internalCallback); + imsRcsController.requestCapabilities(mSubId, mContext.getOpPackageName(), + mContext.getAttributionTag(), contactNumbers, internalCallback); } catch (RemoteException e) { Log.e(TAG, "Error calling IImsRcsController#requestCapabilities", e); throw new ImsException("Remote IMS Service is not available", @@ -341,7 +341,7 @@ public class RcsUceAdapter { * available. This can happen if the ImsService has crashed, for example, or if the subscription * becomes inactive. See {@link ImsException#getCode()} for more information on the error codes. */ - @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) + @RequiresPermission(Manifest.permission.READ_PHONE_STATE) public boolean isUceSettingEnabled() throws ImsException { IImsRcsController imsRcsController = getIImsRcsController(); if (imsRcsController == null) { @@ -349,9 +349,10 @@ public class RcsUceAdapter { throw new ImsException("Can not find remote IMS service", ImsException.CODE_ERROR_SERVICE_UNAVAILABLE); } - try { - return imsRcsController.isUceSettingEnabled(mSubId); + // Telephony.SimInfo#IMS_RCS_UCE_ENABLED can also be used to listen to changes to this. + return imsRcsController.isUceSettingEnabled(mSubId, mContext.getOpPackageName(), + mContext.getAttributionTag()); } catch (RemoteException e) { Log.e(TAG, "Error calling IImsRcsController#isUceSettingEnabled", e); throw new ImsException("Remote IMS Service is not available", @@ -362,6 +363,10 @@ public class RcsUceAdapter { /** * Change the user’s setting for whether or not UCE is enabled for the associated subscription. * <p> + * If an application Requires UCE, they may launch an Activity using the Intent + * {@link ImsRcsManager#ACTION_SHOW_CAPABILITY_DISCOVERY_OPT_IN}, which will ask the user if + * they wish to enable this feature. + * <p> * Note: This setting does not affect whether or not the device publishes its service * capabilities if the subscription supports presence publication. * @@ -371,7 +376,10 @@ public class RcsUceAdapter { * {@link RcsUceAdapter} is valid, but the ImsService associated with the subscription is not * available. This can happen if the ImsService has crashed, for example, or if the subscription * becomes inactive. See {@link ImsException#getCode()} for more information on the error codes. + * @hide */ + @SystemApi + @TestApi @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) public void setUceSettingEnabled(boolean isEnabled) throws ImsException { IImsRcsController imsRcsController = getIImsRcsController(); @@ -391,7 +399,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/RegistrationManager.java b/telephony/java/android/telephony/ims/RegistrationManager.java index 5c86ba732701..1dbaff5df802 100644 --- a/telephony/java/android/telephony/ims/RegistrationManager.java +++ b/telephony/java/android/telephony/ims/RegistrationManager.java @@ -196,11 +196,11 @@ public interface RegistrationManager { } /** - * Notifies the framework when the IMS Provider is deregistered from the IMS network. + * Notifies the framework when the IMS Provider is unregistered from the IMS network. * * @param info the {@link ImsReasonInfo} associated with why registration was disconnected. */ - public void onUnregistered(@Nullable ImsReasonInfo info) { + public void onUnregistered(@NonNull ImsReasonInfo info) { } /** @@ -211,7 +211,7 @@ public interface RegistrationManager { */ public void onTechnologyChangeFailed( @AccessNetworkConstants.TransportType int imsTransportType, - @Nullable ImsReasonInfo info) { + @NonNull ImsReasonInfo info) { } /** diff --git a/telephony/java/android/telephony/ims/aidl/IImsRcsController.aidl b/telephony/java/android/telephony/ims/aidl/IImsRcsController.aidl index 6f6aa44371fa..483c66eedc0c 100644 --- a/telephony/java/android/telephony/ims/aidl/IImsRcsController.aidl +++ b/telephony/java/android/telephony/ims/aidl/IImsRcsController.aidl @@ -42,8 +42,9 @@ interface IImsRcsController { boolean isAvailable(int subId, int capability); // ImsUceAdapter specific - void requestCapabilities(int subId, in List<Uri> contactNumbers, IRcsUceControllerCallback c); + void requestCapabilities(int subId, String callingPackage, String callingFeatureId, + in List<Uri> contactNumbers, IRcsUceControllerCallback c); int getUcePublishState(int subId); - boolean isUceSettingEnabled(int subId); + boolean isUceSettingEnabled(int subId, String callingPackage, String callingFeatureId); void setUceSettingEnabled(int subId, boolean isEnabled); } diff --git a/telephony/java/android/telephony/ims/feature/MmTelFeature.java b/telephony/java/android/telephony/ims/feature/MmTelFeature.java index a3ce1b585f76..7ff8735d7b73 100644 --- a/telephony/java/android/telephony/ims/feature/MmTelFeature.java +++ b/telephony/java/android/telephony/ims/feature/MmTelFeature.java @@ -259,10 +259,7 @@ public class MmTelFeature extends ImsFeature { super(capabilities); } - /** - * @hide - */ - @SystemApi @TestApi + /** @hide */ @IntDef(flag = true, value = { CAPABILITY_TYPE_VOICE, @@ -396,10 +393,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/ImsRegistrationImplBase.java b/telephony/java/android/telephony/ims/stub/ImsRegistrationImplBase.java index 14a64d2585ed..7069e0ab9b1e 100644 --- a/telephony/java/android/telephony/ims/stub/ImsRegistrationImplBase.java +++ b/telephony/java/android/telephony/ims/stub/ImsRegistrationImplBase.java @@ -175,9 +175,11 @@ public class ImsRegistrationImplBase { */ public final void onDeregistered(ImsReasonInfo info) { updateToDisconnectedState(info); + // ImsReasonInfo should never be null. + final ImsReasonInfo reasonInfo = (info != null) ? info : new ImsReasonInfo(); mCallbacks.broadcastAction((c) -> { try { - c.onDeregistered(info); + c.onDeregistered(reasonInfo); } catch (RemoteException e) { Log.w(LOG_TAG, e + " " + "onRegistrationDisconnected() - Skipping " + "callback."); @@ -194,9 +196,10 @@ public class ImsRegistrationImplBase { */ public final void onTechnologyChangeFailed(@ImsRegistrationTech int imsRadioTech, ImsReasonInfo info) { + final ImsReasonInfo reasonInfo = (info != null) ? info : new ImsReasonInfo(); mCallbacks.broadcastAction((c) -> { try { - c.onTechnologyChangeFailed(imsRadioTech, info); + c.onTechnologyChangeFailed(imsRadioTech, reasonInfo); } catch (RemoteException e) { Log.w(LOG_TAG, e + " " + "onRegistrationChangeFailed() - Skipping " + "callback."); diff --git a/telephony/java/android/telephony/ims/stub/ImsUtImplBase.java b/telephony/java/android/telephony/ims/stub/ImsUtImplBase.java index f13371c1d0fa..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; @@ -338,6 +349,7 @@ public class ImsUtImplBase { /** * Updates the configuration of the call barring for specified service class with password. + * @hide */ public int updateCallBarringWithPassword(int cbType, int action, @Nullable String[] barrList, int serviceClass, @NonNull String password) { diff --git a/telephony/java/com/android/ims/ImsConfig.java b/telephony/java/com/android/ims/ImsConfig.java index 96f77d809183..d0cec52dfc86 100644 --- a/telephony/java/com/android/ims/ImsConfig.java +++ b/telephony/java/com/android/ims/ImsConfig.java @@ -270,11 +270,12 @@ public class ImsConfig { /** * Requested expiration for Published Offline availability. * Value is in Integer format. - * @deprecated use {@link ProvisioningManager#KEY_RCS_PUBLISH_TIMER_EXTENDED_SEC}. + * @deprecated use + * {@link ProvisioningManager#KEY_RCS_PUBLISH_OFFLINE_AVAILABILITY_TIMER_SEC}. */ @Deprecated public static final int PUBLISH_TIMER_EXTENDED = - ProvisioningManager.KEY_RCS_PUBLISH_TIMER_EXTENDED_SEC; + ProvisioningManager.KEY_RCS_PUBLISH_OFFLINE_AVAILABILITY_TIMER_SEC; /** * diff --git a/telephony/java/com/android/internal/telephony/ISms.aidl b/telephony/java/com/android/internal/telephony/ISms.aidl index c07a1711b32e..79cdce8cba46 100644 --- a/telephony/java/com/android/internal/telephony/ISms.aidl +++ b/telephony/java/com/android/internal/telephony/ISms.aidl @@ -145,10 +145,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, 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. Internal use only. @@ -270,11 +273,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, 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. diff --git a/telephony/java/com/android/internal/telephony/ISmsImplBase.java b/telephony/java/com/android/internal/telephony/ISmsImplBase.java index ddd3457b3b4d..db0b8e528c87 100644 --- a/telephony/java/com/android/internal/telephony/ISmsImplBase.java +++ b/telephony/java/com/android/internal/telephony/ISmsImplBase.java @@ -61,7 +61,8 @@ public class ISmsImplBase extends ISms.Stub { @Override public void sendTextForSubscriber(int subId, String callingPkg, String destAddr, String scAddr, String text, PendingIntent sentIntent, - PendingIntent deliveryIntent, boolean persistMessageForNonDefaultSmsApp) { + PendingIntent deliveryIntent, boolean persistMessageForNonDefaultSmsApp, + long messageId) { throw new UnsupportedOperationException(); } @@ -90,7 +91,8 @@ public class ISmsImplBase extends ISms.Stub { public void sendMultipartTextForSubscriber(int subId, String callingPkg, 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(); } diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 9f06734989b3..dcf339c1be2f 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -1131,7 +1131,7 @@ interface ITelephony { /** * @hide */ - String[] getMergedSubscriberIdsFromGroup(int subId, String callingPackage); + String[] getMergedImsisFromGroup(int subId, String callingPackage); /** * Override the operator branding for the current ICCID. @@ -2247,4 +2247,24 @@ interface ITelephony { int setIccLockEnabled(int subId, boolean enabled, String password); 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); } diff --git a/telephony/java/com/android/internal/telephony/PhoneConstants.java b/telephony/java/com/android/internal/telephony/PhoneConstants.java index 6eea88f4c103..4d677545bc39 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/RILConstants.java b/telephony/java/com/android/internal/telephony/RILConstants.java index 53ad70a07563..6fdc13e6a31b 100644 --- a/telephony/java/com/android/internal/telephony/RILConstants.java +++ b/telephony/java/com/android/internal/telephony/RILConstants.java @@ -492,6 +492,7 @@ public interface RILConstants { int RIL_REQUEST_ENABLE_UICC_APPLICATIONS = 208; int RIL_REQUEST_GET_UICC_APPLICATIONS_ENABLEMENT = 209; int RIL_REQUEST_SET_SYSTEM_SELECTION_CHANNELS = 210; + int RIL_REQUEST_GET_BARRING_INFO = 211; /* Responses begin */ int RIL_RESPONSE_ACKNOWLEDGEMENT = 800; @@ -557,4 +558,5 @@ public interface RILConstants { int RIL_UNSOL_EMERGENCY_NUMBER_LIST = 1102; int RIL_UNSOL_UICC_APPLICATIONS_ENABLEMENT_CHANGED = 1103; int RIL_UNSOL_REGISTRATION_FAILED = 1104; + int RIL_UNSOL_BARRING_INFO_CHANGED = 1105; } 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 48cb1cd84c07..c074e6e9a438 100644 --- a/telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java +++ b/telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java @@ -44,10 +44,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) @@ -238,6 +234,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 122f0851cf37..ccb14749109d 100644 --- a/telephony/java/com/android/internal/telephony/gsm/SmsMessage.java +++ b/telephony/java/com/android/internal/telephony/gsm/SmsMessage.java @@ -103,14 +103,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() { } /** |