Skip to content
Snippets Groups Projects
Commit 1bfd3ccf authored by Chalard Jean's avatar Chalard Jean
Browse files

Rename throwAboveU to throwAtLeastU

And address other comments on aosp/2527139

Bug: 273963543
Test: FrameworksNetTests
Change-Id: I4328aea2881badc2be667b900b7ac2a296af1678
parent b2852259
No related branches found
No related tags found
No related merge requests found
......@@ -195,7 +195,7 @@ public final class NetworkTemplate implements Parcelable {
}
}
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 @@ public final class NetworkTemplate implements Parcelable {
// 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 @@ public final class NetworkTemplate implements Parcelable {
// 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 @@ public final class NetworkTemplate implements Parcelable {
// 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 @@ public final class NetworkTemplate implements Parcelable {
// 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 @@ public final class NetworkTemplate implements Parcelable {
// 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 @@ public final class NetworkTemplate implements Parcelable {
// 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 @@ public final class NetworkTemplate implements Parcelable {
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 @@ public final class NetworkTemplate implements Parcelable {
this(getBackwardsCompatibleMatchRule(matchRule),
matchSubscriberIds == null ? new String[]{} : matchSubscriberIds,
matchWifiNetworkKeys, metered, roaming, defaultNetwork, ratType, oemManaged);
throwAboveU();
throwAtLeastU();
}
/** @hide */
......@@ -612,7 +619,8 @@ public final class NetworkTemplate implements Parcelable {
/** @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 @@ public final class NetworkTemplate implements Parcelable {
// 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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment