Added setup/tear down data support am: 09c6189ae4
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1927642 Change-Id: Iaca33603e8d3fe7bd7411ce2c3bee5cdc19cd149
This commit is contained in:
@@ -3583,6 +3583,23 @@ public final class Telephony {
|
|||||||
public static final Uri ENFORCE_MANAGED_URI = Uri.parse(
|
public static final Uri ENFORCE_MANAGED_URI = Uri.parse(
|
||||||
"content://telephony/carriers/enforce_managed");
|
"content://telephony/carriers/enforce_managed");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@code content://} style URL for the perferred APN used for internet.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final Uri PREFERRED_APN_URI = Uri.parse(
|
||||||
|
"content://telephony/carriers/preferapn/subId/");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@code content://} style URL for the perferred APN set id.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final Uri PREFERRED_APN_SET_URI = Uri.parse(
|
||||||
|
"content://telephony/carriers/preferapnset/subId/");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The column name for ENFORCE_MANAGED_URI, indicates whether DPC-owned APNs are enforced.
|
* The column name for ENFORCE_MANAGED_URI, indicates whether DPC-owned APNs are enforced.
|
||||||
* @hide
|
* @hide
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package android.telephony;
|
package android.telephony;
|
||||||
|
|
||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
|
import android.net.NetworkAgent;
|
||||||
|
import android.net.NetworkCapabilities;
|
||||||
import android.telecom.Connection;
|
import android.telecom.Connection;
|
||||||
import android.telephony.data.ApnSetting;
|
import android.telephony.data.ApnSetting;
|
||||||
|
|
||||||
@@ -664,4 +666,59 @@ public class Annotation {
|
|||||||
TelephonyManager.THERMAL_MITIGATION_RESULT_INVALID_STATE,
|
TelephonyManager.THERMAL_MITIGATION_RESULT_INVALID_STATE,
|
||||||
TelephonyManager.THERMAL_MITIGATION_RESULT_UNKNOWN_ERROR})
|
TelephonyManager.THERMAL_MITIGATION_RESULT_UNKNOWN_ERROR})
|
||||||
public @interface ThermalMitigationResult {}
|
public @interface ThermalMitigationResult {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Per Android API guideline 8.15, annotation can't be public APIs. So duplicate
|
||||||
|
* android.net.NetworkCapabilities.NetCapability here. Must update here when new capabilities
|
||||||
|
* are added in {@link NetworkCapabilities}.
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
|
@IntDef(prefix = { "NET_CAPABILITY_" }, value = {
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_MMS,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_SUPL,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_DUN,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_FOTA,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_IMS,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_CBS,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_WIFI_P2P,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_IA,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_RCS,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_XCAP,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_EIMS,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_NOT_METERED,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_INTERNET,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_TRUSTED,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_NOT_VPN,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_VALIDATED,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_CAPTIVE_PORTAL,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_FOREGROUND,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_NOT_CONGESTED,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_NOT_SUSPENDED,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_OEM_PAID,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_MCX,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_PARTIAL_CONNECTIVITY,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_TEMPORARILY_NOT_METERED,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_OEM_PRIVATE,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_VEHICLE_INTERNAL,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_ENTERPRISE,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_VSIM,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_BIP,
|
||||||
|
NetworkCapabilities.NET_CAPABILITY_HEAD_UNIT,
|
||||||
|
})
|
||||||
|
public @interface NetCapability { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Per Android API guideline 8.15, annotation can't be public APIs. So duplicate
|
||||||
|
* android.net.NetworkAgent.ValidationStatus here. Must update here when new validation status
|
||||||
|
* are added in {@link NetworkAgent}.
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
|
@IntDef(prefix = { "VALIDATION_STATUS_" }, value = {
|
||||||
|
NetworkAgent.VALIDATION_STATUS_VALID,
|
||||||
|
NetworkAgent.VALIDATION_STATUS_NOT_VALID
|
||||||
|
})
|
||||||
|
public @interface ValidationStatus {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1076,6 +1076,13 @@ public final class DataFailCause {
|
|||||||
*/
|
*/
|
||||||
public static final int SERVICE_TEMPORARILY_UNAVAILABLE = 0x10009;
|
public static final int SERVICE_TEMPORARILY_UNAVAILABLE = 0x10009;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The request is not supported by the vendor.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final int REQUEST_NOT_SUPPORTED = 0x1000A;
|
||||||
|
|
||||||
private static final Map<Integer, String> sFailCauseMap;
|
private static final Map<Integer, String> sFailCauseMap;
|
||||||
static {
|
static {
|
||||||
sFailCauseMap = new HashMap<>();
|
sFailCauseMap = new HashMap<>();
|
||||||
|
|||||||
@@ -22,9 +22,11 @@ import android.annotation.IntDef;
|
|||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.annotation.SystemApi;
|
import android.annotation.SystemApi;
|
||||||
|
import android.net.NetworkCapabilities;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.telephony.Annotation.ApnType;
|
import android.telephony.Annotation.ApnType;
|
||||||
|
import android.telephony.Annotation.NetCapability;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.telephony.TelephonyManager.NetworkTypeBitMask;
|
import android.telephony.TelephonyManager.NetworkTypeBitMask;
|
||||||
import android.telephony.data.ApnSetting.AuthType;
|
import android.telephony.data.ApnSetting.AuthType;
|
||||||
@@ -66,7 +68,7 @@ public final class DataProfile implements Parcelable {
|
|||||||
|
|
||||||
private final @Nullable TrafficDescriptor mTrafficDescriptor;
|
private final @Nullable TrafficDescriptor mTrafficDescriptor;
|
||||||
|
|
||||||
private final boolean mPreferred;
|
private boolean mPreferred;
|
||||||
|
|
||||||
private DataProfile(@NonNull Builder builder) {
|
private DataProfile(@NonNull Builder builder) {
|
||||||
mApnSetting = builder.mApnSetting;
|
mApnSetting = builder.mApnSetting;
|
||||||
@@ -290,6 +292,16 @@ public final class DataProfile implements Parcelable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the preferred flag for the data profile.
|
||||||
|
*
|
||||||
|
* @param preferred {@code true} if this data profile is preferred for internet.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public void setPreferred(boolean preferred) {
|
||||||
|
mPreferred = preferred;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {@code true} if this data profile was used to bring up the last default
|
* @return {@code true} if this data profile was used to bring up the last default
|
||||||
* (i.e internet) data connection successfully, or the one chosen by the user in Settings'
|
* (i.e internet) data connection successfully, or the one chosen by the user in Settings'
|
||||||
@@ -315,6 +327,76 @@ public final class DataProfile implements Parcelable {
|
|||||||
return mTrafficDescriptor;
|
return mTrafficDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if this data profile can satisfy certain network capabilities
|
||||||
|
*
|
||||||
|
* @param networkCapabilities The network capabilities. Note that the non-APN-type capabilities
|
||||||
|
* will be ignored.
|
||||||
|
*
|
||||||
|
* @return {@code true} if this data profile can satisfy the given network capabilities.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public boolean canSatisfy(@NonNull @NetCapability int[] networkCapabilities) {
|
||||||
|
if (mApnSetting != null) {
|
||||||
|
for (int netCap : networkCapabilities) {
|
||||||
|
if (!canSatisfy(netCap)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if this data profile can satisfy a certain network capability.
|
||||||
|
*
|
||||||
|
* @param networkCapability The network capability. Note that the non-APN-type capability
|
||||||
|
* will always be satisfied.
|
||||||
|
* @return {@code true} if this data profile can satisfy the given network capability.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public boolean canSatisfy(@NetCapability int networkCapability) {
|
||||||
|
return mApnSetting != null && mApnSetting.canHandleType(
|
||||||
|
networkCapabilityToApnType(networkCapability));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert network capability into APN type.
|
||||||
|
*
|
||||||
|
* @param networkCapability Network capability.
|
||||||
|
* @return APN type.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
private static @ApnType int networkCapabilityToApnType(@NetCapability int networkCapability) {
|
||||||
|
switch (networkCapability) {
|
||||||
|
case NetworkCapabilities.NET_CAPABILITY_MMS:
|
||||||
|
return ApnSetting.TYPE_MMS;
|
||||||
|
case NetworkCapabilities.NET_CAPABILITY_SUPL:
|
||||||
|
return ApnSetting.TYPE_SUPL;
|
||||||
|
case NetworkCapabilities.NET_CAPABILITY_DUN:
|
||||||
|
return ApnSetting.TYPE_DUN;
|
||||||
|
case NetworkCapabilities.NET_CAPABILITY_FOTA:
|
||||||
|
return ApnSetting.TYPE_FOTA;
|
||||||
|
case NetworkCapabilities.NET_CAPABILITY_IMS:
|
||||||
|
return ApnSetting.TYPE_IMS;
|
||||||
|
case NetworkCapabilities.NET_CAPABILITY_CBS:
|
||||||
|
return ApnSetting.TYPE_CBS;
|
||||||
|
case NetworkCapabilities.NET_CAPABILITY_XCAP:
|
||||||
|
return ApnSetting.TYPE_XCAP;
|
||||||
|
case NetworkCapabilities.NET_CAPABILITY_EIMS:
|
||||||
|
return ApnSetting.TYPE_EMERGENCY;
|
||||||
|
case NetworkCapabilities.NET_CAPABILITY_INTERNET:
|
||||||
|
return ApnSetting.TYPE_DEFAULT;
|
||||||
|
case NetworkCapabilities.NET_CAPABILITY_MCX:
|
||||||
|
return ApnSetting.TYPE_MCX;
|
||||||
|
case NetworkCapabilities.NET_CAPABILITY_IA:
|
||||||
|
return ApnSetting.TYPE_IA;
|
||||||
|
default:
|
||||||
|
return ApnSetting.TYPE_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user