Skip to content

Commit

Permalink
binder: remove existing warnings and allow failOnWarnings (#10989)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdcormie committed Mar 7, 2024
1 parent 0b82f01 commit 8f45a97
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
7 changes: 5 additions & 2 deletions binder/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@ import net.ltgt.gradle.errorprone.CheckSeverity

tasks.withType(JavaCompile).configureEach {
options.compilerArgs += [
"-Xlint:-cast"
"-Xlint:-cast",
// For junit-1.15-api & org.robolectric/shadows-framework/4.11.1
"-Xlint:-classfile",
// Unclaimed annotations. TODO(jdcormie): Fix?
"-Xlint:-processing",
]
options.compilerArgs -= ["-Werror"] // https://github.com/grpc/grpc-java/issues/10297
appendToProperty(it.options.errorprone.excludedPaths, ".*/R.java", "|")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ public static Metadata readMetadata(Parcel parcel, Attributes attributes) throws
}
int parcelableStartPos = parcel.dataPosition();
try {
// readParcelable(Classloader, Class<>) requires SDK 33 and at this layer we can't know
// value's type anyway.
@SuppressWarnings("deprecation")
Parcelable value = parcel.readParcelable(MetadataHelper.class.getClassLoader());
if (value == null) {
throw Status.INTERNAL.withDescription("Read null parcelable in metadata").asException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ final class ParcelableInputStream<P extends Parcelable> extends InputStream {
@SuppressWarnings("unchecked")
static <P extends Parcelable> ParcelableInputStream<P> readFromParcel(
Parcel parcel, ClassLoader classLoader) {
// readParcelable(Classloader, Class<P>) requires SDK 33 and this class isn't typesafe anyway.
@SuppressWarnings("deprecation")
P value = (P) parcel.readParcelable(classLoader);
return new ParcelableInputStream<>(null, value, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ public PackageInfoBuilder setSignatures(Signature... signatures) {
return this;
}

@SuppressWarnings("deprecation") // 'signatures': We don't yet support signing cert rotation.
public PackageInfo build() {
checkState(this.packageName != null, "packageName is a mandatory field");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public void testDefaultInternalOnly() throws Exception {
}

@Test
@Deprecated
public void testDefaultInternalOnly_legacyApi() {
policy = new ServerSecurityPolicy();
assertThat(policy.checkAuthorizationForService(MY_UID, SERVICE1).getCode())
Expand All @@ -80,6 +81,7 @@ public void testInternalOnly_AnotherUid() throws Exception {
}

@Test
@Deprecated
public void testInternalOnly_AnotherUid_legacyApi() {
policy = new ServerSecurityPolicy();
assertThat(policy.checkAuthorizationForService(OTHER_UID, SERVICE1).getCode())
Expand All @@ -98,6 +100,7 @@ public void testBuilderDefault() throws Exception {
}

@Test
@Deprecated
public void testBuilderDefault_legacyApi() {
policy = ServerSecurityPolicy.newBuilder().build();
assertThat(policy.checkAuthorizationForService(MY_UID, SERVICE1).getCode())
Expand Down Expand Up @@ -125,6 +128,7 @@ public void testPerService() throws Exception {


@Test
@Deprecated
public void testPerService_legacyApi() {
policy =
ServerSecurityPolicy.newBuilder()
Expand Down Expand Up @@ -251,6 +255,7 @@ SERVICE2, policy((uid) -> uid == OTHER_UID ? Status.OK : Status.PERMISSION_DENIE
.isEqualTo(Status.PERMISSION_DENIED.getCode());
}
@Test
@Deprecated
public void testPerServiceNoDefault_legacyApi() {
policy =
ServerSecurityPolicy.newBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ public void testWriteToParcel() throws Exception {
stream.writeToParcel(parcel);

parcel.setDataPosition(0);
assertThat((TestParcelable) parcel.readParcelable(getClass().getClassLoader()))
.isEqualTo(testParcelable);
@SuppressWarnings("deprecation") // readParcelable(ClassLoader)'s replacement is only in 33+.
TestParcelable clone = parcel.readParcelable(getClass().getClassLoader());
assertThat(clone).isEqualTo(testParcelable);
}

@Test
Expand All @@ -113,8 +114,9 @@ public void testAsRegularInputStream() throws Exception {
parcel.unmarshall(data, 0, data.length);
parcel.setDataPosition(0);

assertThat((TestParcelable) parcel.readParcelable(getClass().getClassLoader()))
.isEqualTo(testParcelable);
@SuppressWarnings("deprecation") // readParcelable(ClassLoader)'s replacement is only in 33+.
TestParcelable clone = parcel.readParcelable(getClass().getClassLoader());
assertThat(clone).isEqualTo(testParcelable);
}

@Test
Expand Down

0 comments on commit 8f45a97

Please sign in to comment.