From 7b364e515c89ea1e8cb4d70ad3f25504bdeac3e8 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Mon, 26 Sep 2022 16:24:58 -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 Test: Presubmits Change-Id: I7fc09a9d2d312485071364279c448550e3a1e124 Merged-In: Ie6eaf061d74bd773742aa47f731e95e4b137f438 --- .../google/android/lint/EnforcePermissionDetector.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/lint/checks/src/main/java/com/google/android/lint/EnforcePermissionDetector.kt b/tools/lint/checks/src/main/java/com/google/android/lint/EnforcePermissionDetector.kt index 8011b36c9a8fd..8f553abfee313 100644 --- a/tools/lint/checks/src/main/java/com/google/android/lint/EnforcePermissionDetector.kt +++ b/tools/lint/checks/src/main/java/com/google/android/lint/EnforcePermissionDetector.kt @@ -65,8 +65,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 }