diff options
author | Tor Norbye <tnorbye@google.com> | 2012-04-06 10:15:08 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-04-06 10:15:08 -0700 |
commit | bcdedbb8766bd93fc970269a167b9a55dfe14436 (patch) | |
tree | ccbd93d2dffe04e83c8c259476ebbfa9c8f0ad7a | |
parent | 21041955cba2a90b6c593d2ae209f30963eda241 (diff) | |
parent | 55ac65d7eb8aec583f624241551b7b0aec2015ff (diff) | |
download | sdk-bcdedbb8766bd93fc970269a167b9a55dfe14436.zip sdk-bcdedbb8766bd93fc970269a167b9a55dfe14436.tar.gz sdk-bcdedbb8766bd93fc970269a167b9a55dfe14436.tar.bz2 |
am 55ac65d7: Merge "Fix issue 28201: Check API levels through static dispatch as well"
* commit '55ac65d7eb8aec583f624241551b7b0aec2015ff':
Fix issue 28201: Check API levels through static dispatch as well
4 files changed, 41 insertions, 0 deletions
diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ApiDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ApiDetector.java index 52eaaa8..05b640d 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ApiDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ApiDetector.java @@ -345,6 +345,9 @@ public class ApiDetector extends ResourceXmlDetector implements Detector.ClassSc // each inherited method if (node.getOpcode() == Opcodes.INVOKEVIRTUAL) { owner = context.getDriver().getSuperClass(owner); + } else if (node.getOpcode() == Opcodes.INVOKESTATIC && api == -1) { + // Inherit through static classes as well + owner = context.getDriver().getSuperClass(owner); } else { owner = null; } diff --git a/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/ApiDetectorTest.java b/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/ApiDetectorTest.java index 0cde634..01ab449 100644 --- a/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/ApiDetectorTest.java +++ b/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/ApiDetectorTest.java @@ -183,6 +183,21 @@ public class ApiDetectorTest extends AbstractCheckTest { )); } + public void testInheritStatic() throws Exception { + assertEquals( + "ApiCallTest5.java:16: Error: Call requires API level 11 (current min is 2): android.view.View#resolveSizeAndState\n" + + "ApiCallTest5.java:18: Error: Call requires API level 11 (current min is 2): android.view.View#resolveSizeAndState\n" + + "ApiCallTest5.java:20: Error: Call requires API level 11 (current min is 2): android.view.View#combineMeasuredStates\n" + + "ApiCallTest5.java:21: Error: Call requires API level 11 (current min is 2): android.view.View#combineMeasuredStates", + + lintProject( + "apicheck/classpath=>.classpath", + "apicheck/minsdk2.xml=>AndroidManifest.xml", + "apicheck/ApiCallTest5.java.txt=>src/foo/bar/ApiCallTest5.java", + "apicheck/ApiCallTest5.class.data=>bin/classes/foo/bar/ApiCallTest5.class" + )); + } + public void testInheritLocal() throws Exception { // Test virtual dispatch in a local class which extends some other local class (which // in turn extends an Android API) diff --git a/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/apicheck/ApiCallTest5.class.data b/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/apicheck/ApiCallTest5.class.data Binary files differnew file mode 100644 index 0000000..ad0cd48 --- /dev/null +++ b/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/apicheck/ApiCallTest5.class.data diff --git a/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/apicheck/ApiCallTest5.java.txt b/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/apicheck/ApiCallTest5.java.txt new file mode 100644 index 0000000..4be8258 --- /dev/null +++ b/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/apicheck/ApiCallTest5.java.txt @@ -0,0 +1,23 @@ +package test.pkg; + +import android.annotation.TargetApi; +import android.content.Context; +import android.view.View; + +public class ApiCallTest5 extends View { + public ApiCallTest5(Context context) { + super(context); + } + + @SuppressWarnings("unused") + @Override + @TargetApi(2) + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + int measuredWidth = View.resolveSizeAndState(widthMeasureSpec, + widthMeasureSpec, 0); + int measuredHeight = resolveSizeAndState(heightMeasureSpec, + heightMeasureSpec, 0); + View.combineMeasuredStates(0, 0); + ApiCallTest5.combineMeasuredStates(0, 0); + } +} |