diff options
3 files changed, 103 insertions, 25 deletions
diff --git a/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsFactory.java b/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsFactory.java index 151c90dd4155..3b93f1a1905f 100644 --- a/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsFactory.java +++ b/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsFactory.java @@ -25,9 +25,9 @@ import static android.net.NetworkStats.UID_ALL; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; -import android.net.ConnectivityManager; import android.net.NetworkStats; import android.net.UnderlyingNetworkInfo; +import android.os.ServiceSpecificException; import android.os.StrictMode; import android.os.SystemClock; @@ -35,6 +35,7 @@ import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.ProcFileReader; import com.android.net.module.util.CollectionUtils; +import com.android.server.BpfNetMaps; import libcore.io.IoUtils; @@ -74,6 +75,8 @@ public class NetworkStatsFactory { private final Context mContext; + private final BpfNetMaps mBpfNetMaps; + /** * Guards persistent data access in this class * @@ -170,6 +173,7 @@ public class NetworkStatsFactory { mStatsXtIfaceFmt = new File(procRoot, "net/xt_qtaguid/iface_stat_fmt"); mStatsXtUid = new File(procRoot, "net/xt_qtaguid/stats"); mUseBpfStats = useBpfStats; + mBpfNetMaps = new BpfNetMaps(); synchronized (mPersistentDataLock) { mPersistSnapshot = new NetworkStats(SystemClock.elapsedRealtime(), -1); mTunAnd464xlatAdjustedStats = new NetworkStats(SystemClock.elapsedRealtime(), -1); @@ -297,12 +301,14 @@ public class NetworkStatsFactory { } @GuardedBy("mPersistentDataLock") - private void requestSwapActiveStatsMapLocked() { - // Do a active map stats swap. When the binder call successfully returns, - // the system server should be able to safely read and clean the inactive map - // without race problem. - final ConnectivityManager cm = mContext.getSystemService(ConnectivityManager.class); - cm.swapActiveStatsMap(); + private void requestSwapActiveStatsMapLocked() throws IOException { + try { + // Do a active map stats swap. Once the swap completes, this code + // can read and clean the inactive map without races. + mBpfNetMaps.swapActiveStatsMap(); + } catch (ServiceSpecificException e) { + throw new IOException(e); + } } /** @@ -328,11 +334,7 @@ public class NetworkStatsFactory { final NetworkStats stats = new NetworkStats(SystemClock.elapsedRealtime(), 0 /* initialSize */); if (mUseBpfStats) { - try { - requestSwapActiveStatsMapLocked(); - } catch (RuntimeException e) { - throw new IOException(e); - } + requestSwapActiveStatsMapLocked(); // Stats are always read from the inactive map, so they must be read after the // swap if (nativeReadNetworkStatsDetail(stats, mStatsXtUid.getAbsolutePath(), UID_ALL, diff --git a/telephony/java/android/telephony/AccessNetworkConstants.java b/telephony/java/android/telephony/AccessNetworkConstants.java index 1d7a4761dec6..4469ffc14447 100644 --- a/telephony/java/android/telephony/AccessNetworkConstants.java +++ b/telephony/java/android/telephony/AccessNetworkConstants.java @@ -17,6 +17,7 @@ package android.telephony; import android.annotation.IntDef; +import android.annotation.NonNull; import android.annotation.SystemApi; import android.hardware.radio.V1_5.AccessNetwork; @@ -28,6 +29,8 @@ import java.lang.annotation.RetentionPolicy; */ public final class AccessNetworkConstants { + private static final String TAG = AccessNetworkConstants.class.getSimpleName(); + /** * Wireless transportation type * @@ -108,6 +111,21 @@ public final class AccessNetworkConstants { default: return Integer.toString(type); } } + + /** @hide */ + public static @RadioAccessNetworkType int fromString(@NonNull String str) { + switch (str.toUpperCase()) { + case "GERAN" : return GERAN; + case "UTRAN" : return UTRAN; + case "EUTRAN" : return EUTRAN; + case "CDMA2000" : return CDMA2000; + case "IWLAN" : return IWLAN; + case "NGRAN" : return NGRAN; + default: + Rlog.e(TAG, "Invalid access network type " + str); + return UNKNOWN; + } + } } /** diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java index 3fe34920d83b..cd73bda496a1 100644 --- a/telephony/java/android/telephony/CarrierConfigManager.java +++ b/telephony/java/android/telephony/CarrierConfigManager.java @@ -48,6 +48,7 @@ import android.telephony.ims.feature.RcsFeature; import com.android.internal.telephony.ICarrierConfigLoader; import com.android.telephony.Rlog; +import java.util.List; import java.util.concurrent.TimeUnit; /** @@ -559,9 +560,9 @@ public class CarrierConfigManager { KEY_DISABLE_CDMA_ACTIVATION_CODE_BOOL = "disable_cdma_activation_code_bool"; /** - * List of RIL radio technologies (See {@link ServiceState} {@code RIL_RADIO_TECHNOLOGY_*} - * constants) which support only a single data connection at a time. Some carriers do not - * support multiple pdp on UMTS. + * List of network type constants which support only a single data connection at a time. + * Some carriers do not support multiple PDP on UMTS. + * @see TelephonyManager NETWORK_TYPE_* */ public static final String KEY_ONLY_SINGLE_DC_ALLOWED_INT_ARRAY = "only_single_dc_allowed_int_array"; @@ -3669,11 +3670,19 @@ public class CarrierConfigManager { public static final String KEY_5G_WATCHDOG_TIME_MS_LONG = "5g_watchdog_time_ms_long"; /** - * Which NR types are unmetered. A string array containing the following keys: + * Which network types are unmetered. A string array that can contain network type names from + * {@link TelephonyManager#getNetworkTypeName(int)} in addition to the following NR keys: * NR_NSA - NR NSA is unmetered for sub-6 frequencies * NR_NSA_MMWAVE - NR NSA is unmetered for mmwave frequencies * NR_SA - NR SA is unmetered for sub-6 frequencies * NR_SA_MMWAVE - NR SA is unmetered for mmwave frequencies + * + * Note that this config only applies if an unmetered SubscriptionPlan is set via + * {@link SubscriptionManager#setSubscriptionPlans(int, List)} or an unmetered override is set + * via {@link SubscriptionManager#setSubscriptionOverrideUnmetered(int, boolean, int[], long)} + * or {@link SubscriptionManager#setSubscriptionOverrideUnmetered(int, boolean, long)}. + * If neither SubscriptionPlans nor an override are set, then no network types can be unmetered + * regardless of the value of this config. * TODO: remove other unmetered keys and replace with this * @hide */ @@ -3681,6 +3690,27 @@ public class CarrierConfigManager { "unmetered_network_types_string_array"; /** + * Which network types are unmetered when roaming. A string array that can contain network type + * names from {@link TelephonyManager#getNetworkTypeName(int)} in addition to the following + * NR keys: + * NR_NSA - NR NSA is unmetered when roaming for sub-6 frequencies + * NR_NSA_MMWAVE - NR NSA is unmetered when roaming for mmwave frequencies + * NR_SA - NR SA is unmetered when roaming for sub-6 frequencies + * NR_SA_MMWAVE - NR SA is unmetered when roaming for mmwave frequencies + * + * Note that this config only applies if an unmetered SubscriptionPlan is set via + * {@link SubscriptionManager#setSubscriptionPlans(int, List)} or an unmetered override is set + * via {@link SubscriptionManager#setSubscriptionOverrideUnmetered(int, boolean, int[], long)} + * or {@link SubscriptionManager#setSubscriptionOverrideUnmetered(int, boolean, long)}. + * If neither SubscriptionPlans nor an override are set, then no network types can be unmetered + * when roaming regardless of the value of this config. + * TODO: remove KEY_UNMETERED_NR_NSA_WHEN_ROAMING_BOOL and replace with this + * @hide + */ + public static final String KEY_ROAMING_UNMETERED_NETWORK_TYPES_STRING_ARRAY = + "roaming_unmetered_network_types_string_array"; + + /** * Whether NR (non-standalone) should be unmetered for all frequencies. * If either {@link #KEY_UNMETERED_NR_NSA_MMWAVE_BOOL} or * {@link #KEY_UNMETERED_NR_NSA_SUB6_BOOL} are true, then this value will be ignored. @@ -5730,6 +5760,34 @@ public class CarrierConfigManager { public static final String KEY_UNTHROTTLE_DATA_RETRY_WHEN_TAC_CHANGES_BOOL = "unthrottle_data_retry_when_tac_changes_bool"; + /** + * IWLAN handover rules that determine whether handover is allowed or disallowed between + * cellular and IWLAN. + * + * The handover rules will be matched in the order. Here are some sample rules. + * <string-array name="iwlan_handover_rules" num="5"> + * <!-- Handover from IWLAN to 2G/3G is not allowed --> + * <item value="source=IWLAN, target=GERAN|UTRAN, type=disallowed"/> + * <!-- Handover from 2G/3G to IWLAN is not allowed --> + * <item value="source=GERAN|UTRAN, target:IWLAN, type=disallowed"/> + * <!-- Handover from IWLAN to 3G/4G/5G is not allowed if the device is roaming. --> + * <item value="source=IWLAN, target=UTRAN|EUTRAN|NGRAN, roaming=true, type=disallowed"/> + * <!-- Handover from 4G to IWLAN is not allowed --> + * <item value="source=EUTRAN, target=IWLAN, type=disallowed"/> + * <!-- Handover is always allowed in any condition. --> + * <item value="source=GERAN|UTRAN|EUTRAN|NGRAN|IWLAN, + * target=GERAN|UTRAN|EUTRAN|NGRAN|IWLAN, type=allowed"/> + * </string-array> + * + * When handover is not allowed, frameworks will tear down the data network on source transport, + * and then setup a new one on the target transport when Qualified Network Service changes the + * preferred access networks for particular APN types. + * + * @hide + */ + public static final String KEY_IWLAN_HANDOVER_POLICY_STRING_ARRAY = + "iwlan_handover_policy_string_array"; + /** The default value for every variable. */ private final static PersistableBundle sDefaults; @@ -5891,14 +5949,9 @@ public class CarrierConfigManager { sDefaults.putStringArray(KEY_CARRIER_WLAN_DISALLOWED_APN_TYPES_STRING_ARRAY, new String[]{""}); sDefaults.putIntArray(KEY_ONLY_SINGLE_DC_ALLOWED_INT_ARRAY, - new int[]{ - 4, /* IS95A */ - 5, /* IS95B */ - 6, /* 1xRTT */ - 7, /* EVDO_0 */ - 8, /* EVDO_A */ - 12 /* EVDO_B */ - }); + new int[] {TelephonyManager.NETWORK_TYPE_CDMA, TelephonyManager.NETWORK_TYPE_1xRTT, + TelephonyManager.NETWORK_TYPE_EVDO_0, TelephonyManager.NETWORK_TYPE_EVDO_A, + TelephonyManager.NETWORK_TYPE_EVDO_B}); sDefaults.putStringArray(KEY_GSM_ROAMING_NETWORKS_STRING_ARRAY, null); sDefaults.putStringArray(KEY_GSM_NONROAMING_NETWORKS_STRING_ARRAY, null); sDefaults.putString(KEY_CONFIG_IMS_PACKAGE_OVERRIDE_STRING, null); @@ -6241,7 +6294,9 @@ public class CarrierConfigManager { sDefaults.putInt(KEY_NR_ADVANCED_CAPABLE_PCO_ID_INT, 0); sDefaults.putBoolean(KEY_ENABLE_NR_ADVANCED_WHILE_ROAMING_BOOL, true); sDefaults.putBoolean(KEY_LTE_ENDC_USING_USER_DATA_FOR_RRC_DETECTION_BOOL, false); - sDefaults.putStringArray(KEY_UNMETERED_NETWORK_TYPES_STRING_ARRAY, new String[0]); + sDefaults.putStringArray(KEY_UNMETERED_NETWORK_TYPES_STRING_ARRAY, new String[] { + "NR_NSA", "NR_NSA_MMWAVE", "NR_SA", "NR_SA_MMWAVE"}); + sDefaults.putStringArray(KEY_ROAMING_UNMETERED_NETWORK_TYPES_STRING_ARRAY, new String[0]); sDefaults.putBoolean(KEY_UNMETERED_NR_NSA_BOOL, false); sDefaults.putBoolean(KEY_UNMETERED_NR_NSA_MMWAVE_BOOL, false); sDefaults.putBoolean(KEY_UNMETERED_NR_NSA_SUB6_BOOL, false); @@ -6378,6 +6433,9 @@ public class CarrierConfigManager { sDefaults.putBoolean(KEY_UNTHROTTLE_DATA_RETRY_WHEN_TAC_CHANGES_BOOL, false); sDefaults.putBoolean(KEY_VONR_SETTING_VISIBILITY_BOOL, true); sDefaults.putBoolean(KEY_VONR_ENABLED_BOOL, false); + sDefaults.putStringArray(KEY_IWLAN_HANDOVER_POLICY_STRING_ARRAY, new String[]{ + "source=GERAN|UTRAN|EUTRAN|NGRAN|IWLAN, " + + "target=GERAN|UTRAN|EUTRAN|NGRAN|IWLAN, type=allowed"}); } /** |