Merge "5G Q backport" into qt-qpr1-dev

This commit is contained in:
Sarah Chin
2020-03-19 19:10:58 +00:00
committed by Android (Google) Code Review
9 changed files with 223 additions and 2 deletions

View File

@@ -15,6 +15,7 @@
*/
package android.net;
import android.telephony.SubscriptionPlan;
/** {@hide} */
oneway interface INetworkPolicyListener {
@@ -23,4 +24,5 @@ oneway interface INetworkPolicyListener {
void onRestrictBackgroundChanged(boolean restrictBackground);
void onUidPoliciesChanged(int uid, int uidPolicies);
void onSubscriptionOverride(int subId, int overrideMask, int overrideValue);
void onSubscriptionPlansChanged(int subId, in SubscriptionPlan[] plans);
}

View File

@@ -31,6 +31,7 @@ import android.net.wifi.WifiInfo;
import android.os.Build;
import android.os.RemoteException;
import android.os.UserHandle;
import android.telephony.SubscriptionPlan;
import android.util.DebugUtils;
import android.util.Pair;
import android.util.Range;
@@ -381,5 +382,6 @@ public class NetworkPolicyManager {
@Override public void onRestrictBackgroundChanged(boolean restrictBackground) { }
@Override public void onUidPoliciesChanged(int uid, int uidPolicies) { }
@Override public void onSubscriptionOverride(int subId, int overrideMask, int overrideValue) { }
@Override public void onSubscriptionPlansChanged(int subId, SubscriptionPlan[] plans) { }
}
}

View File

@@ -2571,6 +2571,12 @@
rmem_min,rmem_def,rmem_max,wmem_min,wmem_def,wmem_max -->
<string name="config_wifi_tcp_buffers" translatable="false">524288,1048576,2097152,262144,524288,1048576</string>
<!-- What source to use to estimate link upstream and downstream bandwidth capacities.
Default is carrier_config, but it should be set to modem if the modem is returning
predictive (instead of instantaneous) bandwidth estimate.
Values are carrier_config and modem. -->
<string name="config_bandwidthEstimateSource">carrier_config</string>
<!-- Whether WiFi display is supported by this device.
There are many prerequisites for this feature to work correctly.
Here are a few of them:

View File

@@ -518,6 +518,7 @@
<java-symbol type="string" name="config_deviceSpecificDevicePolicyManagerService" />
<java-symbol type="string" name="config_deviceSpecificAudioService" />
<java-symbol type="integer" name="config_num_physical_slots" />
<java-symbol type="string" name="config_bandwidthEstimateSource" />
<java-symbol type="color" name="tab_indicator_text_v4" />

View File

@@ -385,6 +385,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
private static final int MSG_SUBSCRIPTION_OVERRIDE = 16;
private static final int MSG_METERED_RESTRICTED_PACKAGES_CHANGED = 17;
private static final int MSG_SET_NETWORK_TEMPLATE_ENABLED = 18;
private static final int MSG_SUBSCRIPTION_PLANS_CHANGED = 19;
private static final int UID_MSG_STATE_CHANGED = 100;
private static final int UID_MSG_GONE = 101;
@@ -3064,6 +3065,34 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
mContext.enforceCallingOrSelfPermission(MANAGE_SUBSCRIPTION_PLANS, TAG);
}
private void enforceSubscriptionPlanValidity(SubscriptionPlan[] plans) {
// nothing to check if no plans
if (plans.length == 0) {
return;
}
long applicableNetworkTypes = 0;
boolean allNetworks = false;
for (SubscriptionPlan plan : plans) {
if (plan.getNetworkTypes() == null) {
allNetworks = true;
} else {
if ((applicableNetworkTypes & plan.getNetworkTypesBitMask()) != 0) {
throw new IllegalArgumentException(
"Multiple subscription plans defined for a single network type.");
} else {
applicableNetworkTypes |= plan.getNetworkTypesBitMask();
}
}
}
// ensure at least one plan applies for every network type
if (!allNetworks) {
throw new IllegalArgumentException(
"No generic subscription plan that applies to all network types.");
}
}
@Override
public SubscriptionPlan[] getSubscriptionPlans(int subId, String callingPackage) {
enforceSubscriptionPlanAccess(subId, Binder.getCallingUid(), callingPackage);
@@ -3228,9 +3257,26 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
@Override
public void setSubscriptionPlans(int subId, SubscriptionPlan[] plans, String callingPackage) {
enforceSubscriptionPlanAccess(subId, Binder.getCallingUid(), callingPackage);
enforceSubscriptionPlanValidity(plans);
int count5GPlans = 0;
SubscriptionPlan plan5G = null;
for (SubscriptionPlan plan : plans) {
Preconditions.checkNotNull(plan);
// temporary workaround to allow 5G unmetered for March QPR
// TODO: remove once SubscriptionPlan.Builder#setNetworkTypes(int[]) is public in R
if (plan.getTitle() != null && plan.getTitle().toString().contains("NR 5G unmetered")
&& plan.getDataLimitBytes() == SubscriptionPlan.BYTES_UNLIMITED
&& (plan.getDataLimitBehavior() == SubscriptionPlan.LIMIT_BEHAVIOR_UNKNOWN
|| plan.getDataLimitBehavior() == SubscriptionPlan.LIMIT_BEHAVIOR_THROTTLED)) {
count5GPlans++;
plan5G = plan;
}
}
// TODO: remove once SubscriptionPlan.Builder#setNetworkTypes(int[]) is public in R
if (count5GPlans == 1 && plans.length > 1) {
plan5G.setNetworkTypes(new int[] {TelephonyManager.NETWORK_TYPE_NR});
}
final long token = Binder.clearCallingIdentity();
@@ -3256,6 +3302,8 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, subId);
mContext.sendBroadcast(intent, android.Manifest.permission.MANAGE_SUBSCRIPTION_PLANS);
mHandler.sendMessage(
mHandler.obtainMessage(MSG_SUBSCRIPTION_PLANS_CHANGED, subId, 0, plans));
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -4449,6 +4497,16 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
}
}
private void dispatchSubscriptionPlansChanged(INetworkPolicyListener listener, int subId,
SubscriptionPlan[] plans) {
if (listener != null) {
try {
listener.onSubscriptionPlansChanged(subId, plans);
} catch (RemoteException ignored) {
}
}
}
private final Handler.Callback mHandlerCallback = new Handler.Callback() {
@Override
public boolean handleMessage(Message msg) {
@@ -4567,6 +4625,17 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
setNetworkTemplateEnabledInner(template, enabled);
return true;
}
case MSG_SUBSCRIPTION_PLANS_CHANGED: {
final SubscriptionPlan[] plans = (SubscriptionPlan[]) msg.obj;
final int subId = msg.arg1;
final int length = mListeners.beginBroadcast();
for (int i = 0; i < length; i++) {
final INetworkPolicyListener listener = mListeners.getBroadcastItem(i);
dispatchSubscriptionPlansChanged(listener, subId, plans);
}
mListeners.finishBroadcast();
return true;
}
default: {
return false;
}

View File

@@ -2245,6 +2245,21 @@ public class CarrierConfigManager {
public static final String KEY_USE_ONLY_RSRP_FOR_LTE_SIGNAL_BAR_BOOL =
"use_only_rsrp_for_lte_signal_bar_bool";
/**
* String array of default bandwidth values per network type.
* The entries should be of form "network_name:downstream,upstream", with values in Kbps.
* @hide
*/
public static final String KEY_BANDWIDTH_STRING_ARRAY = "bandwidth_string_array";
/**
* For NR (non-standalone), whether to use the LTE value instead of NR value as the default for
* upstream bandwidth. Downstream bandwidth will still use the NR value as the default.
* @hide
*/
public static final String KEY_BANDWIDTH_NR_NSA_USE_LTE_VALUE_FOR_UPSTREAM_BOOL =
"bandwidth_nr_nsa_use_lte_value_for_upstream_bool";
/**
* Key identifying if voice call barring notification is required to be shown to the user.
* @hide
@@ -2696,6 +2711,34 @@ public class CarrierConfigManager {
public static final String KEY_5G_ICON_DISPLAY_GRACE_PERIOD_SEC_INT =
"5g_icon_display_grace_period_sec_int";
/**
* Controls time in milliseconds until DcTracker reevaluates 5G connection state.
* @hide
*/
public static final String KEY_5G_WATCHDOG_TIME_MS_LONG = "5g_watchdog_time_long";
/**
* 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.
* @hide
*/
public static final String KEY_UNMETERED_NR_NSA_BOOL = "unmetered_nr_nsa_bool";
/**
* Whether NR (non-standalone) frequencies above 6GHz (millimeter wave) should be unmetered.
* If this is true, then the value for {@link #KEY_UNMETERED_NR_NSA_BOOL} will be ignored.
* @hide
*/
public static final String KEY_UNMETERED_NR_NSA_MMWAVE_BOOL = "unmetered_nr_nsa_mmwave_bool";
/**
* Whether NR (non-standalone) frequencies below 6GHz (sub6) should be unmetered.
* If this is true, then the value for {@link #KEY_UNMETERED_NR_NSA_BOOL} will be ignored.
* @hide
*/
public static final String KEY_UNMETERED_NR_NSA_SUB6_BOOL = "unmetered_nr_nsa_sub6_bool";
/**
* Support ASCII 7-BIT encoding for long SMS. This carrier config is used to enable
* this feature.
@@ -3582,6 +3625,13 @@ public class CarrierConfigManager {
-95, /* SIGNAL_STRENGTH_GOOD */
-85 /* SIGNAL_STRENGTH_GREAT */
});
sDefaults.putStringArray(KEY_BANDWIDTH_STRING_ARRAY, new String[]{
"GPRS:24,24", "EDGE:70,18", "UMTS:115,115", "CDMA-IS95A:14,14", "CDMA-IS95B:14,14",
"1xRTT:30,30", "EvDo-rev.0:750,48", "EvDo-rev.A:950,550", "HSDPA:4300,620",
"HSUPA:4300,1800", "HSPA:4300,1800", "EvDo-rev.B:1500,550:", "eHRPD:750,48",
"HSPAP:13000,3400", "TD-SCDMA:115,115", "LTE:30000,15000", "NR_NSA:47000,15000",
"NR_NSA_MMWAVE:145000,15000", "NR_SA:145000,15000"});
sDefaults.putBoolean(KEY_BANDWIDTH_NR_NSA_USE_LTE_VALUE_FOR_UPSTREAM_BOOL, false);
sDefaults.putString(KEY_WCDMA_DEFAULT_SIGNAL_STRENGTH_MEASUREMENT_STRING, "rssi");
sDefaults.putBoolean(KEY_CONFIG_SHOW_ORIG_DIAL_STRING_FOR_CDMA_BOOL, false);
sDefaults.putBoolean(KEY_SHOW_CALL_BLOCKING_DISABLED_NOTIFICATION_ALWAYS_BOOL, false);
@@ -3597,6 +3647,11 @@ public class CarrierConfigManager {
sDefaults.putString(KEY_5G_ICON_CONFIGURATION_STRING,
"connected_mmwave:5G,connected:5G");
sDefaults.putInt(KEY_5G_ICON_DISPLAY_GRACE_PERIOD_SEC_INT, 0);
/* Default value is 1 hour. */
sDefaults.putLong(KEY_5G_WATCHDOG_TIME_MS_LONG, 3600000);
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);
sDefaults.putBoolean(KEY_ASCII_7_BIT_SUPPORT_FOR_LONG_MESSAGE_BOOL, false);
/* Default value is minimum RSRP level needed for SIGNAL_STRENGTH_GOOD */
sDefaults.putInt(KEY_OPPORTUNISTIC_NETWORK_ENTRY_THRESHOLD_RSRP_INT, -108);

View File

@@ -2425,8 +2425,12 @@ public class SubscriptionManager {
* @param plans the list of plans. The first plan is always the primary and
* most important plan. Any additional plans are secondary and
* may not be displayed or used by decision making logic.
* The list of all plans must meet the requirements defined in
* {@link SubscriptionPlan.Builder#setNetworkTypes(int[])}.
* @throws SecurityException if the caller doesn't meet the requirements
* outlined above.
* @throws IllegalArgumentException if plans don't meet the requirements
* mentioned above.
*/
public void setSubscriptionPlans(int subId, @NonNull List<SubscriptionPlan> plans) {
try {

View File

@@ -24,6 +24,7 @@ import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
import android.telephony.TelephonyManager.NetworkType;
import android.util.Range;
import android.util.RecurrenceRule;
@@ -33,6 +34,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.time.Period;
import java.time.ZonedDateTime;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Objects;
@@ -42,6 +44,14 @@ import java.util.Objects;
* as explaining how much mobile data they have remaining, and what will happen
* when they run out.
*
* If specifying network types, the developer must supply at least one plan
* that applies to all network types (default), and all additional plans
* may not include a particular network type more than once.
* This is enforced by {@link SubscriptionManager} when setting the plans.
*
* Plan selection will prefer plans that have specific network types defined
* over plans that apply to all network types.
*
* @see SubscriptionManager#setSubscriptionPlans(int, java.util.List)
* @see SubscriptionManager#getSubscriptionPlans(int)
*/
@@ -80,6 +90,8 @@ public final class SubscriptionPlan implements Parcelable {
private int dataLimitBehavior = LIMIT_BEHAVIOR_UNKNOWN;
private long dataUsageBytes = BYTES_UNKNOWN;
private long dataUsageTime = TIME_UNKNOWN;
private @NetworkType int[] networkTypes;
private long networkTypesBitMask;
private SubscriptionPlan(RecurrenceRule cycleRule) {
this.cycleRule = Preconditions.checkNotNull(cycleRule);
@@ -93,6 +105,7 @@ public final class SubscriptionPlan implements Parcelable {
dataLimitBehavior = source.readInt();
dataUsageBytes = source.readLong();
dataUsageTime = source.readLong();
networkTypes = source.createIntArray();
}
@Override
@@ -109,6 +122,7 @@ public final class SubscriptionPlan implements Parcelable {
dest.writeInt(dataLimitBehavior);
dest.writeLong(dataUsageBytes);
dest.writeLong(dataUsageTime);
dest.writeIntArray(networkTypes);
}
@Override
@@ -121,13 +135,14 @@ public final class SubscriptionPlan implements Parcelable {
.append(" dataLimitBehavior=").append(dataLimitBehavior)
.append(" dataUsageBytes=").append(dataUsageBytes)
.append(" dataUsageTime=").append(dataUsageTime)
.append(" networkTypes=").append(Arrays.toString(networkTypes))
.append("}").toString();
}
@Override
public int hashCode() {
return Objects.hash(cycleRule, title, summary, dataLimitBytes, dataLimitBehavior,
dataUsageBytes, dataUsageTime);
dataUsageBytes, dataUsageTime, Arrays.hashCode(networkTypes));
}
@Override
@@ -140,7 +155,8 @@ public final class SubscriptionPlan implements Parcelable {
&& dataLimitBytes == other.dataLimitBytes
&& dataLimitBehavior == other.dataLimitBehavior
&& dataUsageBytes == other.dataUsageBytes
&& dataUsageTime == other.dataUsageTime;
&& dataUsageTime == other.dataUsageTime
&& Arrays.equals(networkTypes, other.networkTypes);
}
return false;
}
@@ -203,6 +219,50 @@ public final class SubscriptionPlan implements Parcelable {
return dataUsageTime;
}
/**
* Return an array containing all {@link NetworkType}s this SubscriptionPlan applies to.
* A null value means this SubscriptionPlan applies to all network types.
* @hide
*/
public @Nullable @NetworkType int[] getNetworkTypes() {
return networkTypes;
}
/**
* Return the networkTypes array converted to a {@link TelephonyManager.NetworkTypeBitMask}
* @hide
*/
public long getNetworkTypesBitMask() {
// calculate bitmask the first time and save for future calls
if (networkTypesBitMask == 0) {
if (networkTypes == null) {
networkTypesBitMask = ~0;
} else {
for (int networkType : networkTypes) {
networkTypesBitMask |= ServiceState.getBitmaskForTech(networkType);
}
}
}
return networkTypesBitMask;
}
/**
* Temporary solution to allow 5G unmetered for March QPR
* TODO: remove once {@link Builder#setNetworkTypes(int[])} is public in R.
* @hide
*/
public void setNetworkTypes(int[] networkTypes) {
if (networkTypes == null || networkTypes.length == 0) {
this.networkTypes = null;
this.networkTypesBitMask = ~0;
} else {
this.networkTypes = networkTypes;
for (int networkType : networkTypes) {
this.networkTypesBitMask |= ServiceState.getBitmaskForTech(networkType);
}
}
}
/**
* Return an iterator that will return all valid data usage cycles based on
* any recurrence rules. The iterator starts from the currently active cycle
@@ -335,5 +395,18 @@ public final class SubscriptionPlan implements Parcelable {
plan.dataUsageTime = dataUsageTime;
return this;
}
/**
* Set the network types this SubscriptionPlan applies to.
*
* @param networkTypes a set of all {@link NetworkType}s that apply to this plan.
* A null value means the plan applies to all network types,
* and an empty array means the plan applies to no network types.
* @hide
*/
public @NonNull Builder setNetworkTypes(@Nullable @NetworkType int[] networkTypes) {
plan.networkTypes = networkTypes;
return this;
}
}
}

View File

@@ -95,6 +95,10 @@ public class DctConstants {
public static final int EVENT_DATA_SERVICE_BINDING_CHANGED = BASE + 49;
public static final int EVENT_DEVICE_PROVISIONED_CHANGE = BASE + 50;
public static final int EVENT_DATA_ENABLED_OVERRIDE_RULES_CHANGED = BASE + 51;
public static final int EVENT_SERVICE_STATE_CHANGED = BASE + 52;
public static final int EVENT_5G_TIMER_HYSTERESIS = BASE + 53;
public static final int EVENT_5G_TIMER_WATCHDOG = BASE + 54;
public static final int EVENT_UPDATE_CARRIER_CONFIGS = BASE + 55;
/***** Constants *****/
@@ -104,4 +108,9 @@ public class DctConstants {
public static final String APN_TYPE_KEY = "apnType";
public static final String PROVISIONING_URL_KEY = "provisioningUrl";
public static final String BANDWIDTH_SOURCE_MODEM_KEY = "modem";
public static final String BANDWIDTH_SOURCE_CARRIER_CONFIG_KEY = "carrier_config";
public static final String RAT_NAME_LTE = "LTE";
public static final String RAT_NAME_NR_NSA = "NR_NSA";
public static final String RAT_NAME_NR_NSA_MMWAVE = "NR_NSA_MMWAVE";
}