DO NOT MERGE: ScanFilter: Fix argument sanitization logic.

Bug: 132888204
Test: Manual
Change-Id: Id8cadbbfac29aca97ccb83815795948b1bbf85a5
This commit is contained in:
Martin Brabham
2019-05-21 17:15:44 -07:00
parent 0bb09184ff
commit 2b3b1429db

View File

@@ -590,6 +590,9 @@ public final class ScanFilter implements Parcelable {
public @NonNull Builder setServiceSolicitationUuid( public @NonNull Builder setServiceSolicitationUuid(
@Nullable ParcelUuid serviceSolicitationUuid) { @Nullable ParcelUuid serviceSolicitationUuid) {
mServiceSolicitationUuid = serviceSolicitationUuid; mServiceSolicitationUuid = serviceSolicitationUuid;
if (serviceSolicitationUuid == null) {
mServiceSolicitationUuidMask = null;
}
return this; return this;
} }
@@ -600,13 +603,16 @@ public final class ScanFilter implements Parcelable {
* indicate a match is needed for the bit in {@code serviceSolicitationUuid}, and 0 to * indicate a match is needed for the bit in {@code serviceSolicitationUuid}, and 0 to
* ignore that bit. * ignore that bit.
* *
* @param serviceSolicitationUuid can only be null if solicitationUuidMask is null.
* @param solicitationUuidMask can be null or a mask with no restriction.
*
* @throws IllegalArgumentException If {@code serviceSolicitationUuid} is {@code null} but * @throws IllegalArgumentException If {@code serviceSolicitationUuid} is {@code null} but
* {@code serviceSolicitationUuidMask} is not {@code null}. * {@code serviceSolicitationUuidMask} is not {@code null}.
*/ */
public @NonNull Builder setServiceSolicitationUuid( public @NonNull Builder setServiceSolicitationUuid(
@Nullable ParcelUuid serviceSolicitationUuid, @Nullable ParcelUuid serviceSolicitationUuid,
@Nullable ParcelUuid solicitationUuidMask) { @Nullable ParcelUuid solicitationUuidMask) {
if (mServiceSolicitationUuidMask != null && mServiceSolicitationUuid == null) { if (solicitationUuidMask != null && serviceSolicitationUuid == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"SolicitationUuid is null while SolicitationUuidMask is not null!"); "SolicitationUuid is null while SolicitationUuidMask is not null!");
} }