Merge "docs: Systrace tool documentation" into jb-dev
diff --git a/docs/html/design/style/iconography.jd b/docs/html/design/style/iconography.jd
index 31274c5..3ba3f71 100644
--- a/docs/html/design/style/iconography.jd
+++ b/docs/html/design/style/iconography.jd
@@ -109,9 +109,7 @@
 
 </p>
 <p>
-
-<a href="{@docRoot}downloads/design/Android_Design_Icons_20120229.zip">Download the Action Bar Icon Pack</a>
-
+<a href="{@docRoot}downloads/design/Android_Design_Icons_20120814.zip">Download the Action Bar Icon Pack</a>
 </p>
 
 <div class="layout-content-row">
diff --git a/docs/html/distribute/distribute_toc.cs b/docs/html/distribute/distribute_toc.cs
index f11e965..76073fb 100644
--- a/docs/html/distribute/distribute_toc.cs
+++ b/docs/html/distribute/distribute_toc.cs
@@ -72,10 +72,10 @@
         <span class="en">Linking to Your Products</a></li>
        <li><a href="<?cs var:toroot ?>distribute/googleplay/promote/badges.html">
         <span class="en">Google Play Badges</a></li>
-       <li><a href="<?cs var:toroot ?>distribute/googleplay/promote/brand.html">
-        <span class="en">Brand Assets and Guidelines</a></li>
        <li><a href="<?cs var:toroot ?>distribute/promote/device-art.html">
         <span class="en">Device Art Generator</a></li>
+       <li><a href="<?cs var:toroot ?>distribute/googleplay/promote/brand.html">
+        <span class="en">Brand Assets and Guidelines</a></li>
      </ul>
    </li>
 
diff --git a/docs/html/distribute/googleplay/promote/badges.jd b/docs/html/distribute/googleplay/promote/badges.jd
index de12e2a..7b64be3 100644
--- a/docs/html/distribute/googleplay/promote/badges.jd
+++ b/docs/html/distribute/googleplay/promote/badges.jd
@@ -1,11 +1,20 @@
 page.title=Google Play Badges
 @jd:body
 
-<p>Google Play badges give you an officially branded way of promoting your app to Android users. Use the form below to quickly create badges to link users to your products from web pages, ads, reviews, and more. See <a href="linking.html">Linking to your products</a> for more ways to bring users to your apps.</p>
+<p>Google Play badges allow you to promote your app with official branding in your
+online ads, promotional materials, or anywhere else you want a link to your app.</p>
 
-<p>Input your app's package or your publisher name, choose the style, size, and language, and click "Build my badge". The form will generate code for an embbeded button that links to your app's product page or a list of your apps. </p>
+<p>In the form below,
+input your app's package name or publisher name, choose the badge style,
+click <em>Build my badge</em>, then paste the HTML into your web content.</p>
 
-<p>Note that you should not modify the Google Play badges after generating them, including colors, size, text, and logo. See <a href="http://www.android.com/branding.html">Android Brand Guidelines</a> for more information.</p>
+<p>If you're creating a promotional web page for your app, you should also use the
+<a href="{@docRoot}distribute/promote/device-art.html">Device Art Generator</a>, which quickly
+wraps your screenshots in real device artwork.</p>
+
+<p>For guidelines when using the Google Play badge and other brand assets,
+see the <a href="{@docRoot}distribute/googleplay/promote/brand.html">Brand Assets and
+Guidelines</a>.</p>
 
 <style type="text/css">
 
@@ -34,11 +43,13 @@
 }
 
 div.button-row input {
-  vertical-align:120%;
+  vertical-align:middle;
+  margin:0 5px 0 0;
 }
 
 #jd-content div.button-row img {
   margin: 0;
+  vertical-align:middle;
 }
 
 </style>
@@ -46,7 +57,7 @@
 <script type="text/javascript">
 
 // variables for creating 'try it out' demo button
-var imagePath = "http://www.android.com/images/brand/"
+var imagePath = "http://developer.android.com/images/brand/"
 var linkStart = "<a href=\"http://play.google.com/store/";
 var imageStart = "\">\n"
         + "  <img alt=\"";
@@ -167,28 +178,29 @@
             onclick="return clearLabel('publisher','Example, Inc.');">clear</a>
          <br/><br/>
 
-<div class="button-row">
-  <input type="radio" name="buttonStyle" value="get_it_on_play_logo_small" id="ns" checked="checked" />
-    <label for="ns"><img src="http://www.android.com/images/brand/get_it_on_play_logo_small.png"
-alt="Get it on Google Play (small)" /></label>
-    &nbsp;&nbsp;&nbsp;&nbsp;
-  <input type="radio" name="buttonStyle" value="get_it_on_play_logo_large" id="nm" />
-    <label for="nm"><img src="http://www.android.com/images/brand/get_it_on_play_logo_large.png"
-alt="Get it on Google Play (large)" /></label>
-</div>
 
 <div class="button-row">
-  <input type="radio" name="buttonStyle" value="android_app_on_play_logo_small" id="ws" />
-    <label for="ws"><img src="http://www.android.com/images/brand/android_app_on_play_logo_small.png"
+  <input type="radio" name="buttonStyle" value="en_app_rgb_wo_45" id="ws" checked="checked" />
+    <label for="ws"><img src="{@docRoot}images/brand/en_app_rgb_wo_45.png"
 alt="Android app on Google Play (small)" /></label>
     &nbsp;&nbsp;&nbsp;&nbsp;
-  <input type="radio" name="buttonStyle" value="android_app_on_play_logo_large" id="wm" />
-    <label for="wm"><img src="http://www.android.com/images/brand/android_app_on_play_logo_large.png"
+  <input type="radio" name="buttonStyle" value="en_app_rgb_wo_60" id="wm" />
+    <label for="wm"><img src="{@docRoot}images/brand/en_app_rgb_wo_60.png"
 alt="Android app on Google Play (large)" /></label>
 </div>
 
+<div class="button-row">
+  <input type="radio" name="buttonStyle" value="en_generic_rgb_wo_45" id="ns" />
+    <label for="ns"><img src="{@docRoot}images/brand/en_generic_rgb_wo_45.png"
+alt="Get it on Google Play (small)" /></label>
+    &nbsp;&nbsp;&nbsp;&nbsp;
+  <input type="radio" name="buttonStyle" value="en_generic_rgb_wo_60" id="nm" />
+    <label for="nm"><img src="{@docRoot}images/brand/en_generic_rgb_wo_60.png"
+alt="Get it on Google Play (large)" /></label>
+</div>
+
   <input type="button" onclick="return buildButton(this.parentNode)" value="Build my badge"
-style="padding:5px" />
+style="padding:10px" />
   <br/>
 </form>
 
diff --git a/docs/html/distribute/googleplay/promote/brand.jd b/docs/html/distribute/googleplay/promote/brand.jd
index 76ed619..4051553 100644
--- a/docs/html/distribute/googleplay/promote/brand.jd
+++ b/docs/html/distribute/googleplay/promote/brand.jd
@@ -88,28 +88,28 @@
           "Android is a trademark of Google Inc."</span>
         </p>
 
+
 <h2 id="brand-google_play">Google Play Brand</h2>
 
-<div style="clear:both">
-  <div style="float:right;width:50%;padding:1.5em;">
-    <p>
-      <img alt="Google Play logo" src="http://www.android.com/images/brand/google_play_logo_450.png">
-    </p>
-    <p>
-    <img alt="Get it on Google Play badge, large" src=
-            "http://www.android.com/images/brand/get_it_on_play_logo_large.png"><br>
-            Download: <a href="http://www.android.com/images/brand/get_it_on_play_logo_small.png">Small</a> | <a href=
-            "http://www.android.com/images/brand/get_it_on_play_logo_large.png">Large</a>
-          </p>
-          <p>
-            <img alt="Android App on Google Play badge, large" src=
-            "http://www.android.com/images/brand/android_app_on_play_logo_large.png"><br>
-            Download: <a href="http://www.android.com/images/brand/android_app_on_play_logo_small.png">Small</a> |
-            <a href="http://www.android.com/images/brand/android_app_on_play_large.png">Large</a>
-          </p>
-  </div> 
+    <img alt="" src="http://www.android.com/images/brand/google_play_logo_450.png"
+         style="float:right;">
+      
+    <img alt="Android app on Google Play badge, large"
+         src="{@docRoot}images/brand/en_app_rgb_wo_60.png"
+         style="float:right;clear:right;">
+
+    <img alt="Android app on Google Play badge, small"
+         src="{@docRoot}images/brand/en_app_rgb_wo_45.png"
+         style="float:right;margin:0 30px 30px">
+
+    <img alt="Get it on Google Play badge, large"
+         src="{@docRoot}images/brand/en_generic_rgb_wo_60.png"
+         style="float:right;clear:right;">
+
+    <img alt="Get it on Google Play badge, small"
+         src="{@docRoot}images/brand/en_generic_rgb_wo_45.png"
+         style="float:right;margin:0 30px 30px;">
         
-  <div style="width:45%;">
     <h4>06/ <em>Get it on Google Play</em> Badge
           </h4>
           <p>
@@ -118,57 +118,34 @@
             Play.
           </p>
           <p>
-            The logos are available in two sizes:
-          </p>
-          <ul>
-            <li>Large: 60(h) x 172(w)</li>
-            </li>
-            <li>Small 45(h) x 129(w)
-            </li>
-          </ul>
-          <p>
             Guidelines for usage:
           </p>
           <ul>
-            <li>Never separate the phrase “Get it on Google Play” or "Android App on Google Play"
-            from the Google Play logo, and do not change the color, proportions, spacing or any
-            other aspect of the logo.
+            <li>Do not modify the color, proportions, spacing or any other aspect of the badge image.
             </li>
-     </ul>
-     </div>
-     
-     <ul>
-            <li>When used online, the badge logo should be used to direct users to:
+            <li>When used alongside logos for other application marketplaces, the Google Play logo
+            should be of equal or greater size.</li>
+            <li>When used online, the badge should link to either:
               <ul>
-                <li>The Google Play landing page: <br />
-                  <span style="margin-left:1em;">http://play.google.com</span>
-                </li>
-                <li>The Google Play Apps landing page: <br />
-                 <span style="margin-left:1em;">http://play.google.com/store/apps</span>
-                </li>
-                <li>A list of products that include your company name, for example, <br />
-                <span style="margin-left:1em;">http://play.google.com/store/search?q=<em>yourCompanyName</em></span>
-                </li>
-                <li>A list of products published by you, for example,<br />
+                <li>A list of products published by you, for example:<br />
                 <span style="margin-left:1em;">http://play.google.com/store/search?q=<em>publisherName</em></span>
                 </li>
-                <li>A specific app product details page within Google Play, for example,<br />
+                <li>A specific app product details page within Google Play, for example:<br />
                 <span style="margin-left:1em;">http://play.google.com/store/apps/details?id=<em>packageName</em></span>
                 </li>
               </ul>
             </li>
-            <li>When used alongside logos for other application marketplaces, the Google Play logo
-            should be of equal or greater size</li>
   </ul>
-            
-            <p>For details on all the ways that you can link to your product details page in Google Play, 
-            see <a href="{@docRoot}distribute/googleplay/promote/linking.html">Linking to your products</a></p>
 
-          <p>For convenience, if you are using the logos online, you can use the 
-            <a href="{@docRoot}distribute/googleplay/promote/badges.html">badge generator</a>
-            to create the appropriate markup and link to your apps.</p>
+          <p>For your convenience, you can use the 
+            <a href="{@docRoot}distribute/googleplay/promote/badges.html">Googe Play badge generator</a>
+            to create badges that link to your apps on Google Play.</p>
+            
+          <p>For details on all the ways that you can link to your product details page in Google Play, 
+            see <a href="{@docRoot}distribute/googleplay/promote/linking.html">Linking to your products</a></p>
 
 <h2>Other Brands</h2>
 
 <p>Any other brands or icons depicted on this site are <em>not</em> are the property of their
 respective owners and usage is reserved. You must seek the developer for appropriate permission to use them.</p>
+
diff --git a/docs/html/guide/appendix/media-formats.jd b/docs/html/guide/appendix/media-formats.jd
index 93e8136..feacdc6 100644
--- a/docs/html/guide/appendix/media-formats.jd
+++ b/docs/html/guide/appendix/media-formats.jd
@@ -57,7 +57,7 @@
 
 <p class="table-caption" id="formats-table"><strong>Table 1.</strong> Core media format and codec support.</p>
 
-<table>
+<table style="font-size:12px">
 <tbody>
 
 <tr>
@@ -70,22 +70,22 @@
 </tr>
 
 <tr>
-<td rowspan="10">Audio</td>
-<td>AAC LC/LTP</td>
+<td rowspan="11">Audio</td>
+<td>AAC LC</td>
 <td style="text-align: center;"><big>&bull;</big></td>
 <td style="text-align: center;"><big>&bull;</big></td>
-<td rowspan="3">Mono/Stereo content in any combination of standard bit
-rates up to 160 kbps and sampling rates from 8 to 48kHz</td>
-<td rowspan="3">
+<td rowspan="2">Support for mono/stereo/5.0/5.1
+content with standard sampling rates from 8 to 48 kHz.</td>
+<td rowspan="4">
   &bull; 3GPP (.3gp)<br>
-  &bull; MPEG-4 (.mp4, .m4a)<br>
+  <nobr>&bull; MPEG-4 (.mp4, .m4a)</nobr><br>
   &bull; ADTS raw AAC (.aac, decode in Android 3.1+, encode in Android 4.0+, ADIF not supported)<br>
   &bull; MPEG-TS (.ts, not seekable, Android 3.0+)</td>
 </tr>
 
 <tr>
 <td>HE-AACv1 (AAC+)</td>
-<td>&nbsp;</td>
+<td style="text-align: center;"><big>&bull;</big><br><small>(Android 4.1+)</small></td>
 <td style="text-align: center;"><big>&bull;</big></td>
 </tr>
 
@@ -93,6 +93,16 @@
 <td>HE-AACv2 (enhanced AAC+)</td>
 <td>&nbsp;</td>
 <td style="text-align: center;"><big>&bull;</big></td>
+<td>Support for stereo/5.0/5.1
+content with standard sampling rates from 8 to 48 kHz.</td>
+</tr>
+
+<tr>
+<td>AAC ELD (enhanced low delay AAC)</td>
+<td style="text-align: center;"><big>&bull;</big><br><small>(Android 4.1+)</small></td>
+<td style="text-align: center;"><big>&bull;</big><br><small>(Android 4.1+)</small></td>
+<td>Support for mono/stereo content
+with standard sampling rates from 16 to 48 kHz</td>
 </tr>
 
 <tr>
@@ -160,9 +170,10 @@
 
 <tr>
 <td>PCM/WAVE</td>
-<td>&nbsp;</td>
+<td style="text-align: center;"><big>&bull;</big><br><small>(Android 4.1+)</small></td>
 <td style="text-align: center;"><big>&bull;</big></td>
-<td>8- and 16-bit linear PCM (rates up to limit of hardware)</td>
+<td>8- and 16-bit linear PCM (rates up to limit of hardware). Sampling
+rates for raw PCM recordings at 8000, 16000 and 44100 Hz.</td>
 <td>
   WAVE (.wav)</td>
 </tr>
diff --git a/docs/html/images/brand/en_app_rgb_wo_45.png b/docs/html/images/brand/en_app_rgb_wo_45.png
new file mode 100644
index 0000000..9891cbb
--- /dev/null
+++ b/docs/html/images/brand/en_app_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/en_app_rgb_wo_60.png b/docs/html/images/brand/en_app_rgb_wo_60.png
new file mode 100644
index 0000000..649e782
--- /dev/null
+++ b/docs/html/images/brand/en_app_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/en_generic_rgb_wo_45.png b/docs/html/images/brand/en_generic_rgb_wo_45.png
new file mode 100644
index 0000000..73dd393
--- /dev/null
+++ b/docs/html/images/brand/en_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/en_generic_rgb_wo_60.png b/docs/html/images/brand/en_generic_rgb_wo_60.png
new file mode 100644
index 0000000..9a50aff
--- /dev/null
+++ b/docs/html/images/brand/en_generic_rgb_wo_60.png
Binary files differ
diff --git a/tools/aapt/Bundle.h b/tools/aapt/Bundle.h
index daeadc0..4f93294 100644
--- a/tools/aapt/Bundle.h
+++ b/tools/aapt/Bundle.h
@@ -62,7 +62,8 @@
           mMinSdkVersion(NULL), mTargetSdkVersion(NULL), mMaxSdkVersion(NULL),
           mVersionCode(NULL), mVersionName(NULL), mCustomPackage(NULL), mExtraPackages(NULL),
           mMaxResVersion(NULL), mDebugMode(false), mNonConstantId(false), mProduct(NULL),
-          mUseCrunchCache(false), mArgc(0), mArgv(NULL)
+          mUseCrunchCache(false), mOutputTextSymbols(NULL),
+          mArgc(0), mArgv(NULL)
         {}
     ~Bundle(void) {}
 
@@ -174,6 +175,8 @@
     void setProduct(const char * val) { mProduct = val; }
     void setUseCrunchCache(bool val) { mUseCrunchCache = val; }
     bool getUseCrunchCache() const { return mUseCrunchCache; }
+    const char* getOutputTextSymbols() const { return mOutputTextSymbols; }
+    void setOutputTextSymbols(const char* val) { mOutputTextSymbols = val; }
 
     /*
      * Set and get the file specification.
@@ -280,6 +283,7 @@
     bool        mNonConstantId;
     const char* mProduct;
     bool        mUseCrunchCache;
+    const char* mOutputTextSymbols;
 
     /* file specification */
     int         mArgc;
diff --git a/tools/aapt/Main.cpp b/tools/aapt/Main.cpp
index 9f05c6a..98c65d2 100644
--- a/tools/aapt/Main.cpp
+++ b/tools/aapt/Main.cpp
@@ -70,7 +70,8 @@
         "        [--product product1,product2,...] \\\n"
         "        [-c CONFIGS] [--preferred-configurations CONFIGS] \\\n"
         "        [-o] \\\n"
-        "        [raw-files-dir [raw-files-dir] ...]\n"
+        "        [raw-files-dir [raw-files-dir] ...] \\\n"
+        "        [--output-text-symbols DIR]\n"
         "\n"
         "   Package the android resources.  It will read assets and resources that are\n"
         "   supplied with the -M -A -S or raw-files-dir arguments.  The -J -P -F and -R\n"
@@ -179,6 +180,9 @@
         "       Make the resources ID non constant. This is required to make an R java class\n"
         "       that does not contain the final value but is used to make reusable compiled\n"
         "       libraries that need to access resources.\n"
+        "   --output-text-symbols\n"
+        "       Generates a text file containing the resource symbols of the R class in the\n"
+        "       specified folder.\n"
         "   --ignore-assets\n"
         "       Assets to be ignored. Default pattern is:\n"
         "       %s\n",
@@ -547,6 +551,15 @@
                     bundle.setInstrumentationPackageNameOverride(argv[0]);
                 } else if (strcmp(cp, "-auto-add-overlay") == 0) {
                     bundle.setAutoAddOverlay(true);
+                } else if (strcmp(cp, "-output-text-symbols") == 0) {
+                    argc--;
+                    argv++;
+                    if (!argc) {
+                        fprintf(stderr, "ERROR: No argument supplied for '-output-text-symbols' option\n");
+                        wantUsage = true;
+                        goto bail;
+                    }
+                    bundle.setOutputTextSymbols(argv[0]);
                 } else if (strcmp(cp, "-product") == 0) {
                     argc--;
                     argv++;
diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp
index ee076e6..e4f8d81 100644
--- a/tools/aapt/Resource.cpp
+++ b/tools/aapt/Resource.cpp
@@ -1821,6 +1821,110 @@
     return hasErrors ? UNKNOWN_ERROR : NO_ERROR;
 }
 
+static status_t writeTextLayoutClasses(
+    FILE* fp, const sp<AaptAssets>& assets,
+    const sp<AaptSymbols>& symbols, bool includePrivate)
+{
+    String16 attr16("attr");
+    String16 package16(assets->getPackage());
+
+    bool hasErrors = false;
+
+    size_t i;
+    size_t N = symbols->getNestedSymbols().size();
+    for (i=0; i<N; i++) {
+        sp<AaptSymbols> nsymbols = symbols->getNestedSymbols().valueAt(i);
+        String16 nclassName16(symbols->getNestedSymbols().keyAt(i));
+        String8 realClassName(nclassName16);
+        if (fixupSymbol(&nclassName16) != NO_ERROR) {
+            hasErrors = true;
+        }
+        String8 nclassName(nclassName16);
+
+        SortedVector<uint32_t> idents;
+        Vector<uint32_t> origOrder;
+        Vector<bool> publicFlags;
+
+        size_t a;
+        size_t NA = nsymbols->getSymbols().size();
+        for (a=0; a<NA; a++) {
+            const AaptSymbolEntry& sym(nsymbols->getSymbols().valueAt(a));
+            int32_t code = sym.typeCode == AaptSymbolEntry::TYPE_INT32
+                    ? sym.int32Val : 0;
+            bool isPublic = true;
+            if (code == 0) {
+                String16 name16(sym.name);
+                uint32_t typeSpecFlags;
+                code = assets->getIncludedResources().identifierForName(
+                    name16.string(), name16.size(),
+                    attr16.string(), attr16.size(),
+                    package16.string(), package16.size(), &typeSpecFlags);
+                if (code == 0) {
+                    fprintf(stderr, "ERROR: In <declare-styleable> %s, unable to find attribute %s\n",
+                            nclassName.string(), sym.name.string());
+                    hasErrors = true;
+                }
+                isPublic = (typeSpecFlags&ResTable_typeSpec::SPEC_PUBLIC) != 0;
+            }
+            idents.add(code);
+            origOrder.add(code);
+            publicFlags.add(isPublic);
+        }
+
+        NA = idents.size();
+
+        fprintf(fp, "int[] styleable %s {", nclassName.string());
+
+        for (a=0; a<NA; a++) {
+            if (a != 0) {
+                fprintf(fp, ",");
+            }
+            fprintf(fp, " 0x%08x", idents[a]);
+        }
+
+        fprintf(fp, " }\n");
+
+        for (a=0; a<NA; a++) {
+            ssize_t pos = idents.indexOf(origOrder.itemAt(a));
+            if (pos >= 0) {
+                const AaptSymbolEntry& sym = nsymbols->getSymbols().valueAt(a);
+                if (!publicFlags.itemAt(a) && !includePrivate) {
+                    continue;
+                }
+                String8 name8(sym.name);
+                String16 comment(sym.comment);
+                String16 typeComment;
+                if (comment.size() <= 0) {
+                    comment = getAttributeComment(assets, name8, &typeComment);
+                } else {
+                    getAttributeComment(assets, name8, &typeComment);
+                }
+                String16 name(name8);
+                if (fixupSymbol(&name) != NO_ERROR) {
+                    hasErrors = true;
+                }
+
+                uint32_t typeSpecFlags = 0;
+                String16 name16(sym.name);
+                assets->getIncludedResources().identifierForName(
+                    name16.string(), name16.size(),
+                    attr16.string(), attr16.size(),
+                    package16.string(), package16.size(), &typeSpecFlags);
+                //printf("%s:%s/%s: 0x%08x\n", String8(package16).string(),
+                //    String8(attr16).string(), String8(name16).string(), typeSpecFlags);
+                const bool pub = (typeSpecFlags&ResTable_typeSpec::SPEC_PUBLIC) != 0;
+
+                fprintf(fp,
+                        "int styleable.%s_%s %d\n",
+                        nclassName.string(),
+                        String8(name).string(), (int)pos);
+            }
+        }
+    }
+
+    return hasErrors ? UNKNOWN_ERROR : NO_ERROR;
+}
+
 static status_t writeSymbolClass(
     FILE* fp, const sp<AaptAssets>& assets, bool includePrivate,
     const sp<AaptSymbols>& symbols, const String8& className, int indent,
@@ -1848,7 +1952,6 @@
             continue;
         }
         String16 name(sym.name);
-        String8 realName(name);
         if (fixupSymbol(&name) != NO_ERROR) {
             return UNKNOWN_ERROR;
         }
@@ -1960,6 +2063,51 @@
     return NO_ERROR;
 }
 
+static status_t writeTextSymbolClass(
+    FILE* fp, const sp<AaptAssets>& assets, bool includePrivate,
+    const sp<AaptSymbols>& symbols, const String8& className)
+{
+    size_t i;
+    status_t err = NO_ERROR;
+
+    size_t N = symbols->getSymbols().size();
+    for (i=0; i<N; i++) {
+        const AaptSymbolEntry& sym = symbols->getSymbols().valueAt(i);
+        if (sym.typeCode != AaptSymbolEntry::TYPE_INT32) {
+            continue;
+        }
+
+        if (!assets->isJavaSymbol(sym, includePrivate)) {
+            continue;
+        }
+
+        String16 name(sym.name);
+        if (fixupSymbol(&name) != NO_ERROR) {
+            return UNKNOWN_ERROR;
+        }
+
+        fprintf(fp, "int %s %s 0x%08x\n",
+                className.string(),
+                String8(name).string(), (int)sym.int32Val);
+    }
+
+    N = symbols->getNestedSymbols().size();
+    for (i=0; i<N; i++) {
+        sp<AaptSymbols> nsymbols = symbols->getNestedSymbols().valueAt(i);
+        String8 nclassName(symbols->getNestedSymbols().keyAt(i));
+        if (nclassName == "styleable") {
+            err = writeTextLayoutClasses(fp, assets, nsymbols, includePrivate);
+        } else {
+            err = writeTextSymbolClass(fp, assets, includePrivate, nsymbols, nclassName);
+        }
+        if (err != NO_ERROR) {
+            return err;
+        }
+    }
+
+    return NO_ERROR;
+}
+
 status_t writeResourceSymbols(Bundle* bundle, const sp<AaptAssets>& assets,
     const String8& package, bool includePrivate)
 {
@@ -1967,11 +2115,15 @@
         return NO_ERROR;
     }
 
+    const char* textSymbolsDest = bundle->getOutputTextSymbols();
+
+    String8 R("R");
     const size_t N = assets->getSymbols().size();
     for (size_t i=0; i<N; i++) {
         sp<AaptSymbols> symbols = assets->getSymbols().valueAt(i);
         String8 className(assets->getSymbols().keyAt(i));
         String8 dest(bundle->getRClassDir());
+
         if (bundle->getMakePackageDirs()) {
             String8 pkg(package);
             const char* last = pkg.string();
@@ -2003,14 +2155,14 @@
         }
 
         fprintf(fp,
-        "/* AUTO-GENERATED FILE.  DO NOT MODIFY.\n"
-        " *\n"
-        " * This class was automatically generated by the\n"
-        " * aapt tool from the resource data it found.  It\n"
-        " * should not be modified by hand.\n"
-        " */\n"
-        "\n"
-        "package %s;\n\n", package.string());
+            "/* AUTO-GENERATED FILE.  DO NOT MODIFY.\n"
+            " *\n"
+            " * This class was automatically generated by the\n"
+            " * aapt tool from the resource data it found.  It\n"
+            " * should not be modified by hand.\n"
+            " */\n"
+            "\n"
+            "package %s;\n\n", package.string());
 
         status_t err = writeSymbolClass(fp, assets, includePrivate, symbols,
                 className, 0, bundle->getNonConstantId());
@@ -2019,14 +2171,37 @@
         }
         fclose(fp);
 
+        if (textSymbolsDest != NULL && R == className) {
+            String8 textDest(textSymbolsDest);
+            textDest.appendPath(className);
+            textDest.append(".txt");
+
+            FILE* fp = fopen(textDest.string(), "w+");
+            if (fp == NULL) {
+                fprintf(stderr, "ERROR: Unable to open text symbol file %s: %s\n",
+                        textDest.string(), strerror(errno));
+                return UNKNOWN_ERROR;
+            }
+            if (bundle->getVerbose()) {
+                printf("  Writing text symbols for class %s.\n", className.string());
+            }
+
+            status_t err = writeTextSymbolClass(fp, assets, includePrivate, symbols,
+                    className);
+            if (err != NO_ERROR) {
+                return err;
+            }
+            fclose(fp);
+        }
+
         // If we were asked to generate a dependency file, we'll go ahead and add this R.java
         // as a target in the dependency file right next to it.
-        if (bundle->getGenDependencies()) {
+        if (bundle->getGenDependencies() && R == className) {
             // Add this R.java to the dependency file
             String8 dependencyFile(bundle->getRClassDir());
             dependencyFile.appendPath("R.java.d");
 
-            fp = fopen(dependencyFile.string(), "a");
+            FILE *fp = fopen(dependencyFile.string(), "a");
             fprintf(fp,"%s \\\n", dest.string());
             fclose(fp);
         }
@@ -2036,7 +2211,6 @@
 }
 
 
-
 class ProguardKeepSet
 {
 public: