From 8ed095c389e0616d83bbf2c8e7ec050850de7ddf Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Tue, 27 Sep 2022 13:08:56 -0700 Subject: [PATCH] Add null checks Lint is being updated, and a type that used to be non-null is now nullable, and needs to be null checked. Bug: 247885568 Bug: 249337906 Bug: 249335143 Test: Presubmits Change-Id: I3efc2d206a17a58dbff4306c98666cb4b06b0de7 --- .../android/lint/aidl/EnforcePermissionDetector.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/lint/checks/src/main/java/com/google/android/lint/aidl/EnforcePermissionDetector.kt b/tools/lint/checks/src/main/java/com/google/android/lint/aidl/EnforcePermissionDetector.kt index a415217105a84..bba819cd9096e 100644 --- a/tools/lint/checks/src/main/java/com/google/android/lint/aidl/EnforcePermissionDetector.kt +++ b/tools/lint/checks/src/main/java/com/google/android/lint/aidl/EnforcePermissionDetector.kt @@ -82,8 +82,16 @@ class EnforcePermissionDetector : Detector(), SourceCodeScanner { if (attr1[i].name != attr2[i].name) { return false } - val v1 = ConstantEvaluator.evaluate(context, attr1[i].value) - val v2 = ConstantEvaluator.evaluate(context, attr2[i].value) + val value1 = attr1[i].value + val value2 = attr2[i].value + if (value1 == null && value2 == null) { + continue + } + if (value1 == null || value2 == null) { + return false + } + val v1 = ConstantEvaluator.evaluate(context, value1) + val v2 = ConstantEvaluator.evaluate(context, value2) if (v1 != v2) { return false }