diff options
author | Tor Norbye <tnorbye@google.com> | 2012-12-10 10:47:54 -0800 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2012-12-10 10:47:54 -0800 |
commit | b9fe954f3bb38d53c5a7b8775f869bc5d1a5ff0f (patch) | |
tree | e17f3312b9978a2092bbd6cc3ee5ded8ba134f95 | |
parent | 9bc6ffa29911d67ef12202697cce3d15c37a6431 (diff) | |
parent | f8d65e59e16e22a71eb915e3b200c7482f647776 (diff) | |
download | sdk-b9fe954f3bb38d53c5a7b8775f869bc5d1a5ff0f.zip sdk-b9fe954f3bb38d53c5a7b8775f869bc5d1a5ff0f.tar.gz sdk-b9fe954f3bb38d53c5a7b8775f869bc5d1a5ff0f.tar.bz2 |
Merge "41154: Handle allowBackup properly for target < 4"
3 files changed, 17 insertions, 3 deletions
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ManifestOrderDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ManifestOrderDetectorTest.java index ccb9123..8508d40 100644 --- a/lint/cli/src/test/java/com/android/tools/lint/checks/ManifestOrderDetectorTest.java +++ b/lint/cli/src/test/java/com/android/tools/lint/checks/ManifestOrderDetectorTest.java @@ -214,6 +214,7 @@ public class ManifestOrderDetectorTest extends AbstractCheckTest { "0 errors, 1 warnings\n", lintProject( "AndroidManifest.xml", + "apicheck/minsdk14.xml=>AndroidManifest.xml", "res/values/strings.xml")); } @@ -226,6 +227,18 @@ public class ManifestOrderDetectorTest extends AbstractCheckTest { "res/values/strings.xml")); } + public void testAllowBackupOk2() throws Exception { + // Requires build api >= 4 + mEnabled = Collections.singleton(ManifestOrderDetector.ALLOW_BACKUP); + assertEquals( + "No warnings.", + lintProject( + "AndroidManifest.xml", + "apicheck/minsdk1.xml=>AndroidManifest.xml", + "res/values/strings.xml")); + } + + public void testAllowIgnore() throws Exception { mEnabled = Collections.singleton(ManifestOrderDetector.ALLOW_BACKUP); assertEquals( diff --git a/lint/libs/lint_checks/src/main/java/com/android/tools/lint/checks/ManifestOrderDetector.java b/lint/libs/lint_checks/src/main/java/com/android/tools/lint/checks/ManifestOrderDetector.java index 16bca84..e0cd15b 100644 --- a/lint/libs/lint_checks/src/main/java/com/android/tools/lint/checks/ManifestOrderDetector.java +++ b/lint/libs/lint_checks/src/main/java/com/android/tools/lint/checks/ManifestOrderDetector.java @@ -449,7 +449,8 @@ public class ManifestOrderDetector extends Detector implements Detector.XmlScann if (tag.equals(TAG_APPLICATION)) { mSeenApplication = true; if (!element.hasAttributeNS(ANDROID_URI, SdkConstants.ATTR_ALLOW_BACKUP) - && context.isEnabled(ALLOW_BACKUP)) { + && context.isEnabled(ALLOW_BACKUP) + && context.getMainProject().getMinSdk() >= 4) { context.report(ALLOW_BACKUP, element, context.getLocation(element), "Should explicitly set android:allowBackup to true or " + "false (it's true by default, and that can have some security " + diff --git a/templates/projects/NewAndroidApplication/root/AndroidManifest.xml.ftl b/templates/projects/NewAndroidApplication/root/AndroidManifest.xml.ftl index 80895b3..390a9da 100644 --- a/templates/projects/NewAndroidApplication/root/AndroidManifest.xml.ftl +++ b/templates/projects/NewAndroidApplication/root/AndroidManifest.xml.ftl @@ -3,9 +3,9 @@ android:versionCode="1" android:versionName="1.0"> - <uses-sdk android:minSdkVersion="${minApi}" android:targetSdkVersion="${targetApi}" /> + <uses-sdk android:minSdkVersion="${minApi}" <#if buildApi gte 4>android:targetSdkVersion="${targetApi}" </#if>/> - <application android:allowBackup="true" + <application <#if minApiLevel gte 4 && buildApi gte 4>android:allowBackup="true"</#if> android:label="@string/app_name" android:icon="@drawable/ic_launcher"<#if baseTheme != "none"> android:theme="@style/AppTheme"</#if>> |