]> git.saurik.com Git - android/aapt.git/commitdiff
Use correct API version for UTF-8 checking
authorKenny Root <kroot@google.com>
Wed, 24 Mar 2010 18:55:16 +0000 (11:55 -0700)
committerKenny Root <kroot@google.com>
Wed, 24 Mar 2010 19:05:24 +0000 (12:05 -0700)
Use the constant for checking the API version in aapt instead of a bare
number.

Bug: 2541326
Change-Id: Ice7af7b393363a00f1832dd84753b8138d057fb4

Bundle.h
Resource.cpp
ResourceTable.cpp

index c8b6837c1ef94d8da53de1b32637a6155093ec75..3308a3531dc7db534ecc1639af3f14c43c60db31 100644 (file)
--- a/Bundle.h
+++ b/Bundle.h
@@ -162,10 +162,11 @@ public:
     void setPackageCount(int val) { mPackageCount = val; }
 #endif
 
-    /* UTF-8 is only available on APIs 7 or above or
-     * SDK levels that have code names.
+    /* Certain features may only be available on a specific SDK level or
+     * above. SDK levels that have a non-numeric identifier are assumed
+     * to be newer than any SDK level that has a number designated.
      */
-    bool isUTF8Available() {
+    bool isMinSdkAtLeast(int desired) {
         /* If the application specifies a minSdkVersion in the manifest
          * then use that. Otherwise, check what the user specified on
          * the command line. If neither, it's not available since
@@ -183,7 +184,7 @@ public:
         char *end;
         int minSdkNum = (int)strtol(minVer, &end, 0);
         if (*end == '\0') {
-            if (minSdkNum < 7) {
+            if (minSdkNum < desired) {
                 return false;
             }
         }
index a8ac2eca99a22a08a0d168e828851c6c84cb0fbb..cafd635c97d34ab6e316ec98665f2ff0baea541e 100644 (file)
@@ -775,7 +775,7 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets)
      * allow UTF-8 to be used.
      */
     if (!bundle->getWantUTF16()
-            && bundle->isUTF8Available()) {
+            && bundle->isMinSdkAtLeast(SDK_FROYO)) {
         xmlFlags |= XML_COMPILE_UTF8;
     }
 
index 66db4500b6de54134e2ede87fb5c63bd156a76f5..a2f085a02b878db6897a9f62581c74d51428bd70 100644 (file)
@@ -2527,7 +2527,7 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp<AaptFile>& dest)
     const size_t N = mOrderedPackages.size();
     size_t pi;
 
-    bool useUTF8 = !bundle->getWantUTF16() && bundle->isUTF8Available();
+    bool useUTF8 = !bundle->getWantUTF16() && bundle->isMinSdkAtLeast(SDK_FROYO);
 
     // Iterate through all data, collecting all values (strings,
     // references, etc).