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 {
// 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());
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;
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 {
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;
}
/**
- * 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 {
@Domain
private final int mDomain;
- /** {@link TransportType} */
private final int mTransportType;
@RegState
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
* @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,
* 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) {
* 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,
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=")
*
* @return The same instance of the builder.
*/
- public @NonNull Builder setTransportType(int transportType) {
+ public @NonNull Builder setTransportType(@TransportType int transportType) {
mTransportType = transportType;
return this;
}
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;
@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();
}
*/
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);
}
@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();
}
@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);
@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);
// 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);
// 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);
*/
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();
}
@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
}
final NetworkRegistrationState regState = getNetworkRegistrationState(
- NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TransportType.WWAN);
+ NetworkRegistrationState.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
if (regState != null) {
return regState.getAccessNetworkTechnology();
}
@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();
}
/**
* 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
/**
* 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) {
* 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
*
@Deprecated
@SystemApi
public NetworkRegistrationState getNetworkRegistrationStates(@Domain int domain,
- int transportType) {
+ @TransportType int transportType) {
return getNetworkRegistrationState(domain, transportType);
}
* 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
*
@Nullable
@SystemApi
public NetworkRegistrationState getNetworkRegistrationState(@Domain int domain,
- int transportType) {
+ @TransportType int transportType) {
synchronized (mNetworkRegistrationStates) {
for (NetworkRegistrationState networkRegistrationState : mNetworkRegistrationStates) {
if (networkRegistrationState.getTransportType() == transportType
// 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;