[Mainline] Create getDataRegistrationState and expose as system api

Bug: 144486008
Test: atest ServiceStateTest  (PASS)

Change-Id: Ice803f412135932ac2cedadc09433957c16ea512
This commit is contained in:
SongFerngWang
2019-12-02 21:19:24 +08:00
parent 1f5d183def
commit e5202be5ba
2 changed files with 63 additions and 5 deletions

View File

@@ -9485,6 +9485,7 @@ package android.telephony {
}
public class ServiceState implements android.os.Parcelable {
method public int getDataRegistrationState();
method @Nullable public android.telephony.NetworkRegistrationInfo getNetworkRegistrationInfo(int, int);
method @NonNull public java.util.List<android.telephony.NetworkRegistrationInfo> getNetworkRegistrationInfoList();
method @NonNull public java.util.List<android.telephony.NetworkRegistrationInfo> getNetworkRegistrationInfoListForDomain(int);

View File

@@ -65,6 +65,13 @@ public class ServiceState implements Parcelable {
static final boolean DBG = false;
static final boolean VDBG = false; // STOPSHIP if true
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef(prefix = "STATE_",
value = {STATE_IN_SERVICE, STATE_OUT_OF_SERVICE, STATE_EMERGENCY_ONLY,
STATE_POWER_OFF})
public @interface RegState {}
/**
* Normal operation condition, the phone is registered
* with an operator either in home network or in roaming.
@@ -83,6 +90,7 @@ public class ServiceState implements Parcelable {
/**
* The phone is registered and locked. Only emergency numbers are allowed. {@more}
*/
//TODO: This state is not used anymore. It should be deprecated in a future release.
public static final int STATE_EMERGENCY_ONLY =
TelephonyProtoEnums.SERVICE_STATE_EMERGENCY_ONLY; // 2
@@ -501,13 +509,15 @@ public class ServiceState implements Parcelable {
}
/**
* Get current data service state
* Get current data registration state.
*
* @see #STATE_IN_SERVICE
* @see #STATE_OUT_OF_SERVICE
* @see #STATE_EMERGENCY_ONLY
* @see #STATE_POWER_OFF
*
* @return current data registration state {@link RegState}
*
* @hide
*/
@UnsupportedAppUsage
@@ -515,6 +525,23 @@ public class ServiceState implements Parcelable {
return mDataRegState;
}
/**
* Get current data registration state.
*
* @see #STATE_IN_SERVICE
* @see #STATE_OUT_OF_SERVICE
* @see #STATE_EMERGENCY_ONLY
* @see #STATE_POWER_OFF
*
* @return current data registration state {@link RegState}
*
* @hide
*/
@SystemApi
public @RegState int getDataRegistrationState() {
return getDataRegState();
}
/**
* Get the current duplex mode
*
@@ -1408,7 +1435,15 @@ public class ServiceState implements Parcelable {
return getRilDataRadioTechnology();
}
/** @hide */
/**
* Transform RIL radio technology {@link RilRadioTechnology} value to Network
* type {@link NetworkType}.
*
* @param rat The RIL radio technology {@link RilRadioTechnology}.
* @return The network type {@link NetworkType}.
*
* @hide
*/
public static int rilRadioTechnologyToNetworkType(@RilRadioTechnology int rat) {
switch(rat) {
case RIL_RADIO_TECHNOLOGY_GPRS:
@@ -1490,7 +1525,15 @@ public class ServiceState implements Parcelable {
}
}
/** @hide */
/**
* Transform network type {@link NetworkType} value to RIL radio technology
* {@link RilRadioTechnology}.
*
* @param networkType The network type {@link NetworkType}.
* @return The RIL radio technology {@link RilRadioTechnology}.
*
* @hide
*/
public static int networkTypeToRilRadioTechnology(int networkType) {
switch(networkType) {
case TelephonyManager.NETWORK_TYPE_GPRS:
@@ -1691,7 +1734,14 @@ public class ServiceState implements Parcelable {
return bearerBitmask;
}
/** @hide */
/**
* Convert network type bitmask to bearer bitmask.
*
* @param networkTypeBitmask The network type bitmask value
* @return The bearer bitmask value.
*
* @hide
*/
public static int convertNetworkTypeBitmaskToBearerBitmask(int networkTypeBitmask) {
if (networkTypeBitmask == 0) {
return 0;
@@ -1705,7 +1755,14 @@ public class ServiceState implements Parcelable {
return bearerBitmask;
}
/** @hide */
/**
* Convert bearer bitmask to network type bitmask.
*
* @param bearerBitmask The bearer bitmask value.
* @return The network type bitmask value.
*
* @hide
*/
public static int convertBearerBitmaskToNetworkTypeBitmask(int bearerBitmask) {
if (bearerBitmask == 0) {
return 0;