From 0a6fd7387c281876ed719189058da4b5dbf30cc9 Mon Sep 17 00:00:00 2001 From: Tor Norbye Date: Sun, 27 Jan 2013 19:49:51 -0800 Subject: Fix API check via support library This CL fixes the API check such that it properly handles calls in the Android support library (android.support.*). There was an optimization to skip looking up inherited API calls once the API checker reaches the android.* namespace, since at that point all the inherited methods are inlined in the database, but this should not be done if the package starts with android.support.*, since those methods still could be inheriting from the Android APIs without appearing in the database. Change-Id: Iab7b9f98daa5507794a0673a8db53ce953f2bcd9 --- .../java/com/android/tools/lint/checks/ApiDetector.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'lint/libs') diff --git a/lint/libs/lint_checks/src/main/java/com/android/tools/lint/checks/ApiDetector.java b/lint/libs/lint_checks/src/main/java/com/android/tools/lint/checks/ApiDetector.java index 146e9e1..cc2b212 100644 --- a/lint/libs/lint_checks/src/main/java/com/android/tools/lint/checks/ApiDetector.java +++ b/lint/libs/lint_checks/src/main/java/com/android/tools/lint/checks/ApiDetector.java @@ -461,9 +461,10 @@ public class ApiDetector extends ResourceXmlDetector while (owner != null) { // For virtual dispatch, walk up the inheritance chain checking // each inherited method - if (owner.startsWith("android/") //$NON-NLS-1$ - || owner.startsWith("java/") //$NON-NLS-1$ - || owner.startsWith("javax/")) { //$NON-NLS-1$ + if ((owner.startsWith("android/") //$NON-NLS-1$ + && !owner.startsWith("android/support/")) //$NON-NLS-1$ + || owner.startsWith("java/") //$NON-NLS-1$ + || owner.startsWith("javax/")) { //$NON-NLS-1$ frameworkParent = owner; break; } @@ -628,7 +629,13 @@ public class ApiDetector extends ResourceXmlDetector || owner.startsWith("javax/")) { //$NON-NLS-1$ // The API map has already inlined all inherited methods // so no need to keep checking up the chain - owner = null; + // -- unless it's the support library which is also in + // the android/ namespace: + if (owner.startsWith("android/support/")) { //$NON-NLS-1$ + owner = context.getDriver().getSuperClass(owner); + } else { + owner = null; + } } else if (owner.startsWith("java/")) { //$NON-NLS-1$ if (owner.equals(LocaleDetector.DATE_FORMAT_OWNER)) { checkSimpleDateFormat(context, method, node, minSdk); -- cgit v1.1