Merge "Rename throwAboveU to throwAtLeastU" am: 5edc307e57

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2527124

Change-Id: Ie607715c8fd03974798703eece24da1a1f590684
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Jean Chalard
2023-04-10 02:01:34 +00:00
committed by Automerger Merge Worker

View File

@@ -195,7 +195,7 @@ public final class NetworkTemplate implements Parcelable {
} }
} }
private static void throwAboveU() { private static void throwAtLeastU() {
if (SdkLevel.isAtLeastU()) { if (SdkLevel.isAtLeastU()) {
throw new UnsupportedOperationException("Method not supported on Android U or above"); 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. // including in OEM code which can access this by linking against the framework.
public static NetworkTemplate buildTemplateBluetooth() { public static NetworkTemplate buildTemplateBluetooth() {
// TODO : this is part of hidden-o txt, does that mean it should be annotated with // 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(); 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. // including in OEM code which can access this by linking against the framework.
public static NetworkTemplate buildTemplateProxy() { public static NetworkTemplate buildTemplateProxy() {
// TODO : this is part of hidden-o txt, does that mean it should be annotated with // 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); 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, // 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. // including in OEM code which can access this by linking against the framework.
public static NetworkTemplate buildTemplateCarrierMetered(@NonNull String subscriberId) { public static NetworkTemplate buildTemplateCarrierMetered(@NonNull String subscriberId) {
throwAboveU(); throwAtLeastU();
return new NetworkTemplate.Builder(MATCH_CARRIER) 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)) .setSubscriberIds(Set.of(subscriberId))
.setMeteredness(METERED_YES) .setMeteredness(METERED_YES)
.build(); .build();
@@ -323,7 +326,7 @@ public final class NetworkTemplate implements Parcelable {
// including in OEM code which can access this by linking against the framework. // including in OEM code which can access this by linking against the framework.
public static NetworkTemplate buildTemplateMobileWithRatType(@Nullable String subscriberId, public static NetworkTemplate buildTemplateMobileWithRatType(@Nullable String subscriberId,
int ratType, int metered) { int ratType, int metered) {
throwAboveU(); throwAtLeastU();
return new NetworkTemplate.Builder(MATCH_MOBILE) return new NetworkTemplate.Builder(MATCH_MOBILE)
.setSubscriberIds(TextUtils.isEmpty(subscriberId) .setSubscriberIds(TextUtils.isEmpty(subscriberId)
? Collections.emptySet() ? 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. // including in OEM code which can access this by linking against the framework.
public static NetworkTemplate buildTemplateWifi(@NonNull String wifiNetworkKey) { public static NetworkTemplate buildTemplateWifi(@NonNull String wifiNetworkKey) {
// TODO : this is part of hidden-o txt, does that mean it should be annotated with // 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) 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)) .setWifiNetworkKeys(Set.of(wifiNetworkKey))
.build(); .build();
} }
@@ -368,7 +374,7 @@ public final class NetworkTemplate implements Parcelable {
// including in OEM code which can access this by linking against the framework. // including in OEM code which can access this by linking against the framework.
public static NetworkTemplate buildTemplateWifi(@Nullable String wifiNetworkKey, public static NetworkTemplate buildTemplateWifi(@Nullable String wifiNetworkKey,
@Nullable String subscriberId) { @Nullable String subscriberId) {
throwAboveU(); throwAtLeastU();
return new NetworkTemplate.Builder(MATCH_WIFI) return new NetworkTemplate.Builder(MATCH_WIFI)
.setSubscriberIds(setOf(subscriberId)) .setSubscriberIds(setOf(subscriberId))
.setWifiNetworkKeys(wifiNetworkKey == null .setWifiNetworkKeys(wifiNetworkKey == null
@@ -489,7 +495,8 @@ public final class NetworkTemplate implements Parcelable {
ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL, ROAMING_ALL, DEFAULT_NETWORK_ALL, NETWORK_TYPE_ALL,
OEM_MANAGED_ALL); OEM_MANAGED_ALL);
// TODO : this is part of hidden-o txt, does that mean it should be annotated with // 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 */ /** @hide */
@@ -504,7 +511,7 @@ public final class NetworkTemplate implements Parcelable {
this(getBackwardsCompatibleMatchRule(matchRule), this(getBackwardsCompatibleMatchRule(matchRule),
matchSubscriberIds == null ? new String[]{} : matchSubscriberIds, matchSubscriberIds == null ? new String[]{} : matchSubscriberIds,
matchWifiNetworkKeys, metered, roaming, defaultNetwork, ratType, oemManaged); matchWifiNetworkKeys, metered, roaming, defaultNetwork, ratType, oemManaged);
throwAboveU(); throwAtLeastU();
} }
/** @hide */ /** @hide */
@@ -612,7 +619,8 @@ public final class NetworkTemplate implements Parcelable {
/** @hide */ /** @hide */
public boolean isMatchRuleMobile() { public boolean isMatchRuleMobile() {
// TODO : this is part of hidden-o txt, does that mean it should be annotated with // 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) { switch (mMatchRule) {
case MATCH_MOBILE: case MATCH_MOBILE:
// Old MATCH_MOBILE_WILDCARD // 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, // 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. // including in OEM code which can access this by linking against the framework.
public static NetworkTemplate normalize(NetworkTemplate template, List<String[]> mergedList) { public static NetworkTemplate normalize(NetworkTemplate template, List<String[]> mergedList) {
throwAboveU(); throwAtLeastU();
return normalizeImpl(template, mergedList); return normalizeImpl(template, mergedList);
} }