Merge "Prevent crash in AppWidgetHost that can be triggered by an AppWidget" into jb-dev
diff --git a/core/java/android/provider/CalendarContract.java b/core/java/android/provider/CalendarContract.java
index 1ef0916..a28585c 100644
--- a/core/java/android/provider/CalendarContract.java
+++ b/core/java/android/provider/CalendarContract.java
@@ -1442,9 +1442,9 @@
attendeeValues.put(Attendees.ATTENDEE_STATUS,
subCursor.getInt(COLUMN_ATTENDEE_STATUS));
attendeeValues.put(Attendees.ATTENDEE_IDENTITY,
- subCursor.getInt(COLUMN_ATTENDEE_IDENTITY));
+ subCursor.getString(COLUMN_ATTENDEE_IDENTITY));
attendeeValues.put(Attendees.ATTENDEE_ID_NAMESPACE,
- subCursor.getInt(COLUMN_ATTENDEE_ID_NAMESPACE));
+ subCursor.getString(COLUMN_ATTENDEE_ID_NAMESPACE));
entity.addSubValue(Attendees.CONTENT_URI, attendeeValues);
}
} finally {
diff --git a/data/etc/platform.xml b/data/etc/platform.xml
index 4b93e74..833064e 100644
--- a/data/etc/platform.xml
+++ b/data/etc/platform.xml
@@ -163,6 +163,12 @@
<assign-permission name="android.permission.FORCE_STOP_PACKAGES" uid="shell" />
<assign-permission name="android.permission.STOP_APP_SWITCHES" uid="shell" />
<assign-permission name="android.permission.ACCESS_CONTENT_PROVIDERS_EXTERNALLY" uid="shell" />
+ <assign-permission name="android.permission.GRANT_REVOKE_PERMISSIONS" uid="shell" />
+ <assign-permission name="android.permission.SET_KEYBOARD_LAYOUT" uid="shell" />
+ <assign-permission name="android.permission.GET_DETAILED_TASKS" uid="shell" />
+ <assign-permission name="android.permission.SET_SCREEN_COMPATIBILITY" uid="shell" />
+ <assign-permission name="android.permission.READ_EXTERNAL_STORAGE" uid="shell" />
+ <assign-permission name="android.permission.WRITE_EXTERNAL_STORAGE" uid="shell" />
<assign-permission name="android.permission.MODIFY_AUDIO_SETTINGS" uid="media" />
<assign-permission name="android.permission.ACCESS_DRM" uid="media" />
diff --git a/docs/html/develop/index.jd b/docs/html/develop/index.jd
index 6e541ee..eaa70e2 100644
--- a/docs/html/develop/index.jd
+++ b/docs/html/develop/index.jd
@@ -24,6 +24,7 @@
</div>
</div>
+
<div class="wrap">
<!-- Slideshow -->
<div class="slideshow-container slideshow-develop col-16">
@@ -34,6 +35,24 @@
<li class="item carousel-home">
<div class="col-8">
<img
+src="http://4.bp.blogspot.com/-g05If_eKKRQ/UAcrVLI-OYI/AAAAAAAAAr8/AWvunVb5S-w/s320/nexus7.png"
+class="play no-shadow no-transform" />
+ </div>
+ <div class="content-right col-6">
+ <p class="title-intro">From the blog:</p>
+ <h2>Getting Your App Ready for Jelly Bean and Nexus 7</h2>
+ <p>For many people, their first taste of Jelly Bean will be on the beautiful
+ Nexus 7. While most applications will run just fine on Nexus 7, who wants
+ their app to be just fine? Here are some tips for optimizing your application
+ to make the most of this device.</p>
+ <p><a
+href="http://android-developers.blogspot.com/2012/07/getting-your-app-ready-for-jelly-bean.html" class="button">Read
+more</a></p>
+ </div>
+ </li>
+ <li class="item carousel-home">
+ <div class="col-8">
+ <img
src="http://1.bp.blogspot.com/-6qyjPxTuzv0/T6lde-Oq_fI/AAAAAAAABXc/zle7OFEGP44/s400/fddns%2Bcopy.png"
class="play no-shadow no-transform" />
</div>
@@ -93,6 +112,12 @@
<div class="feed-frame">
<!-- DEVELOPER NEWS -->
<ul>
+ <li><a href="http://android-developers.blogspot.com/2012/06/android-sdk-tools-revision-20.html">
+ <div class="feed-image" style="background:url('http://1.bp.blogspot.com/-Kp1qE5du6l8/T-xurIjfPgI/AAAAAAAABAM/kuWQwPgi0rw/s640/newactivity+(1).png') no-repeat 0 0">
+ </div>
+ <h4>Android SDK Tools, Revision 20</h4>
+ <p>Along with the preview of the Android 4.1 (Jelly Bean) platform, we launched Android SDK Tools R20 and ADT 20.0.0. Here are a few things...</p>
+ </a></li>
<li><a href="http://android-developers.blogspot.com/2012/04/faster-emulator-with-better-hardware.html">
<div class="feed-image" style="background:url('../images/emulator-wvga800l.png') no-repeat 0 0">
</div>
@@ -112,13 +137,7 @@
<h4>Accessibility</h4>
<p>We recently published some new resources to help developers make their Android applications more accessible... </p>
</a></li>
- <li><a href="http://android-developers.blogspot.com/2012/04/new-seller-countries-in-google-play.html">
- <div class="feed-image" style="background:url('http://developer.android.com/images/home/play_logo.png') no-repeat 0 0" >
- </div>
- <h4>New Seller Countries in Google Play</h4>
- <p>Over the past year we’ve been working to expand the list of
- countries and currencies from which Android developers...</p>
- </a></li>
+
</ul>
<!-- FEATURED DOCS -->
<ul>
@@ -294,7 +313,7 @@
*/
var playlists = {
'googleio' : {
- 'ids': ["734A052F802C96B9"]
+ 'ids': ["4C6BCDE45E05F49E"]
},
'fridayreview' : {
'ids': ["B7B9B23D864A55C3"]
diff --git a/docs/html/distribute/googleplay/publish/preparing.jd b/docs/html/distribute/googleplay/publish/preparing.jd
index ab8fadf..6ea0f53 100644
--- a/docs/html/distribute/googleplay/publish/preparing.jd
+++ b/docs/html/distribute/googleplay/publish/preparing.jd
@@ -435,7 +435,6 @@
<tr>
<td><p>Related resources:</p>
<ul style="margin-top:-.5em;">
-<li><strong><a href="{@docRoot}distribute/googleplay/promote/product-pages.html">Your Product Page</a></strong> — Tips and details on creating your product details page.</li>
<li><strong><a href="http://support.google.com/googleplay/android-developer/bin/answer.py?hl=en&answer=113475&topic=2365760&ctx=topic">Category types
</a></strong> — Help Center document listing available categories for apps.</li>
<li><strong><a href="http://support.google.com/googleplay/android-developer/bin/answer.py?hl=en&answer=1078870&topic=2365760&ctx=topic">Graphic Assets for your Application
diff --git a/docs/html/guide/topics/resources/layout-resource.jd b/docs/html/guide/topics/resources/layout-resource.jd
index 5643075..c653b0c 100644
--- a/docs/html/guide/topics/resources/layout-resource.jd
+++ b/docs/html/guide/topics/resources/layout-resource.jd
@@ -161,11 +161,10 @@
supported by the root element in the included layout and they will override those defined in the
root element.</p>
- <p class="caution"><strong>Caution:</strong> If you want to override the layout dimensions,
-you must override both <code>android:layout_height</code> and
-<code>android:layout_width</code>—you cannot override only the height or only the width.
-If you override only one, it will not take effect. (Other layout properties, such as weight,
-are still inherited from the source layout.)</p>
+ <p class="caution"><strong>Caution:</strong> If you want to override layout attributes using
+ the <code><include></code> tag, you must override both
+ <code>android:layout_height</code> and <code>android:layout_width</code> in order for
+ other layout attributes to take effect.</p>
<p>Another way to include a layout is to use {@link android.view.ViewStub}. It is a lightweight
View that consumes no layout space until you explicitly inflate it, at which point, it includes a
diff --git a/docs/html/images/tools/avd_manager.png b/docs/html/images/tools/avd_manager.png
new file mode 100644
index 0000000..f8a173c
--- /dev/null
+++ b/docs/html/images/tools/avd_manager.png
Binary files differ
diff --git a/docs/html/images/tools/eclipse-new.png b/docs/html/images/tools/eclipse-new.png
new file mode 100644
index 0000000..d918427
--- /dev/null
+++ b/docs/html/images/tools/eclipse-new.png
Binary files differ
diff --git a/docs/html/images/tools/eclipse-run.png b/docs/html/images/tools/eclipse-run.png
new file mode 100644
index 0000000..925f0b9
--- /dev/null
+++ b/docs/html/images/tools/eclipse-run.png
Binary files differ
diff --git a/docs/html/images/tools/lint.png b/docs/html/images/tools/lint.png
new file mode 100644
index 0000000..889e325
--- /dev/null
+++ b/docs/html/images/tools/lint.png
Binary files differ
diff --git a/docs/html/images/tools/lint_output.png b/docs/html/images/tools/lint_output.png
new file mode 100644
index 0000000..554aee7
--- /dev/null
+++ b/docs/html/images/tools/lint_output.png
Binary files differ
diff --git a/docs/html/images/tools/new_adt_project.png b/docs/html/images/tools/new_adt_project.png
new file mode 100644
index 0000000..0f0e883
--- /dev/null
+++ b/docs/html/images/tools/new_adt_project.png
Binary files differ
diff --git a/docs/html/images/tools/sdk_manager.png b/docs/html/images/tools/sdk_manager.png
new file mode 100644
index 0000000..08ffda8
--- /dev/null
+++ b/docs/html/images/tools/sdk_manager.png
Binary files differ
diff --git a/docs/html/images/training/firstapp/adt-firstapp-setup.png b/docs/html/images/training/firstapp/adt-firstapp-setup.png
index c092562..daf02b2 100644
--- a/docs/html/images/training/firstapp/adt-firstapp-setup.png
+++ b/docs/html/images/training/firstapp/adt-firstapp-setup.png
Binary files differ
diff --git a/docs/html/images/training/firstapp/adt-new-activity.png b/docs/html/images/training/firstapp/adt-new-activity.png
new file mode 100644
index 0000000..2d579d3
--- /dev/null
+++ b/docs/html/images/training/firstapp/adt-new-activity.png
Binary files differ
diff --git a/docs/html/index.jd b/docs/html/index.jd
index 8930c7f..1d47ed7 100644
--- a/docs/html/index.jd
+++ b/docs/html/index.jd
@@ -43,11 +43,11 @@
<img src="{@docRoot}images/home/google-io.png">
</div>
<div class="content-right col-5">
- <h1>Watch Android at <br/>Google I/O!</h1>
- <p>See the keynote and more than 40 Android developer sessions streamed live from Moscone Center in San Francisco.</p>
- <p>Begins June 27, 9AM PDT (UTC-7).</p>
- <p><a href="https://developers.google.com/events/io/sessions#android"
-class="button">See the Android Sessions</a></p>
+ <h1>Android videos<br/> from Google I/O!</h1>
+ <p>If you couldn't make it to Google I/O this year or want to review some of the material,
+ all of the Android sessions are now available for viewing online.</p>
+ <p><a href="http://www.youtube.com/playlist?list=PL4C6BCDE45E05F49E&feature=plcp"
+class="button">Watch the Android sessions</a></p>
</div>
</li>
<li class="item carousel-home">
@@ -68,7 +68,6 @@
<!-- /End slideshow -->
-
</div>
<div class="wrap" style="padding-bottom:20px">
<!-- Section links -->
diff --git a/docs/html/sdk/installing/adding-packages.jd b/docs/html/sdk/installing/adding-packages.jd
index 7765343..65c5d94 100644
--- a/docs/html/sdk/installing/adding-packages.jd
+++ b/docs/html/sdk/installing/adding-packages.jd
@@ -4,8 +4,9 @@
@jd:body
-<p>The Android SDK separates different parts of the SDK into separately downloadable packages. The
-SDK starter package that you've installed includes only the SDK Tools. To develop an Android app,
+<p>The Android SDK separates tools, platforms, and other components into packages you can
+ download using the Android SDK Manager. The original
+SDK package you've downloaded includes only the SDK Tools. To develop an Android app,
you also need to download at least one Android platform and the latest SDK Platform-tools.</p>
<p>You can update and install SDK packages at any time using the Android SDK Manager.</p>
@@ -48,28 +49,32 @@
<dd><strong>Required.</strong> You must install this package when you install the SDK for
the first time.</dd>
<dt>SDK Platform</dt>
- <dd><strong>Required.</strong>You need to download <strong
-style="color:red">at least one platform</strong> into your environment so you're
-able to compile your application. In order to provide the best user experience on the latest
-devices, we recommend that you use the latest platform version as your build target. You'll
-still be able to run your app on older versions, but you must build against the latest version
-in order to use new features when running on devices with the latest version of Android.</dd>
+ <dd><strong>Required.</strong>You must download <em>at least one platform</em> into your
+environment so you're able to compile your application. In order to provide the best user experience
+on the latest devices, we recommend that you use the latest platform version as your build target.
+You'll still be able to run your app on older versions, but you must build against the latest
+version in order to use new features when running on devices with the latest version of Android.
+ <p>To get started, download the latest Android version, plus the lowest version you plan
+ to support (we recommend Android 2.2 for your lowest version).</p></dd>
<dt>System Image</dt>
<dd>Recommended. Although you might have one or more Android-powered devices on which to test
your app, it's unlikely you have a device for every version of Android your app supports. It's
-a good practice to download a system image for each version of Android you support and use them
-to test your app on the Android emulator.</dd>
+a good practice to download system images for all versions of Android your app supports and test
+your app running on them with the <a href="{@docRoot}tools/devices/emulator.html">Android emulator</a>.</dd>
+ <dt>Android Support</dt>
+ <dd>Recommended. Includes a static library that allows you to use some of the latest
+Android APIs (such as <a href="{@docRoot}guide/components/fragments.html">fragments</a>,
+plus others not included in the framework at all) on devices running
+a platform version as old as Android 1.6. All of the activity templates available when creating
+a new project with the <a href="{@docRoot}tools/sdk/eclipse-adt.html">ADT Plugin</a>
+require this. For more information, read <a
+href="{@docRoot}tools/extras/support-library.html">Support Library</a>.</dd>
<dt>SDK Samples</dt>
<dd>Recommended. The samples give you source code that you can use to learn about
Android, load as a project and run, or reuse in your own app. Note that multiple
samples packages are available — one for each Android platform version. When
you are choosing a samples package to download, select the one whose API Level
matches the API Level of the Android platform that you plan to use.</dd>
- <dt>Android Support</dt>
- <dd>Recommended. The APIs available in this static library allow you to use a variety of new
-framework features (including some not available in even the latest version) on devices running
-a platform version as old as Android 1.6. For more information, read <a
-href="{@docRoot}tools/extras/support-library.html">Support Library</a>.</dd>
</dl>
diff --git a/docs/html/sdk/installing/installing-adt.jd b/docs/html/sdk/installing/installing-adt.jd
index 60f67a2..414b97b 100644
--- a/docs/html/sdk/installing/installing-adt.jd
+++ b/docs/html/sdk/installing/installing-adt.jd
@@ -1,9 +1,9 @@
page.title=Installing the Eclipse Plugin
walkthru=1
-adt.zip.version=20.0.1
-adt.zip.download=ADT-20.0.1.zip
-adt.zip.bytes=12387574
-adt.zip.checksum=6ebd7f8566bfd2cd031b07d56d49542d
+adt.zip.version=20.0.2
+adt.zip.download=ADT-20.0.2.zip
+adt.zip.bytes=12388464
+adt.zip.checksum=8e727bcdc9789c900784a82e6330ec22
@jd:body
diff --git a/docs/html/tools/debugging/debugging-ui.jd b/docs/html/tools/debugging/debugging-ui.jd
index c1976b8..a5991ec 100644
--- a/docs/html/tools/debugging/debugging-ui.jd
+++ b/docs/html/tools/debugging/debugging-ui.jd
@@ -29,7 +29,7 @@
<li><a href="#overlays">Working with Pixel Perfect overlays</a></li>
</ol>
</li>
- <li><a href="#layoutopt">Using layoutopt</a></li>
+ <li><a href="#lint">Using lint to optimize your UI</a></li>
</ol>
<h2>Related videos</h2>
<ol>
@@ -55,15 +55,15 @@
<p>
Sometimes your application's layout can slow down your application.
To help debug issues in your layout, the Android SDK provides the Hierarchy Viewer and
- <code>layoutopt</code> tools.
+ <code>lint</code> tools.
</p>
<p>The Hierarchy Viewer application allows you to debug and optimize your user interface. It
provides a visual representation of the layout's View hierarchy (the View Hierarchy window)
and a magnified view of the display (the Pixel Perfect window).</p>
- <p><code>layoutopt</code> is a command-line tool that helps you optimize the layouts and layout
- hierarchies of your applications. You can run it against your layout files or resource
+ <p>Android <code>lint</code> is a static code scanning tool that helps you optimize the layouts and layout
+ hierarchies of your applications, as well as detect other common coding problems. You can run it against your layout files or resource
directories to quickly check for inefficiencies or other types of problems that could be
affecting the performance of your application.</p>
@@ -491,57 +491,7 @@
alt=""
height="600"/>
<p class="img-caption"><strong>Figure 4.</strong> The Pixel Perfect window</p>
-<h2 id="layoutopt">Using layoutopt</h2>
-<p>
- The <code>layoutopt</code> tool lets you analyze the XML files that define your
- application's UI to find inefficiencies in the view hierarchy.</p>
-
-<p>
- To run the tool, open a terminal and launch <code>layoutopt <xmlfiles></code>
- from your SDK <code>tools/</code> directory. The <xmlfiles> argument is a space-
- delimited list of resources you want to analyze, either uncompiled resource xml files or
- directories of such files.
-</p>
-<p>
- The tool loads the specified XML files and analyzes their definitions and
- hierarchies according to a set of predefined rules. For every issue it detects, it
- displays the following information:
-</p>
-<ul>
- <li>
- The filename in which the issue was detected.
- </li>
- <li>
- The line number for the issue.
- </li>
- <li>
- A description of the issue, and for some types of issues it also suggests a resolution.
- </li>
-</ul>
-<p>The following is a sample of the output from the tool:</p>
-<pre>
-$ layoutopt samples/
-samples/compound.xml
- 7:23 The root-level <FrameLayout/> can be replaced with <merge/>
- 11:21 This LinearLayout layout or its FrameLayout parent is useless
-samples/simple.xml
- 7:7 The root-level <FrameLayout/> can be replaced with <merge/>
-samples/too_deep.xml
- -1:-1 This layout has too many nested layouts: 13 levels, it should have <= 10!
- 20:81 This LinearLayout layout or its LinearLayout parent is useless
- 24:79 This LinearLayout layout or its LinearLayout parent is useless
- 28:77 This LinearLayout layout or its LinearLayout parent is useless
- 32:75 This LinearLayout layout or its LinearLayout parent is useless
- 36:73 This LinearLayout layout or its LinearLayout parent is useless
- 40:71 This LinearLayout layout or its LinearLayout parent is useless
- 44:69 This LinearLayout layout or its LinearLayout parent is useless
- 48:67 This LinearLayout layout or its LinearLayout parent is useless
- 52:65 This LinearLayout layout or its LinearLayout parent is useless
- 56:63 This LinearLayout layout or its LinearLayout parent is useless
-samples/too_many.xml
- 7:413 The root-level <FrameLayout/> can be replaced with <merge/>
- -1:-1 This layout has too many views: 81 views, it should have <= 80!
-samples/useless.xml
- 7:19 The root-level <FrameLayout/> can be replaced with <merge/>
- 11:17 This LinearLayout layout or its FrameLayout parent is useless
-</pre>
+<h2 id="lint">Using lint to Optimize Your UI</h2>
+<p>The Android {@code lint} tool lets you analyze the XML files that define your application's UI to find inefficiencies in the view hierarchy.</p>
+<p class="note"><strong>Note: </strong>The Android <code>layoutopt</code> tool has been replaced by the {@code lint} tool beginning in ADT and SDK Tools revision 16. The {@code lint} tool reports UI layout performance issues in a similar way as <code>layoutopt</code>, and detects additional problems.</p>
+<p>For more information about using {@code lint}, see <a href="{@docRoot}tools/debugging/improving-w-lint.html">Improving Your Code with lint</a> and the <a href="{@docRoot}tools/help/lint.html">lint reference documentation</a>.</p>
diff --git a/docs/html/tools/debugging/improving-w-lint.jd b/docs/html/tools/debugging/improving-w-lint.jd
new file mode 100644
index 0000000..7e238fa
--- /dev/null
+++ b/docs/html/tools/debugging/improving-w-lint.jd
@@ -0,0 +1,219 @@
+page.title=Improving Your Code with lint
+parent.title=Debugging
+parent.link=index.html
+@jd:body
+
+<div id="qv-wrapper">
+ <div id="qv">
+ <h2>In This Document</h2>
+
+ <ol>
+ <li><a href="#overview">Overview</a></li>
+ <li><a href=#eclipse">Running lint from Eclipse</a></li>
+ <li><a href=#commandline">Running lint from the command-line</a></li>
+ <li><a href=#config">Configuring lint</a>
+ <ol>
+ <LI><a href="#eclipse_config">Configuring lint in Eclipse</a></LI>
+ <LI><a href="#pref">Configuring the lint file</a></LI>
+ <LI><a href="#src">Configuring lint checking in Java and XML source files</a></LI>
+ </ol>
+ </li>
+ </ol>
+ <h2>See Also</h2>
+ <ol>
+ <li><a href="{@docRoot}tools/help/lint.html">lint (reference)</a></li>
+ </ol>
+ </div>
+</div>
+
+
+<p>
+In addition to testing that your Android application meets its functional requirements, it's important to ensure that your code has no structural problems. Poorly structured code can impact the reliability and efficiency of your Android apps and make your code harder to maintain. For example, if your XML resource files contain unused namespaces, this takes up space and incurs unnecessary processing. Other structural issues, such as use of deprecated elements or API calls that are not supported by the target API versions, might lead to code failing to run correctly.</p>
+
+<h2 id="overview">Overview</h2>
+<p>The Android SDK provides a code scanning tool called {@code lint} that can help you to easily identify and correct problems with the structural quality of your code, without having to execute the app or write any test cases. Each problem detected by the tool is reported with a description message and a severity level, so that you can quickly prioritize the critical improvements that need to be made. You can also configure a problem's severity level to ignore issues that are not relevant for your project, or raise the severity level. The tool has a command-line interface, so you can easily integrate it into your automated testing process.</p>
+<p>The {@code lint} tool checks your Android project source files for potential bugs and optimization improvements for correctness, security, performance, usability, accessibility, and internationalization. You can run {@code lint} from the command-line or from the Eclipse environment.</p>
+<p>Figure 1 shows how the {@code lint} tool processes the application source files.</p>
+<img id="Fig1" src="{@docRoot}images/tools/lint.png" alt="">
+<p class="img-caption"><strong>Figure 1.</strong> Code scanning workflow with the {@code lint} tool</p>
+<dl>
+<dt><b>Application source files</b></dt>
+<dd>The source files consist of files that make up your Android project, including Java and XML files, icons, and ProGuard configuration files. </dd>
+<dt><b>The <code>lint.xml</code> file</b></dt>
+<dd>A configuration file that you can use to specify any {@code lint} checks that you want to exclude and to customize problem severity levels.</dd>
+<dt><b>The {@code lint} tool</b></dt>
+<dd>A static code scanning tool that you can run on your Android project from the command-line or from Eclipse. The {@code lint} tool checks for structural code problems that could affect the quality and performance of your Android application. It is strongly recommended that you correct any errors that {@code lint} detects before publishing your application.</dd>
+<dt><b>Results of {@code lint} checking</b></dt>
+<dd>You can view the results from {@code lint} in the console or in the <strong>Lint Warnings</strong> view in Eclipse. Each issue is identified by the location in the source files where it occurred and a description of the issue.</dd>
+</dl>
+<p>The {@code lint} tool is automatically installed as part of the Android SDK Tools revision 16 or higher. If you want to use {@code lint} in the Eclipse environment, you must also install the Android Development Tools (ADT) Plugin for Eclipse revision 16 or higher. For more information about installing the SDK or the ADT Plugin for Eclipse, see <a href="http://developer.android.com/sdk/installing.html">Installing the SDK.</a></p>
+
+<h2 id="eclipse">Running lint from Eclipse</h2>
+<p>If the ADT Plugin is installed in your Eclipse environment, the {@code lint} tool runs automatically when you perform one of these actions:</p>
+<ul>
+<LI>Export an APK</LI>
+<LI>Edit and save an XML source file in your Android project (such as a manifest or layout file)</LI>
+<LI>Use the layout editor in Eclipse to make changes</LI>
+</ul>
+<p>Note that when you export an APK, {@code lint} only runs an automatic check for fatal errors and aborts the export if fatal errors are found. You can turn off this automatic checking from the <strong>Lint Error Checking</strong> page in Eclipse Preferences. </p>
+<p>The output is displayed in the <strong>Lint Warnings</strong> view. If the <strong>Lint Warnings</strong> view is not showing in the workbench, you can bring it up from the Eclipse menu by clicking <strong>Window > Show View > Other > Android > Lint Warnings</strong>.</p>
+<p>Figure 2 shows an example of the output in the Lint Warnings view.</p>
+<img id="Fig2" src="{@docRoot}images/tools/lint_output.png" alt="">
+<p class="img-caption"><strong>Figure 2.</strong> Sample output in the <strong>Lint Warnings</strong> view</p>
+<p>You can also run a {@code lint} scan manually on your Android project in Eclipse by right-clicking on the project folder in the Package Explorer > <strong>Android Tools > Run Lint: Check for Common Errors</strong>.</p>
+
+
+<h2 id="commandline">Running lint from the Command-Line</h2>
+<p>
+To run {@code lint} against a list of files in a project directory:
+<pre>lint [flags] <project directory></pre>
+<p>For example, you can issue the following command to scan the files under the {@code myproject} directory and its subdirectories. The issue ID <code>MissingPrefix</code> tells {@code lint} to only scan for XML attributes that are missing the Android namespace prefix.</p>
+<pre>lint --check MissingPrefix myproject </pre>
+<p>To see the full list of flags and command-line arguments supported by the tool:</p>
+<pre>lint --help</pre>
+</p>
+
+<h3>Example lint output</h3>
+<p>The following example shows the console output when the {@code lint} command is run against a project called Earthquake. </p>
+<pre>
+$ lint Earthquake
+
+Scanning Earthquake: ...............................................................................................................................
+Scanning Earthquake (Phase 2): .......
+AndroidManifest.xml:23: Warning: <uses-sdk> tag appears after <application> tag [ManifestOrder]
+ <uses-sdk android:minSdkVersion="7" />
+ ^
+AndroidManifest.xml:23: Warning: <uses-sdk> tag should specify a target API level (the highest verified version; when running on later versions, compatibility behaviors may be enabled) with android:targetSdkVersion="?" [UsesMinSdkAttributes]
+ <uses-sdk android:minSdkVersion="7" />
+ ^
+res/layout/preferences.xml: Warning: The resource R.layout.preferences appears to be unused [UnusedResources]
+res: Warning: Missing density variation folders in res: drawable-xhdpi [IconMissingDensityFolder]
+0 errors, 4 warnings
+</pre>
+<p>The output above lists four warnings and no errors in this project. Three warnings ({@code ManifestOrder}, {@code UsesMinSdkAttributes}, and {@code UsesMinSdkAttributes}) were found in the project's <code>AndroidManifest.xml</code> file. The remaining warning ({@code IconMissingDensityFolder}) was found in the <code>Preferences.xml</code> layout file.</p>
+
+<h2 id="config">Configuring lint</h2>
+<p>By default, when you run a {@code lint} scan, the tool checks for all issues that are supported by {@code lint}. You can also restrict the issues for {@code lint} to check and assign the severity level for those issues. For example, you can disable {@code lint} checking for specific issues that are not relevant to your project and configure {@code lint} to report non-critical issues at a lower severity level.</p>
+<p>You can configure {@code lint} checking at different levels:</p>
+<ul>
+<LI>Globally, for all projects</LI>
+<li>Per project</li>
+<li>Per file</li>
+<li>Per Java class or method (by using the <code>@SuppressLint</code> annotation), or per XML element (by using the <code>tools:ignore</code> attribute.</li>
+</ul>
+
+<h3 id="eclipse_config">Configuring lint in Eclipse</h3>
+<p>You can configure global, project-specific, and file-specific settings for {@code lint} from the Eclipse user interface.</p>
+
+<h4>Global preferences</h4>
+<ol>
+<LI>Open <strong>Window > Preferences > Android > Lint Error Checking</strong>.</LI>
+<li>Specify your preferences and click <b>OK</b>.</li>
+</ol>
+<p>These settings are applied by default when you run {@code lint} on your Android projects in Eclipse.</p>
+
+<h4>Project and file-specific preferences</h4>
+<ol>
+<LI>Run the {@code lint} tool on your project by right-clicking on your project folder in the Package Explorer and selecting <strong>Android Tools > Run Lint: Check for Common Errors</strong>. This action brings up the <strong>Lint Warnings</strong> view which displays a list of issues that {@code lint} detected in your project.</LI>
+<li>From the <strong>Lint Warnings</strong> view, use the toolbar options to configure {@code lint} preferences for individual projects and files in Eclipse. The options you can select include:
+<ul>
+<LI><b>Suppress this error with an annotation/attribute</b> - If the issue appears in a Java class, the {@code lint} tool adds a <code>@SuppressLint</code> annotation to the method where the issue was detected. If the issue appears in an {@code .xml} file, {@code lint} inserts a <code>tools:ignore</code> attribute to disable checking for the {@code lint} issue in this file.</LI>
+<LI><b>Ignore in this file</b> - Disables checking for this {@code lint} issue in this file.</LI>
+<li><b>Ignore in this project</b> - Disables checking for this {@code lint} issue in this project.</li>
+<li><b>Always ignore</b> - Disables checking for this {@code lint} issue globally for all projects.</li>
+</ul>
+</li>
+</ol>
+<p>If you select the second or third option, the {@code lint} tool automatically generates a <code>lint.xml</code> file with these configuration settings in your Android application project folder. </p>
+
+<h3 id="pref">Configuring the lint file</h3>
+<p>You can specify your {@code lint} checking preferences in the <code>lint.xml</code> file. If you are creating this file manually, place it in the root directory of your Android project. If you are configuring {@code lint} preferences in Eclipse, the <code>lint.xml</code> file is automatically created and added to your Android project for you.</p>
+<p>The <code>lint.xml</code> file consists of an enclosing <code><lint></code> parent tag that contains one or more children <code><issue></code> elements. Each <code><issue></code> is identified by a unique <code>id</code> attribute value, which is defined by {@code lint}.</p>
+<pre>
+<?xml version="1.0" encoding="UTF-8"?>
+ <lint>
+ <!-- list of issues to configure -->
+</lint>
+</pre>
+<p>By setting the severity attribute value in the <code><issue></code> tag, you can disable {@code lint} checking for an issue or change the severity level for an issue. </p>
+<p class="note"><strong>Tip: </strong>To see the full list of issues supported by the {@code lint} tool and their corresponding issue IDs, run the <code>lint --list</code> command.</p>
+
+<h4>Sample lint.xml file</h4>
+<p>The following example shows the contents of a <code>lint.xml</code> file.</p>
+<pre>
+<?xml version="1.0" encoding="UTF-8"?>
+<lint>
+ <!-- Disable the given check in this project -->
+ <issue id="IconMissingDensityFolder" severity="ignore" />
+
+ <!-- Ignore the ObsoleteLayoutParam issue in the specified files -->
+ <issue id="ObsoleteLayoutParam">
+ <ignore path="res/layout/activation.xml" />
+ <ignore path="res/layout-xlarge/activation.xml" />
+ </issue>
+
+ <!-- Ignore the UselessLeaf issue in the specified file -->
+ <issue id="UselessLeaf">
+ <ignore path="res/layout/main.xml" />
+ </issue>
+
+ <!-- Change the severity of hardcoded strings to "error" -->
+ <issue id="HardcodedText" severity="error" />
+</lint>
+</pre>
+
+<h3 id="src">Configuring lint checking in Java and XML source files</h3>
+<p>You can disable {@code lint} checking from your Java and XML source files.</p>
+
+<p class="note"><strong>Tip: </strong>If you are using Eclipse, you can use the <strong>Quick Fix</strong> feature to automatically add the annotation or attribute to disable {@code lint} checking to your Java or XML source files:
+<ol>
+<LI>Open the Java or XML file that has a {@code lint} warning or error in an Eclipse editor.</LI>
+<LI>Move your cursor to the location in the file where is {@code lint} issue is found, then press <code>Ctrl+1</code> to bring up the <strong>Quick Fix</strong> pop-up.</LI>
+<li>From the <strong>Quick Fix</strong> pop-up, select the action to add an annotation or attribute to ignore the {@code lint} issue.</li>
+</ol>
+</p>
+
+<h4>Configuring lint checking in Java</h4>
+<p>To disable {@code lint} checking specifically for a Java class or method in your Android project, add the <code>@SuppressLint</code> annotation to that Java code. </p>
+<p>The following example shows how you can turn off {@code lint} checking for the {@code NewApi} issue in the <code>onCreate</code> method. The {@code lint} tool continues to check for the {@code NewApi} issue in other methods of this class.</p>
+<pre>
+@SuppressLint("NewApi")
+@Override
+public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+</pre>
+<p>The following example shows how to turn off {@code lint} checking for the {@code ParserError} issue in the <code>FeedProvider</code> class:</p>
+<pre>
+@SuppressLint("ParserError")
+public class FeedProvider extends ContentProvider {
+</pre>
+<p>To suppress checking for all {@code lint} issues in the Java file, use the {@code all} keyword, like this:</p>
+<pre>
+@SuppressLint("all")
+</pre>
+
+<h4>Configuring lint checking in XML</h4>
+<p>You can use the <code>tools:ignore</code> attribute to disable {@code lint} checking for specific sections of your XML files. In order for this attribute to be recognized by the {@code lint} tool, the following namespace value must be included in your XML file:</p>
+<pre>
+namespace xmlns:tools="http://schemas.android.com/tools"
+</pre>
+<p>The following example shows how you can turn off {@code lint} checking for the {@code UnusedResources} issue for the <code><LinearLayout></code> element of an XML layout file. The <code>ignore</code> attribute is inherited by the children elements of the parent element in which the attribute is declared. In this example, the {@code lint} check is also disabled for the child <code><TextView></code> element. </p>
+<pre>
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ tools:ignore="UnusedResources" >
+
+ <TextView
+ android:text="@string/auto_update_prompt" />
+</LinearLayout>
+</pre>
+<p>To disable more than one issue, list the issues to disable in a comma-separated string. For example:</p>
+<pre>
+tools:ignore="NewApi,StringFormatInvalid"
+</pre>
+<p>To suppress checking for all {@code lint} issues in the XML element, use the {@code all} keyword, like this:</p>
+<pre>
+tools:ignore="all"
+</pre>
diff --git a/docs/html/tools/help/bmgr.jd b/docs/html/tools/help/bmgr.jd
index 2248fa6..8823f33 100644
--- a/docs/html/tools/help/bmgr.jd
+++ b/docs/html/tools/help/bmgr.jd
@@ -7,9 +7,6 @@
<div id="qv-wrapper">
<div id="qv">
- <h2>bmgr quickview</h2>
-<p><code>bmgr</code> lets you control the backup/restore system on an Android device.
-
<h2>In this document</h2>
<ol>
<li><a href="#backup">Forcing a Backup Operation</a></li>
diff --git a/docs/html/tools/help/lint.jd b/docs/html/tools/help/lint.jd
new file mode 100644
index 0000000..ba31f6d
--- /dev/null
+++ b/docs/html/tools/help/lint.jd
@@ -0,0 +1,178 @@
+page.title=lint
+parent.title=Tools
+parent.link=index.html
+@jd:body
+
+<div id="qv-wrapper">
+ <div id="qv">
+ <h2>In this document</h2>
+ <ol>
+ <li><a href="#syntax">Syntax</a></li>
+ <li><a href="#options">Options</a></li>
+ <li><a href="#config_keywords">Configuring Java and XML Source Files</a></li>
+ </ol>
+ </div>
+</div>
+
+<p>The Android {@code lint} tool is a static code analysis tool that checks your Android project source files for potential bugs and optimization improvements for correctness, security, performance, usability, accessibility, and internationalization. </p>
+<p>For more information on running {@code lint}, see <a href="{@docRoot}tools/debugging/improving-w-lint.html">Improving Your Code with lint</a>.</p>
+
+<h2 id="syntax">Syntax</h2>
+<p>
+<pre>lint [flags] <project directory></pre>
+
+For example, you can issue the following command to scan the Java and XML files under the {@code myproject} directory and its subdirectories. The result is displayed on the console.
+<pre>lint myproject</pre>
+
+You can also use {@code lint} to check for a specific issue. For example, you can run the following command to scan the files under the {@code myproject} directory and its subdirectories to check for XML attributes missing the Android namespace prefix. The issue ID {@code MissingPrefix} tells lint to only scan for this issue.
+<pre>lint --check MissingPrefix myproject</pre>
+
+You can create an HTML report for the issues that {@code lint} detects. For example, you can run the following command to scan the {@code myproject} directory and its subdirectories for accessibility issues, then generate an HTML report in the {@code accessibility_report.html} file.
+<pre>lint --check Accessibility --HTML accessibility_report.html myproject</pre>
+</p>
+
+<h2 id="options">Options</h2>
+<p>Table 1 describes the command-line options for {@code lint}.</p>
+<p class="table-caption" id="table1">
+ <strong>Table 1.</strong> Command-line options for lint</p>
+<table>
+<tr>
+ <th>Category</th>
+ <th>Option</th>
+ <th>Description</th>
+ <th>Comments</th>
+</tr>
+
+<tr>
+<td rowspan="7">Checking</td>
+<td><nobr><code>--disable <list></code></nobr></td>
+<td>Disable checking for a specific list of issues.</td>
+<td>The <code><list></code> must be a comma-separated list of {@code lint} issue IDs or categories.</td>
+</tr>
+
+<tr>
+<td><nobr><code>--enable <list></code></nobr></td>
+<td>Check for all the default issues supported by {@code lint} as well as the specifically enabled list of issues.</td>
+<td>The <code><list></code> must be a comma-separated list of {@code lint} issue IDs or categories.</td>
+</tr>
+
+<tr>
+<td><nobr><code>--check <list></code></nobr></td>
+<td>Check for a specific list of issues.</td>
+<td>The <code><list></code> must be a comma-separated list of {@code lint} issue IDs or categories.</td>
+</tr>
+
+<tr>
+<td><nobr><code>-w</code> or <code>--nowarn</code></nobr></td>
+<td>Only check for errors and ignore warnings</td>
+<td> </td>
+</tr>
+
+<tr>
+<td><nobr><code>-Wall</code></nobr></td>
+<td>Check for all warnings, including those that are disabled by default</td>
+<td> </td>
+</tr>
+
+<tr>
+<td><nobr><code>-Werror</code></nobr></td>
+<td>Report all warnings as errors</td>
+<td> </td>
+</tr>
+
+<tr>
+<td><nobr><code>--config <filename></code></nobr></td>
+<td>Use the specified configuration file to determine if issues are enabled or disabled for {@code lint} checking</td>
+<td>If the project contains a {@code lint.xml} file, the {@code lint.xml} file will be used as the configuration file by default.</td>
+</tr>
+
+<tr>
+<td rowspan="9">Reporting</td>
+<td><nobr><code>--html <filename></code></nobr></td>
+<td>Generate an HTML report.</td>
+<td>The report is saved in the output file specified in the argument. The HTML output includes code snippets of the source code where {@code lint} detected an issue, a verbose description of the issue found, and links to the source file.</td>
+</tr>
+
+<tr>
+<td><nobr><code>--url <filepath>=<url></code></nobr></td>
+<td>In the HTML output, replace a local path prefix <code><filepath></code> with a url prefix <code><url></code>.</td>
+<td>The {@code --url} option only applies when you are generating an HTML report with the {@code --html} option. You can specify multiple <filepath>=<url> mappings in the argument by separating each mapping with a comma.<p>To turn off linking to files, use {@code --url none}</p></td>
+</tr>
+
+<tr>
+<td><nobr><code>--simplehtml <filename></code></nobr></td>
+<td>Generate a simple HTML report</td>
+<td>The report is saved in the output file specified in the argument.</td>
+</tr>
+
+<tr>
+<td><nobr><code>--xml <filename></code></nobr></td>
+<td>Generate an XML report</td>
+<td>The report is saved in the output file specified in the argument.</td>
+</tr>
+
+<tr>
+<td><nobr><code>--fullpath</code></nobr></td>
+<td>Show the full file paths in the {@code lint} checking results.</td>
+<td> </td>
+</tr>
+
+<tr>
+<td><nobr><code>--showall</code></nobr></td>
+<td>Don't truncate long messages or lists of alternate locations.</td>
+<td> </td>
+</tr>
+
+<tr>
+<td><nobr><code>--nolines</code></nobr></td>
+<td>Don't include code snippets from the source files in the output.</td>
+<td> </td>
+</tr>
+
+<tr>
+<td><nobr><code>--exitcode</code></nobr></td>
+<td>Set the exit code to 1 if errors are found.</td>
+<td> </td>
+</tr>
+
+<tr>
+<td><nobr><code>--quiet</code></nobr></td>
+<td>Don't show the progress indicator.</td>
+<td> </td>
+</tr>
+
+<tr>
+<td rowspan="4">Help</td>
+<td><nobr><code>--help</code></nobr></td>
+<td>List the command-line arguments supported by the {@code lint} tool.</td>
+<td>Use {@code --help <topic>} to see help information for a specific topic, such as "suppress".</td>
+</tr>
+
+<tr>
+<td><nobr><code>--list</code></nobr></td>
+<td>List the ID and short description for issues that can be checked by {@code lint}</td>
+<td> </td>
+</tr>
+
+<tr>
+<td><nobr><code>--show</code></nobr></td>
+<td>List the ID and verbose description for issues that can be checked by {@code lint}</td>
+<td>Use {@code --show <ids>} to see descriptions for a specific list of {@code lint} issue IDs.</td>
+</tr>
+
+<tr>
+<td><nobr><code>--version</code></nobr></td>
+<td>Show the {@code lint} version</td>
+<td> </td>
+</tr>
+
+</table>
+
+
+<h2 id="config_keywords">Configuring Java and XML Source Files</h2>
+<p>To configure lint checking, you can apply the following annotation or attribute to the source files in your Android project. </p>
+<ul>
+<LI>To disable lint checking for a specific Java class or method, use the <code>@SuppressLint</code> annotation. </LI>
+<li>To disable lint checking for specific sections of your XML file, use the <code>tools:ignore</code> attribute. </li>
+</ul>
+<p>You can also specify your lint checking preferences for a specific Android project in the lint.xml file. For more information on configuring lint, see <a href="{@docRoot}tools/debugging/improving-w-lint.html">Improving Your Code with lint</a>.</p>
diff --git a/docs/html/tools/help/monitor.jd b/docs/html/tools/help/monitor.jd
index 8e2ea36..18fb49a 100644
--- a/docs/html/tools/help/monitor.jd
+++ b/docs/html/tools/help/monitor.jd
@@ -1,7 +1,7 @@
-page.title=Debug Monitor
+page.title=Device Monitor
@jd:body
-<p>Android Debug Monitor is a stand-alone tool that provides a graphical user interface for
+<p>Android Device Monitor is a stand-alone tool that provides a graphical user interface for
several Android application debugging and analysis tools. The Monitor tool does not
require installation of a integrated development environment, such as Eclipse, and encapsulates the
following tools:</p>
@@ -16,9 +16,9 @@
<h2 id="usage">Usage</h2>
-<p>To start Debug Monitor, enter the following command from the SDK <code>tools/</code>
+<p>To start Device Monitor, enter the following command from the SDK <code>tools/</code>
directory:</p>
<pre>monitor</pre>
-<p>Start an Android emulator or connect an Android device via USB cable, and connect the Debug
+<p>Start an Android emulator or connect an Android device via USB cable, and connect Device
Monitor to the device by selecting it in the <strong>Devices</strong> window.</p>
diff --git a/docs/html/tools/sdk/eclipse-adt.jd b/docs/html/tools/sdk/eclipse-adt.jd
index 947e463..bdb4a9e 100644
--- a/docs/html/tools/sdk/eclipse-adt.jd
+++ b/docs/html/tools/sdk/eclipse-adt.jd
@@ -96,8 +96,41 @@
<div class="toggleable opened">
<a href="#" onclick="return toggleDiv(this)">
<img src="{@docRoot}assets/images/triangle-opened.png" class="toggle-img" height="9px"
- width="9px" />
-ADT 20.0.1</a> <em>(June 2012)</em>
+ width="9px"/>
+ADT 20.0.2</a> <em>(July 2012)</em>
+ <div class="toggleme">
+<dl>
+ <dt>Dependencies:</dt>
+
+ <dd>
+ <ul>
+ <li>Java 1.6 or higher is required for ADT 20.0.2.</li>
+ <li>Eclipse Helios (Version 3.6.2) or higher is required for ADT 20.0.2.</li>
+ <li>ADT 20.0.2 is designed for use with <a href="{@docRoot}tools/sdk/tools-notes.html">SDK
+ Tools r20.0.1</a>. If you haven't already installed SDK Tools r20.0.1 into your SDK, use the
+ Android SDK Manager to do so.</li>
+ </ul>
+ </dd>
+
+ <dt>Bug fixes:</dt>
+ <dd>
+ <ul>
+ <li>Fixed keybindings in various XML editors for Eclipse 4.x.</li>
+ <li>Fixed bug when creating layout configurations that already exist.</li>
+ </ul>
+ </dd>
+
+</dl>
+
+</div>
+</div>
+
+
+<div class="toggleable closed">
+ <a href="#" onclick="return toggleDiv(this)">
+ <img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-img" height="9px"
+ width="9px"/>
+ADT 20.0.1</a> <em>(July 2012)</em>
<div class="toggleme">
<dl>
<dt>Dependencies:</dt>
diff --git a/docs/html/tools/sdk/ndk/index.jd b/docs/html/tools/sdk/ndk/index.jd
index 216a304..064b2c3 100644
--- a/docs/html/tools/sdk/ndk/index.jd
+++ b/docs/html/tools/sdk/ndk/index.jd
@@ -161,10 +161,10 @@
co-exist with the original GCC 4.4.3 toolchain ({@code binutils} 2.19 and GDB 6.6).</p>
<ul>
<li>GCC 4.6 is now the default toolchain. You may set {@code
-NDK_TOOLCHAIN_VERSION=4.4.3} in {@code Android.mk} to select the original one.</li>
+NDK_TOOLCHAIN_VERSION=4.4.3} in {@code Application.mk} to select the original one.</li>
<li>Support for the {@code gold} linker is only available for ARM and x86
architectures on Linux and Mac OS hosts. This support is disabled by default. Add {@code
-LOCAL_C_FLAGS += -fuse-ld=gold} in {@code Android.mk} to enable it.</li>
+LOCAL_LDLIBS += -fuse-ld=gold} in {@code Android.mk} to enable it.</li>
<li>Programs compiled with {@code -fPIE} require the new {@code GDB} for debugging,
including binaries in Android 4.1 (API Level 16) system images.</li>
<li>The {@code binutils} 2.21 {@code ld} tool contains back-ported fixes from
diff --git a/docs/html/tools/tools_toc.cs b/docs/html/tools/tools_toc.cs
index c7cdded..850e0ec 100644
--- a/docs/html/tools/tools_toc.cs
+++ b/docs/html/tools/tools_toc.cs
@@ -107,6 +107,7 @@
<li><a href="<?cs var:toroot ?>tools/debugging/debugging-projects-cmdline.html"><span class="en">From Other IDEs</span></a></li>
<li><a href="<?cs var:toroot ?>tools/debugging/ddms.html"><span class="en">Using DDMS</span></a></li>
<li><a href="<?cs var:toroot ?>tools/debugging/debugging-log.html"><span class="en">Reading and Writing Logs</span></a></li>
+ <li><a href="<?cs var:toroot ?>tools/debugging/improving-w-lint.html"><span class="en">Improving Your Code with lint</span></a></li>
<li><a href="<?cs var:toroot ?>tools/debugging/debugging-ui.html"><span class="en">Optimizing your UI</span></a></li>
<li><a href="<?cs var:toroot ?>tools/debugging/debugging-tracing.html"><span class="en">Profiling with Traceview and dmtracedump</span></a></li>
<li><a href="<?cs var:toroot ?>tools/debugging/debugging-devtools.html"><span class="en">Using the Dev Tools App</span></a></li>
@@ -137,7 +138,7 @@
<li><a href="<?cs var:toroot ?>tools/help/etc1tool.html">etc1tool</a></li>
<li><a href="<?cs var:toroot ?>tools/help/hierarchy-viewer.html">Hierarchy Viewer</a></li>
<li><a href="<?cs var:toroot ?>tools/help/hprof-conv.html">hprof-conv</a></li>
- <li><a href="<?cs var:toroot ?>tools/help/layoutopt.html">layoutopt</a></li>
+ <li><a href="<?cs var:toroot ?>tools/help/lint.html">lint</span></a></li>
<li><a href="<?cs var:toroot ?>tools/help/logcat.html">logcat</a></li>
<li><a href="<?cs var:toroot ?>tools/help/mksdcard.html">mksdcard</a></li>
<li><a href="<?cs var:toroot ?>tools/help/monkey.html">monkey</a></li>
diff --git a/docs/html/training/basics/firstapp/building-ui.jd b/docs/html/training/basics/firstapp/building-ui.jd
index f0ec79e..bc6c47c 100644
--- a/docs/html/training/basics/firstapp/building-ui.jd
+++ b/docs/html/training/basics/firstapp/building-ui.jd
@@ -18,7 +18,7 @@
<h2>This lesson teaches you to</h2>
<ol>
- <li><a href="#LinearLayout">Use a Linear Layout</a></li>
+ <li><a href="#LinearLayout">Create a Linear Layout</a></li>
<li><a href="#TextInput">Add a Text Field</a></li>
<li><a href="#Strings">Add String Resources</a></li>
<li><a href="#Button">Add a Button</a></li>
@@ -28,10 +28,9 @@
<h2>You should also read</h2>
<ul>
- <li><a href="{@docRoot}guide/topics/ui/declaring-layout.html">XML Layouts</a></li>
+ <li><a href="{@docRoot}guide/topics/ui/declaring-layout.html">Layouts</a></li>
</ul>
-
-
+
</div>
</div>
@@ -39,63 +38,68 @@
<p>The graphical user interface for an Android app is built using a hierarchy of {@link
android.view.View} and {@link android.view.ViewGroup} objects. {@link android.view.View} objects are
-usually UI widgets such as a button or text field and {@link android.view.ViewGroup} objects are
+usually UI widgets such as <a href="{@docRoot}guide/topics/ui/controls/button.html">buttons</a> or
+<a href="{@docRoot}guide/topics/ui/controls/text.html">text fields</a> and {@link
+android.view.ViewGroup} objects are
invisible view containers that define how the child views are laid out, such as in a
grid or a vertical list.</p>
<p>Android provides an XML vocabulary that corresponds to the subclasses of {@link
-android.view.View} and {@link android.view.ViewGroup} so you can define your UI in XML with a
-hierarchy of view elements.</p>
+android.view.View} and {@link android.view.ViewGroup} so you can define your UI in XML using
+a hierarchy of UI elements.</p>
<div class="sidebox-wrapper">
<div class="sidebox">
<h2>Alternative Layouts</h2>
- <p>Separating the UI layout into XML files is important for several reasons,
-but it's especially important on Android because it allows you to define alternative layouts for
+ <p>Declaring your UI layout in XML rather than runtime code is useful for several reasons,
+but it's especially important so you can create different layouts for
different screen sizes. For example, you can create two versions of a layout and tell
the system to use one on "small" screens and the other on "large" screens. For more information,
see the class about <a
href="{@docRoot}training/basics/supporting-devices/index.html">Supporting Different
-Hardware</a>.</p>
+Devices</a>.</p>
</div>
</div>
-<img src="{@docRoot}images/viewgroup.png" alt="" width="440" />
+<img src="{@docRoot}images/viewgroup.png" alt="" width="400" />
<p class="img-caption"><strong>Figure 1.</strong> Illustration of how {@link
-android.view.ViewGroup} objects form branches in the layout and contain {@link
+android.view.ViewGroup} objects form branches in the layout and contain other {@link
android.view.View} objects.</p>
-<p>In this lesson, you'll create a layout in XML that includes a text input field and a
+<p>In this lesson, you'll create a layout in XML that includes a text field and a
button. In the following lesson, you'll respond when the button is pressed by sending the
content of the text field to another activity.</p>
-<h2 id="LinearLayout">Use a Linear Layout</h2>
+<h2 id="LinearLayout">Create a Linear Layout</h2>
-<p>Open the <code>main.xml</code> file from the <code>res/layout/</code>
-directory (every new Android project includes this file by default).</p>
+<p>Open the <code>activity_main.xml</code> file from the <code>res/layout/</code>
+directory.</p>
<p class="note"><strong>Note:</strong> In Eclipse, when you open a layout file, you’re first shown
-the ADT Layout Editor. This is an editor that helps you build layouts using WYSIWYG tools. For this
-lesson, you’re going to work directly with the XML, so click the <em>main.xml</em> tab at
+the Graphical Layout editor. This is an editor that helps you build layouts using WYSIWYG tools. For this
+lesson, you’re going to work directly with the XML, so click the <em>activity_main.xml</em> tab at
the bottom of the screen to open the XML editor.</p>
-<p>By default, the <code>main.xml</code> file includes a layout with a {@link
-android.widget.LinearLayout} root view group and a {@link android.widget.TextView} child view.
-You’re going to re-use the {@link android.widget.LinearLayout} in this lesson, but change its
-contents and layout orientation.</p>
+<p>The BlankActivity template you used to start this project creates the
+<code>activity_main.xml</code> file with a {@link
+android.widget.RelativeLayout} root view and a {@link android.widget.TextView} child view.</p>
-<p>First, delete the {@link android.widget.TextView} element and change the value
+<p>First, delete the {@link android.widget.TextView <TextView>} element and change the {@link
+ android.widget.RelativeLayout <RelativeLayout>} element to {@link
+ android.widget.LinearLayout <LinearLayout>}. Then add the
<a href="{@docRoot}reference/android/widget/LinearLayout.html#attr_android:orientation">{@code
-android:orientation}</a> to be <code>"horizontal"</code>. The result looks like this:</p>
+android:orientation}</a> attribute and set it to <code>"horizontal"</code>.
+The result looks like this:</p>
<pre>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
android:orientation="horizontal" >
</LinearLayout>
</pre>
@@ -116,26 +120,18 @@
<p>Because the {@link android.widget.LinearLayout} is the root view in the layout, it should fill
the entire screen area that's
available to the app by setting the width and height to
-<code>"fill_parent"</code>.</p>
-
-<p class="note"><strong>Note:</strong> Beginning with Android 2.2 (API level 8),
-<code>"fill_parent"</code> has been renamed <code>"match_parent"</code> to better reflect the
-behavior. The reason is that if you set a view to <code>"fill_parent"</code> it does not expand to
-fill the remaining space after sibling views are considered, but instead expands to
-<em>match</em> the size of the parent view no matter what—it will overlap any sibling
-views.</p>
+<code>"match_parent"</code>. This value declares that the view should expand its width
+or height to <em>match</em> the width or height of the parent view.</p>
<p>For more information about layout properties, see the <a
-href="{@docRoot}guide/topics/ui/declaring-layout.html">XML Layout</a> guide.</p>
+href="{@docRoot}guide/topics/ui/declaring-layout.html">Layout</a> guide.</p>
<h2 id="TextInput">Add a Text Field</h2>
<p>To create a user-editable text field, add an {@link android.widget.EditText
-<EditText>} element inside the {@link android.widget.LinearLayout <LinearLayout>}. The {@link
-android.widget.EditText} class is a subclass of {@link android.view.View} that displays an editable
-text field.</p>
+<EditText>} element inside the {@link android.widget.LinearLayout <LinearLayout>}.</p>
<p>Like every {@link android.view.View} object, you must define certain XML attributes to specify
the {@link android.widget.EditText} object's properties. Here’s how you should declare it
@@ -164,6 +160,8 @@
which allows you to reference that view from other code.</p>
<p>The SDK tools generate the {@code R.java} each time you compile your app. You should never
modify this file by hand.</p>
+ <p>For more information, read the guide to <a
+href="{@docRoot}guide/topics/resources/providing-resources.html">Providing Resources</a>.</p>
</div>
</div>
@@ -175,17 +173,18 @@
from your app code, such as to read and manipulate the object (you'll see this in the next
lesson).
-<p>The at-symbol (<code>@</code>) is required when you want to refer to a resource object from
-XML, followed by the resource type ({@code id} in this case), then the resource name ({@code
-edit_message}). (Other resources can use the same name as long as they are not the same
-resource type—for example, the string resource uses the same name.)</p>
+<p>The at sign (<code>@</code>) is required when you're referring to any resource object from
+XML. It is followed by the resource type ({@code id} in this case), a slash, then the resource name
+({@code edit_message}).</p>
-<p>The plus-symbol (<code>+</code>) is needed only when you're defining a resource ID for the
-first time. It tells the SDK tools that the resource ID needs to be created. Thus, when the app is
-compiled, the SDK tools use the ID value, <code>edit_message</code>, to create a new identifier in
-your project's {@code gen/R.java} file that is now associated with the {@link
-android.widget.EditText} element. Once the resource ID is created, other references to the ID do not
-need the plus symbol. This is the only attribute that may need the plus-symbol. See the sidebox for
+<p>The plus sign (<code>+</code>) before the resource type is needed only when you're defining a
+resource ID for the first time. When you compile the app,
+the SDK tools use the ID name to create a new resource ID in
+your project's {@code gen/R.java} file that refers to the {@link
+android.widget.EditText} element. Once the resource ID is declared once this way,
+other references to the ID do not
+need the plus sign. Using the plus sign is necessary only when specifying a new resource ID and not
+needed for concrete resources such as strings or layouts. See the sidebox for
more information about resource objects.</p></dd>
<dt><a
@@ -195,39 +194,42 @@
android:layout_height}</a></dt>
<dd>Instead of using specific sizes for the width and height, the <code>"wrap_content"</code> value
specifies that the view should be only as big as needed to fit the contents of the view. If you
-were to instead use <code>"fill_parent"</code>, then the {@link android.widget.EditText}
-element would fill the screen, because it'd match the size of the parent {@link
+were to instead use <code>"match_parent"</code>, then the {@link android.widget.EditText}
+element would fill the screen, because it would match the size of the parent {@link
android.widget.LinearLayout}. For more information, see the <a
-href="{@docRoot}guide/topics/ui/declaring-layout.html">XML Layouts</a> guide.</dd>
+href="{@docRoot}guide/topics/ui/declaring-layout.html">Layouts</a> guide.</dd>
<dt><a
href="{@docRoot}reference/android/widget/TextView.html#attr_android:hint">{@code
android:hint}</a></dt>
<dd>This is a default string to display when the text field is empty. Instead of using a hard-coded
-string as the value, the {@code "@string/edit_message"} value refers to a string resource defined
-in a separate file. Because this value refers to an existing resource, it does not need the
-plus-symbol. However, because you haven't defined the string resource yet, you’ll see a compiler
-error when you add the {@code "@string/edit_message"} value. You'll fix this in the next section by
-defining the string resource.</dd>
+string as the value, the {@code "@string/edit_message"} value refers to a string resource defined in
+a separate file. Because this refers to a concrete resource (not just an identifier), it does not
+need the plus sign. However, because you haven't defined the string resource yet, you’ll see a
+compiler error at first. You'll fix this in the next section by defining the string.
+<p class="note"><strong>Note:</strong> This string resource has the same name as the element ID:
+{@code edit_message}. However, references
+to resources are always scoped by the resource type (such as {@code id} or {@code string}), so using
+the same name does not cause collisions.</p>
+</dd>
</dl>
<h2 id="Strings">Add String Resources</h2>
-<p>When you need to add text in the user interface, you should always specify each string of text in
-a resource file. String resources allow you to maintain a single location for all string
-values, which makes it easier to find and update text. Externalizing the strings also allows you to
+<p>When you need to add text in the user interface, you should always specify each string as
+a resource. String resources allow you to manage all UI text in a single location,
+which makes it easier to find and update text. Externalizing the strings also allows you to
localize your app to different languages by providing alternative definitions for each
-string.</p>
+string resource.</p>
<p>By default, your Android project includes a string resource file at
-<code>res/values/strings.xml</code>. Open this file, delete the existing <code>"hello"</code>
-string, and add one for the
-<code>"edit_message"</code> string used by the {@link android.widget.EditText <EditText>}
-element.</p>
+<code>res/values/strings.xml</code>. Open this file and delete the {@code <string>} element
+named <code>"hello_world"</code>. Then add a new one named
+<code>"edit_message"</code> and set the value to "Enter a message."</p>
-<p>While you’re in this file, also add a string for the button you’ll soon add, called
+<p>While you’re in this file, also add a "Send" string for the button you’ll soon add, called
<code>"button_send"</code>.</p>
<p>The result for <code>strings.xml</code> looks like this:</p>
@@ -238,12 +240,14 @@
<string name="app_name">My First App</string>
<string name="edit_message">Enter a message</string>
<string name="button_send">Send</string>
+ <string name="menu_settings">Settings</string>
+ <string name="title_activity_main">MainActivity</string>
</resources>
</pre>
-<p>For more information about using string resources to localize your app for several languages,
+<p>For more information about using string resources to localize your app for other languages,
see the <a
-href="{@docRoot}training/basics/supporting-devices/index.html">Supporting Various Devices</a>
+href="{@docRoot}training/basics/supporting-devices/index.html">Supporting Different Devices</a>
class.</p>
@@ -280,23 +284,26 @@
<code>"wrap_content"</code>.</p>
<p>This works fine for the button, but not as well for the text field, because the user might type
-something longer and there's extra space left on the screen. So, it'd be nice to fill that width
-using the text field.
-{@link android.widget.LinearLayout} enables such a design with the <em>weight</em> property, which
+something longer. So, it would be nice to fill the unused screen width
+with the text field. You can do this inside a
+{@link android.widget.LinearLayout} with the <em>weight</em> property, which
you can specify using the <a
href="{@docRoot}reference/android/widget/LinearLayout.LayoutParams.html#weight">{@code
android:layout_weight}</a> attribute.</p>
-<p>The weight value allows you to specify the amount of remaining space each view should consume,
-relative to the amount consumed by sibling views, just like the ingredients in a drink recipe: "2
+<p>The weight value is a number that specifies the amount of remaining space each view should
+consume,
+relative to the amount consumed by sibling views. This works kind of like the
+amount of ingredients in a drink recipe: "2
parts vodka, 1 part coffee liqueur" means two-thirds of the drink is vodka. For example, if you give
-one view a weight of 2 and another one a weight of 1, the sum is 3, so the first view gets 2/3 of
-the remaining space and the second view gets the rest. If you give a third view a weight of 1,
-then the first view now gets 1/2 the remaining space, while the remaining two each get 1/4.</p>
+one view a weight of 2 and another one a weight of 1, the sum is 3, so the first view fills 2/3 of
+the remaining space and the second view fills the rest. If you add a third view and give it a weight
+of 1, then the first view (with weight of 2) now gets 1/2 the remaining space, while the remaining
+two each get 1/4.</p>
<p>The default weight for all views is 0, so if you specify any weight value
-greater than 0 to only one view, then that view fills whatever space remains after each view is
-given the space it requires. So, to fill the remaining space with the {@link
+greater than 0 to only one view, then that view fills whatever space remains after all views are
+given the space they require. So, to fill the remaining space in your layout with the {@link
android.widget.EditText} element, give it a weight of 1 and leave the button with no weight.</p>
<pre>
@@ -331,8 +338,9 @@
<pre>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
android:orientation="horizontal">
<EditText android:id="@+id/edit_message"
android:layout_weight="1"
@@ -351,7 +359,8 @@
results:</p>
<ul>
- <li>In Eclipse, click <strong>Run</strong> from the toolbar.</li>
+ <li>In Eclipse, click Run <img src="{@docRoot}images/tools/eclipse-run.png"
+ style="vertical-align:baseline;margin:0" /> from the toolbar.</li>
<li>Or from a command line, change directories to the root of your Android project and
execute:
<pre>
diff --git a/docs/html/training/basics/firstapp/creating-project.jd b/docs/html/training/basics/firstapp/creating-project.jd
index 4fbfe34..2ea8b2f 100644
--- a/docs/html/training/basics/firstapp/creating-project.jd
+++ b/docs/html/training/basics/firstapp/creating-project.jd
@@ -34,66 +34,77 @@
<p>An Android project contains all the files that comprise the source code for your Android
app. The Android SDK tools make it easy to start a new Android project with a set of
-default project directories and files.</p>
+default project directories and files.</p>
<p>This lesson
shows how to create a new project either using Eclipse (with the ADT plugin) or using the
SDK tools from a command line.</p>
<p class="note"><strong>Note:</strong> You should already have the Android SDK installed, and if
-you're using Eclipse, you should have installed the <a
-href="{@docRoot}tools/sdk/eclipse-adt.html">ADT plugin</a> as well. If you have not installed
-these, see <a href="{@docRoot}sdk/installing/index.html">Installing the Android SDK</a> and return here
-when you've completed the installation.</p>
+you're using Eclipse, you should also have the <a href="{@docRoot}tools/sdk/eclipse-adt.html">ADT
+plugin</a> installed (version 20.0.0 or higher). If you don't have these, follow the guide to <a
+href="{@docRoot}sdk/installing/index.html">Installing the Android SDK</a> before you start this
+lesson.</p>
<h2 id="Eclipse">Create a Project with Eclipse</h2>
-<div class="figure" style="width:416px">
+<ol>
+ <li>In Eclipse, click New Android
+ App Project <img src="{@docRoot}images/tools/new_adt_project.png"
+ style="vertical-align:baseline;margin:0" />
+ in the toolbar. (If you don’t see this button,
+then you have not installed the ADT plugin—see <a
+href="{@docRoot}sdk/installing/installing-adt.html">Installing the Eclipse Plugin</a>.)
+ </li>
+
+<div class="figure" style="width:420px">
<img src="{@docRoot}images/training/firstapp/adt-firstapp-setup.png" alt="" />
-<p class="img-caption"><strong>Figure 1.</strong> The new project wizard in Eclipse.</p>
+<p class="img-caption"><strong>Figure 1.</strong> The New Android App Project wizard in Eclipse.</p>
</div>
-<ol>
- <li>In Eclipse, select <strong>File > New > Project</strong>.
-The resulting dialog should have a folder labeled <em>Android</em>. (If you don’t see the
-<em>Android</em> folder,
-then you have not installed the ADT plugin—see <a
-href="{@docRoot}tools/sdk/eclipse-adt.html#installing">Installing the ADT Plugin</a>).</li>
- <li>Open the <em>Android</em> folder, select <em>Android Project</em> and click
-<strong>Next</strong>.</li>
- <li>Enter a project name (such as "MyFirstApp") and click <strong>Next</strong>.</li>
- <li>Select a build target. This is the platform version against which you will compile your app.
-<p>We recommend that you select the latest version possible. You can still build your app to
-support older versions, but setting the build target to the latest version allows you to
-easily optimize your app for a great user experience on the latest Android-powered devices.</p>
-<p>If you don't see any built targets listed, you need to install some using the Android SDK
-Manager tool. See <a href="{@docRoot}sdk/installing/index.html#AddingComponents">step 4 in the
-installing guide</a>.</p>
-<p>Click <strong>Next</strong>.</p></li>
- <li>Specify other app details, such as the:
+ <li>Fill in the form that appears:
<ul>
- <li><em>Application Name</em>: The app name that appears to the user. Enter "My First
-App".</li>
- <li><em>Package Name</em>: The package namespace for your app (following the same
+ <li><em>Application Name</em> is the app name that appears to users.
+ For this project, use "My First App."</p></li>
+ <li><em>Project Name</em> is the name of your project directory and the name visible in Eclipse.</li>
+ <li><em>Package Name</em> is the package namespace for your app (following the same
rules as packages in the Java programming language). Your package name
-must be unique across all packages installed on the Android system. For this reason, it's important
-that you use a standard domain-style package name that’s appropriate to your company or
-publisher entity. For
-your first app, you can use something like "com.example.myapp." However, you cannot publish your
-app using the "com.example" namespace.</li>
- <li><em>Create Activity</em>: This is the class name for the primary user activity in your
-app (an activity represents a single screen in your app). Enter "MyFirstActivity".</li>
- <li><em>Minimum SDK</em>: Select <em>4 (Android 1.6)</em>.
- <p>Because this version is lower than the build target selected for the app, a warning
-appears, but that's alright. You simply need to be sure that you don't use any APIs that require an
-<a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#ApiLevels">API level</a> greater than the minimum SDK
-version without first using some code to verify the device's system version (you'll see this in some
-other classes).</p>
- </li>
+must be unique across all packages installed on the Android system. For this reason, it's generally
+best if you use a name that begins with the reverse domain name of your organization or
+publisher entity. For this project, you can use something like "com.example.myfirstapp."
+However, you cannot publish your app on Google Play using the "com.example" namespace.</li>
+ <li><em>Build SDK</em> is the platform version against which you will compile your app.
+ By default, this is set to the latest version of Android available in your SDK. (It should
+ be Android 4.1 or greater; if you don't have such a version available, you must install one
+ using the <a href="{@docRoot}sdk/installing/adding-packages.html">SDK Manager</a>).
+ You can still build your app to
+support older versions, but setting the build target to the latest version allows you to
+enable new features and optimize your app for a great user experience on the latest
+devices.</li>
+ <li><em>Minimum Required SDK</em> is the lowest version of Android that your app supports.
+ To support as many devices as possible, you should set this to the lowest version available
+ that allows your app to provide its core feature set. If any feature of your app is possible
+ only on newer versions of Android and it's not critical to the app's core feature set, you
+ can enable the feature only when running on the versions that support it.
+ <p>Leave this set to the default value for this project.</p>
</ul>
- <p>Click <strong>Finish</strong>.</p>
+ <p>Click <strong>Next</strong>.</p>
</li>
+
+ <li>The following screen provides tools to help you create a launcher icon for your app.
+ <p>You can customize an icon in several ways and the tool generates an icon for all
+ screen densities. Before you publish your app, you should be sure your icon meets
+ the specifications defined in the <a
+ href="{@docRoot}design/style/iconography.html">Iconography</a>
+ design guide.</p>
+ <p>Click <strong>Next</strong>.</p>
+ </li>
+ <li>Now you can select an activity template from which to begin building your app.
+ <p>For this project, select <strong>BlankActivity</strong> and click <strong>Next</strong>.</p>
+ </li>
+ <li>Leave all the details for the activity in their default state and click
+ <strong>Finish</strong>.</li>
</ol>
<p>Your Android project is now set up with some default files and you’re ready to begin
@@ -104,7 +115,7 @@
<h2 id="CommandLine">Create a Project with Command Line Tools</h2>
<p>If you're not using the Eclipse IDE with the ADT plugin, you can instead create your project
-using the SDK tools in a command line:</p>
+using the SDK tools from a command line:</p>
<ol>
<li>Change directories into the Android SDK’s <code>tools/</code> path.</li>
@@ -117,13 +128,13 @@
your app for the latest devices.</p>
<p>If you don't see any targets listed, you need to
install some using the Android SDK
-Manager tool. See <a href="{@docRoot}sdk/installing/index.html#AddingComponents">step 4 in the
-installing guide</a>.</p></li>
+Manager tool. See <a href="{@docRoot}sdk/installing/adding-packages.html">Adding Platforms
+ and Packages</a>.</p></li>
<li>Execute:
<pre class="no-pretty-print">
android create project --target <target-id> --name MyFirstApp \
---path <path-to-workspace>/MyFirstApp --activity MyFirstActivity \
---package com.example.myapp
+--path <path-to-workspace>/MyFirstApp --activity MainActivity \
+--package com.example.myfirstapp
</pre>
<p>Replace <code><target-id></code> with an id from the list of targets (from the previous step)
and replace
diff --git a/docs/html/training/basics/firstapp/index.jd b/docs/html/training/basics/firstapp/index.jd
index 43b289b..4c1a0dc3 100644
--- a/docs/html/training/basics/firstapp/index.jd
+++ b/docs/html/training/basics/firstapp/index.jd
@@ -14,8 +14,9 @@
<h2>Dependencies and prerequisites</h2>
<ul>
- <li>Android 1.6 or higher</li>
<li><a href="http://developer.android.com/sdk/index.html">Android SDK</a></li>
+ <li><a href="{@docRoot}tools/sdk/eclipse-adt.html">ADT Plugin</a> 20.0.0 or higher
+ (if you're using Eclipse)</li>
</ul>
</div>
@@ -27,39 +28,21 @@
project and run a debuggable version of the app. You'll also learn some fundamentals of Android app
design, including how to build a simple user interface and handle user input.</p>
-<p>Before you start this class, be sure that you have your development environment set up. You need
+<p>Before you start this class, be sure you have your development environment set up. You need
to:</p>
<ol>
- <li>Download the Android SDK Starter Package.</li>
+ <li>Download the Android SDK.</li>
<li>Install the ADT plugin for Eclipse (if you’ll use the Eclipse IDE).</li>
<li>Download the latest SDK tools and platforms using the SDK Manager.</li>
</ol>
-<p>If you haven't already done this setup, read <a href="{@docRoot}sdk/installing/index.html">Installing
-the SDK</a>. Once you've finished the setup, you're ready to begin this class.</p>
+<p>If you haven't already done these tasks, start by downloading the
+ <a href="{@docRoot}sdk/index.html">Android SDK</a> and following the install steps.
+ Once you've finished the setup, you're ready to begin this class.</p>
-<p>This class uses a tutorial format that incrementally builds a small Android app in order to teach
+<p>This class uses a tutorial format that incrementally builds a small Android app that teaches
you some fundamental concepts about Android development, so it's important that you follow each
step.</p>
<p><strong><a href="creating-project.html">Start the first lesson ›</a></strong></p>
-
-<h2>Lessons</h2>
-
-<dl>
- <dt><b><a href="creating-project.html">Creating an Android Project</a></b></dt>
- <dd>Shows how to create a project for an Android app, which includes a set of default
-app files.</dd>
-
- <dt><b><a href="running-app.html">Running Your Application</a></b></dt>
- <dd>Shows how to run your app on an Android-powered device or the Android
-emulator.</dd>
-
- <dt><b><a href="building-ui.html">Building a Simple User Interface</a></b></dt>
- <dd>Shows how to create a new user interface using an XML file.</dd>
-
- <dt><b><a href="starting-activity.html">Starting Another Activity</a></b></dt>
- <dd>Shows how to respond to a button press, start another activity, send it some
-data, then receive the data in the subsequent activity.</dd>
-</dl>
diff --git a/docs/html/training/basics/firstapp/running-app.jd b/docs/html/training/basics/firstapp/running-app.jd
index 5105a3b..0c428e7 100644
--- a/docs/html/training/basics/firstapp/running-app.jd
+++ b/docs/html/training/basics/firstapp/running-app.jd
@@ -37,7 +37,7 @@
<p>If you followed the <a href="creating-project.html">previous lesson</a> to create an
Android project, it includes a default set of "Hello World" source files that allow you to
-run the app right away.</p>
+immediately run the app.</p>
<p>How you run your app depends on two things: whether you have a real Android-powered device and
whether you’re using Eclipse. This lesson shows you how to install and run your app on a
@@ -49,14 +49,16 @@
<dl>
<dt><code>AndroidManifest.xml</code></dt>
- <dd>This manifest file describes the fundamental characteristics of the app and defines each of
+ <dd>The <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">manifest file</a> describes
+the fundamental characteristics of the app and defines each of
its components. You'll learn about various declarations in this file as you read more training
classes.</dd>
<dt><code>src/</code></dt>
<dd>Directory for your app's main source files. By default, it includes an {@link
android.app.Activity} class that runs when your app is launched using the app icon.</dd>
<dt><code>res/</code></dt>
- <dd>Contains several sub-directories for app resources. Here are just a few:
+ <dd>Contains several sub-directories for <a
+href="{@docRoot}guide/topics/resources/overview.html">app resources</a>. Here are just a few:
<dl style="margin-top:1em">
<dt><code>drawable-hdpi/</code></dt>
<dd>Directory for drawable objects (such as bitmaps) that are designed for high-density
@@ -70,30 +72,30 @@
</dd>
</dl>
-<p>When you build and run the default Android project, the default {@link android.app.Activity}
-class in the <code>src/</code> directory starts and loads a layout file from the
-<code>layout/</code> directory, which includes a "Hello World" message. Not real exciting, but it's
-important that you understand how to build and run your app before adding real functionality to
-the app.</p>
+<p>When you build and run the default Android app, the default {@link android.app.Activity}
+class starts and loads a layout file
+that says "Hello World." The result is nothing exciting, but it's
+important that you understand how to run your app before you start developing.</p>
<h2 id="RealDevice">Run on a Real Device</h2>
-<p>Whether you’re using Eclipse or the command line, you need to:</p>
+<p>If you have a real Android-powered device, here's how you can install and run your app:</p>
<ol>
- <li>Plug in your Android-powered device to your machine with a USB cable.
+ <li>Plug in your device to your development machine with a USB cable.
If you’re developing on Windows, you might need to install the appropriate USB driver for your
device. For help installing drivers, see the <a href="{@docRoot}tools/extras/oem-usb.html">OEM USB
Drivers</a> document.</li>
<li>Ensure that <strong>USB debugging</strong> is enabled in the device Settings (open Settings
-and navitage to <strong>Applications > Development</strong> on most devices, or select
+and navitage to <strong>Applications > Development</strong> on most devices, or click
<strong>Developer options</strong> on Android 4.0 and higher).</li>
</ol>
<p>To run the app from Eclipse, open one of your project's files and click
-<strong>Run</strong> from the toolbar. Eclipse installs the app on your connected device and starts
+Run <img src="{@docRoot}images/tools/eclipse-run.png" style="vertical-align:baseline;margin:0" />
+from the toolbar. Eclipse installs the app on your connected device and starts
it.</p>
@@ -108,18 +110,18 @@
<li>On your device, locate <em>MyFirstActivity</em> and open it.</li>
</ol>
-<p>To start adding stuff to the app, continue to the <a href="building-ui.html">next
+<p>That's how you build and run your Android app on a device!
+ To start developing, continue to the <a href="building-ui.html">next
lesson</a>.</p>
<h2 id="Emulator">Run on the Emulator</h2>
-<p>Whether you’re using Eclipse or the command line, you need to first create an <a
-href="{@docRoot}tools/devices/index.html">Android Virtual
-Device</a> (AVD). An AVD is a
-device configuration for the Android emulator that allows you to model
-different device configurations.</p>
+<p>Whether you’re using Eclipse or the command line, to run your app on the emulator you need to
+first create an <a href="{@docRoot}tools/devices/index.html">Android Virtual Device</a> (AVD). An
+AVD is a device configuration for the Android emulator that allows you to model different
+devices.</p>
<div class="figure" style="width:457px">
<img src="{@docRoot}images/screens_support/avds-config.png" alt="" />
@@ -131,13 +133,15 @@
<ol>
<li>Launch the Android Virtual Device Manager:
<ol type="a">
- <li>In Eclipse, select <strong>Window > AVD Manager</strong>, or click the <em>AVD
-Manager</em> icon in the Eclipse toolbar.</li>
- <li>From the command line, change directories to <code><sdk>/tools/</code> and execute:
-<pre class="no-pretty-print">./android avd</pre></li>
+ <li>In Eclipse, click Android Virtual Device Manager
+ <img src="{@docRoot}images/tools/avd_manager.png"
+style="vertical-align:baseline;margin:0" /> from the toolbar.</li>
+ <li>From the command line, change
+directories to <code><sdk>/tools/</code> and execute:
+<pre class="no-pretty-print">android avd</pre></li>
</ol>
</li>
- <li>In the <em>Android Virtual Device Device Manager</em> panel, click <strong>New</strong>.</li>
+ <li>In the <em>Android Virtual Device Manager</em> panel, click <strong>New</strong>.</li>
<li>Fill in the details for the AVD.
Give it a name, a platform target, an SD card size, and a skin (HVGA is default).</li>
<li>Click <strong>Create AVD</strong>.</li>
@@ -147,7 +151,8 @@
</ol>
<p>To run the app from Eclipse, open one of your project's files and click
-<strong>Run</strong> from the toolbar. Eclipse installs the app on your AVD and starts it.</p>
+Run <img src="{@docRoot}images/tools/eclipse-run.png" style="vertical-align:baseline;margin:0" />
+from the toolbar. Eclipse installs the app on your AVD and starts it.</p>
<p>Or to run your app from the command line:</p>
@@ -163,7 +168,8 @@
</ol>
-<p>To start adding stuff to the app, continue to the <a href="building-ui.html">next
+<p>That's how you build and run your Android app on the emulator!
+ To start developing, continue to the <a href="building-ui.html">next
lesson</a>.</p>
diff --git a/docs/html/training/basics/firstapp/starting-activity.jd b/docs/html/training/basics/firstapp/starting-activity.jd
index 37bc871..cbd063a 100644
--- a/docs/html/training/basics/firstapp/starting-activity.jd
+++ b/docs/html/training/basics/firstapp/starting-activity.jd
@@ -43,8 +43,8 @@
<p>After completing the <a href="building-ui.html">previous lesson</a>, you have an app that
shows an activity (a single screen) with a text field and a button. In this lesson, you’ll add some
-code to <code>MyFirstActivity</code> that
-starts a new activity when the user selects the Send button.</p>
+code to <code>MainActivity</code> that
+starts a new activity when the user clicks the Send button.</p>
<h2 id="RespondToButton">Respond to the Send Button</h2>
@@ -64,13 +64,13 @@
<p>The <a
href="{@docRoot}reference/android/view/View.html#attr_android:onClick">{@code
-android:onClick}</a> attribute’s value, <code>sendMessage</code>, is the name of a method in your
-activity that you want to call when the user selects the button.</p>
+android:onClick}</a> attribute’s value, <code>"sendMessage"</code>, is the name of a method in your
+activity that the system calls when the user clicks the button.</p>
-<p>Add the corresponding method inside the <code>MyFirstActivity</code> class:</p>
+<p>Open the <code>MainActivity</code> class and add the corresponding method:</p>
<pre>
-/** Called when the user selects the Send button */
+/** Called when the user clicks the Send button */
public void sendMessage(View view) {
// Do something in response to button
}
@@ -79,7 +79,7 @@
<p class="note"><strong>Tip:</strong> In Eclipse, press Ctrl + Shift + O to import missing classes
(Cmd + Shift + O on Mac).</p>
-<p>Note that, in order for the system to match this method to the method name given to <a
+<p>In order for the system to match this method to the method name given to <a
href="{@docRoot}reference/android/view/View.html#attr_android:onClick">{@code android:onClick}</a>,
the signature must be exactly as shown. Specifically, the method must:</p>
@@ -99,11 +99,11 @@
<p>An {@link android.content.Intent} is an object that provides runtime binding between separate
components (such as two activities). The {@link android.content.Intent} represents an
-app’s "intent to do something." You can use an {@link android.content.Intent} for a wide
+app’s "intent to do something." You can use intents for a wide
variety of tasks, but most often they’re used to start another activity.</p>
<p>Inside the {@code sendMessage()} method, create an {@link android.content.Intent} to start
-an activity called {@code DisplayMessageActvity}:</p>
+an activity called {@code DisplayMessageActivity}:</p>
<pre>
Intent intent = new Intent(this, DisplayMessageActivity.class);
@@ -127,7 +127,7 @@
can also be <em>implicit</em>, in which case the {@link android.content.Intent} does not specify
the desired component, but allows any app installed on the device to respond to the intent
as long as it satisfies the meta-data specifications for the action that's specified in various
-{@link android.content.Intent} parameters. For more informations, see the class about <a
+{@link android.content.Intent} parameters. For more information, see the class about <a
href="{@docRoot}training/basics/intents/index.html">Interacting with Other Apps</a>.</p>
</div>
</div>
@@ -136,9 +136,9 @@
will raise an error if you’re using an IDE such as Eclipse because the class doesn’t exist yet.
Ignore the error for now; you’ll create the class soon.</p>
-<p>An intent not only allows you to start another activity, but can carry a bundle of data to the
+<p>An intent not only allows you to start another activity, but it can carry a bundle of data to the
activity as well. So, use {@link android.app.Activity#findViewById findViewById()} to get the
-{@link android.widget.EditText} element and add its message to the intent:</p>
+{@link android.widget.EditText} element and add its text value to the intent:</p>
<pre>
Intent intent = new Intent(this, DisplayMessageActivity.class);
@@ -148,37 +148,36 @@
</pre>
<p>An {@link android.content.Intent} can carry a collection of various data types as key-value
-pairs called <em>extras</em>. The {@link android.content.Intent#putExtra putExtra()} method takes a
-string as the key and the value in the second parameter.</p>
+pairs called <em>extras</em>. The {@link android.content.Intent#putExtra putExtra()} method takes the
+key name in the first parameter and the value in the second parameter.</p>
-<p>In order for the next activity to query the extra data, you should define your keys using a
+<p>In order for the next activity to query the extra data, you should define your key using a
public constant. So add the {@code EXTRA_MESSAGE} definition to the top of the {@code
-MyFirstActivity} class:</p>
+MainActivity} class:</p>
<pre>
-public class MyFirstActivity extends Activity {
- public final static String EXTRA_MESSAGE = "com.example.myapp.MESSAGE";
+public class MainActivity extends Activity {
+ public final static String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";
...
}
</pre>
-<p>It's generally a good practice to define keys for extras with your app's package name as a prefix
-to ensure it's unique, in case your app interacts with other apps.</p>
+<p>It's generally a good practice to define keys for intent extras using your app's package name
+as a prefix. This ensures they are unique, in case your app interacts with other apps.</p>
<h2 id="StartActivity">Start the Second Activity</h2>
<p>To start an activity, you simply need to call {@link android.app.Activity#startActivity
-startActivity()} and pass it your {@link android.content.Intent}.</p>
-
-<p>The system receives this call and starts an instance of the {@link android.app.Activity}
+startActivity()} and pass it your {@link android.content.Intent}. The system receives this call
+and starts an instance of the {@link android.app.Activity}
specified by the {@link android.content.Intent}.</p>
-<p>With this method included, the complete {@code sendMessage()} method that's invoked by the Send
+<p>With this new code, the complete {@code sendMessage()} method that's invoked by the Send
button now looks like this:</p>
<pre>
-/** Called when the user selects the Send button */
+/** Called when the user clicks the Send button */
public void sendMessage(View view) {
Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById(R.id.edit_message);
@@ -195,20 +194,48 @@
<h2 id="CreateActivity">Create the Second Activity</h2>
-<p>In your project, create a new class file under the <code>src/<package-name>/</code>
-directory called <code>DisplayMessageActivity.java</code>.</p>
+<div class="figure" style="width:400px">
+<img src="{@docRoot}images/training/firstapp/adt-new-activity.png" alt="" />
+<p class="img-caption"><strong>Figure 1.</strong> The new activity wizard in Eclipse.</p>
+</div>
-<p class="note"><strong>Tip:</strong> In Eclipse, right-click the package name under the
-<code>src/</code> directory and select <strong>New > Class</strong>.
-Enter "DisplayMessageActivity" for the name and {@code android.app.Activity} for the superclass.</p>
+<p>To create a new activity using Eclipse:</p>
-<p>Inside the class, add the {@link android.app.Activity#onCreate onCreate()} callback method:</p>
+<ol>
+ <li>Click New <img src="{@docRoot}images/tools/eclipse-new.png"
+ style="vertical-align:baseline;margin:0" /> in the toolbar.</li>
+ <li>In the window that appears, open the <strong>Android</strong> folder
+ and select <strong>Android Activity</strong>. Click <strong>Next</strong>.</li>
+ <li>Select <strong>BlankActivity</strong> and click <strong>Next</strong>.</li>
+ <li>Fill in the activity details:
+ <ul>
+ <li><em>Project</em>: MyFirstApp</li>
+ <li><em>Activity Name</em>: DisplayMessageActivity</li>
+ <li><em>Layout Name</em>: activity_display_message</li>
+ <li><em>Navigation Type</em>: None</li>
+ <li><em>Hierarchial Parent</em>: com.example.myfirstapp.MainActivity</li>
+ <li><em>Title</em>: My Message</li>
+ </ul>
+ <p>Click <strong>Finish</strong>.</p>
+ </li>
+</ol>
+
+<p>If you're using a different IDE or the command line tools, create a new file named
+{@code DisplayMessageActivity.java} in the project's <code>src/</code> directory, next to
+the original {@code MainActivity.java} file.</p>
+
+<p>Open the {@code DisplayMessageActivity.java} file. If you used Eclipse to create it, the class
+already includes an implementation of the required {@link android.app.Activity#onCreate onCreate()}
+method. There's also an implemtation of the {@link android.app.Activity#onCreateOptionsMenu
+onCreateOptionsMenu()} method, but
+you won't need it for this app so you can remove it. The class should look like this:</p>
<pre>
public class DisplayMessageActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_display_message);
}
}
</pre>
@@ -216,7 +243,7 @@
<p>All subclasses of {@link android.app.Activity} must implement the {@link
android.app.Activity#onCreate onCreate()} method. The system calls this when creating a new
instance of the activity. It is where you must define the activity layout and where you should
-initialize essential activity components.</p>
+perform initial setup for the activity components.</p>
@@ -226,22 +253,39 @@
<a
href="{@docRoot}guide/topics/manifest/activity-element.html">{@code <activity>}</a> element.</p>
-<p>Because {@code DisplayMessageActivity} is invoked using an explicit intent, it does not require
-any intent filters (such as those you can see in the manifest for <code>MyFirstActivity</code>). So
-the declaration for <code>DisplayMessageActivity</code> can be simply one line of code inside the <a
-href="{@docRoot}guide/topics/manifest/application-element.html">{@code <application>}</a>
-element:</p>
+<p>When you use the Eclipse tools to create the activity, it creates a default entry. It should
+look like this:</p>
<pre>
<application ... >
- <activity android:name="com.example.myapp.DisplayMessageActivity" />
...
+ <activity
+ android:name=".DisplayMessageActivity"
+ android:label="@string/title_activity_display_message" >
+ <meta-data
+ android:name="android.support.PARENT_ACTIVITY"
+ android:value="com.example.myfirstapp.MainActivity" />
+ </activity>
</application>
</pre>
+<p>The <a href="{@docRoot}guide/topics/manifest/meta-data-element.html">{@code
+ <meta-data>}</a> element declares the name of this activity's parent activity
+ within the app's logical hierarchy. The Android <a
+href="{@docRoot}tools/extras/support-library.html">Support Library</a> uses this information
+ to implement default navigation behaviors, such as <a
+ href="{@docRoot}design/patterns/navigation.html">Up navigation</a>.</p>
+
+<p class="note"><strong>Note:</strong> During <a
+href="{@docRoot}sdk/installing/adding-packages.html">installation</a>, you should have downloaded
+the latest Support Library. Eclipse automatically includes this library in your app project (you
+can see the library's JAR file listed under <em>Android Dependencies</em>). If you're not using
+Eclipse, you may need to manually add the library to your project—follow this guide for <a
+href="{@docRoot}tools/extras/support-library.html#SettingUp">setting up the Support Library</a>.</p>
+
<p>The app is now runnable because the {@link android.content.Intent} in the
first activity now resolves to the {@code DisplayMessageActivity} class. If you run the app now,
-pressing the Send button starts the
+clicking the Send button starts the
second activity, but it doesn't show anything yet.</p>
@@ -249,15 +293,15 @@
<p>Every {@link android.app.Activity} is invoked by an {@link android.content.Intent}, regardless of
how the user navigated there. You can get the {@link android.content.Intent} that started your
-activity by calling {@link android.app.Activity#getIntent()} and the retrieve data contained
+activity by calling {@link android.app.Activity#getIntent()} and retrieve the data contained
within it.</p>
<p>In the {@code DisplayMessageActivity} class’s {@link android.app.Activity#onCreate onCreate()}
-method, get the intent and extract the message delivered by {@code MyFirstActivity}:</p>
+method, get the intent and extract the message delivered by {@code MainActivity}:</p>
<pre>
Intent intent = getIntent();
-String message = intent.getStringExtra(MyFirstActivity.EXTRA_MESSAGE);
+String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
</pre>
@@ -279,22 +323,23 @@
// Get the message from the intent
Intent intent = getIntent();
- String message = intent.getStringExtra(MyFirstActivity.EXTRA_MESSAGE);
+ String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
// Create the text view
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(message);
+ // Set the text view as the activity layout
setContentView(textView);
}
</pre>
-<p>You can now run the app, type a message in the text field, press Send, and view the message on
-the second activity.</p>
+<p>You can now run the app. When it opens, type a message in the text field, click Send,
+ and the message appears on the second activity.</p>
<img src="{@docRoot}images/training/firstapp/firstapp.png" />
-<p class="img-caption"><strong>Figure 1.</strong> Both activities in the final app, running
+<p class="img-caption"><strong>Figure 2.</strong> Both activities in the final app, running
on Android 4.0.
<p>That's it, you've built your first Android app!</p>
diff --git a/keystore/tests/src/android/security/KeyStoreTest.java b/keystore/tests/src/android/security/KeyStoreTest.java
index 008d682..91c56d6 100755
--- a/keystore/tests/src/android/security/KeyStoreTest.java
+++ b/keystore/tests/src/android/security/KeyStoreTest.java
@@ -35,9 +35,9 @@
public class KeyStoreTest extends ActivityUnitTestCase<Activity> {
private static final String TEST_PASSWD = "12345678";
private static final String TEST_PASSWD2 = "87654321";
- private static final String TEST_KEYNAME = "testkey";
- private static final String TEST_KEYNAME1 = "testkey1";
- private static final String TEST_KEYNAME2 = "testkey2";
+ private static final String TEST_KEYNAME = "test-key";
+ private static final String TEST_KEYNAME1 = "test-key.1";
+ private static final String TEST_KEYNAME2 = "test-key.2";
private static final byte[] TEST_KEYVALUE = "test value".getBytes(Charsets.UTF_8);
// "Hello, World" in Chinese
@@ -45,10 +45,12 @@
private static final byte[] TEST_I18N_VALUE = TEST_I18N_KEY.getBytes(Charsets.UTF_8);
// Test vector data for signatures
- private static final byte[] TEST_DATA = {
- (byte) 0x00, (byte) 0xA0, (byte) 0xFF, (byte) 0x0A, (byte) 0x00, (byte) 0xFF,
- (byte) 0xAA, (byte) 0x55, (byte) 0x05, (byte) 0x5A,
- };
+ private static final byte[] TEST_DATA = new byte[256];
+ static {
+ for (int i = 0; i < TEST_DATA.length; i++) {
+ TEST_DATA[i] = (byte) i;
+ }
+ }
private KeyStore mKeyStore = null;
@@ -155,9 +157,9 @@
}
public void testDelete() throws Exception {
- assertTrue(mKeyStore.delete(TEST_KEYNAME));
+ assertFalse(mKeyStore.delete(TEST_KEYNAME));
mKeyStore.password(TEST_PASSWD);
- assertTrue(mKeyStore.delete(TEST_KEYNAME));
+ assertFalse(mKeyStore.delete(TEST_KEYNAME));
mKeyStore.put(TEST_KEYNAME, TEST_KEYVALUE);
assertTrue(Arrays.equals(TEST_KEYVALUE, mKeyStore.get(TEST_KEYNAME)));
diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java
index e76d25a..870a4a9 100644
--- a/media/java/android/media/MediaPlayer.java
+++ b/media/java/android/media/MediaPlayer.java
@@ -2026,6 +2026,7 @@
if (msg.obj instanceof Parcel) {
Parcel parcel = (Parcel)msg.obj;
TimedText text = new TimedText(parcel);
+ parcel.recycle();
mOnTimedTextListener.onTimedText(mMediaPlayer, text);
}
}
diff --git a/media/jni/android_media_MediaPlayer.cpp b/media/jni/android_media_MediaPlayer.cpp
index de22e09..c2a6889 100644
--- a/media/jni/android_media_MediaPlayer.cpp
+++ b/media/jni/android_media_MediaPlayer.cpp
@@ -72,7 +72,6 @@
JNIMediaPlayerListener();
jclass mClass; // Reference to MediaPlayer class
jobject mObject; // Weak ref to MediaPlayer Java object to call on
- jobject mParcel;
};
JNIMediaPlayerListener::JNIMediaPlayerListener(JNIEnv* env, jobject thiz, jobject weak_thiz)
@@ -91,7 +90,6 @@
// We use a weak reference so the MediaPlayer object can be garbage collected.
// The reference is only used as a proxy for callbacks.
mObject = env->NewGlobalRef(weak_thiz);
- mParcel = env->NewGlobalRef(createJavaParcelObject(env));
}
JNIMediaPlayerListener::~JNIMediaPlayerListener()
@@ -100,20 +98,18 @@
JNIEnv *env = AndroidRuntime::getJNIEnv();
env->DeleteGlobalRef(mObject);
env->DeleteGlobalRef(mClass);
-
- recycleJavaParcelObject(env, mParcel);
- env->DeleteGlobalRef(mParcel);
}
void JNIMediaPlayerListener::notify(int msg, int ext1, int ext2, const Parcel *obj)
{
JNIEnv *env = AndroidRuntime::getJNIEnv();
if (obj && obj->dataSize() > 0) {
- if (mParcel != NULL) {
- Parcel* nativeParcel = parcelForJavaObject(env, mParcel);
+ jobject jParcel = createJavaParcelObject(env);
+ if (jParcel != NULL) {
+ Parcel* nativeParcel = parcelForJavaObject(env, jParcel);
nativeParcel->setData(obj->data(), obj->dataSize());
env->CallStaticVoidMethod(mClass, fields.post_event, mObject,
- msg, ext1, ext2, mParcel);
+ msg, ext1, ext2, jParcel);
}
} else {
env->CallStaticVoidMethod(mClass, fields.post_event, mObject,
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java b/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java
index 504bb63..fb6ff24 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java
@@ -147,7 +147,7 @@
if (enableScreenRotation) {
if (DEBUG) Log.d(TAG, "Rotation sensor for lock screen On!");
- mWindowLayoutParams.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR;
+ mWindowLayoutParams.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_USER;
} else {
if (DEBUG) Log.d(TAG, "Rotation sensor for lock screen Off!");
mWindowLayoutParams.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
diff --git a/telephony/java/android/telephony/cdma/CdmaSmsCbProgramData.java b/telephony/java/android/telephony/cdma/CdmaSmsCbProgramData.java
index f94efd8..010ad2b 100644
--- a/telephony/java/android/telephony/cdma/CdmaSmsCbProgramData.java
+++ b/telephony/java/android/telephony/cdma/CdmaSmsCbProgramData.java
@@ -81,8 +81,8 @@
/** Service category to modify. */
private final int mCategory;
- /** Language used for service category name (ISO 639 two character code). */
- private final String mLanguage;
+ /** Language used for service category name (defined in BearerData.LANGUAGE_*). */
+ private final int mLanguage;
/** Maximum number of messages to store for this service category. */
private final int mMaxMessages;
@@ -94,7 +94,7 @@
private final String mCategoryName;
/** Create a new CdmaSmsCbProgramData object with the specified values. */
- public CdmaSmsCbProgramData(int operation, int category, String language, int maxMessages,
+ public CdmaSmsCbProgramData(int operation, int category, int language, int maxMessages,
int alertOption, String categoryName) {
mOperation = operation;
mCategory = category;
@@ -108,7 +108,7 @@
CdmaSmsCbProgramData(Parcel in) {
mOperation = in.readInt();
mCategory = in.readInt();
- mLanguage = in.readString();
+ mLanguage = in.readInt();
mMaxMessages = in.readInt();
mAlertOption = in.readInt();
mCategoryName = in.readString();
@@ -124,7 +124,7 @@
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(mOperation);
dest.writeInt(mCategory);
- dest.writeString(mLanguage);
+ dest.writeInt(mLanguage);
dest.writeInt(mMaxMessages);
dest.writeInt(mAlertOption);
dest.writeString(mCategoryName);
@@ -147,10 +147,10 @@
}
/**
- * Returns the ISO-639-1 language code for the service category name, or null if not present.
- * @return a two-digit ISO-639-1 language code, e.g. "en" for English
+ * Returns the CDMA language code for this service category.
+ * @return one of the language values defined in BearerData.LANGUAGE_*
*/
- public String getLanguageCode() {
+ public int getLanguage() {
return mLanguage;
}
@@ -171,7 +171,7 @@
}
/**
- * Returns the service category name, in the language specified by {@link #getLanguageCode()}.
+ * Returns the service category name, in the language specified by {@link #getLanguage()}.
* @return an optional service category name
*/
public String getCategoryName() {
diff --git a/telephony/java/android/telephony/cdma/CdmaSmsCbProgramResults.java b/telephony/java/android/telephony/cdma/CdmaSmsCbProgramResults.java
new file mode 100644
index 0000000..68bfa3c
--- /dev/null
+++ b/telephony/java/android/telephony/cdma/CdmaSmsCbProgramResults.java
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.telephony.cdma;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * CDMA Service Category Program Results from SCPT teleservice SMS.
+ *
+ * {@hide}
+ */
+public class CdmaSmsCbProgramResults implements Parcelable {
+
+ /** Program result: success. */
+ public static final int RESULT_SUCCESS = 0;
+
+ /** Program result: memory limit exceeded. */
+ public static final int RESULT_MEMORY_LIMIT_EXCEEDED = 1;
+
+ /** Program result: limit exceeded. */
+ public static final int RESULT_CATEGORY_LIMIT_EXCEEDED = 2;
+
+ /** Program result: category already opted in. */
+ public static final int RESULT_CATEGORY_ALREADY_ADDED = 3;
+
+ /** Program result: category already opted in. */
+ public static final int RESULT_CATEGORY_ALREADY_DELETED = 4;
+
+ /** Program result: invalid MAX_MESSAGES. */
+ public static final int RESULT_INVALID_MAX_MESSAGES = 5;
+
+ /** Program result: invalid ALERT_OPTION. */
+ public static final int RESULT_INVALID_ALERT_OPTION = 6;
+
+ /** Program result: invalid service category name. */
+ public static final int RESULT_INVALID_CATEGORY_NAME = 7;
+
+ /** Program result: unspecified programming failure. */
+ public static final int RESULT_UNSPECIFIED_FAILURE = 8;
+
+ /** Service category to modify. */
+ private final int mCategory;
+
+ /** Language used for service category name (defined in BearerData.LANGUAGE_*). */
+ private final int mLanguage;
+
+ /** Result of service category programming for this category. */
+ private final int mCategoryResult;
+
+ /** Create a new CdmaSmsCbProgramResults object with the specified values. */
+ public CdmaSmsCbProgramResults(int category, int language, int categoryResult) {
+ mCategory = category;
+ mLanguage = language;
+ mCategoryResult = categoryResult;
+ }
+
+ /** Create a new CdmaSmsCbProgramResults object from a Parcel. */
+ CdmaSmsCbProgramResults(Parcel in) {
+ mCategory = in.readInt();
+ mLanguage = in.readInt();
+ mCategoryResult = in.readInt();
+ }
+
+ /**
+ * Flatten this object into a Parcel.
+ *
+ * @param dest The Parcel in which the object should be written.
+ * @param flags Additional flags about how the object should be written (ignored).
+ */
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(mCategory);
+ dest.writeInt(mLanguage);
+ dest.writeInt(mCategoryResult);
+ }
+
+ /**
+ * Returns the CDMA service category to modify.
+ * @return a 16-bit CDMA service category value
+ */
+ public int getCategory() {
+ return mCategory;
+ }
+
+ /**
+ * Returns the CDMA language code for this service category.
+ * @return one of the language values defined in BearerData.LANGUAGE_*
+ */
+ public int getLanguage() {
+ return mLanguage;
+ }
+
+ /**
+ * Returns the result of service programming for this category
+ * @return the result of service programming for this category
+ */
+ public int getCategoryResult() {
+ return mCategoryResult;
+ }
+
+ @Override
+ public String toString() {
+ return "CdmaSmsCbProgramResults{category=" + mCategory
+ + ", language=" + mLanguage + ", result=" + mCategoryResult + '}';
+ }
+
+ /**
+ * Describe the kinds of special objects contained in the marshalled representation.
+ * @return a bitmask indicating this Parcelable contains no special objects
+ */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /** Creator for unparcelling objects. */
+ public static final Parcelable.Creator<CdmaSmsCbProgramResults>
+ CREATOR = new Parcelable.Creator<CdmaSmsCbProgramResults>() {
+ @Override
+ public CdmaSmsCbProgramResults createFromParcel(Parcel in) {
+ return new CdmaSmsCbProgramResults(in);
+ }
+
+ @Override
+ public CdmaSmsCbProgramResults[] newArray(int size) {
+ return new CdmaSmsCbProgramResults[size];
+ }
+ };
+}
diff --git a/telephony/java/com/android/internal/telephony/SMSDispatcher.java b/telephony/java/com/android/internal/telephony/SMSDispatcher.java
index 07d733e..40c22a7 100644
--- a/telephony/java/com/android/internal/telephony/SMSDispatcher.java
+++ b/telephony/java/com/android/internal/telephony/SMSDispatcher.java
@@ -339,6 +339,22 @@
}
/**
+ * Grabs a wake lock and sends intent as an ordered broadcast.
+ * Used for setting a custom result receiver for CDMA SCPD.
+ *
+ * @param intent intent to broadcast
+ * @param permission Receivers are required to have this permission
+ * @param resultReceiver the result receiver to use
+ */
+ public void dispatch(Intent intent, String permission, BroadcastReceiver resultReceiver) {
+ // Hold a wake lock for WAKE_LOCK_TIMEOUT seconds, enough to give any
+ // receivers time to take their own wake locks.
+ mWakeLock.acquire(WAKE_LOCK_TIMEOUT);
+ mContext.sendOrderedBroadcast(intent, permission, resultReceiver,
+ this, Activity.RESULT_OK, null, null);
+ }
+
+ /**
* Called when SMS send completes. Broadcasts a sentIntent on success.
* On failure, either sets up retries or broadcasts a sentIntent with
* the failure in the result code.
diff --git a/telephony/java/com/android/internal/telephony/cat/CatService.java b/telephony/java/com/android/internal/telephony/cat/CatService.java
index 2b37072..17574ce 100644
--- a/telephony/java/com/android/internal/telephony/cat/CatService.java
+++ b/telephony/java/com/android/internal/telephony/cat/CatService.java
@@ -169,8 +169,11 @@
} catch (ClassCastException e) {
// for error handling : cast exception
CatLog.d(this, "Fail to parse proactive command");
- sendTerminalResponse(mCurrntCmd.mCmdDet, ResultCode.CMD_DATA_NOT_UNDERSTOOD,
+ // Don't send Terminal Resp if command detail is not available
+ if (mCurrntCmd != null) {
+ sendTerminalResponse(mCurrntCmd.mCmdDet, ResultCode.CMD_DATA_NOT_UNDERSTOOD,
false, 0x00, null);
+ }
break;
}
if (cmdParams != null) {
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java b/telephony/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java
index e6b45f6..a6b32f9 100755
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java
@@ -20,20 +20,23 @@
import android.app.Activity;
import android.app.PendingIntent;
import android.app.PendingIntent.CanceledException;
-import android.content.ContentValues;
+import android.content.BroadcastReceiver;
+import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
-import android.database.Cursor;
-import android.database.SQLException;
+import android.content.res.Resources;
+import android.os.Bundle;
import android.os.Message;
import android.os.SystemProperties;
import android.preference.PreferenceManager;
import android.provider.Telephony;
import android.provider.Telephony.Sms.Intents;
+import android.telephony.PhoneNumberUtils;
import android.telephony.SmsCbMessage;
import android.telephony.SmsManager;
import android.telephony.SmsMessage.MessageClass;
import android.telephony.cdma.CdmaSmsCbProgramData;
+import android.telephony.cdma.CdmaSmsCbProgramResults;
import android.util.Log;
import com.android.internal.telephony.CommandsInterface;
@@ -45,16 +48,17 @@
import com.android.internal.telephony.SmsUsageMonitor;
import com.android.internal.telephony.TelephonyProperties;
import com.android.internal.telephony.WspTypeDecoder;
+import com.android.internal.telephony.cdma.sms.BearerData;
+import com.android.internal.telephony.cdma.sms.CdmaSmsAddress;
import com.android.internal.telephony.cdma.sms.SmsEnvelope;
import com.android.internal.telephony.cdma.sms.UserData;
-import com.android.internal.util.HexDump;
import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
-import java.util.List;
-
-import android.content.res.Resources;
final class CdmaSMSDispatcher extends SMSDispatcher {
@@ -107,15 +111,16 @@
* {@link android.telephony.cdma.CdmaSmsCbProgramData} objects.
*/
private void handleServiceCategoryProgramData(SmsMessage sms) {
- List<CdmaSmsCbProgramData> programDataList = sms.getSmsCbProgramData();
+ ArrayList<CdmaSmsCbProgramData> programDataList = sms.getSmsCbProgramData();
if (programDataList == null) {
Log.e(TAG, "handleServiceCategoryProgramData: program data list is null!");
return;
}
Intent intent = new Intent(Intents.SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED_ACTION);
- intent.putExtra("program_data_list", (CdmaSmsCbProgramData[]) programDataList.toArray());
- dispatch(intent, RECEIVE_SMS_PERMISSION);
+ intent.putExtra("sender", sms.getOriginatingAddress());
+ intent.putParcelableArrayListExtra("program_data", programDataList);
+ dispatch(intent, RECEIVE_SMS_PERMISSION, mScpResultsReceiver);
}
/** {@inheritDoc} */
@@ -425,4 +430,72 @@
}
return false;
}
+
+ // Receiver for Service Category Program Data results.
+ // We already ACK'd the original SCPD SMS, so this sends a new response SMS.
+ // TODO: handle retries if the RIL returns an error.
+ private final BroadcastReceiver mScpResultsReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ int rc = getResultCode();
+ boolean success = (rc == Activity.RESULT_OK) || (rc == Intents.RESULT_SMS_HANDLED);
+ if (!success) {
+ Log.e(TAG, "SCP results error: result code = " + rc);
+ return;
+ }
+ Bundle extras = getResultExtras(false);
+ if (extras == null) {
+ Log.e(TAG, "SCP results error: missing extras");
+ return;
+ }
+ String sender = extras.getString("sender");
+ if (sender == null) {
+ Log.e(TAG, "SCP results error: missing sender extra.");
+ return;
+ }
+ ArrayList<CdmaSmsCbProgramResults> results
+ = extras.getParcelableArrayList("results");
+ if (results == null) {
+ Log.e(TAG, "SCP results error: missing results extra.");
+ return;
+ }
+
+ BearerData bData = new BearerData();
+ bData.messageType = BearerData.MESSAGE_TYPE_SUBMIT;
+ bData.messageId = SmsMessage.getNextMessageId();
+ bData.serviceCategoryProgramResults = results;
+ byte[] encodedBearerData = BearerData.encode(bData);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(100);
+ DataOutputStream dos = new DataOutputStream(baos);
+ try {
+ dos.writeInt(SmsEnvelope.TELESERVICE_SCPT);
+ dos.writeInt(0); //servicePresent
+ dos.writeInt(0); //serviceCategory
+ CdmaSmsAddress destAddr = CdmaSmsAddress.parse(
+ PhoneNumberUtils.cdmaCheckAndProcessPlusCode(sender));
+ dos.write(destAddr.digitMode);
+ dos.write(destAddr.numberMode);
+ dos.write(destAddr.ton); // number_type
+ dos.write(destAddr.numberPlan);
+ dos.write(destAddr.numberOfDigits);
+ dos.write(destAddr.origBytes, 0, destAddr.origBytes.length); // digits
+ // Subaddress is not supported.
+ dos.write(0); //subaddressType
+ dos.write(0); //subaddr_odd
+ dos.write(0); //subaddr_nbr_of_digits
+ dos.write(encodedBearerData.length);
+ dos.write(encodedBearerData, 0, encodedBearerData.length);
+ // Ignore the RIL response. TODO: implement retry if SMS send fails.
+ mCm.sendCdmaSms(baos.toByteArray(), null);
+ } catch (IOException e) {
+ Log.e(TAG, "exception creating SCP results PDU", e);
+ } finally {
+ try {
+ dos.close();
+ } catch (IOException ignored) {
+ }
+ }
+ }
+ };
}
diff --git a/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java b/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java
index a723de3..9a0ebed 100644
--- a/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java
+++ b/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java
@@ -42,6 +42,7 @@
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
import static android.telephony.SmsMessage.MessageClass;
@@ -468,7 +469,13 @@
* {@link com.android.internal.telephony.cdma.sms.SmsEnvelope#MESSAGE_TYPE_ACKNOWLEDGE},
*/
/* package */ int getMessageType() {
- return mEnvelope.messageType;
+ // NOTE: mEnvelope.messageType is not set correctly for cell broadcasts with some RILs.
+ // Use the service category parameter to detect CMAS and other cell broadcast messages.
+ if (mEnvelope.serviceCategory != 0) {
+ return SmsEnvelope.MESSAGE_TYPE_BROADCAST;
+ } else {
+ return SmsEnvelope.MESSAGE_TYPE_POINT_TO_POINT;
+ }
}
/**
@@ -775,7 +782,7 @@
* binder-call, and hence should be thread-safe, it has been
* synchronized.
*/
- private synchronized static int getNextMessageId() {
+ synchronized static int getNextMessageId() {
// Testing and dialog with partners has indicated that
// msgId==0 is (sometimes?) treated specially by lower levels.
// Specifically, the ID is not preserved for delivery ACKs.
@@ -991,7 +998,7 @@
* Returns the list of service category program data, if present.
* @return a list of CdmaSmsCbProgramData objects, or null if not present
*/
- List<CdmaSmsCbProgramData> getSmsCbProgramData() {
+ ArrayList<CdmaSmsCbProgramData> getSmsCbProgramData() {
return mBearerData.serviceCategoryProgramData;
}
}
diff --git a/telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java b/telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java
index 0f49762..5cacd23 100755
--- a/telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java
+++ b/telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java
@@ -18,9 +18,9 @@
import android.content.res.Resources;
import android.telephony.SmsCbCmasInfo;
-import android.telephony.SmsCbMessage;
import android.telephony.SmsMessage;
import android.telephony.cdma.CdmaSmsCbProgramData;
+import android.telephony.cdma.CdmaSmsCbProgramResults;
import android.text.format.Time;
import android.util.Log;
@@ -32,8 +32,6 @@
import com.android.internal.util.BitwiseOutputStream;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
import java.util.TimeZone;
import static android.telephony.SmsMessage.ENCODING_16BIT;
@@ -353,7 +351,14 @@
* {@link android.telephony.cdma.CdmaSmsCbProgramData} objects containing the
* operation(s) to perform.
*/
- public List<CdmaSmsCbProgramData> serviceCategoryProgramData;
+ public ArrayList<CdmaSmsCbProgramData> serviceCategoryProgramData;
+
+ /**
+ * The Service Category Program Results subparameter informs the message center
+ * of the results of a Service Category Program Data request.
+ */
+ public ArrayList<CdmaSmsCbProgramResults> serviceCategoryProgramResults;
+
private static class CodingException extends Exception {
public CodingException(String s) {
@@ -857,6 +862,21 @@
outStream.skip(6);
}
+ private static void encodeScpResults(BearerData bData, BitwiseOutputStream outStream)
+ throws BitwiseOutputStream.AccessException
+ {
+ ArrayList<CdmaSmsCbProgramResults> results = bData.serviceCategoryProgramResults;
+ outStream.write(8, (results.size() * 4)); // 4 octets per program result
+ for (CdmaSmsCbProgramResults result : results) {
+ int category = result.getCategory();
+ outStream.write(8, category >> 8);
+ outStream.write(8, category);
+ outStream.write(8, result.getLanguage());
+ outStream.write(4, result.getCategoryResult());
+ outStream.skip(4);
+ }
+ }
+
/**
* Create serialized representation for BearerData object.
* (See 3GPP2 C.R1001-F, v1.0, section 4.5 for layout details)
@@ -916,6 +936,10 @@
outStream.write(8, SUBPARAM_MESSAGE_STATUS);
encodeMsgStatus(bData, outStream);
}
+ if (bData.serviceCategoryProgramResults != null) {
+ outStream.write(8, SUBPARAM_SERVICE_CATEGORY_PROGRAM_RESULTS);
+ encodeScpResults(bData, outStream);
+ }
return outStream.toByteArray();
} catch (BitwiseOutputStream.AccessException ex) {
Log.e(LOG_TAG, "BearerData encode failed: " + ex);
@@ -1638,7 +1662,7 @@
while (paramBits >= CATEGORY_FIELD_MIN_SIZE) {
int operation = inStream.read(4);
int category = (inStream.read(8) << 8) | inStream.read(8);
- String language = getLanguageCodeForValue(inStream.read(8));
+ int language = inStream.read(8);
int maxMessages = inStream.read(8);
int alertOption = inStream.read(4);
int numFields = inStream.read(8);
diff --git a/telephony/tests/telephonytests/src/com/android/internal/telephony/cdma/CdmaSmsCbTest.java b/telephony/tests/telephonytests/src/com/android/internal/telephony/cdma/CdmaSmsCbTest.java
index d2faceb..a95f60c 100644
--- a/telephony/tests/telephonytests/src/com/android/internal/telephony/cdma/CdmaSmsCbTest.java
+++ b/telephony/tests/telephonytests/src/com/android/internal/telephony/cdma/CdmaSmsCbTest.java
@@ -635,7 +635,7 @@
assertEquals(CdmaSmsCbProgramData.OPERATION_ADD_CATEGORY, programData.getOperation());
assertEquals(SmsEnvelope.SERVICE_CATEGORY_CMAS_EXTREME_THREAT, programData.getCategory());
assertEquals(CAT_EXTREME_THREAT, programData.getCategoryName());
- assertEquals("en", programData.getLanguageCode());
+ assertEquals(BearerData.LANGUAGE_ENGLISH, programData.getLanguage());
assertEquals(100, programData.getMaxMessages());
assertEquals(CdmaSmsCbProgramData.ALERT_OPTION_DEFAULT_ALERT, programData.getAlertOption());
}
@@ -692,7 +692,7 @@
assertEquals(CdmaSmsCbProgramData.OPERATION_DELETE_CATEGORY, programData.getOperation());
assertEquals(SmsEnvelope.SERVICE_CATEGORY_CMAS_SEVERE_THREAT, programData.getCategory());
assertEquals(CAT_SEVERE_THREAT, programData.getCategoryName());
- assertEquals("en", programData.getLanguageCode());
+ assertEquals(BearerData.LANGUAGE_ENGLISH, programData.getLanguage());
assertEquals(0, programData.getMaxMessages());
assertEquals(CdmaSmsCbProgramData.ALERT_OPTION_NO_ALERT, programData.getAlertOption());
@@ -701,7 +701,7 @@
assertEquals(SmsEnvelope.SERVICE_CATEGORY_CMAS_CHILD_ABDUCTION_EMERGENCY,
programData.getCategory());
assertEquals(CAT_AMBER_ALERTS, programData.getCategoryName());
- assertEquals("en", programData.getLanguageCode());
+ assertEquals(BearerData.LANGUAGE_ENGLISH, programData.getLanguage());
assertEquals(0, programData.getMaxMessages());
assertEquals(CdmaSmsCbProgramData.ALERT_OPTION_NO_ALERT, programData.getAlertOption());
}
diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp
index a69adc1..ee076e6 100644
--- a/tools/aapt/Resource.cpp
+++ b/tools/aapt/Resource.cpp
@@ -2210,7 +2210,7 @@
status_t
writeProguardForXml(ProguardKeepSet* keep, const sp<AaptFile>& layoutFile,
- const char* startTag, const KeyedVector<String8, NamespaceAttributePair>* tagAttrPairs)
+ const char* startTag, const KeyedVector<String8, Vector<NamespaceAttributePair> >* tagAttrPairs)
{
status_t err;
ResXMLTree tree;
@@ -2254,17 +2254,21 @@
} else if (tagAttrPairs != NULL) {
ssize_t tagIndex = tagAttrPairs->indexOfKey(tag);
if (tagIndex >= 0) {
- const NamespaceAttributePair& nsAttr = tagAttrPairs->valueAt(tagIndex);
- ssize_t attrIndex = tree.indexOfAttribute(nsAttr.ns, nsAttr.attr);
- if (attrIndex < 0) {
- // fprintf(stderr, "%s:%d: <%s> does not have attribute %s:%s.\n",
- // layoutFile->getPrintableSource().string(), tree.getLineNumber(),
- // tag.string(), nsAttr.ns, nsAttr.attr);
- } else {
- size_t len;
- addProguardKeepRule(keep,
- String8(tree.getAttributeStringValue(attrIndex, &len)), NULL,
- layoutFile->getPrintableSource(), tree.getLineNumber());
+ const Vector<NamespaceAttributePair>& nsAttrVector = tagAttrPairs->valueAt(tagIndex);
+ for (size_t i = 0; i < nsAttrVector.size(); i++) {
+ const NamespaceAttributePair& nsAttr = nsAttrVector[i];
+
+ ssize_t attrIndex = tree.indexOfAttribute(nsAttr.ns, nsAttr.attr);
+ if (attrIndex < 0) {
+ // fprintf(stderr, "%s:%d: <%s> does not have attribute %s:%s.\n",
+ // layoutFile->getPrintableSource().string(), tree.getLineNumber(),
+ // tag.string(), nsAttr.ns, nsAttr.attr);
+ } else {
+ size_t len;
+ addProguardKeepRule(keep,
+ String8(tree.getAttributeStringValue(attrIndex, &len)), NULL,
+ layoutFile->getPrintableSource(), tree.getLineNumber());
+ }
}
}
}
@@ -2280,9 +2284,18 @@
return NO_ERROR;
}
-static void addTagAttrPair(KeyedVector<String8, NamespaceAttributePair>* dest,
+static void addTagAttrPair(KeyedVector<String8, Vector<NamespaceAttributePair> >* dest,
const char* tag, const char* ns, const char* attr) {
- dest->add(String8(tag), NamespaceAttributePair(ns, attr));
+ String8 tagStr(tag);
+ ssize_t index = dest->indexOfKey(tagStr);
+
+ if (index < 0) {
+ Vector<NamespaceAttributePair> vector;
+ vector.add(NamespaceAttributePair(ns, attr));
+ dest->add(tagStr, vector);
+ } else {
+ dest->editValueAt(index).add(NamespaceAttributePair(ns, attr));
+ }
}
status_t
@@ -2291,13 +2304,13 @@
status_t err;
// tag:attribute pairs that should be checked in layout files.
- KeyedVector<String8, NamespaceAttributePair> kLayoutTagAttrPairs;
+ KeyedVector<String8, Vector<NamespaceAttributePair> > kLayoutTagAttrPairs;
addTagAttrPair(&kLayoutTagAttrPairs, "view", NULL, "class");
addTagAttrPair(&kLayoutTagAttrPairs, "fragment", NULL, "class");
addTagAttrPair(&kLayoutTagAttrPairs, "fragment", RESOURCES_ANDROID_NAMESPACE, "name");
// tag:attribute pairs that should be checked in xml files.
- KeyedVector<String8, NamespaceAttributePair> kXmlTagAttrPairs;
+ KeyedVector<String8, Vector<NamespaceAttributePair> > kXmlTagAttrPairs;
addTagAttrPair(&kXmlTagAttrPairs, "PreferenceScreen", RESOURCES_ANDROID_NAMESPACE, "fragment");
addTagAttrPair(&kXmlTagAttrPairs, "header", RESOURCES_ANDROID_NAMESPACE, "fragment");
@@ -2307,7 +2320,7 @@
const sp<AaptDir>& d = dirs.itemAt(k);
const String8& dirName = d->getLeaf();
const char* startTag = NULL;
- const KeyedVector<String8, NamespaceAttributePair>* tagAttrPairs = NULL;
+ const KeyedVector<String8, Vector<NamespaceAttributePair> >* tagAttrPairs = NULL;
if ((dirName == String8("layout")) || (strncmp(dirName.string(), "layout-", 7) == 0)) {
tagAttrPairs = &kLayoutTagAttrPairs;
} else if ((dirName == String8("xml")) || (strncmp(dirName.string(), "xml-", 4) == 0)) {
@@ -2339,6 +2352,7 @@
if (overlay.get()) {
return writeProguardForLayouts(keep, overlay);
}
+
return NO_ERROR;
}