| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package android.net.vcn; |
| 17 |
|
| 18 |
import static android.net.NetworkCapabilities.NET_CAPABILITY_CBS; |
| 19 |
import static android.net.NetworkCapabilities.NET_CAPABILITY_DUN; |
| 20 |
import static android.net.NetworkCapabilities.NET_CAPABILITY_IMS; |
| 21 |
import static android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET; |
| 22 |
import static android.net.NetworkCapabilities.NET_CAPABILITY_MMS; |
| 23 |
import static android.net.NetworkCapabilities.NET_CAPABILITY_RCS; |
| 24 |
import static android.net.vcn.VcnUnderlyingNetworkTemplate.MATCH_ANY; |
| 25 |
import static android.net.vcn.VcnUnderlyingNetworkTemplate.getMatchCriteriaString; |
| 26 |
|
| 27 |
import static com.android.internal.annotations.VisibleForTesting.Visibility; |
| 28 |
import static com.android.server.vcn.util.PersistableBundleUtils.INTEGER_DESERIALIZER; |
| 29 |
import static com.android.server.vcn.util.PersistableBundleUtils.INTEGER_SERIALIZER; |
| 30 |
import static com.android.server.vcn.util.PersistableBundleUtils.STRING_DESERIALIZER; |
| 31 |
import static com.android.server.vcn.util.PersistableBundleUtils.STRING_SERIALIZER; |
| 32 |
|
| 33 |
import android.annotation.NonNull; |
| 34 |
import android.annotation.Nullable; |
| 35 |
import android.annotation.SuppressLint; |
| 36 |
import android.net.NetworkCapabilities; |
| 37 |
import android.net.vcn.VcnUnderlyingNetworkTemplate.MatchCriteria; |
| 38 |
import android.os.PersistableBundle; |
| 39 |
import android.telephony.SubscriptionInfo; |
| 40 |
import android.telephony.SubscriptionManager; |
| 41 |
import android.telephony.TelephonyManager; |
| 42 |
import android.util.ArraySet; |
| 43 |
|
| 44 |
import com.android.internal.annotations.VisibleForTesting; |
| 45 |
import com.android.internal.util.IndentingPrintWriter; |
| 46 |
import com.android.internal.util.Preconditions; |
| 47 |
import com.android.server.vcn.util.PersistableBundleUtils; |
| 48 |
|
| 49 |
import java.util.ArrayList; |
| 50 |
import java.util.Collections; |
| 51 |
import java.util.HashMap; |
| 52 |
import java.util.Map; |
| 53 |
import java.util.Objects; |
| 54 |
import java.util.Set; |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
public final class VcnCellUnderlyingNetworkTemplate extends VcnUnderlyingNetworkTemplate { |
| 63 |
private static final String ALLOWED_NETWORK_PLMN_IDS_KEY = "mAllowedNetworkPlmnIds"; |
| 64 |
@NonNull private final Set<String> mAllowedNetworkPlmnIds; |
| 65 |
private static final String ALLOWED_SPECIFIC_CARRIER_IDS_KEY = "mAllowedSpecificCarrierIds"; |
| 66 |
@NonNull private final Set<Integer> mAllowedSpecificCarrierIds; |
| 67 |
|
| 68 |
private static final String ROAMING_MATCH_KEY = "mRoamingMatchCriteria"; |
| 69 |
private static final int DEFAULT_ROAMING_MATCH_CRITERIA = MATCH_ANY; |
| 70 |
private final int mRoamingMatchCriteria; |
| 71 |
|
| 72 |
private static final String OPPORTUNISTIC_MATCH_KEY = "mOpportunisticMatchCriteria"; |
| 73 |
private static final int DEFAULT_OPPORTUNISTIC_MATCH_CRITERIA = MATCH_ANY; |
| 74 |
private final int mOpportunisticMatchCriteria; |
| 75 |
|
| 76 |
private static final String CAPABILITIES_MATCH_CRITERIA_KEY = "mCapabilitiesMatchCriteria"; |
| 77 |
@NonNull private final Map<Integer, Integer> mCapabilitiesMatchCriteria; |
| 78 |
|
| 79 |
private static final Map<Integer, Integer> CAPABILITIES_MATCH_CRITERIA_DEFAULT; |
| 80 |
|
| 81 |
static { |
| 82 |
Map<Integer, Integer> capsMatchCriteria = new HashMap<>(); |
| 83 |
capsMatchCriteria.put(NET_CAPABILITY_CBS, MATCH_ANY); |
| 84 |
capsMatchCriteria.put(NET_CAPABILITY_DUN, MATCH_ANY); |
| 85 |
capsMatchCriteria.put(NET_CAPABILITY_IMS, MATCH_ANY); |
| 86 |
capsMatchCriteria.put(NET_CAPABILITY_INTERNET, MATCH_REQUIRED); |
| 87 |
capsMatchCriteria.put(NET_CAPABILITY_MMS, MATCH_ANY); |
| 88 |
capsMatchCriteria.put(NET_CAPABILITY_RCS, MATCH_ANY); |
| 89 |
|
| 90 |
CAPABILITIES_MATCH_CRITERIA_DEFAULT = Collections.unmodifiableMap(capsMatchCriteria); |
| 91 |
} |
| 92 |
|
| 93 |
private VcnCellUnderlyingNetworkTemplate( |
| 94 |
int meteredMatchCriteria, |
| 95 |
int minEntryUpstreamBandwidthKbps, |
| 96 |
int minExitUpstreamBandwidthKbps, |
| 97 |
int minEntryDownstreamBandwidthKbps, |
| 98 |
int minExitDownstreamBandwidthKbps, |
| 99 |
Set<String> allowedNetworkPlmnIds, |
| 100 |
Set<Integer> allowedSpecificCarrierIds, |
| 101 |
int roamingMatchCriteria, |
| 102 |
int opportunisticMatchCriteria, |
| 103 |
Map<Integer, Integer> capabilitiesMatchCriteria) { |
| 104 |
super( |
| 105 |
NETWORK_PRIORITY_TYPE_CELL, |
| 106 |
meteredMatchCriteria, |
| 107 |
minEntryUpstreamBandwidthKbps, |
| 108 |
minExitUpstreamBandwidthKbps, |
| 109 |
minEntryDownstreamBandwidthKbps, |
| 110 |
minExitDownstreamBandwidthKbps); |
| 111 |
mAllowedNetworkPlmnIds = new ArraySet<>(allowedNetworkPlmnIds); |
| 112 |
mAllowedSpecificCarrierIds = new ArraySet<>(allowedSpecificCarrierIds); |
| 113 |
mRoamingMatchCriteria = roamingMatchCriteria; |
| 114 |
mOpportunisticMatchCriteria = opportunisticMatchCriteria; |
| 115 |
mCapabilitiesMatchCriteria = new HashMap<>(capabilitiesMatchCriteria); |
| 116 |
|
| 117 |
validate(); |
| 118 |
} |
| 119 |
|
| 120 |
|
| 121 |
@Override |
| 122 |
protected void validate() { |
| 123 |
super.validate(); |
| 124 |
validatePlmnIds(mAllowedNetworkPlmnIds); |
| 125 |
validateCapabilitiesMatchCriteria(mCapabilitiesMatchCriteria); |
| 126 |
Objects.requireNonNull(mAllowedSpecificCarrierIds, "matchingCarrierIds is null"); |
| 127 |
validateMatchCriteria(mRoamingMatchCriteria, "mRoamingMatchCriteria"); |
| 128 |
validateMatchCriteria(mOpportunisticMatchCriteria, "mOpportunisticMatchCriteria"); |
| 129 |
} |
| 130 |
|
| 131 |
private static void validatePlmnIds(Set<String> matchingOperatorPlmnIds) { |
| 132 |
Objects.requireNonNull(matchingOperatorPlmnIds, "matchingOperatorPlmnIds is null"); |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
for (String id : matchingOperatorPlmnIds) { |
| 137 |
if ((id.length() == 5 || id.length() == 6) && id.matches("[0-9]+")) { |
| 138 |
continue; |
| 139 |
} else { |
| 140 |
throw new IllegalArgumentException("Found invalid PLMN ID: " + id); |
| 141 |
} |
| 142 |
} |
| 143 |
} |
| 144 |
|
| 145 |
private static void validateCapabilitiesMatchCriteria( |
| 146 |
Map<Integer, Integer> capabilitiesMatchCriteria) { |
| 147 |
Objects.requireNonNull(capabilitiesMatchCriteria, "capabilitiesMatchCriteria is null"); |
| 148 |
|
| 149 |
boolean requiredCapabilityFound = false; |
| 150 |
for (Map.Entry<Integer, Integer> entry : capabilitiesMatchCriteria.entrySet()) { |
| 151 |
final int capability = entry.getKey(); |
| 152 |
final int matchCriteria = entry.getValue(); |
| 153 |
|
| 154 |
Preconditions.checkArgument( |
| 155 |
CAPABILITIES_MATCH_CRITERIA_DEFAULT.containsKey(capability), |
| 156 |
"NetworkCapability " + capability + "out of range"); |
| 157 |
validateMatchCriteria(matchCriteria, "capability " + capability); |
| 158 |
|
| 159 |
requiredCapabilityFound |= (matchCriteria == MATCH_REQUIRED); |
| 160 |
} |
| 161 |
|
| 162 |
if (!requiredCapabilityFound) { |
| 163 |
throw new IllegalArgumentException("No required capabilities found"); |
| 164 |
} |
| 165 |
} |
| 166 |
|
| 167 |
|
| 168 |
@NonNull |
| 169 |
@VisibleForTesting(visibility = Visibility.PROTECTED) |
| 170 |
public static VcnCellUnderlyingNetworkTemplate fromPersistableBundle( |
| 171 |
@NonNull PersistableBundle in) { |
| 172 |
Objects.requireNonNull(in, "PersistableBundle is null"); |
| 173 |
|
| 174 |
final int meteredMatchCriteria = in.getInt(METERED_MATCH_KEY); |
| 175 |
|
| 176 |
final int minEntryUpstreamBandwidthKbps = |
| 177 |
in.getInt(MIN_ENTRY_UPSTREAM_BANDWIDTH_KBPS_KEY, DEFAULT_MIN_BANDWIDTH_KBPS); |
| 178 |
final int minExitUpstreamBandwidthKbps = |
| 179 |
in.getInt(MIN_EXIT_UPSTREAM_BANDWIDTH_KBPS_KEY, DEFAULT_MIN_BANDWIDTH_KBPS); |
| 180 |
final int minEntryDownstreamBandwidthKbps = |
| 181 |
in.getInt(MIN_ENTRY_DOWNSTREAM_BANDWIDTH_KBPS_KEY, DEFAULT_MIN_BANDWIDTH_KBPS); |
| 182 |
final int minExitDownstreamBandwidthKbps = |
| 183 |
in.getInt(MIN_EXIT_DOWNSTREAM_BANDWIDTH_KBPS_KEY, DEFAULT_MIN_BANDWIDTH_KBPS); |
| 184 |
|
| 185 |
final PersistableBundle plmnIdsBundle = |
| 186 |
in.getPersistableBundle(ALLOWED_NETWORK_PLMN_IDS_KEY); |
| 187 |
Objects.requireNonNull(plmnIdsBundle, "plmnIdsBundle is null"); |
| 188 |
final Set<String> allowedNetworkPlmnIds = |
| 189 |
new ArraySet<String>( |
| 190 |
PersistableBundleUtils.toList(plmnIdsBundle, STRING_DESERIALIZER)); |
| 191 |
|
| 192 |
final PersistableBundle specificCarrierIdsBundle = |
| 193 |
in.getPersistableBundle(ALLOWED_SPECIFIC_CARRIER_IDS_KEY); |
| 194 |
Objects.requireNonNull(specificCarrierIdsBundle, "specificCarrierIdsBundle is null"); |
| 195 |
final Set<Integer> allowedSpecificCarrierIds = |
| 196 |
new ArraySet<Integer>( |
| 197 |
PersistableBundleUtils.toList( |
| 198 |
specificCarrierIdsBundle, INTEGER_DESERIALIZER)); |
| 199 |
|
| 200 |
final PersistableBundle capabilitiesMatchCriteriaBundle = |
| 201 |
in.getPersistableBundle(CAPABILITIES_MATCH_CRITERIA_KEY); |
| 202 |
final Map<Integer, Integer> capabilitiesMatchCriteria; |
| 203 |
if (capabilitiesMatchCriteriaBundle == null) { |
| 204 |
capabilitiesMatchCriteria = CAPABILITIES_MATCH_CRITERIA_DEFAULT; |
| 205 |
} else { |
| 206 |
capabilitiesMatchCriteria = |
| 207 |
PersistableBundleUtils.toMap( |
| 208 |
capabilitiesMatchCriteriaBundle, |
| 209 |
INTEGER_DESERIALIZER, |
| 210 |
INTEGER_DESERIALIZER); |
| 211 |
} |
| 212 |
|
| 213 |
final int roamingMatchCriteria = in.getInt(ROAMING_MATCH_KEY); |
| 214 |
final int opportunisticMatchCriteria = in.getInt(OPPORTUNISTIC_MATCH_KEY); |
| 215 |
|
| 216 |
return new VcnCellUnderlyingNetworkTemplate( |
| 217 |
meteredMatchCriteria, |
| 218 |
minEntryUpstreamBandwidthKbps, |
| 219 |
minExitUpstreamBandwidthKbps, |
| 220 |
minEntryDownstreamBandwidthKbps, |
| 221 |
minExitDownstreamBandwidthKbps, |
| 222 |
allowedNetworkPlmnIds, |
| 223 |
allowedSpecificCarrierIds, |
| 224 |
roamingMatchCriteria, |
| 225 |
opportunisticMatchCriteria, |
| 226 |
capabilitiesMatchCriteria); |
| 227 |
} |
| 228 |
|
| 229 |
|
| 230 |
@Override |
| 231 |
@NonNull |
| 232 |
@VisibleForTesting(visibility = Visibility.PROTECTED) |
| 233 |
public PersistableBundle toPersistableBundle() { |
| 234 |
final PersistableBundle result = super.toPersistableBundle(); |
| 235 |
|
| 236 |
final PersistableBundle plmnIdsBundle = |
| 237 |
PersistableBundleUtils.fromList( |
| 238 |
new ArrayList<>(mAllowedNetworkPlmnIds), STRING_SERIALIZER); |
| 239 |
result.putPersistableBundle(ALLOWED_NETWORK_PLMN_IDS_KEY, plmnIdsBundle); |
| 240 |
|
| 241 |
final PersistableBundle specificCarrierIdsBundle = |
| 242 |
PersistableBundleUtils.fromList( |
| 243 |
new ArrayList<>(mAllowedSpecificCarrierIds), INTEGER_SERIALIZER); |
| 244 |
result.putPersistableBundle(ALLOWED_SPECIFIC_CARRIER_IDS_KEY, specificCarrierIdsBundle); |
| 245 |
|
| 246 |
final PersistableBundle capabilitiesMatchCriteriaBundle = |
| 247 |
PersistableBundleUtils.fromMap( |
| 248 |
mCapabilitiesMatchCriteria, INTEGER_SERIALIZER, INTEGER_SERIALIZER); |
| 249 |
result.putPersistableBundle( |
| 250 |
CAPABILITIES_MATCH_CRITERIA_KEY, capabilitiesMatchCriteriaBundle); |
| 251 |
|
| 252 |
result.putInt(ROAMING_MATCH_KEY, mRoamingMatchCriteria); |
| 253 |
result.putInt(OPPORTUNISTIC_MATCH_KEY, mOpportunisticMatchCriteria); |
| 254 |
|
| 255 |
return result; |
| 256 |
} |
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
@NonNull |
| 264 |
public Set<String> getOperatorPlmnIds() { |
| 265 |
return Collections.unmodifiableSet(mAllowedNetworkPlmnIds); |
| 266 |
} |
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
@NonNull |
| 275 |
public Set<Integer> getSimSpecificCarrierIds() { |
| 276 |
return Collections.unmodifiableSet(mAllowedSpecificCarrierIds); |
| 277 |
} |
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
@MatchCriteria |
| 285 |
public int getRoaming() { |
| 286 |
return mRoamingMatchCriteria; |
| 287 |
} |
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
@MatchCriteria |
| 295 |
public int getOpportunistic() { |
| 296 |
return mOpportunisticMatchCriteria; |
| 297 |
} |
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
@MatchCriteria |
| 305 |
public int getCbs() { |
| 306 |
return mCapabilitiesMatchCriteria.get(NET_CAPABILITY_CBS); |
| 307 |
} |
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
@MatchCriteria |
| 315 |
public int getDun() { |
| 316 |
return mCapabilitiesMatchCriteria.get(NET_CAPABILITY_DUN); |
| 317 |
} |
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
@MatchCriteria |
| 324 |
public int getIms() { |
| 325 |
return mCapabilitiesMatchCriteria.get(NET_CAPABILITY_IMS); |
| 326 |
} |
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
@MatchCriteria |
| 333 |
public int getInternet() { |
| 334 |
return mCapabilitiesMatchCriteria.get(NET_CAPABILITY_INTERNET); |
| 335 |
} |
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
@MatchCriteria |
| 342 |
public int getMms() { |
| 343 |
return mCapabilitiesMatchCriteria.get(NET_CAPABILITY_MMS); |
| 344 |
} |
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
@MatchCriteria |
| 352 |
public int getRcs() { |
| 353 |
return mCapabilitiesMatchCriteria.get(NET_CAPABILITY_RCS); |
| 354 |
} |
| 355 |
|
| 356 |
|
| 357 |
@Override |
| 358 |
public Map<Integer, Integer> getCapabilitiesMatchCriteria() { |
| 359 |
return Collections.unmodifiableMap(new HashMap<>(mCapabilitiesMatchCriteria)); |
| 360 |
} |
| 361 |
|
| 362 |
@Override |
| 363 |
public int hashCode() { |
| 364 |
return Objects.hash( |
| 365 |
super.hashCode(), |
| 366 |
mAllowedNetworkPlmnIds, |
| 367 |
mAllowedSpecificCarrierIds, |
| 368 |
mCapabilitiesMatchCriteria, |
| 369 |
mRoamingMatchCriteria, |
| 370 |
mOpportunisticMatchCriteria); |
| 371 |
} |
| 372 |
|
| 373 |
@Override |
| 374 |
public boolean equals(@Nullable Object other) { |
| 375 |
if (!super.equals(other)) { |
| 376 |
return false; |
| 377 |
} |
| 378 |
|
| 379 |
if (!(other instanceof VcnCellUnderlyingNetworkTemplate)) { |
| 380 |
return false; |
| 381 |
} |
| 382 |
|
| 383 |
final VcnCellUnderlyingNetworkTemplate rhs = (VcnCellUnderlyingNetworkTemplate) other; |
| 384 |
return Objects.equals(mAllowedNetworkPlmnIds, rhs.mAllowedNetworkPlmnIds) |
| 385 |
&& Objects.equals(mAllowedSpecificCarrierIds, rhs.mAllowedSpecificCarrierIds) |
| 386 |
&& Objects.equals(mCapabilitiesMatchCriteria, rhs.mCapabilitiesMatchCriteria) |
| 387 |
&& mRoamingMatchCriteria == rhs.mRoamingMatchCriteria |
| 388 |
&& mOpportunisticMatchCriteria == rhs.mOpportunisticMatchCriteria; |
| 389 |
} |
| 390 |
|
| 391 |
|
| 392 |
@Override |
| 393 |
void dumpTransportSpecificFields(IndentingPrintWriter pw) { |
| 394 |
if (!mAllowedNetworkPlmnIds.isEmpty()) { |
| 395 |
pw.println("mAllowedNetworkPlmnIds: " + mAllowedNetworkPlmnIds); |
| 396 |
} |
| 397 |
if (!mAllowedNetworkPlmnIds.isEmpty()) { |
| 398 |
pw.println("mAllowedSpecificCarrierIds: " + mAllowedSpecificCarrierIds); |
| 399 |
} |
| 400 |
pw.println("mCapabilitiesMatchCriteria: " + mCapabilitiesMatchCriteria); |
| 401 |
if (mRoamingMatchCriteria != DEFAULT_ROAMING_MATCH_CRITERIA) { |
| 402 |
pw.println("mRoamingMatchCriteria: " + getMatchCriteriaString(mRoamingMatchCriteria)); |
| 403 |
} |
| 404 |
if (mOpportunisticMatchCriteria != DEFAULT_OPPORTUNISTIC_MATCH_CRITERIA) { |
| 405 |
pw.println( |
| 406 |
"mOpportunisticMatchCriteria: " |
| 407 |
+ getMatchCriteriaString(mOpportunisticMatchCriteria)); |
| 408 |
} |
| 409 |
} |
| 410 |
|
| 411 |
|
| 412 |
public static final class Builder { |
| 413 |
private int mMeteredMatchCriteria = DEFAULT_METERED_MATCH_CRITERIA; |
| 414 |
|
| 415 |
@NonNull private final Set<String> mAllowedNetworkPlmnIds = new ArraySet<>(); |
| 416 |
@NonNull private final Set<Integer> mAllowedSpecificCarrierIds = new ArraySet<>(); |
| 417 |
@NonNull private final Map<Integer, Integer> mCapabilitiesMatchCriteria = new HashMap<>(); |
| 418 |
|
| 419 |
private int mRoamingMatchCriteria = DEFAULT_ROAMING_MATCH_CRITERIA; |
| 420 |
private int mOpportunisticMatchCriteria = DEFAULT_OPPORTUNISTIC_MATCH_CRITERIA; |
| 421 |
|
| 422 |
private int mMinEntryUpstreamBandwidthKbps = DEFAULT_MIN_BANDWIDTH_KBPS; |
| 423 |
private int mMinExitUpstreamBandwidthKbps = DEFAULT_MIN_BANDWIDTH_KBPS; |
| 424 |
private int mMinEntryDownstreamBandwidthKbps = DEFAULT_MIN_BANDWIDTH_KBPS; |
| 425 |
private int mMinExitDownstreamBandwidthKbps = DEFAULT_MIN_BANDWIDTH_KBPS; |
| 426 |
|
| 427 |
|
| 428 |
public Builder() { |
| 429 |
mCapabilitiesMatchCriteria.putAll(CAPABILITIES_MATCH_CRITERIA_DEFAULT); |
| 430 |
} |
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
@SuppressLint("MissingGetterMatchingBuilder") |
| 446 |
@NonNull |
| 447 |
public Builder setMetered(@MatchCriteria int matchCriteria) { |
| 448 |
validateMatchCriteria(matchCriteria, "setMetered"); |
| 449 |
|
| 450 |
mMeteredMatchCriteria = matchCriteria; |
| 451 |
return this; |
| 452 |
} |
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
@NonNull |
| 468 |
public Builder setOperatorPlmnIds(@NonNull Set<String> operatorPlmnIds) { |
| 469 |
validatePlmnIds(operatorPlmnIds); |
| 470 |
|
| 471 |
mAllowedNetworkPlmnIds.clear(); |
| 472 |
mAllowedNetworkPlmnIds.addAll(operatorPlmnIds); |
| 473 |
return this; |
| 474 |
} |
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
@NonNull |
| 485 |
public Builder setSimSpecificCarrierIds(@NonNull Set<Integer> simSpecificCarrierIds) { |
| 486 |
Objects.requireNonNull(simSpecificCarrierIds, "simSpecificCarrierIds is null"); |
| 487 |
|
| 488 |
mAllowedSpecificCarrierIds.clear(); |
| 489 |
mAllowedSpecificCarrierIds.addAll(simSpecificCarrierIds); |
| 490 |
return this; |
| 491 |
} |
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
@NonNull |
| 505 |
public Builder setRoaming(@MatchCriteria int matchCriteria) { |
| 506 |
validateMatchCriteria(matchCriteria, "setRoaming"); |
| 507 |
|
| 508 |
mRoamingMatchCriteria = matchCriteria; |
| 509 |
return this; |
| 510 |
} |
| 511 |
|
| 512 |
|
| 513 |
|
| 514 |
|
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
@NonNull |
| 520 |
public Builder setOpportunistic(@MatchCriteria int matchCriteria) { |
| 521 |
validateMatchCriteria(matchCriteria, "setOpportunistic"); |
| 522 |
|
| 523 |
mOpportunisticMatchCriteria = matchCriteria; |
| 524 |
return this; |
| 525 |
} |
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
@NonNull |
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
@SuppressLint("MissingGetterMatchingBuilder") |
| 555 |
public Builder setMinUpstreamBandwidthKbps( |
| 556 |
int minEntryUpstreamBandwidthKbps, int minExitUpstreamBandwidthKbps) { |
| 557 |
validateMinBandwidthKbps(minEntryUpstreamBandwidthKbps, minExitUpstreamBandwidthKbps); |
| 558 |
|
| 559 |
mMinEntryUpstreamBandwidthKbps = minEntryUpstreamBandwidthKbps; |
| 560 |
mMinExitUpstreamBandwidthKbps = minExitUpstreamBandwidthKbps; |
| 561 |
|
| 562 |
return this; |
| 563 |
} |
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
|
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
@NonNull |
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
@SuppressLint("MissingGetterMatchingBuilder") |
| 593 |
public Builder setMinDownstreamBandwidthKbps( |
| 594 |
int minEntryDownstreamBandwidthKbps, int minExitDownstreamBandwidthKbps) { |
| 595 |
validateMinBandwidthKbps( |
| 596 |
minEntryDownstreamBandwidthKbps, minExitDownstreamBandwidthKbps); |
| 597 |
|
| 598 |
mMinEntryDownstreamBandwidthKbps = minEntryDownstreamBandwidthKbps; |
| 599 |
mMinExitDownstreamBandwidthKbps = minExitDownstreamBandwidthKbps; |
| 600 |
|
| 601 |
return this; |
| 602 |
} |
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
|
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
@NonNull |
| 617 |
public Builder setCbs(@MatchCriteria int matchCriteria) { |
| 618 |
validateMatchCriteria(matchCriteria, "setCbs"); |
| 619 |
|
| 620 |
mCapabilitiesMatchCriteria.put(NET_CAPABILITY_CBS, matchCriteria); |
| 621 |
return this; |
| 622 |
} |
| 623 |
|
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
|
| 631 |
|
| 632 |
|
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
@NonNull |
| 637 |
public Builder setDun(@MatchCriteria int matchCriteria) { |
| 638 |
validateMatchCriteria(matchCriteria, "setDun"); |
| 639 |
|
| 640 |
mCapabilitiesMatchCriteria.put(NET_CAPABILITY_DUN, matchCriteria); |
| 641 |
return this; |
| 642 |
} |
| 643 |
|
| 644 |
|
| 645 |
|
| 646 |
|
| 647 |
|
| 648 |
|
| 649 |
|
| 650 |
|
| 651 |
|
| 652 |
|
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
@NonNull |
| 657 |
public Builder setIms(@MatchCriteria int matchCriteria) { |
| 658 |
validateMatchCriteria(matchCriteria, "setIms"); |
| 659 |
|
| 660 |
mCapabilitiesMatchCriteria.put(NET_CAPABILITY_IMS, matchCriteria); |
| 661 |
return this; |
| 662 |
} |
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
@NonNull |
| 677 |
public Builder setInternet(@MatchCriteria int matchCriteria) { |
| 678 |
validateMatchCriteria(matchCriteria, "setInternet"); |
| 679 |
|
| 680 |
mCapabilitiesMatchCriteria.put(NET_CAPABILITY_INTERNET, matchCriteria); |
| 681 |
return this; |
| 682 |
} |
| 683 |
|
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
|
| 690 |
|
| 691 |
|
| 692 |
|
| 693 |
|
| 694 |
|
| 695 |
|
| 696 |
@NonNull |
| 697 |
public Builder setMms(@MatchCriteria int matchCriteria) { |
| 698 |
validateMatchCriteria(matchCriteria, "setMms"); |
| 699 |
|
| 700 |
mCapabilitiesMatchCriteria.put(NET_CAPABILITY_MMS, matchCriteria); |
| 701 |
return this; |
| 702 |
} |
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
@NonNull |
| 717 |
public Builder setRcs(@MatchCriteria int matchCriteria) { |
| 718 |
validateMatchCriteria(matchCriteria, "setRcs"); |
| 719 |
|
| 720 |
mCapabilitiesMatchCriteria.put(NET_CAPABILITY_RCS, matchCriteria); |
| 721 |
return this; |
| 722 |
} |
| 723 |
|
| 724 |
|
| 725 |
@NonNull |
| 726 |
public VcnCellUnderlyingNetworkTemplate build() { |
| 727 |
return new VcnCellUnderlyingNetworkTemplate( |
| 728 |
mMeteredMatchCriteria, |
| 729 |
mMinEntryUpstreamBandwidthKbps, |
| 730 |
mMinExitUpstreamBandwidthKbps, |
| 731 |
mMinEntryDownstreamBandwidthKbps, |
| 732 |
mMinExitDownstreamBandwidthKbps, |
| 733 |
mAllowedNetworkPlmnIds, |
| 734 |
mAllowedSpecificCarrierIds, |
| 735 |
mRoamingMatchCriteria, |
| 736 |
mOpportunisticMatchCriteria, |
| 737 |
mCapabilitiesMatchCriteria); |
| 738 |
} |
| 739 |
} |
| 740 |
} |