The following code gave newApi errors on BasicReason, in spite of the method being protected by @TargetApi:
@TargetApi(Build.VERSION_CODES.N)
private static AndroidCertVerifyResult validationError(CertPathValidatorException e) {
CertPathValidatorException.Reason reason = e.getReason();
if (reason instanceof CertPathValidatorException.BasicReason) {
switch ((CertPathValidatorException.BasicReason) e.getReason()) {
case EXPIRED:
return new AndroidCertVerifyResult(CertVerifyStatusAndroid.EXPIRED);
case NOT_YET_VALID:
return new AndroidCertVerifyResult(CertVerifyStatusAndroid.NOT_YET_VALID);
case REVOKED:
return new AndroidCertVerifyResult(CertVerifyStatusAndroid.REVOKED);
default:
return new AndroidCertVerifyResult(CertVerifyStatusAndroid.FAILED);
}
} else {
return new AndroidCertVerifyResult(CertVerifyStatusAndroid.FAILED);
}
}
The reason seems to be that the Java compiler generates an inner class to handle the enum switch, and Java Lint isn't applying the annotation to the inner class. The only workaround I could find was to replace the switch statement with an if statement.
The Lint error xml file is attached.
|
Deleted:
result.xml
87 bytes
|