Merge "Moved transport to IntDef"

This commit is contained in:
Treehugger Robot
2019-03-15 23:21:29 +00:00
committed by Gerrit Code Review
7 changed files with 95 additions and 76 deletions

View File

@@ -5508,9 +5508,10 @@ package android.telecom {
package android.telephony {
public static final class AccessNetworkConstants.TransportType {
field public static final int WLAN = 2; // 0x2
field public static final int WWAN = 1; // 0x1
public final class AccessNetworkConstants {
field public static final int TRANSPORT_TYPE_INVALID = -1; // 0xffffffff
field public static final int TRANSPORT_TYPE_WLAN = 2; // 0x2
field public static final int TRANSPORT_TYPE_WWAN = 1; // 0x1
}
public final class CallAttributes implements android.os.Parcelable {

View File

@@ -1617,7 +1617,7 @@ public class NetworkMonitor extends StateMachine {
// See if the data sub is registered for PS services on cell.
final NetworkRegistrationState nrs = dataSs.getNetworkRegistrationState(
NetworkRegistrationState.DOMAIN_PS,
AccessNetworkConstants.TransportType.WWAN);
AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
latencyBroadcast.putExtra(
NetworkMonitorUtils.EXTRA_CELL_ID,
nrs == null ? null : nrs.getCellIdentity());

View File

@@ -28,6 +28,7 @@ import android.content.Intent;
import android.content.res.Resources;
import android.net.wifi.WifiInfo;
import android.os.UserHandle;
import android.telephony.AccessNetworkConstants.TransportType;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Slog;
@@ -92,7 +93,7 @@ public class NetworkNotificationManager {
return -1;
}
private static String getTransportName(int transportType) {
private static String getTransportName(@TransportType int transportType) {
Resources r = Resources.getSystem();
String[] networkTypes = r.getStringArray(R.array.network_switch_type_name);
try {

View File

@@ -16,13 +16,59 @@
package android.telephony;
import android.annotation.IntDef;
import android.annotation.SystemApi;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* Contains access network related constants.
*/
public final class AccessNetworkConstants {
/**
* Wireless transportation type
*
* @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef(prefix = {"TRANSPORT_TYPE_"},
value = {
TRANSPORT_TYPE_INVALID,
TRANSPORT_TYPE_WWAN,
TRANSPORT_TYPE_WLAN})
public @interface TransportType {}
/**
* Invalid transport type
* @hide
*/
@SystemApi
public static final int TRANSPORT_TYPE_INVALID = -1;
/**
* Transport type for Wireless Wide Area Networks (i.e. Cellular)
* @hide
*/
@SystemApi
public static final int TRANSPORT_TYPE_WWAN = 1;
/**
* Transport type for Wireless Local Area Networks (i.e. Wifi)
* @hide
*/
@SystemApi
public static final int TRANSPORT_TYPE_WLAN = 2;
/** @hide */
public static String transportTypeToString(@TransportType int transportType) {
switch (transportType) {
case TRANSPORT_TYPE_WWAN: return "WWAN";
case TRANSPORT_TYPE_WLAN: return "WLAN";
default: return Integer.toString(transportType);
}
}
public static final class AccessNetworkType {
public static final int UNKNOWN = 0;
public static final int GERAN = 1;
@@ -49,39 +95,7 @@ public final class AccessNetworkConstants {
}
/**
* Wireless transportation type
* @hide
*/
@SystemApi
public static final class TransportType {
/**
* Invalid transport type.
* @hide
*/
public static final int INVALID = -1;
/** Wireless Wide Area Networks (i.e. Cellular) */
public static final int WWAN = 1;
/** Wireless Local Area Networks (i.e. Wifi) */
public static final int WLAN = 2;
/** @hide */
private TransportType() {}
/** @hide */
public static String toString(int type) {
switch (type) {
case INVALID: return "INVALID";
case WWAN: return "WWAN";
case WLAN: return "WLAN";
default: return Integer.toString(type);
}
}
}
/**
* Frenquency bands for GERAN.
* Frequency bands for GERAN.
* http://www.etsi.org/deliver/etsi_ts/145000_145099/145005/14.00.00_60/ts_145005v140000p.pdf
*/
public static final class GeranBand {

View File

@@ -129,7 +129,6 @@ public class NetworkRegistrationState implements Parcelable {
@Domain
private final int mDomain;
/** {@link TransportType} */
private final int mTransportType;
@RegState
@@ -165,14 +164,15 @@ public class NetworkRegistrationState implements Parcelable {
private DataSpecificRegistrationStates mDataSpecificStates;
/**
* @param domain Network domain. Must be a {@link Domain}. For {@link TransportType#WLAN}
* transport, this must set to {@link #DOMAIN_PS}.
* @param transportType Transport type. Must be one of the{@link TransportType}.
* @param domain Network domain. Must be a {@link Domain}. For transport type
* {@link AccessNetworkConstants#TRANSPORT_TYPE_WLAN}, this must set to {@link #DOMAIN_PS}.
* @param transportType Transport type.
* @param regState Network registration state. Must be one of the {@link RegState}. For
* {@link TransportType#WLAN} transport, only {@link #REG_STATE_HOME} and
* {@link #REG_STATE_NOT_REG_NOT_SEARCHING} are valid states.
* @param accessNetworkTechnology Access network technology.For {@link TransportType#WLAN}
* transport, set to {@link TelephonyManager#NETWORK_TYPE_IWLAN}.
* transport type {@link AccessNetworkConstants#TRANSPORT_TYPE_WLAN}, only
* {@link #REG_STATE_HOME} and {@link #REG_STATE_NOT_REG_NOT_SEARCHING} are valid states.
* @param accessNetworkTechnology Access network technology.For transport type
* {@link AccessNetworkConstants#TRANSPORT_TYPE_WLAN}, set to
* {@link TelephonyManager#NETWORK_TYPE_IWLAN}.
* @param rejectCause Reason for denial if the registration state is {@link #REG_STATE_DENIED}.
* Depending on {@code accessNetworkTechnology}, the values are defined in 3GPP TS 24.008
* 10.5.3.6 for UMTS, 3GPP TS 24.301 9.9.3.9 for LTE, and 3GPP2 A.S0001 6.2.2.44 for CDMA. If
@@ -184,7 +184,8 @@ public class NetworkRegistrationState implements Parcelable {
* @param cellIdentity The identity representing a unique cell or wifi AP. Set to null if the
* information is not available.
*/
public NetworkRegistrationState(@Domain int domain, int transportType, @RegState int regState,
public NetworkRegistrationState(@Domain int domain, @TransportType int transportType,
@RegState int regState,
@NetworkType int accessNetworkTechnology, int rejectCause,
boolean emergencyOnly,
@NonNull @ServiceType int[] availableServices,
@@ -206,7 +207,7 @@ public class NetworkRegistrationState implements Parcelable {
* Constructor for voice network registration states.
* @hide
*/
public NetworkRegistrationState(int domain, int transportType, int regState,
public NetworkRegistrationState(int domain, @TransportType int transportType, int regState,
int accessNetworkTechnology, int rejectCause, boolean emergencyOnly,
int[] availableServices, @Nullable CellIdentity cellIdentity, boolean cssSupported,
int roamingIndicator, int systemIsInPrl, int defaultRoamingIndicator) {
@@ -221,7 +222,7 @@ public class NetworkRegistrationState implements Parcelable {
* Constructor for data network registration states.
* @hide
*/
public NetworkRegistrationState(int domain, int transportType, int regState,
public NetworkRegistrationState(int domain, @TransportType int transportType, int regState,
int accessNetworkTechnology, int rejectCause, boolean emergencyOnly,
int[] availableServices, @Nullable CellIdentity cellIdentity, int maxDataCalls,
boolean isDcNrRestricted, boolean isNrAvailable, boolean isEndcAvailable,
@@ -434,7 +435,8 @@ public class NetworkRegistrationState implements Parcelable {
public String toString() {
return new StringBuilder("NetworkRegistrationState{")
.append(" domain=").append((mDomain == DOMAIN_CS) ? "CS" : "PS")
.append(" transportType=").append(TransportType.toString(mTransportType))
.append(" transportType=").append(
AccessNetworkConstants.transportTypeToString(mTransportType))
.append(" regState=").append(regStateToString(mRegState))
.append(" roamingType=").append(ServiceState.roamingTypeToString(mRoamingType))
.append(" accessNetworkTechnology=")
@@ -627,7 +629,7 @@ public class NetworkRegistrationState implements Parcelable {
*
* @return The same instance of the builder.
*/
public @NonNull Builder setTransportType(int transportType) {
public @NonNull Builder setTransportType(@TransportType int transportType) {
mTransportType = transportType;
return this;
}

View File

@@ -28,6 +28,7 @@ import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.telephony.AccessNetworkConstants.AccessNetworkType;
import android.telephony.AccessNetworkConstants.TransportType;
import android.telephony.NetworkRegistrationState.Domain;
import android.telephony.NetworkRegistrationState.NRStatus;
import android.text.TextUtils;
@@ -620,7 +621,7 @@ public class ServiceState implements Parcelable {
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
public @RoamingType int getVoiceRoamingType() {
final NetworkRegistrationState regState = getNetworkRegistrationState(
NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TransportType.WWAN);
NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
if (regState != null) {
return regState.getRoamingType();
}
@@ -644,7 +645,7 @@ public class ServiceState implements Parcelable {
*/
public boolean getDataRoamingFromRegistration() {
final NetworkRegistrationState regState = getNetworkRegistrationState(
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TransportType.WWAN);
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
if (regState != null) {
return (regState.getRegState() == NetworkRegistrationState.REG_STATE_ROAMING);
}
@@ -659,7 +660,7 @@ public class ServiceState implements Parcelable {
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
public @RoamingType int getDataRoamingType() {
final NetworkRegistrationState regState = getNetworkRegistrationState(
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TransportType.WWAN);
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
if (regState != null) {
return regState.getRoamingType();
}
@@ -1130,10 +1131,10 @@ public class ServiceState implements Parcelable {
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
public void setVoiceRoamingType(@RoamingType int type) {
NetworkRegistrationState regState = getNetworkRegistrationState(
NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TransportType.WWAN);
NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
if (regState == null) {
regState = new NetworkRegistrationState(
NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TransportType.WWAN,
NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
ServiceState.ROAMING_TYPE_NOT_ROAMING, TelephonyManager.NETWORK_TYPE_UNKNOWN, 0,
false, null, null);
addNetworkRegistrationState(regState);
@@ -1151,10 +1152,10 @@ public class ServiceState implements Parcelable {
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
public void setDataRoamingType(@RoamingType int type) {
NetworkRegistrationState regState = getNetworkRegistrationState(
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TransportType.WWAN);
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
if (regState == null) {
regState = new NetworkRegistrationState(
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TransportType.WWAN,
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
ServiceState.ROAMING_TYPE_NOT_ROAMING, TelephonyManager.NETWORK_TYPE_UNKNOWN, 0,
false, null, null);
addNetworkRegistrationState(regState);
@@ -1326,10 +1327,10 @@ public class ServiceState implements Parcelable {
// sync to network registration state
NetworkRegistrationState regState = getNetworkRegistrationState(
NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TransportType.WWAN);
NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
if (regState == null) {
regState = new NetworkRegistrationState(
NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TransportType.WWAN,
NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
ServiceState.ROAMING_TYPE_NOT_ROAMING, TelephonyManager.NETWORK_TYPE_UNKNOWN,
0, false, null, null);
addNetworkRegistrationState(regState);
@@ -1353,11 +1354,11 @@ public class ServiceState implements Parcelable {
// sync to network registration state
NetworkRegistrationState regState = getNetworkRegistrationState(
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TransportType.WWAN);
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
if (regState == null) {
regState = new NetworkRegistrationState(
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TransportType.WWAN,
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
ServiceState.ROAMING_TYPE_NOT_ROAMING, TelephonyManager.NETWORK_TYPE_UNKNOWN,
0, false, null, null);
addNetworkRegistrationState(regState);
@@ -1391,7 +1392,7 @@ public class ServiceState implements Parcelable {
*/
public @NRStatus int getNrStatus() {
final NetworkRegistrationState regState = getNetworkRegistrationState(
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TransportType.WWAN);
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
if (regState == null) return NetworkRegistrationState.NR_STATUS_NONE;
return regState.getNrStatus();
}
@@ -1576,7 +1577,7 @@ public class ServiceState implements Parcelable {
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
public @TelephonyManager.NetworkType int getDataNetworkType() {
final NetworkRegistrationState iwlanRegState = getNetworkRegistrationState(
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TransportType.WLAN);
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WLAN);
if (iwlanRegState != null
&& iwlanRegState.getRegState() == NetworkRegistrationState.REG_STATE_HOME) {
// If the device is on IWLAN, return IWLAN as the network type. This is to simulate the
@@ -1587,7 +1588,7 @@ public class ServiceState implements Parcelable {
}
final NetworkRegistrationState regState = getNetworkRegistrationState(
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TransportType.WWAN);
NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
if (regState != null) {
return regState.getAccessNetworkTechnology();
}
@@ -1598,7 +1599,7 @@ public class ServiceState implements Parcelable {
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
public @TelephonyManager.NetworkType int getVoiceNetworkType() {
final NetworkRegistrationState regState = getNetworkRegistrationState(
NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TransportType.WWAN);
NetworkRegistrationState.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
if (regState != null) {
return regState.getAccessNetworkTechnology();
}
@@ -1777,11 +1778,11 @@ public class ServiceState implements Parcelable {
/**
* Get the network registration states for the transport type.
*
* @param transportType The {@link AccessNetworkConstants.TransportType transport type}
* @param transportType The transport type
* @return List of {@link NetworkRegistrationState}
* @hide
*
* @deprecated Use {@link #getNetworkRegistrationStatesFromTransportType(int)}
* @deprecated Use {@link #getNetworkRegistrationStatesForTransportType(int)}
*/
@NonNull
@Deprecated
@@ -1793,14 +1794,14 @@ public class ServiceState implements Parcelable {
/**
* Get the network registration states for the transport type.
*
* @param transportType The {@link AccessNetworkConstants.TransportType transport type}
* @param transportType The transport type
* @return List of {@link NetworkRegistrationState}
* @hide
*/
@NonNull
@SystemApi
public List<NetworkRegistrationState> getNetworkRegistrationStatesForTransportType(
int transportType) {
@TransportType int transportType) {
List<NetworkRegistrationState> list = new ArrayList<>();
synchronized (mNetworkRegistrationStates) {
@@ -1842,7 +1843,7 @@ public class ServiceState implements Parcelable {
* Get the network registration state for the transport type and network domain.
*
* @param domain The network {@link NetworkRegistrationState.Domain domain}
* @param transportType The {@link AccessNetworkConstants.TransportType transport type}
* @param transportType The transport type
* @return The matching {@link NetworkRegistrationState}
* @hide
*
@@ -1852,7 +1853,7 @@ public class ServiceState implements Parcelable {
@Deprecated
@SystemApi
public NetworkRegistrationState getNetworkRegistrationStates(@Domain int domain,
int transportType) {
@TransportType int transportType) {
return getNetworkRegistrationState(domain, transportType);
}
@@ -1860,7 +1861,7 @@ public class ServiceState implements Parcelable {
* Get the network registration state for the transport type and network domain.
*
* @param domain The network {@link NetworkRegistrationState.Domain domain}
* @param transportType The {@link AccessNetworkConstants.TransportType transport type}
* @param transportType The transport type
* @return The matching {@link NetworkRegistrationState}
* @hide
*
@@ -1868,7 +1869,7 @@ public class ServiceState implements Parcelable {
@Nullable
@SystemApi
public NetworkRegistrationState getNetworkRegistrationState(@Domain int domain,
int transportType) {
@TransportType int transportType) {
synchronized (mNetworkRegistrationStates) {
for (NetworkRegistrationState networkRegistrationState : mNetworkRegistrationStates) {
if (networkRegistrationState.getTransportType() == transportType

View File

@@ -107,9 +107,9 @@ public class ImsMmTelManager {
// case, since it is defined.
put(ImsRegistrationImplBase.REGISTRATION_TECH_NONE, -1);
put(ImsRegistrationImplBase.REGISTRATION_TECH_LTE,
AccessNetworkConstants.TransportType.WWAN);
AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
put(ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN,
AccessNetworkConstants.TransportType.WLAN);
AccessNetworkConstants.TRANSPORT_TYPE_WLAN);
}};
private final RegistrationCallback mLocalCallback;