From d53df964260339ed00ea19fa6615d33bebcd6088 Mon Sep 17 00:00:00 2001 From: Cassie Date: Tue, 5 Dec 2017 13:34:33 -0800 Subject: Expose a new public column network_type_bitmask and deprecate bearer_bitmask gradually. Bug: 21276001 Test: Basic telephony sanity Change-Id: I2896ba64959863d19c98af3e656d4c7e7b4f8d16 --- api/current.txt | 3 +- telephony/java/android/telephony/ServiceState.java | 66 +++++++++++++++++++++- telephony/java/android/telephony/Telephony.java | 11 ++++ 3 files changed, 78 insertions(+), 2 deletions(-) diff --git a/api/current.txt b/api/current.txt index 0c8190f7ec58..8081136ce855 100644 --- a/api/current.txt +++ b/api/current.txt @@ -35430,7 +35430,7 @@ package android.provider { public static final class Telephony.Carriers implements android.provider.BaseColumns { field public static final java.lang.String APN = "apn"; field public static final java.lang.String AUTH_TYPE = "authtype"; - field public static final java.lang.String BEARER = "bearer"; + field public static final deprecated java.lang.String BEARER = "bearer"; field public static final java.lang.String CARRIER_ENABLED = "carrier_enabled"; field public static final android.net.Uri CONTENT_URI; field public static final java.lang.String CURRENT = "current"; @@ -35443,6 +35443,7 @@ package android.provider { field public static final java.lang.String MVNO_MATCH_DATA = "mvno_match_data"; field public static final java.lang.String MVNO_TYPE = "mvno_type"; field public static final java.lang.String NAME = "name"; + field public static final java.lang.String NETWORK_TYPE_BITMASK = "network_type_bitmask"; field public static final java.lang.String NUMERIC = "numeric"; field public static final java.lang.String PASSWORD = "password"; field public static final java.lang.String PORT = "port"; diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java index 116e711ee886..254970bbe6e9 100644 --- a/telephony/java/android/telephony/ServiceState.java +++ b/telephony/java/android/telephony/ServiceState.java @@ -16,12 +16,16 @@ package android.telephony; +import android.annotation.IntDef; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.telephony.Rlog; import android.text.TextUtils; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + /** * Contains phone state and service related information. * @@ -105,6 +109,31 @@ public class ServiceState implements Parcelable { /** @hide */ public static final int RIL_REG_STATE_UNKNOWN_EMERGENCY_CALL_ENABLED = 14; + /** @hide */ + @Retention(RetentionPolicy.SOURCE) + @IntDef(prefix = { "RIL_RADIO_TECHNOLOGY_" }, + value = { + RIL_RADIO_TECHNOLOGY_UNKNOWN, + RIL_RADIO_TECHNOLOGY_GPRS, + RIL_RADIO_TECHNOLOGY_EDGE, + RIL_RADIO_TECHNOLOGY_UMTS, + RIL_RADIO_TECHNOLOGY_IS95A, + RIL_RADIO_TECHNOLOGY_IS95B, + RIL_RADIO_TECHNOLOGY_1xRTT, + RIL_RADIO_TECHNOLOGY_EVDO_0, + RIL_RADIO_TECHNOLOGY_EVDO_A, + RIL_RADIO_TECHNOLOGY_HSDPA, + RIL_RADIO_TECHNOLOGY_HSUPA, + RIL_RADIO_TECHNOLOGY_HSPA, + RIL_RADIO_TECHNOLOGY_EVDO_B, + RIL_RADIO_TECHNOLOGY_EHRPD, + RIL_RADIO_TECHNOLOGY_LTE, + RIL_RADIO_TECHNOLOGY_HSPAP, + RIL_RADIO_TECHNOLOGY_GSM, + RIL_RADIO_TECHNOLOGY_TD_SCDMA, + RIL_RADIO_TECHNOLOGY_IWLAN, + RIL_RADIO_TECHNOLOGY_LTE_CA}) + public @interface RilRadioTechnology {} /** * Available radio technologies for GSM, UMTS and CDMA. * Duplicates the constants from hardware/radio/include/ril.h @@ -162,6 +191,12 @@ public class ServiceState implements Parcelable { */ public static final int RIL_RADIO_TECHNOLOGY_LTE_CA = 19; + /** + * Number of radio technologies for GSM, UMTS and CDMA. + * @hide + */ + private static final int NEXT_RIL_RADIO_TECHNOLOGY = 20; + /** @hide */ public static final int RIL_RADIO_CDMA_TECHNOLOGY_BITMASK = (1 << (RIL_RADIO_TECHNOLOGY_IS95A - 1)) @@ -1153,7 +1188,8 @@ public class ServiceState implements Parcelable { return getRilDataRadioTechnology(); } - private int rilRadioTechnologyToNetworkType(int rt) { + /** @hide */ + public static int rilRadioTechnologyToNetworkType(@RilRadioTechnology int rt) { switch(rt) { case ServiceState.RIL_RADIO_TECHNOLOGY_GPRS: return TelephonyManager.NETWORK_TYPE_GPRS; @@ -1300,6 +1336,34 @@ public class ServiceState implements Parcelable { return bearerBitmask; } + /** @hide */ + public static int convertNetworkTypeBitmaskToBearerBitmask(int networkTypeBitmask) { + if (networkTypeBitmask == 0) { + return 0; + } + int bearerBitmask = 0; + for (int bearerInt = 0; bearerInt < NEXT_RIL_RADIO_TECHNOLOGY; bearerInt++) { + if (bitmaskHasTech(networkTypeBitmask, rilRadioTechnologyToNetworkType(bearerInt))) { + bearerBitmask |= getBitmaskForTech(bearerInt); + } + } + return bearerBitmask; + } + + /** @hide */ + public static int convertBearerBitmaskToNetworkTypeBitmask(int bearerBitmask) { + if (bearerBitmask == 0) { + return 0; + } + int networkTypeBitmask = 0; + for (int bearerInt = 0; bearerInt < NEXT_RIL_RADIO_TECHNOLOGY; bearerInt++) { + if (bitmaskHasTech(bearerBitmask, bearerInt)) { + networkTypeBitmask |= getBitmaskForTech(rilRadioTechnologyToNetworkType(bearerInt)); + } + } + return networkTypeBitmask; + } + /** * Returns a merged ServiceState consisting of the base SS with voice settings from the * voice SS. The voice SS is only used if it is IN_SERVICE (otherwise the base SS is returned). diff --git a/telephony/java/android/telephony/Telephony.java b/telephony/java/android/telephony/Telephony.java index d7b6142a5de6..be34f45b8ffe 100644 --- a/telephony/java/android/telephony/Telephony.java +++ b/telephony/java/android/telephony/Telephony.java @@ -2693,6 +2693,7 @@ public final class Telephony { * but is currently only used for LTE (14) and eHRPD (13). *

Type: INTEGER

*/ + @Deprecated public static final String BEARER = "bearer"; /** @@ -2704,8 +2705,18 @@ public final class Telephony { *

Type: INTEGER

* @hide */ + @Deprecated public static final String BEARER_BITMASK = "bearer_bitmask"; + /** + * Radio technology (network type) bitmask. + * To check what values can be contained, refer to + * {@link android.telephony.TelephonyManager}. + * Bitmask for a radio tech R is (1 << (R - 1)) + *

Type: INTEGER

+ */ + public static final String NETWORK_TYPE_BITMASK = "network_type_bitmask"; + /** * MVNO type: * {@code SPN (Service Provider Name), IMSI, GID (Group Identifier Level 1)}. -- cgit v1.2.3-59-g8ed1b