Rename throwAboveU to throwAtLeastU
And address other comments on aosp/2527139
Bug: 273963543
Test: FrameworksNetTests
Change-Id: I4328aea2881badc2be667b900b7ac2a296af1678
diff --git a/framework-t/src/android/net/NetworkTemplate.java b/framework-t/src/android/net/NetworkTemplate.java
index af68e2e..28c988f 100644
--- a/framework-t/src/android/net/NetworkTemplate.java
+++ b/framework-t/src/android/net/NetworkTemplate.java
@@ -195,7 +195,7 @@
}
}
- private static void throwAboveU() {
+ private static void throwAtLeastU() {
if (SdkLevel.isAtLeastU()) {
throw new UnsupportedOperationException("Method not supported on Android U or above");
}
@@ -278,7 +278,8 @@
// including in OEM code which can access this by linking against the framework.
public static NetworkTemplate buildTemplateBluetooth() {
// TODO : this is part of hidden-o txt, does that mean it should be annotated with
- // @UnsupportedAppUsage(maxTargetSdk = O) ? If yes, can't throwAboveU().
+ // @UnsupportedAppUsage(maxTargetSdk = O) ? If yes, can't throwAtLeastU() lest apps
+ // targeting O- crash on those devices.
return new NetworkTemplate.Builder(MATCH_BLUETOOTH).build();
}
@@ -292,7 +293,8 @@
// including in OEM code which can access this by linking against the framework.
public static NetworkTemplate buildTemplateProxy() {
// TODO : this is part of hidden-o txt, does that mean it should be annotated with
- // @UnsupportedAppUsage(maxTargetSdk = O) ? If yes, can't throwAboveU().
+ // @UnsupportedAppUsage(maxTargetSdk = O) ? If yes, can't throwAtLeastU() lest apps
+ // targeting O- crash on those devices.
return new NetworkTemplate(MATCH_PROXY, null, null);
}
@@ -304,9 +306,10 @@
// TODO(b/273963543): Remove this method. This can only be done after there are no more callers,
// including in OEM code which can access this by linking against the framework.
public static NetworkTemplate buildTemplateCarrierMetered(@NonNull String subscriberId) {
- throwAboveU();
+ throwAtLeastU();
return new NetworkTemplate.Builder(MATCH_CARRIER)
- // Set.of will throw if subscriberId is null
+ // Set.of will throw if wifiNetworkKey is null, which is the historical
+ // behavior and should be preserved.
.setSubscriberIds(Set.of(subscriberId))
.setMeteredness(METERED_YES)
.build();
@@ -323,7 +326,7 @@
// including in OEM code which can access this by linking against the framework.
public static NetworkTemplate buildTemplateMobileWithRatType(@Nullable String subscriberId,
int ratType, int metered) {
- throwAboveU();
+ throwAtLeastU();
return new NetworkTemplate.Builder(MATCH_MOBILE)
.setSubscriberIds(TextUtils.isEmpty(subscriberId)
? Collections.emptySet()
@@ -345,8 +348,11 @@
// including in OEM code which can access this by linking against the framework.
public static NetworkTemplate buildTemplateWifi(@NonNull String wifiNetworkKey) {
// TODO : this is part of hidden-o txt, does that mean it should be annotated with
- // @UnsupportedAppUsage(maxTargetSdk = O) ? If yes, can't throwAboveU().
+ // @UnsupportedAppUsage(maxTargetSdk = O) ? If yes, can't throwAtLeastU() lest apps
+ // targeting O- crash on those devices.
return new NetworkTemplate.Builder(MATCH_WIFI)
+ // Set.of will throw if wifiNetworkKey is null, which is the historical
+ // behavior and should be preserved.
.setWifiNetworkKeys(Set.of(wifiNetworkKey))
.build();
}
@@ -368,7 +374,7 @@
// including in OEM code which can access this by linking against the framework.
public static NetworkTemplate buildTemplateWifi(@Nullable String wifiNetworkKey,
@Nullable String subscriberId) {
- throwAboveU();
+ throwAtLeastU();
return new NetworkTemplate.Builder(MATCH_WIFI)
.setSubscriberIds(setOf(subscriberId))
.setWifiNetworkKeys(wifiNetworkKey == null
@@ -489,7 +495,8 @@
ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL,
OEM_MANAGED_ALL);
// TODO : this is part of hidden-o txt, does that mean it should be annotated with
- // @UnsupportedAppUsage(maxTargetSdk = O) ? If yes, can't throwAboveU().
+ // @UnsupportedAppUsage(maxTargetSdk = O) ? If yes, can't throwAtLeastU() lest apps
+ // targeting O- crash on those devices.
}
/** @hide */
@@ -504,7 +511,7 @@
this(getBackwardsCompatibleMatchRule(matchRule),
matchSubscriberIds == null ? new String[]{} : matchSubscriberIds,
matchWifiNetworkKeys, metered, roaming, defaultNetwork, ratType, oemManaged);
- throwAboveU();
+ throwAtLeastU();
}
/** @hide */
@@ -612,7 +619,8 @@
/** @hide */
public boolean isMatchRuleMobile() {
// TODO : this is part of hidden-o txt, does that mean it should be annotated with
- // @UnsupportedAppUsage(maxTargetSdk = O) ? If yes, can't throwAboveU().
+ // @UnsupportedAppUsage(maxTargetSdk = O) ? If yes, can't throwAtLeastU() lest apps
+ // targeting O- crash on those devices.
switch (mMatchRule) {
case MATCH_MOBILE:
// Old MATCH_MOBILE_WILDCARD
@@ -954,7 +962,7 @@
// TODO(b/273963543): Remove this method. This can only be done after there are no more callers,
// including in OEM code which can access this by linking against the framework.
public static NetworkTemplate normalize(NetworkTemplate template, List<String[]> mergedList) {
- throwAboveU();
+ throwAtLeastU();
return normalizeImpl(template, mergedList);
}