summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThe Android Automerger <android-build@android.com>2010-05-11 16:40:17 -0700
committerThe Android Automerger <android-build@android.com>2010-05-11 16:40:17 -0700
commit841eb0a43595000b6616f41ac1eb8cbb2e45fac6 (patch)
tree5e4014c259c35c96f1055568a90a49c4861069e3
parent4c42d0bd9d3031c0318b0738aeccb123954c1e88 (diff)
parent6bc3304b74ba41bf9fd132d48c7bb764d631d3fa (diff)
downloadframeworks_base-841eb0a43595000b6616f41ac1eb8cbb2e45fac6.zip
frameworks_base-841eb0a43595000b6616f41ac1eb8cbb2e45fac6.tar.gz
frameworks_base-841eb0a43595000b6616f41ac1eb8cbb2e45fac6.tar.bz2
Merge branch 'froyo' into froyo-release
-rw-r--r--api/8.xml26
-rw-r--r--api/current.xml26
-rw-r--r--common/java/com/android/common/GoogleLogTags.logtags2
-rw-r--r--core/java/android/content/Intent.java2
-rw-r--r--core/java/android/net/Uri.java3
-rw-r--r--core/java/android/webkit/WebView.java37
-rw-r--r--core/res/AndroidManifest.xml8
-rw-r--r--core/tests/coretests/src/android/net/UriTest.java20
-rw-r--r--docs/html/guide/appendix/install-location.jd197
-rw-r--r--docs/html/guide/developing/testing/index.jd37
-rw-r--r--docs/html/guide/developing/testing/testing_eclipse.jd370
-rw-r--r--docs/html/guide/developing/testing/testing_otheride.jd683
-rw-r--r--docs/html/guide/guide_toc.cs28
-rw-r--r--docs/html/guide/topics/manifest/application-element.jd12
-rw-r--r--docs/html/guide/topics/manifest/instrumentation-element.jd8
-rw-r--r--docs/html/guide/topics/manifest/manifest-element.jd1
-rwxr-xr-xdocs/html/guide/topics/testing/testing_android.jd137
-rw-r--r--docs/html/images/home/io-logo.pngbin0 -> 8694 bytes
-rw-r--r--docs/html/index.jd39
-rw-r--r--docs/html/resources/tutorials/testing/helloandroid_test.jd2
-rw-r--r--docs/html/sdk/ndk/index.jd237
-rw-r--r--docs/html/sdk/sdk_toc.cs2
-rw-r--r--include/camera/CameraParameters.h11
-rw-r--r--include/media/stagefright/HTTPDataSource.h1
-rw-r--r--libs/camera/CameraParameters.cpp5
-rw-r--r--media/java/android/media/AudioManager.java36
-rw-r--r--media/java/android/media/AudioService.java33
-rw-r--r--media/java/android/media/MediaScanner.java7
-rw-r--r--media/libstagefright/HTTPDataSource.cpp17
-rw-r--r--media/libstagefright/HTTPStream.cpp17
-rw-r--r--media/libstagefright/OggExtractor.cpp13
-rw-r--r--media/libstagefright/codecs/vorbis/dec/VorbisDecoder.cpp18
-rw-r--r--media/libstagefright/include/HTTPStream.h3
-rw-r--r--services/java/com/android/server/LocationManagerService.java2
-rw-r--r--services/java/com/android/server/NotificationPlayer.java15
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java12
36 files changed, 1769 insertions, 298 deletions
diff --git a/api/8.xml b/api/8.xml
index e757db2..9d259f3 100644
--- a/api/8.xml
+++ b/api/8.xml
@@ -80490,19 +80490,6 @@
<parameter name="volume" type="float">
</parameter>
</method>
-<method name="registerAudioFocusListener"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="l" type="android.media.AudioManager.OnAudioFocusChangeListener">
-</parameter>
-</method>
<method name="registerMediaButtonEventReceiver"
return="void"
abstract="false"
@@ -80762,19 +80749,6 @@
visibility="public"
>
</method>
-<method name="unregisterAudioFocusListener"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="l" type="android.media.AudioManager.OnAudioFocusChangeListener">
-</parameter>
-</method>
<method name="unregisterMediaButtonEventReceiver"
return="void"
abstract="false"
diff --git a/api/current.xml b/api/current.xml
index e757db2..9d259f3 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -80490,19 +80490,6 @@
<parameter name="volume" type="float">
</parameter>
</method>
-<method name="registerAudioFocusListener"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="l" type="android.media.AudioManager.OnAudioFocusChangeListener">
-</parameter>
-</method>
<method name="registerMediaButtonEventReceiver"
return="void"
abstract="false"
@@ -80762,19 +80749,6 @@
visibility="public"
>
</method>
-<method name="unregisterAudioFocusListener"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="l" type="android.media.AudioManager.OnAudioFocusChangeListener">
-</parameter>
-</method>
<method name="unregisterMediaButtonEventReceiver"
return="void"
abstract="false"
diff --git a/common/java/com/android/common/GoogleLogTags.logtags b/common/java/com/android/common/GoogleLogTags.logtags
index a5c9bb0..bf6091a 100644
--- a/common/java/com/android/common/GoogleLogTags.logtags
+++ b/common/java/com/android/common/GoogleLogTags.logtags
@@ -80,7 +80,7 @@ option java_package com.android.common
204004 gtalk_heartbeat_reset (interval_and_nt|1),(ip|3)
# This event is logged when an Rmq v2 packet is sent or received.
-204005 push_messaging (packet_type|1),(persistent_id|3),(stream_id|1),(last_stream_id|1)
+204005 data_messaging (packet_type|1),(persistent_id|3),(stream_id|1),(last_stream_id|1)
#####
# Google Login Service and Setup Wizard
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index ed548c5..6aac4b9 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -1866,7 +1866,7 @@ public class Intent implements Parcelable, Cloneable {
* @hide
*/
public static final String ACTION_REMOTE_INTENT =
- "com.google.android.pushmessaging.intent.RECEIVE";
+ "com.google.android.datamessaging.intent.RECEIVE";
/**
* Broadcast Action: hook for permforming cleanup after a system update.
diff --git a/core/java/android/net/Uri.java b/core/java/android/net/Uri.java
index eca4569..47faaba 100644
--- a/core/java/android/net/Uri.java
+++ b/core/java/android/net/Uri.java
@@ -1588,6 +1588,9 @@ public abstract class Uri implements Parcelable, Comparable<Uri> {
break;
}
final int equalsIndex = keyIndex + encodedKeyLength;
+ if (equalsIndex >= query.length()) {
+ break;
+ }
if (query.charAt(equalsIndex) != '=') {
encodedKeySearchIndex = equalsIndex + 1;
continue;
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 6b316ce..f921caa 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -30,10 +30,12 @@ import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Interpolator;
+import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Picture;
import android.graphics.Point;
import android.graphics.Rect;
+import android.graphics.RectF;
import android.graphics.Region;
import android.graphics.Shader;
import android.graphics.drawable.Drawable;
@@ -1994,6 +1996,23 @@ public class WebView extends AbsoluteLayout
}
/**
+ * Given a x coordinate in view space, convert it to content space.
+ * Returns the result as a float.
+ */
+ private float viewToContentXf(int x) {
+ return x * mInvActualScale;
+ }
+
+ /**
+ * Given a y coordinate in view space, convert it to content space.
+ * Takes into account the height of the title bar if there is one
+ * embedded into the WebView. Returns the result as a float.
+ */
+ private float viewToContentYf(int y) {
+ return (y - getTitleHeight()) * mInvActualScale;
+ }
+
+ /**
* Given a distance in content space, convert it to view space. Note: this
* does not reflect translation, just scaling, so this should not be called
* with coordinates, but should be called for dimensions like width or
@@ -2230,6 +2249,24 @@ public class WebView extends AbsoluteLayout
r.bottom = Math.min(viewToContentY(r.bottom), mContentHeight);
}
+ // Sets r to be our visible rectangle in content coordinates. We use this
+ // method on the native side to compute the position of the fixed layers.
+ // Uses floating coordinates (necessary to correctly place elements when
+ // the scale factor is not 1)
+ private void calcOurContentVisibleRectF(RectF r) {
+ Rect ri = new Rect(0,0,0,0);
+ calcOurVisibleRect(ri);
+ // pin the rect to the bounds of the content
+ r.left = Math.max(viewToContentXf(ri.left), 0.0f);
+ // viewToContentY will remove the total height of the title bar. Add
+ // the visible height back in to account for the fact that if the title
+ // bar is partially visible, the part of the visible rect which is
+ // displaying our content is displaced by that amount.
+ r.top = Math.max(viewToContentYf(ri.top + getVisibleTitleHeight()), 0.0f);
+ r.right = Math.min(viewToContentXf(ri.right), (float)mContentWidth);
+ r.bottom = Math.min(viewToContentYf(ri.bottom), (float)mContentHeight);
+ }
+
static class ViewSizeData {
int mWidth;
int mHeight;
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index db71b21..5a92dbe 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -1225,12 +1225,12 @@
android:description="@string/permlab_copyProtectedData"
android:protectionLevel="signature" />
- <!-- Push messaging permission.
+ <!-- Data messaging permission.
@hide Used internally.
-->
- <permission android:name="android.intent.category.MASTER_CLEAR.permission.PUSH_MESSAGE"
+ <permission android:name="android.intent.category.MASTER_CLEAR.permission.DATA_MESSAGE"
android:protectionLevel="signature" />
- <uses-permission android:name="android.intent.category.MASTER_CLEAR.permission.PUSH_MESSAGE"/>
+ <uses-permission android:name="android.intent.category.MASTER_CLEAR.permission.DATA_MESSAGE"/>
<application android:process="system"
android:persistent="true"
@@ -1314,7 +1314,7 @@
<action android:name="android.intent.action.MASTER_CLEAR" />
<!-- MCS always uses REMOTE_INTENT: category=MASTER_CLEAR -->
- <action android:name="com.google.android.pushmessaging.intent.RECEIVE" />
+ <action android:name="com.google.android.datamessaging.intent.RECEIVE" />
<category android:name="android.intent.category.MASTER_CLEAR" />
</intent-filter>
</receiver>
diff --git a/core/tests/coretests/src/android/net/UriTest.java b/core/tests/coretests/src/android/net/UriTest.java
index 095ee13..a5fda20 100644
--- a/core/tests/coretests/src/android/net/UriTest.java
+++ b/core/tests/coretests/src/android/net/UriTest.java
@@ -582,5 +582,25 @@ public class UriTest extends TestCase {
.appendQueryParameter("bkey", "e f")
.build();
assertNull(uri.getQueryParameter("key"));
+
+ // key is a prefix or suffix of the query
+ uri = Uri.parse("http://test/?qq=foo");
+ assertNull(uri.getQueryParameter("q"));
+ assertNull(uri.getQueryParameter("oo"));
+
+ // escaped keys
+ uri = Uri.parse("http://www.google.com/?a%20b=foo&c%20d=");
+ assertEquals("foo", uri.getQueryParameter("a b"));
+ assertEquals("", uri.getQueryParameter("c d"));
+ assertNull(uri.getQueryParameter("e f"));
+ assertNull(uri.getQueryParameter("b"));
+ assertNull(uri.getQueryParameter("c"));
+ assertNull(uri.getQueryParameter(" d"));
+
+ // empty values
+ uri = Uri.parse("http://www.google.com/?a=&b=&&c=");
+ assertEquals("", uri.getQueryParameter("a"));
+ assertEquals("", uri.getQueryParameter("b"));
+ assertEquals("", uri.getQueryParameter("c"));
}
}
diff --git a/docs/html/guide/appendix/install-location.jd b/docs/html/guide/appendix/install-location.jd
new file mode 100644
index 0000000..77cebc6
--- /dev/null
+++ b/docs/html/guide/appendix/install-location.jd
@@ -0,0 +1,197 @@
+page.title=App Install Location
+@jd:body
+
+
+<div id="qv-wrapper">
+<div id="qv">
+
+ <h2>Quickview</h2>
+ <ul>
+ <li>You can allow your application to install on the device's external storage.</li>
+ <li>Some types of applications should <strong>not</strong> allow installation on the external
+storage.</li>
+ <li>Installing on the external storage is ideal for large applications that are not tightly
+integrated with the system (most commonly, games).</li>
+ </ul>
+
+ <h2>In this document</h2>
+ <ol>
+ <li><a href="#Compatiblity">Backward Compatibility</a></li>
+ <li><a href="#ShouldNot">Applications That Should NOT Install on External Storage</a></li>
+ <li><a href="#Should">Applications That Should Install on External Storage</a></li>
+ </ol>
+
+ <h2>See also</h2>
+ <ol>
+ <li><code><a href="{@docRoot}guide/topics/manifest/manifest-element.html">
+&lt;manifest&gt;</a></code></li>
+ </ol>
+
+</div>
+</div>
+
+<p>Beginning with API Level 8, you can allow your application to be installed on the
+external storage (for example, the device's SD card). This is an optional feature you can declare
+for your application with the <a
+href="{@docRoot}guide/topics/manifest/manifest-element.html#install">{@code
+android:installLocation}</a> manifest attribute. If you do
+<em>not</em> declare this attribute, your application will be installed on the internal storage
+only and it cannot be moved to the external storage.</p>
+
+<p>To allow the system to install your application on the external storage, modify your
+manifest file to include the <a
+href="{@docRoot}guide/topics/manifest/manifest-element.html#install">{@code
+android:installLocation}</a> attribute in the <code><a
+href="{@docRoot}guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></code> element,
+with a value of either "{@code preferExternal}" or "{@code auto}". For example:</p>
+
+<pre>
+&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ android:installLocation="preferExternal"
+ ... &gt;
+</pre>
+
+<p>If you declare "{@code preferExternal}", you request that your application be installed on the
+external storage, but the system does not guarantee that your application will be installed on
+the external storage. If the external storage is full, the system will install it on the internal
+storage. The user can also move your application between the two locations.</p>
+
+<p>If you declare "{@code auto}", you indicate that your application may be installed on the
+external storage, but you don't have a preference of install location. The system will
+decide where to install your application based on several factors. The user can also move your
+application between the two locations.</p>
+
+<p>When your application is installed on the external storage:</p>
+<ul>
+ <li>There is no effect on the application performance so long
+as the external storage is mounted on the device.</li>
+ <li>The {@code .apk} file is saved on the external storage, but all private user data,
+databases, optimized {@code .dex} files, and extracted native code are saved on the
+internal device memory.</li>
+ <li>The unique container in which your application is stored is encrypted with a randomly
+generated key that can be decrypted only by the device that originally installed it. Thus, an
+application installed on an SD card works for only one device.</li>
+ <li>The user can move your application to the internal storage through the system settings.</li>
+</ul>
+
+<p class="warning"><strong>Warning:</strong> When the user enables USB mass storage to share files
+with a computer or unmounts the SD card via the system settings, the external storage is unmounted
+from the device and all applications running on the external storage are immediately killed.</p>
+
+
+
+<h2 id="Compatiblity">Backward Compatibility</h2>
+
+<p>The ability for your application to install on the external storage is a feature available only
+on devices running API Level 8 (Android 2.2) or greater. Existing applications that were built prior
+to API Level 8 will always install on the internal storage and cannot be moved to the external
+storage (even on devices with API Level 8). However, if your application is designed to support an
+API Level <em>lower than</em> 8, you can choose to support this feature for devices with API Level 8
+or greater and still be compatible with devices using an API Level lower than 8.</p>
+
+<p>To allow installation on external storage and remain compatible with versions lower than API
+Level 8:</p>
+<ol>
+ <li>Include the {@code android:installLocation} attribute with a value of "{@code auto}" or
+"{@code preferExternal}" in the <code><a
+href="{@docRoog}guide/topics/manifest/uses-sdk-element.html">&lt;manifest&gt;</a></code>
+element.</li>
+ <li>Leave your {@code android:minSdkVersion} attribute as is (something <em>less
+than</em> "8") and be certain that your application code uses only APIs compatible with that
+level.</li>
+ <li>In order to compile your application, change your build target to API Level 8. This is
+necessary because older Android libraries don't understand the {@code android:installLocation}
+attribute and will not compile your application when it's present.</li>
+</ol>
+
+<p>When your application is installed on a device with an API Level lower than 8, the {@code
+android:installLocation} attribute is ignored and the application is installed on the internal
+storage.</p>
+
+<p class="caution"><strong>Caution:</strong> Although XML markup such as this will be ignored by
+older platforms, you must be careful not to use programming APIs introduced in API Level 8
+while your {@code minSdkVersion} is less than "8", unless you perform the work necessary to
+provide backward compatiblity in your code. For information about building
+backward compatibility in your application code, see the <a
+href="{@docRoot}resources/articles/backward-compatibility.html">Backward Compatibility</a>
+article.</p>
+
+
+
+<h2 id="ShouldNot">Applications That Should NOT Install on External Storage</h2>
+
+<p>When the user enables USB mass storage to share files with their computer (or otherwise
+unmounts or removes the external storage), any application
+installed on the external storage and currently running is killed. The system effectively becomes
+unaware of the application until mass storage is disabled and the external storage is
+remounted on the device. Besides killing the application and making it unavailable to the user,
+this can break some types of applications in a more serious way. In order for your application to
+consistently behave as expected, you <strong>should not</strong> allow your application to be
+installed on the external storage if it uses any of the following features, due to the cited
+consequences when the external storage is unmounted:</p>
+
+<dl>
+ <dt>Services</dt>
+ <dd>Your running {@link android.app.Service} will be killed and will not be restarted when
+external storage is remounted. You can, however, register for the {@link
+android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE} broadcast Intent, which will notify
+your application when applications installed on external storage have become available to the
+system again. At which time, you can restart your Service.</dd>
+ <dt>Alarm Services</dt>
+ <dd>Your alarms registered with {@link android.app.AlarmManager} will be cancelled. You must
+manually re-register any alarms when external storage is remounted.</dd>
+ <dt>Input Method Engines</dt>
+ <dd>Your <a href="{@docRoot}resources/articles/on-screen-inputs.html">IME</a> will be
+replaced by the default IME. When external storage is remounted, the user can open system settings
+to enable your IME again.</dd>
+ <dt>Live Wallpapers</dt>
+ <dd>Your running <a href="{@docRoot}resources/articles/live-wallpapers.html">Live Wallpaper</a>
+will be replaced by the default Live Wallpaper. When external storage is remounted, the user can
+select your Live Wallpaper again.</dd>
+ <dt>Live Folders</dt>
+ <dd>Your <a href="{@docRoot}resources/articles/live-folders.html">Live Folder</a> will be
+removed from the home screen. When external storage is remounted, the user can add your Live Folder
+to the home screen again.</dd>
+ <dt>App Widgets</dt>
+ <dd>Your <a href="{@docRoot}guide/topics/appwidgets/index.html">App Widget</a> will be removed
+from the home screen. When external storage is remounted, your App Widget will <em>not</em> be
+available for the user to select until the system resets the home application (usually not until a
+system reboot).</dd>
+ <dt>Account Managers</dt>
+ <dd>Your accounts created with {@link android.accounts.AccountManager} will disappear until
+external storage is remounted.</dd>
+ <dt>Sync Adapters</dt>
+ <dd>Your {@link android.content.AbstractThreadedSyncAdapter} and all its sync functionality will
+not work until external storage is remounted.</dd>
+ <dt>Device Administrators</dt>
+ <dd>Your {@link android.app.admin.DeviceAdminReceiver} and all its admin capabilities will
+be disabled, which can have unforeseeable consequences for the device functionality, which may
+persist after external storage is remounted.</dd>
+</dl>
+
+<p>If your application uses any of the features listed above, you <strong>should not</strong> allow
+your application to install on external storage. By default, the system <em>will not</em> allow your
+application to install on the external storage, so you don't need to worry about your existing
+applications. However, if you're certain that your application should never be installed on the
+external storage, then you should make this clear by declaring <a
+href="{@docRoot}guide/topics/manifest/manifest-element.html#install">{@code
+android:installLocation}</a> with a value of "{@code internalOnly}". Though this does not
+change the default behavior, it explicitly states that your application should only be installed
+on the internal storage and serves as a reminder to you and other developers that this decision has
+been made.</p>
+
+
+<h2 id="Should">Applications That Should Install on External Storage</h2>
+
+<p>In simple terms, anything that does not use the features listed in the previous section
+are safe when installed on external storage. Large games are more commonly the types of
+applications that should allow installation on external storage, because games don't typically
+provide additional services when innactive. When external storage becomes unavailable and a game
+process is killed, there should be no visible effect when the storage becomes available again and
+the user restarts the game (assuming that the game properly saved its state during the normal
+<a href="{@docRoot}guide/topics/fundamentals.html#lcycles">Activity lifecycle</a>).</p>
+
+<p>If your application requires several megabytes for the APK file, you should
+carefully consider whether to enable the application to install on the external storage so that
+users can preserve space on their internal storage.</p>
+
diff --git a/docs/html/guide/developing/testing/index.jd b/docs/html/guide/developing/testing/index.jd
new file mode 100644
index 0000000..ea61cc3
--- /dev/null
+++ b/docs/html/guide/developing/testing/index.jd
@@ -0,0 +1,37 @@
+page.title=Testing Overview
+@jd:body
+
+<p>
+ Android includes powerful tools for setting up and running test applications.
+ Whether you are working in Eclipse with ADT or working from the command line, these tools
+ help you set up and run your tests within an emulator or the device you are targeting.
+ The documents listed below explain how to work with the tools in your development environment.
+</p>
+<p>
+ If you aren't yet familiar with the Android testing framework, please read the topic
+ <a href="{@docRoot}guide/topics/testing/testing_android.html">Testing and Instrumentation</a>
+ before you get started.
+ For a step-by-step introduction to Android testing, try the <a
+ href="{@docRoot}resources/tutorials/testing/helloandroid_test.html">Hello, Testing</a>
+ tutorial, which introduces basic testing concepts and procedures.
+ For a more advanced tutorial, try <a
+ href="{@docRoot}resources/tutorials/testing/activity_test.html">Activity Testing</a>,
+ which guides you through a more complex testing scenario.
+</p>
+<dl>
+ <dt><a href="testing_eclipse.html">Testing in Eclipse, with ADT</a></dt>
+ <dd>
+ The ADT plugin lets you quickly set up and manage test projects directly in
+ the Eclipse UI. Once you have written your tests, you can build and run them and
+ then see the results in the Eclipse JUnit view. You can also use the SDK command-line
+ tools to execute your tests if needed.
+ </dd>
+ <dt><a href="testing_otheride.html">Testing in Other IDEs</a></dt>
+ <dd>
+ The SDK command-line tools provide the same capabilities as the ADT plugin. You can
+ use them to set up and manage test projects, build your test application,
+ run your tests, and see the results. You use
+ the <code>android</code> tool to create and manage test projects, the Ant build system
+ to compile them, and the <code>adb</code> tool to install and run them.
+ </dd>
+</dl>
diff --git a/docs/html/guide/developing/testing/testing_eclipse.jd b/docs/html/guide/developing/testing/testing_eclipse.jd
new file mode 100644
index 0000000..da1c0f0
--- /dev/null
+++ b/docs/html/guide/developing/testing/testing_eclipse.jd
@@ -0,0 +1,370 @@
+page.title=Testing In Eclipse, with ADT
+@jd:body
+
+<div id="qv-wrapper">
+ <div id="qv">
+ <h2>In this document</h2>
+ <ol>
+ <li><a href="#CreateTestProjectEclipse">Creating a Test Project</a></li>
+ <li><a href="#CreateTestAppEclipse">Creating a Test Application</a></li>
+ <li><a href="#RunTestEclipse">Running Tests</a></li>
+ </ol>
+ </div>
+</div>
+<p>
+ This topic explains how create and run tests of Android applications in Eclipse with ADT.
+
+ with the basic processes for creating and running applications with ADT, as described in
+ <a href="{@docRoot}guide/developing/eclipse-adt.html">Developing In Eclipse, with ADT</a>.
+
+ Before you read this topic, you should read about how to create a Android application with the
+ basic processes for creating and running applications with ADT, as described in
+ <a href="{@docRoot}guide/developing/eclipse-adt.html">Developing In Eclipse, with ADT</a>.
+ You may also want to read
+ <a href="{@docRoot}guide/topics/testing/testing_android.html">Testing and Instrumentation</a>,
+ which provides an overview of the Android testing framework.
+</p>
+<p>
+ ADT provides several features that help you set up and manage your testing environment
+ effectively:
+</p>
+ <ul>
+ <li>
+ It lets you quickly create a test project and link it to the application under test.
+ When it creates the test project, it automatically inserts the necessary
+ <code>&lt;instrumentation&gt;</code> element in the test application's manifest file.
+ </li>
+ <li>
+ It lets you quickly import the classes of the application under test, so that your
+ tests can inspect them.
+ </li>
+ <li>
+ It lets you create run configurations for your test application and include in
+ them flags that are passed to the Android testing framework.
+ </li>
+ <li>
+ It lets you run your test application without leaving Eclipse. ADT builds both the
+ application under test and the test application automatically, installs them if
+ necessary to your device or emulator, runs the test application, and displays the
+ results in a separate window in Eclipse.
+ </li>
+ </ul>
+<p>
+ If you are not developing in Eclipse or you want to learn how to create and run tests from the
+ command line, see
+ <a href="{@docRoot}guide/developing/testing/testing_otheride.html">Testing in Other IDEs</a>.
+</p>
+<h2 id="CreateTestProjectEclipse">Creating a Test Project</h2>
+ <p>
+ To set up a test environment for your Android application, you must first create a separate
+ application project that holds the test code. The new project follows the directory structure
+ used for any Android application. It includes the same types of content and files, such as
+ source code, resources, a manifest file, and so forth. The test application you
+ create is connected to the application under test by an
+ <a href="{@docRoot}guide/topics/manifest/instrumentation-element.html">
+ <code>&lt;instrumentation&gt;</code></a> element in its manifest file.
+ </p>
+ <p>
+ The <strong>New Android Test Project</strong> dialog makes it easy for you to generate a
+ new test project that has the proper structure, including the
+ <code>&lt;instrumentation&gt;</code> element in the manifest file. You can use the New Android
+ Test Project dialog to generate the test project at any time. The dialog appears just after you
+ create a new Android main application project, but you can also run it to create a test project
+ for a project that you created previously.
+ </p>
+<p>
+ To create a test project in Eclipse with ADT:
+</p>
+<ol>
+ <li>
+ In Eclipse, select <strong>File &gt; New &gt; Other</strong>. This
+ opens the Select a Wizard dialog.
+ </li>
+ <li>
+ In the dialog, in the Wizards drop-down list,
+ find the entry for Android, then click the toggle to the left. Select
+ Android Test Project, then at the bottom
+ of the dialog click Next. The New Android Test Project wizard appears.
+ </li>
+ <li>
+ Enter a project name. You may use any name, but you may want to
+ associate the name with the project name for your Application. One
+ way to do this is to take the Application's project name, append the
+ string "Test" to it, and then use this as the test case project name.
+ </li>
+ <li>
+ In the Test Target panel, set
+ An Existing Android Project, click
+ Browse, then select your Android application from
+ the list. You now see that the wizard has completed the Test
+ Target Package, Application Name, and
+ Package Name fields for you (the latter two are in
+ the Properties panel).
+ </li>
+ <li>
+ In the Build Target panel, select the Android SDK
+ platform that you will use to test your application. Make this the same as the
+ build target of the application under test.
+ </li>
+ <li>
+ Click Finish to complete the wizard. If
+ Finish is disabled, look
+ for error messages at the top of the wizard dialog, and then fix
+ any problems.
+ </li>
+</ol>
+<p>
+
+</p>
+<h2 id="CreateTestAppEclipse">Creating a Test Application</h2>
+<p>
+ Once you have created a test project, you populate it with a test
+ Android application. This application does not require an {@link android.app.Activity Activity},
+ although you can define one if you wish. Although your test application can
+ combine Activities, Android test class extensions, JUnit extensions, or
+ ordinary classes, you should extend one of the Android test classes or JUnit classes,
+ because these provide the best testing features.
+</p>
+<p>
+ Test applications do not have an Android GUI. Instead, when you run the application in
+ Eclipse with ADT, its results appear in the JUnit view. If you run
+ your tests with {@link android.test.InstrumentationTestRunner InstrumentationTestRunner} (or a related test runner),
+ then it will run all the methods in each class. You can modify this behavior
+ by using the {@link junit.framework.TestSuite TestSuite} class.
+</p>
+
+<p>
+ To create a test application, start with one of Android's test classes in the Java package {@link android.test android.test}.
+ These extend the JUnit {@link junit.framework.TestCase TestCase} class. With a few exceptions, the Android test classes
+ also provide instrumentation for testing.
+</p>
+<p>
+ For test classes that extend {@link junit.framework.TestCase TestCase}, you probably want to override
+ the <code>setUp()</code> and <code>tearDown()</code> methods:
+</p>
+<ul>
+ <li>
+ <code>setUp()</code>: This method is invoked before any of the test methods in the class.
+ Use it to set up the environment for the test. You can use <code>setUp()</code>
+ to instantiate a new <code>Intent</code> object with the action <code>ACTION_MAIN</code>. You can
+ then use this intent to start the Activity under test.
+ <p class="note"><strong>Note:</strong> If you override this method, call
+ <code>super.setUp()</code> as the first statement in your code.
+ </p>
+ </li>
+ <li>
+ <code>tearDown()</code>: This method is invoked after all the test methods in the class. Use
+ it to do garbage collection and re-setting before moving on to the next set of tests.
+ <p class="note"><strong>Note:</strong> If you override this method, you must call
+ <code>super.tearDown()</code> as the <em>last</em> statement in your code.</p>
+ </li>
+</ul>
+<p>
+ Another useful convention is to add the method <code>testPreConditions()</code> to your test
+ class. Use this method to test that the application under test is initialized correctly. If this
+ test fails, you know that that the initial conditions were in error. When this happens, further test
+ results are suspect, regardless of whether or not the tests succeeded.
+</p>
+<p>
+ The Resources tab contains an <a href="{@docRoot}resources/tutorials/testing/activity_test.html">Activity Testing</a>
+ tutorial with more information about creating test classes and methods.
+</p>
+<h2 id="RunTestEclipse">Running Tests</h2>
+<div class="sidebox-wrapper">
+ <div class="sidebox">
+ <h2>Running tests from the command line</h2>
+ <p>
+ If you've created your tests in Eclipse, you can still run your tests and test
+ suites by using command-line tools included with the Android SDK. You may want to
+ do this, for example, if you have a large number of tests to run, if you have a
+ large test case, or if you want a fine level of control over which tests are run at
+ a particular time.
+ </p>
+ <p>
+ To run tests created in Eclipse with ADT with command-line tools, you must first
+ install additional files into the test project using the <code>android</code> tool's
+ "create test-project" option. To see how to do this, read the section
+ <a href="{@docRoot}guide/developing/testing/testing_otheride.html#CreateProject">
+ Creating a test project</a> in the topic
+ <a href="{@docRoot}guide/developing/testing/testing_otheride.html">Testing in Other
+ IDEs</a>.
+ </p>
+ </div>
+</div>
+<p>
+ When you run a test application in Eclipse with ADT, the output appears in
+ an Eclipse view panel. You can run the entire test application, one class, or one
+ method of a class. To do this, Eclipse runs the <code>adb</code> command for running a test application, and
+ displays the output, so there is no difference between running tests inside Eclipse and running them from the command line.
+</p>
+<p>
+ As with any other application, to run a test application in Eclipse with ADT you must either attach a device to your
+ computer or use the Android emulator. If you use the emulator, you must have an Android Virtual Device (AVD) that uses
+ the same target
+</p>
+<p>
+ To run a test in Eclipse, you have two choices:</p>
+<ol>
+ <li>
+ Run a test just as you run an application, by selecting
+ <strong>Run As... &gt; Android JUnit Test</strong> from the project's context menu or
+ from the main menu's <strong>Run</strong> item.
+ </li>
+ <li>
+ Create an Eclipse run configuration for your test project. This is useful if you want multiple test suites, each consisting of selected tests from the project. To run
+ a test suite, you run the test configuration.
+ <p>
+ Creating and running test configurations is described in the next section.
+ </p>
+ </li>
+</ol>
+<p>To create and run a test suite using a run configuration:</p>
+<ol>
+ <li>
+ In the Package Explorer, select the test
+ project, then from the main menu, select
+ <strong>Run &gt; Run Configurations...</strong>. The
+ Run Configurations dialog appears.
+ </li>
+ <li>
+ In the left-hand pane, find the
+ Android JUnit Test entry.
+ In the right-hand pane, click the Test tab.
+ The Name: text box
+ shows the name of your project. The
+ Test class: dropdown box shows one your project's classes
+ test classes in your project.
+ </li>
+ <li>
+ To run one test class, click Run a single test, then enter your project
+ name in the Project: text box and the class name in the
+ Test class: text box.
+ <p>
+ To run all the test classes,
+ click Run all tests in the selected project or package,
+ then enter the project or package name in the text box.
+ </p>
+ </li>
+ <li>
+ Now click the Target tab.
+ <ul>
+ <li>
+ Optional: If you are using the emulator, click
+ Automatic, then in the Android Virtual Device (AVD)
+ selection table, select an existing AVD.
+ </li>
+ <li>
+ In the Emulator Launch Parameters pane, set the
+ Android emulator flags you want to use. These are documented in the topic
+ <a href="{@docRoot}guide/developing/tools/emulator.html#startup-options">Emulator Startup Options</a>.
+ </li>
+ </ul>
+ <li>
+ Click the Common tab. In the
+ Save As pane, click Local to save
+ this run configuration locally, or click Shared to
+ save it to another project.
+ </li>
+ <li>
+ Optional: Add the configuration to the Run toolbar and the <strong>Favorites</strong>
+ menu: in the Display in Favorites pane
+ click the checkbox next to Run.
+ </li>
+ <li>
+ Optional: To add this configuration to the <strong>Debug</strong> menu and toolbar, click
+ the checkbox next to Debug.
+ </li>
+ <li>
+ To save your settings, click Close.<br/>
+ <p class="note"><strong>Note:</strong> Although you can run the test immediately by
+ clicking Run, you should save the test first and then
+ run it by selecting it from the Eclipse standard toolbar.</p>
+ </li>
+ <li>
+ On the Eclipse standard toolbar, click the down arrow next to the
+ green Run arrow. This displays a menu of saved Run and Debug
+ configurations.
+ </li>
+ <li>
+ Select the test run configuration you just created.
+ </li>
+ <li>
+ The progress of your test appears in the Console view.
+ You should see the following messages, among others:
+ <ul>
+ <li>
+ <code>Performing Android.test.InstrumentationTestRunner JUnit launch</code><br>
+ The class name that proceeds "JUnit" depends on the Android instrumentation
+ class you have chosen.
+ </li>
+ <li>
+ If you are using an emulator and you have not yet started it, then you will see
+ the message:
+ <p>
+ <code>Automatic Target Mode: launching new emulator with compatible
+ AVD <em>avdname</em></code><br>(where <em>avdname</em> is the name of
+ the AVD you are using.)
+ </p>
+ </li>
+ <li>
+ If you have not already installed your test application, then you will see
+ the message:
+ <p>
+ <code>Uploading <em>testclass</em>.apk onto device '<em>device-id</em>'</code><br>
+ where <em>testclass</em> is the name of your unit test class and <em>device-id</em>
+ is the name and port for your test device or emulator, followed by the message <code>Installing <em>testclass</em>.apk</code>
+ </p>
+ </li>
+ <li>
+ <code>Launching instrumentation Android.test.InstrumentationTestRunner on device <em>device-id</em></code>.<br>
+ This indicates that Android's Instrumentation system is now testing your code. Again, the
+ instrumentation class name depends on the Android instrumentation class you have chosen.
+ </li>
+ <li>
+ <code>Test run complete</code>.<br> When you see this, your unit tests have finished.
+ </li>
+ </ul>
+</ol>
+<p>
+ The test results appear in the JUnit view. This is divided into an upper summary pane,
+ and a lower stack trace pane.
+</p>
+<p>
+ The upper pane contains test information. In the pane's header, you see the following
+ information:
+</p>
+ <ul>
+ <li>
+ Total time elapsed for the test application (labeled Finished after <em>x</em> seconds).
+ </li>
+ <li>
+ Number of runs (Runs:) - the number of tests in the entire test class.
+ </li>
+ <li>
+ Number of errors (Errors:) - the number of program errors and exceptions encountered
+ during the test run.
+ </li>
+ <li>
+ Number of failures (Failures:) - the number of test failures encountered during the test
+ run. This is the number of assertion failures. A test can fail even if the program does
+ not encounter an error.
+ </li>
+ <li>
+ A progress bar. The progress bar extends from left to right as the tests run. If all the
+ tests succeed, the bar remains green. If a test fails, the bar turns from green to red.
+ </li>
+ </ul>
+<p>
+ The body of the upper pane contains the details of the test run. For each test case class
+ that was run, you see a line with the class name. To look at the results for the individual
+ test methods in that class, you click the left arrow to expand the line. You now see a
+ line for each test method in the class, and to its right the time it took to run.
+ If you double-click the method name, Eclipse opens the test class source in an editor view
+ pane and moves the focus to the first line of the test method.
+</p>
+<p>
+ The lower pane is for stack traces. If you highlight a failed test in the upper pane, the
+ lower pane contains a stack trace for the test. If a line corresponds to a point in your
+ test code, you can double-click it to display the code in an editor view pane, with the
+ line highlighted. For a successful test, the lower pane is empty.
+</p>
diff --git a/docs/html/guide/developing/testing/testing_otheride.jd b/docs/html/guide/developing/testing/testing_otheride.jd
new file mode 100644
index 0000000..2bdf4d0
--- /dev/null
+++ b/docs/html/guide/developing/testing/testing_otheride.jd
@@ -0,0 +1,683 @@
+page.title=Testing In Other IDEs
+@jd:body
+
+<div id="qv-wrapper">
+ <div id="qv">
+ <h2>In this document</h2>
+ <ol>
+ <li>
+ <a href="#CreateTestProjectCommand">Working with Test Projects</a>
+ <ol>
+ <li>
+ <a href="#CreateTestProject">Creating a test project</a>
+ </li>
+ <li>
+ <a href="#UpdateTestProject">Updating a test project</a>
+ </li>
+ </ol>
+ </li>
+ <li>
+ <a href="#CreateTestApp">Creating a Test Application</a>
+ </li>
+ <li>
+ <a href="#RunTestsCommand">Running Tests</a>
+ <ol>
+ <li>
+ <a href="#RunTestsAnt">Quick build and run with Ant</a>
+ </li>
+ <li>
+ <a href="#RunTestsDevice">Running tests on a device or emulator</a>
+ </li>
+ </ol>
+ </li>
+ <li>
+ <a href="#AMSyntax">Using the Instrument Command</a>
+ <ol>
+ <li>
+ <a href="#AMOptionsSyntax">Instrument options</a>
+ </li>
+ <li>
+ <a href="#RunTestExamples">Instrument examples</a>
+ </li>
+ </ol>
+ </li>
+
+ </ol>
+ <h2>See Also</h2>
+ <ol>
+ <li>
+ <a
+ href="{@docRoot}guide/topics/testing/testing_android.html">Testing and Instrumentation</a>
+ </li>
+ <li>
+ <a href="{@docRoot}resources/tutorials/testing/activity_test.html">Activity Testing</a>
+ </li>
+ <li>
+ <a href="{@docRoot}guide/developing/tools/adb.html">Android Debug Bridge</a>
+ </li>
+ </ol>
+ </div>
+</div>
+<p>
+ This document describes how to create and run tests directly from the command line.
+ You can use the techniques described here if you are developing in an IDE other than Eclipse
+ or if you prefer to work from the command line. This document assumes that you already know how
+ to create a Android application in your programming environment. Before you start this
+ document, you should read the document <a
+ href="{@docRoot}guide/topics/testing/testing_android.html">Testing and Instrumentation</a>,
+ which provides an overview of Android testing.
+</p>
+<p>
+ If you are developing in Eclipse with ADT, you can set up and run your tests
+directly in Eclipse. For more information, please read <a
+ href="{@docRoot}guide/developing/testing/testing_eclipse.html">Testing&nbsp;in&nbsp;Eclipse,&nbsp;with&nbsp;ADT</a>.
+</p>
+<h2 id="CreateTestProjectCommand">Working with Test Projects</h2>
+<p>
+ You use the <code>android</code> tool to create test projects.
+ You also use <code>android</code> to convert existing test code into an Android test project,
+ or to add the <code>run-tests</code> Ant target to an existing Android test project.
+ These operations are described in more detail in the section <a
+ href="#UpdateTestProject">Updating a test project</a>.
+ The <code>run-tests</code> target is described in <a
+ href="#RunTestsAnt">Quick build and run with Ant</a>.
+</p>
+<h3 id="CreateTestProject">Creating a test project</h3>
+<p>
+ To create a test project with the <code>android</code> tool, enter:
+<pre>android create test-project -m &lt;main_path&gt; -n &lt;project_name&gt; -p &lt;test_path&gt;</pre>
+<p>
+ You must supply all the flags. The following table explains them in detail:
+</p>
+<table>
+ <tr>
+ <th>Flag</th>
+ <th>Value</th>
+ <th>Description</th>
+ <tr>
+ <td><code>-m, --main</code></td>
+ <td>
+ Path to the project of the application under test, relative to the test application
+ directory.
+ </td>
+ <td>
+ For example, if the application under test is in <code>source/HelloAndroid</code>, and you
+ want to create the test project in <code>source/HelloAndroidTest</code>, then the value of
+ <code>--main</code> should be <code>../HelloAndroid</code>.
+ </td>
+ <tr>
+ <td><code>-n, --name</code></td>
+ <td>Name that you want to give the test project.</td>
+ <td>&nbsp;</td>
+ </tr>
+ <tr>
+ <td><code>-p, --path</code></td>
+ <td>Directory in which you want to create the new test project.</td>
+ <td>
+ The <code>android</code> tool creates the test project files and directory structure in this
+ directory. If the directory does not exist, <code>android</code> creates it.
+ </td>
+ </tr>
+</table>
+<p>
+ If the operation is successful, <code>android</code> lists to STDOUT the names of the files
+ and directories it has created.
+</p>
+<p>
+ This creates a new test project with the appropriate directories and build files. The directory
+ structure and build file contents are identical to those in a regular Android application
+ project. They are described in detail in the topic
+ <a href="{@docRoot}guide/developing/other-ide.html">Developing In Other IDEs</a>.
+</p>
+<p>
+ The operation also creates an <code>AndroidManifest.xml</code> file with instrumentation
+ information. When you run the test, Android uses this information to load the application you
+ are testing and control it with instrumentation.
+</p>
+<p>
+ For example, suppose you create the <a
+ href="{@docRoot}resources/tutorials/hello-world.html">Hello, World</a> tutorial application
+ in the directory <code>~/source/HelloAndroid</code>. In the tutorial, this application uses the
+ package name <code>com.example.helloandroid</code> and the activity name
+ <code>HelloAndroid</code>. You can to create the test for this in
+ <code>~/source/HelloAndroidTest</code>. To do so, you enter:
+</p>
+<pre>
+$ cd ~/source
+$ android create test-project -m ../HelloAndroid -n HelloAndroidTest -p HelloAndroidTest
+</pre>
+<p>
+ This creates a directory called <code>~/src/HelloAndroidTest</code>. In the new directory you
+ see the file <code>AndroidManifest.xml</code>. This file contains the following
+ instrumentation-related elements and attributes:
+</p>
+<ul>
+ <li>
+ <code>&lt;application&gt;</code>: to contain the
+ <code>&lt;uses-library&gt;</code> element.
+ </li>
+ <li>
+ <code>&lt;uses-library android:name=&quot;android.test.runner&quot;</code>:
+ specifies this testing application uses the <code>android.test.runner</code> library.
+ </li>
+ <li>
+ <code>&lt;instrumentation&gt;</code>: contains attributes that control Android
+ instrumentation. The attributes are:
+ <ul>
+ <li>
+ <code>android:name=&quot;android.test.InstrumentationTestRunner&quot;</code>:
+ {@link android.test.InstrumentationTestRunner} runs test cases. It extends both
+ JUnit test case runner classes and Android instrumentation classes.
+ </li>
+ <li>
+ <code>android:targetPackage=&quot;com.example.helloandroid&quot;</code>: specifies
+ that the tests in HelloAndroidTest should be run against the application with the
+ <em>Android</em> package name <code>com.example.helloandroid</code>. This is the
+ package name of the <a
+ href="{@docRoot}resources/tutorials/hello-world.html">Hello, World</a>
+ tutorial application.
+ </li>
+ <li>
+ <code>android:label=&quot;Tests for .HelloAndroid&quot;</code>: specifies a
+ user-readable label for the instrumentation class. By default,
+ the <code>android</code> tool gives it the value &quot;Tests for &quot; plus
+ the name of the main Activity of the application under test.
+ </li>
+ </ul>
+ </li>
+</ul>
+<h3 id="UpdateTestProject">Updating a test project</h3>
+<p>
+ You use the <code>android</code> tool when you need to change the path to the
+ project of the application under test. If you are changing an existing test project created in
+ Eclipse with ADT so that you can also build and run it from the command line, you must use the
+ "create" operation. See the section <a href="#CreateTestProject">Creating a test project</a>.
+</p>
+<p class="note">
+ <strong>Note:</strong> If you change the Android package name of the application under test,
+ you must <em>manually</em> change the value of the <code>&lt;android:targetPackage&gt;</code>
+ attribute within the <code>AndroidManifest.xml</code> file of the test application.
+ Running <code>android update test-project</code> does not do this.
+</p>
+<p>
+ To update a test project with the <code>android</code> tool, enter:
+</p>
+<pre>android update-test-project -m &lt;main_path&gt; -p &lt;test_path&gt;</pre>
+
+<table>
+<tr>
+ <th>Flag</th>
+ <th>Value</th>
+ <th>Description</th>
+</tr>
+<tr>
+ <td><code>-m, --main</code></td>
+ <td>The path to the project of the application under test, relative to the test project</td>
+ <td>
+ For example, if the application under test is in <code>source/HelloAndroid</code>, and
+ the test project is in <code>source/HelloAndroidTest</code>, then the value for
+ <code>--main</code> is <code>../HelloAndroid</code>.
+ </td>
+</tr>
+<tr>
+ <td><code>-p, --path</code></td>
+ <td>The of the test project.</td>
+ <td>
+ For example, if the test project is in <code>source/HelloAndroidTest</code>, then the
+ value for <code>--path</code> is <code>HelloAndroidTest</code>.
+ </td>
+</tr>
+</table>
+<p>
+ If the operation is successful, <code>android</code> lists to STDOUT the names of the files
+ and directories it has created.
+</p>
+<h2 id="CreateTestApp">Creating a Test Application</h2>
+<p>
+ Once you have created a test project, you populate it with a test application.
+ The application does not require an {@link android.app.Activity Activity},
+ although you can define one if you wish. Although your test application can
+ combine Activities, Android test class extensions, JUnit extensions, or
+ ordinary classes, you should extend one of the Android test classes or JUnit classes,
+ because these provide the best testing features.
+</p>
+<p>
+ If you run your tests with {@link android.test.InstrumentationTestRunner}
+ (or a related test runner), then it will run all the methods in each class. You can modify
+ this behavior by using the {@link junit.framework.TestSuite TestSuite} class.
+</p>
+
+<p>
+ To create a test application, start with one of Android's test classes in the Java package
+ {@link android.test android.test}. These extend the JUnit
+ {@link junit.framework.TestCase TestCase} class. With a few exceptions, the Android test
+ classes also provide instrumentation for testing.
+</p>
+<p>
+ For test classes that extend {@link junit.framework.TestCase TestCase}, you probably want to
+ override the <code>setUp()</code> and <code>tearDown()</code> methods:
+</p>
+<ul>
+ <li>
+ <code>setUp()</code>: This method is invoked before any of the test methods in the class.
+ Use it to set up the environment for the test. You can use <code>setUp()</code>
+ to instantiate a new <code>Intent</code> object with the action <code>ACTION_MAIN</code>.
+ You can then use this intent to start the Activity under test.
+ <p class="note">
+ <strong>Note:</strong> If you override this method, call
+ <code>super.setUp()</code> as the first statement in your code.
+ </p>
+ </li>
+ <li>
+ <code>tearDown()</code>: This method is invoked after all the test methods in the class. Use
+ it to do garbage collection and re-setting before moving on to the next set of tests.
+ <p class="note"><strong>Note:</strong> If you override this method, you must call
+ <code>super.tearDown()</code> as the <em>last</em> statement in your code.</p>
+ </li>
+</ul>
+<p>
+ Another useful convention is to add the method <code>testPreConditions()</code> to your test
+ class. Use this method to test that the application under test is initialized correctly. If this
+ test fails, you know that that the initial conditions were in error. When this happens, further
+ test results are suspect, regardless of whether or not the tests succeeded.
+</p>
+<p>
+ To learn more about creating test applications, see the topic <a
+ href="{@docRoot}guide/topics/testing/testing_android.html">Testing and Instrumentation</a>,
+ which provides an overview of Android testing. If you prefer to follow a tutorial,
+ try the <a href="{@docRoot}resources/tutorials/testing/activity_test.html">Activity Testing</a>
+ tutorial, which leads you through the creation of tests for an actual Android application.
+</p>
+<h2 id="RunTestsCommand">Running Tests</h2>
+<p>
+ If you are not developing in Eclipse with ADT, you need to run tests from the command line.
+ You can do this either with Ant or with the {@link android.app.ActivityManager ActivityManager}
+ command line interface.
+</p>
+<p>
+ You can also run tests from the command line even if you are using Eclipse with ADT to develop
+ them. To do this, you need to create the proper files and directory structure in the test
+ project, using the <code>android</code> tool with the option <code>create test-project</code>.
+ This is described in the section <a
+ href="#CreateTestProjectCommand">Working with Test Projects</a>.
+</p>
+<h3 id="RunTestsAnt">Quick build and run with Ant</h3>
+<p>
+ You can use Ant to run all the tests in your test project, using the target
+ <code>run-tests</code>, which is created automatically when you create a test project with
+ the <code>android</code> tool.
+</p>
+<p>
+ This target re-builds your main project and test project if necessary, installs the test
+ application to the current AVD or device, and then runs all the test classes in the test
+ application. The results are directed to <code>STDOUT</code>.
+</p>
+<p>
+ You can update an existing test project to use this feature. To do this, use the
+ <code>android</code> tool with the <code>update test-project</code> option. This is described
+ in the section <a href="#UpdateTestProject">Updating a test project</a>.
+<h3 id="RunTestsDevice">Running tests on a device or emulator</h3>
+<p>
+ When you run tests from the command line with the ActivityManager (<code>am</code>)
+ command-line tool, you get more options for choosing the tests to run than with any other
+ method. You can select individual test methods, filter tests according to their annotation, or
+ specify testing options. Since the test run is controlled entirely from a command line, you can
+ customize your testing with shell scripts in various ways.
+</p>
+<p>
+ You run the <code>am</code> tool on an Android device or emulator using the
+ <a href="{@docRoot}guide/developing/tools/adb.html">Android Debug Bridge</a>
+ (<code>adb</code>) shell. When you do this, you use the ActivityManager
+ <code>instrument</code> option to run your test application using an Android test runner
+ (usually {@link android.test.InstrumentationTestRunner}). You set <code>am</code>
+ options with command-line flags.
+</p>
+<p>
+ To run a test with <code>am</code>:
+</p>
+<ol>
+ <li>
+ If necessary, re-build your main application and test application.
+ </li>
+ <li>
+ Install your test application and main application Android package files
+ (<code>.apk</code> files) to your current Android device or emulator</li>
+ <li>
+ At the command line, enter:
+<pre>
+$ adb shell am instrument -w &lt;test_package_name&gt;/&lt;runner_class&gt;
+</pre>
+<p>
+ where <code>&lt;test_package_name&gt;</code> is the Android package name of your test
+ application, and <code>&lt;runner_class&gt;</code> is the name of the Android test runner
+ class you are using. The Android package name is the value of the <code>package</code>
+ attribute of the <code>manifest</code> element in the manifest file
+ (<code>AndroidManifest.xml</code>) of your test application. The Android test runner
+ class is usually <code>InstrumentationTestRunner</code>.
+</p>
+<p>Your test results appear in <code>STDOUT</code>.</p>
+ </li>
+</ol>
+<p>
+ This operation starts an <code>adb</code> shell, then runs <code>am instrument</code> in it
+ with the specified parameters. This particular form of the command will run all of the tests
+ in your test application. You can control this behavior with flags that you pass to
+ <code>am instrument</code>. These flags are described in the next section.
+</p>
+<h2 id="AMSyntax">Using the Instrument Command</h2>
+<p>
+ The general syntax of the <code>am instrument</code> command is:
+</p>
+<pre>
+ am instrument [flags] &lt;test_package&gt;/&lt;runner_class&gt;
+</pre>
+<p>
+ The main input parameters to <code>am instrument</code> are described in the following table:
+</p>
+<table>
+ <tr>
+ <th>
+ Parameter
+ </th>
+ <th>
+ Value
+ </th>
+ <th>
+ Description
+ </th>
+ </tr>
+ <tr>
+ <td>
+ <code>&lt;test_package&gt;</code>
+ </td>
+ <td>
+ The Android package name of the test application.
+ </td>
+ <td>
+ The value of the <code>package</code> attribute of the <code>manifest</code>
+ element in the test application's manifest file.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <code>&lt;runner_class&gt;</code>
+ </td>
+ <td>
+ The class name of the instrumented test runner you are using.
+ </td>
+ <td>
+ This is usually {@link android.test.InstrumentationTestRunner}.
+ </td>
+ </tr>
+</table>
+<p>
+The flags for <code>am instrument</code> are described in the following table:
+</p>
+<table>
+ <tr>
+ <th>
+ Flag
+ </th>
+ <th>
+ Value
+ </th>
+ <th>
+ Description
+ </th>
+ </tr>
+ <tr>
+ <td>
+ <code>-w</code>
+ </td>
+ <td>
+ (none)
+ </td>
+ <td>
+ Forces <code>am instrument</code> to wait until the instrumentation terminates
+ before terminating itself. The net effect is to keep the shell open until the tests
+ have finished. This flag is not required, but if you do not use it, you will not
+ see the results of your tests.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <code>-r</code>
+ </td>
+ <td>
+ (none)
+ </td>
+ <td>
+ Outputs results in raw format. Use this flag when you want to collect
+ performance measurements, so that they are not formatted as test results. This flag is
+ designed for use with the flag <code>-e perf true</code> (documented in the section
+ <a href="#AMOptionsSyntax">Instrument options</a>).
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <code>-e</code>
+ </td>
+ <td>
+ &lt;test_options&gt;
+ </td>
+ <td>
+ Provides testing options , in the form of key-value pairs. The
+ <code>am instrument</code> tool passes these to the specified instrumentation class
+ via its <code>onCreate()</code> method. You can specify multiple occurrences of
+ <code>-e &lt;test_options</code>. The keys and values are described in the next table.
+ <p>
+ The only instrumentation class that understands these key-value pairs is
+ <code>InstrumentationTestRunner</code> (or a subclass). Using them with
+ any other class has no effect.
+ </p>
+ </td>
+ </tr>
+</table>
+
+<h3 id="AMOptionsSyntax">Instrument options</h3>
+<p>
+ The <code>am instrument</code> tool passes testing options to
+ <code>InstrumentationTestRunner</code> or a subclass in the form of key-value pairs,
+ using the <code>-e</code> flag, with this syntax:
+</p>
+<pre>
+ -e &lt;key&gt; &lt;value&gt;
+</pre>
+<p>
+ Where applicable, a &lt;key&gt; may have multiple values separated by a comma (,).
+ For example, this invocation of <code>InstrumentationTestRunner</code> provides multiple
+ values for the <code>package</code> key:
+<pre>
+$ adb shell am instrument -w -e package com.android.test.package1,com.android.test.package2 com.android.test/android.test.InstrumentationTestRunner
+</pre>
+<p>
+ The following table describes the key-value pairs and their result. Please review the
+ <strong>Usage Notes</strong> following the table.
+</p>
+<table>
+<tr>
+ <th>Key</th>
+ <th>Value</th>
+ <th>Description</th>
+</tr>
+<tr>
+ <td>
+ <code>package</code>
+ </td>
+ <td>
+ &lt;Java_package_name&gt;
+ </td>
+ <td>
+ The fully-qualified <em>Java</em> package name for one of the packages in the test
+ application. Any test case class that uses this package name is executed. Notice that this
+ is not an <em>Android</em> package name; a test application has a single Android package
+ name but may have several Java packages within it.
+ </td>
+</tr>
+<tr>
+ <td rowspan="2"><code>class</code></td>
+ <td>&lt;class_name&gt;</td>
+ <td>
+ The fully-qualified Java class name for one of the test case classes. Only this test case
+ class is executed.
+ </td>
+</tr>
+<tr>
+ <td>&lt;class_name&gt;<strong>#</strong>method name</td>
+ <td>
+ A fully-qualified test case class name, and one of its methods. Only this method is
+ executed. Note the hash mark (#) between the class name and the method name.
+ </td>
+</tr>
+<tr>
+ <td><code>func</code></td>
+ <td><code>true</code></td>
+ <td>
+ Runs all test classes that extend {@link android.test.InstrumentationTestCase}.
+ </td>
+</tr>
+<tr>
+ <td><code>unit</code></td>
+ <td><code>true</code></td>
+ <td>
+ Runs all test classes that do <em>not</em> extend either
+ {@link android.test.InstrumentationTestCase} or {@link android.test.PerformanceTestCase}.
+ </td>
+</tr>
+<tr>
+ <td><code>size</code></td>
+ <td>[<code>small</code> | <code>medium</code> | <code>large</code>]
+ </td>
+ <td>
+ Runs a test method annotated by size. The annotations are <code>@SmallTest</code>,
+ <code>@MediumTest</code>, and <code>@LargeTest</code>.
+ </td>
+</tr>
+<tr>
+ <td><code>perf</code></td>
+ <td><code>true</code></td>
+ <td>
+ Runs all test classes that implement {@link android.test.PerformanceTestCase}.
+ When you use this option, also specify the <code>-r</code> flag for
+ <code>am instrument</code>, so that the output is kept in raw format and not
+ re-formatted as test results.
+ </td>
+</tr>
+<tr>
+ <td><code>debug</code></td>
+ <td><code>true</code></td>
+ <td>
+ Runs tests in debug mode.
+ </td>
+</tr>
+<tr>
+ <td><code>log</code></td>
+ <td><code>true</code></td>
+ <td>
+ Loads and logs all specified tests, but does not run them. The test
+ information appears in <code>STDOUT</code>. Use this to verify combinations of other filters
+ and test specifications.
+ </td>
+</tr>
+<tr>
+ <td><code>emma</code></td>
+ <td><code>true</code></td>
+ <td>
+ Runs an EMMA code coverage analysis and writes the output to <code>/data//coverage.ec</code>
+ on the device. To override the file location, use the <code>coverageFile</code> key that
+ is described in the following entry.
+ <p class="note">
+ <strong>Note:</strong> This option requires an EMMA-instrumented build of the test
+ application, which you can generate with the <code>coverage</code> target.
+ </p>
+ </td>
+</tr>
+<tr>
+ <td><code>coverageFile</code></td>
+ <td><code>&lt;filename&gt;</code></td>
+ <td>
+ Overrides the default location of the EMMA coverage file on the device. Specify this
+ value as a path and filename in UNIX format. The default filename is described in the
+ entry for the <code>emma</code> key.
+ </td>
+</tr>
+</table>
+<strong><code>-e</code> Flag Usage Notes</strong>
+<ul>
+ <li>
+ <code>am instrument</code> invokes
+ {@link android.test.InstrumentationTestRunner#onCreate(Bundle)}
+ with a {@link android.os.Bundle} containing the key-value pairs.
+ </li>
+ <li>
+ The <code>package</code> key takes precedence over the <code>class</code> key. If you
+ specifiy a package, and then separately specify a class within that package, Android
+ will run all the tests in the package and ignore the <code>class</code> key.
+ </li>
+ <li>
+ The <code>func</code> key and <code>unit</code> key are mutually exclusive.
+ </li>
+</ul>
+<h3 id="RunTestExamples">Instrument examples</h3>
+<p>
+Here are some examples of using <code>am instrument</code> to run tests. They are based on
+the following structure:</p>
+<ul>
+ <li>
+ The test application has the Android package name <code>com.android.demo.app.tests</code>
+ </li>
+ <li>
+ There are three test classes:
+ <ul>
+ <li>
+ <code>UnitTests</code>, which contains the methods
+ <code>testPermissions</code> and <code>testSaveState</code>.
+ </li>
+ <li>
+ <code>FunctionTests</code>, which contains the methods
+ <code>testCamera</code>, <code>testXVGA</code>, and <code>testHardKeyboard</code>.
+ </li>
+ <li>
+ <code>IntegrationTests</code>,
+ which contains the method <code>testActivityProvider</code>.
+ </li>
+ </ul>
+ </li>
+ <li>
+ The test runner is {@link android.test.InstrumentationTestRunner}.
+ </li>
+</ul>
+<h4>Running the Entire Test Application</h4>
+<p>
+ To run all of the test classes in the test application, enter:
+</p>
+<pre>
+$ adb shell am instrument -w com.android.demo.app.tests/android.test.InstrumentationTestRunner
+</pre>
+<h4>Running All Tests in a Test Case Class</h4>
+<p>
+ To run all of the tests in the class <code>UnitTests</code>, enter:
+</p>
+<pre>
+$ adb shell am instrument -w \
+-e class com.android.demo.app.tests.UnitTests \
+com.android.demo.app.tests/android.test.InstrumentationTestRunner
+</pre>
+<p>
+ <code>am instrument</code> gets the value of the <code>-e</code> flag, detects the
+ <code>class</code> keyword, and runs all the methods in the <code>UnitTests</code> class.
+</p>
+<h4>Selecting a Subset of Tests</h4>
+<p>
+ To run all of the tests in <code>UnitTests</code>, and the <code>testCamera</code> method in
+ <code>FunctionTests</code>, enter:
+</p>
+<pre>
+$ adb shell am instrument -w \
+-e class com.android.demo.app.tests.UnitTests,com.android.demo.app.tests.FunctionTests#testCamera \
+com.android.demo.app.tests/android.test.InstrumentationTestRunner
+</pre>
+<p>
+ You can find more examples of the command in the documentation for
+ {@link android.test.InstrumentationTestRunner}.
+</p>
diff --git a/docs/html/guide/guide_toc.cs b/docs/html/guide/guide_toc.cs
index 31d9f1a..a484c9f 100644
--- a/docs/html/guide/guide_toc.cs
+++ b/docs/html/guide/guide_toc.cs
@@ -110,7 +110,7 @@
</a></li>
<li><a href="<?cs var:toroot ?>guide/topics/resources/runtime-changes.html">
<span class="en">Handling Runtime Changes</span>
- </a></li>
+ </a> <span class="new">new!</span></li>
<li><a href="<?cs var:toroot ?>guide/topics/resources/localization.html">
<span class="en">Localization</span>
</a></li>
@@ -275,6 +275,25 @@
<span class="en">Debugging Tasks</span>
</a></li>
<li class="toggle-list">
+ <div>
+ <a href="<?cs var:toroot ?>guide/developing/testing/index.html">
+ <span class="en">Testing</span>
+ </a> <span class="new">new!</span>
+ </div>
+ <ul>
+ <li>
+ <a href="<?cs var:toroot ?>guide/developing/testing/testing_eclipse.html">
+ <span class="en">Testing in Eclipse, with ADT</span>
+ </a> <span class="new">new!</span>
+ </li>
+ <li>
+ <a href="<?cs var:toroot ?>guide/developing/testing/testing_otheride.html">
+ <span class="en">Testing in Other IDEs</span>
+ </a> <span class="new">new!</span>
+ </li>
+ </ul>
+ </li>
+ <li class="toggle-list">
<div><a href="<?cs var:toroot ?>guide/developing/tools/index.html">
<span class="en">Tools</span>
</a></div>
@@ -412,8 +431,11 @@
<span class="en">Android API Levels</span>
</a></li>
<li><a href="<?cs var:toroot ?>guide/appendix/market-filters.html">
- <span class="en">Market Filters </span>
- </a><span class="new">new!</span></li>
+ <span class="en">Market Filters</span>
+ </a> <span class="new">new!</span></li>
+ <li><a href="<?cs var:toroot ?>guide/appendix/install-location.html">
+ <span class="en">App Install Location</span>
+ </a> <span class="new">new!</span></li>
<li><a href="<?cs var:toroot ?>guide/appendix/media-formats.html">
<span class="en">Supported Media Formats</span>
</a></li>
diff --git a/docs/html/guide/topics/manifest/application-element.jd b/docs/html/guide/topics/manifest/application-element.jd
index 08f35e9..786223f 100644
--- a/docs/html/guide/topics/manifest/application-element.jd
+++ b/docs/html/guide/topics/manifest/application-element.jd
@@ -3,8 +3,7 @@ page.title=&lt;application&gt;
<dl class="xml">
<dt>syntax:</dt>
-<dd><pre class="stx">&lt;application android:<a href="#backup">allowBackup</a>=["true" | "false"]
- android:<a href="#clear">allowClearUserData</a>=["true" | "false"]
+<dd><pre class="stx">&lt;application android:<a href="#clear">allowClearUserData</a>=["true" | "false"]
android:<a href="#reparent">allowTaskReparenting</a>=["true" | "false"]
android:<a href="#agent">backupAgent</a>="<i>string</i>"
android:<a href="#debug">debuggable</a>=["true" | "false"]
@@ -49,15 +48,6 @@ cannot be overridden by the components.</dd>
<dt>attributes</dt>
<dd><dl class="attr">
-<dt><a name="backup"></a>{@code android:allowBackup}</dt>
-<dd>Whether the application allows its data to be backed up through the Android
-Backup Manager &mdash; "{@code true}" if it does, "{@code false}" if not. By
-default this attribute is "{@code true}". If an application declares this
-attribute to be "{@code false}" the Backup Manager will never attempt to
-perform any backup or restore operation, even if the application declares a
-valid <a href="#agent">{@code android:backupAgent}</a> attribute in its
-manifest.
-</dd>
<dt><a name="clear"></a>{@code android:allowClearUserData}</dt>
<dd>Whether or not users are given the option to remove user data &mdash;
diff --git a/docs/html/guide/topics/manifest/instrumentation-element.jd b/docs/html/guide/topics/manifest/instrumentation-element.jd
index 1fd1dd0..b18e777 100644
--- a/docs/html/guide/topics/manifest/instrumentation-element.jd
+++ b/docs/html/guide/topics/manifest/instrumentation-element.jd
@@ -51,10 +51,6 @@ name specified in the <code><a href="{@docRoot}guide/topics/manifest/manifest-el
There is no default. The name must be specified.
</p></dd>
-<!-- ##api level indication## -->
-<dt>introduced in:</dt>
-<dd>API Level 1</dd>
-
<dt><a name="trgt"></a>{@code android:targetPackage}</dt>
<dd>The application that the Instrumentation object will run against.
An application is identified by the package name assigned in its manifest
@@ -62,4 +58,8 @@ file by the <code><a href="{@docRoot}guide/topics/manifest/manifest-element.html
</dl></dd>
+<!-- ##api level indication## -->
+<dt>introduced in:</dt>
+<dd>API Level 1</dd>
+
</dl>
diff --git a/docs/html/guide/topics/manifest/manifest-element.jd b/docs/html/guide/topics/manifest/manifest-element.jd
index 3353755..a35c5a1 100644
--- a/docs/html/guide/topics/manifest/manifest-element.jd
+++ b/docs/html/guide/topics/manifest/manifest-element.jd
@@ -161,6 +161,7 @@ this attribute is set to {@code internalOnly}, which is the default setting.</p>
<p>Introduced in: API Level 8.</p>
+
</dd>
</dl>
diff --git a/docs/html/guide/topics/testing/testing_android.jd b/docs/html/guide/topics/testing/testing_android.jd
index fc1d223..46ba769 100755
--- a/docs/html/guide/topics/testing/testing_android.jd
+++ b/docs/html/guide/topics/testing/testing_android.jd
@@ -1,5 +1,6 @@
page.title=Testing and Instrumentation
@jd:body
+
<div id="qv-wrapper">
<div id="qv">
<h2>In this document</h2>
@@ -72,70 +73,92 @@ page.title=Testing and Instrumentation
<h2>See Also</h2>
<ol>
<li>
- <a href="{@docRoot}guide/developing/testing_eclipse.html">Testing in Eclipse, with ADT</a>
+ <a href="{@docRoot}guide/developing/testing/testing_eclipse.html">Testing in Eclipse, with ADT</a>
</li>
<li>
- <a href="{@docRoot}guide/developing/testing_otheride.html">Testing in Other IDEs</a>
+ <a href="{@docRoot}guide/developing/testing/testing_otheride.html">Testing in Other IDEs</a>
</li>
</ol>
</div>
</div>
-<p>
-Android includes a powerful set of testing tools that extend the industry-standard JUnit test framework with features specific to the Android environment. Although you can
-test an Android application with JUnit, the Android tools allow you to write much more sophisticated tests for every aspect of your application, both at the unit and at the framework level.
-</p>
-<p>
-Key features of the Android testing environment include:
-</p>
+
+<p>Android includes a powerful set of testing tools that extend the
+industry-standard JUnit test framework with features specific to the Android
+environment. Although you can test an Android application with JUnit, the
+Android tools allow you to write much more sophisticated tests for every aspect
+of your application, both at the unit and framework levels.</p>
+
+<p>Key features of the Android testing environment include:</p>
+
<ul>
- <li>Android extensions to the JUnit framework that provide access to Android system objects.</li>
- <li>An instrumentation framework that lets tests control and examine the application.</li>
+ <li>Android extensions to the JUnit framework that provide access to Android
+system objects.</li>
+ <li>An instrumentation framework that lets tests control and examine the
+application.</li>
<li>Mock versions of commonly-used Android system objects.</li>
- <li>Tools for running single tests or test suites, with or without instrumentation.</li>
- <li>Support for managing tests and test projects in the ADT Plugin for Eclipse and at the command line.</li>
+ <li>Tools for running single tests or test suites, with or without
+instrumentation.</li>
+ <li>Support for managing tests and test projects in the ADT Plugin for Eclipse
+and at the command line.</li>
</ul>
-<p>
-This document is an overview of the Android testing environment and the way you use it. The document assumes you have a basic knowledge of
-Android application programming and JUnit testing methodology.
-</p>
+
+<p>This document is an overview of the Android testing environment and the way
+you use it. The document assumes you have a basic knowledge of Android
+application programming and JUnit testing methodology.</p>
+
<h2 id="Overview">Overview</h2>
-<p>
-At the heart of the Android testing environment is an instrumentation framework that your test application uses to precisely control the application under test. With instrumentation, you can
-set up mock system objects such as Contexts before the main application starts, control your application at various points of its lifecycle, send UI events to the application, and
-examine the application's state during its execution. The instrumentation framework accomplishes this by running both the main application and the test application in the same process.
-</p>
-<p>
- Your test application's manifest file links it to the application under test. The the &lt;instrumentation&gt; attribute in the manifest file points to the application under test
- and also tells Android how to run the test application. This is described in more detail in the section <a href="#InstrumentationTestRunner">Instrumentation Test Runner</a>.
-</p>
-<p>
-The following diagram summarizes the Android testing environment:
-</p>
+
+<p> At the heart of the Android testing environment is an instrumentation
+framework that your test application uses to precisely control the application
+under test. With instrumentation, you can set up mock system objects such as
+Contexts before the main application starts, control your application at various
+points of its lifecycle, send UI events to the application, and examine the
+application's state during its execution. The instrumentation framework
+accomplishes this by running both the main application and the test application
+in the same process. </p>
+
+<p>Your test application is linked to the application under test by means of an
+<a
+href="{@docRoot}guide/topics/manifest/instrumentation-element.html"><code>&lt;instrumentation&gt;</code></a>
+element in the test application's manifest file. The attributes of the element
+specify the package name of the application under test and also tell Android how
+to run the test application. Instrumentation is described in more detail in the
+section <a href="#InstrumentationTestRunner">Instrumentation Test
+Runner</a>.</p>
+
+<p>The following diagram summarizes the Android testing environment:</p>
+
<img src="{@docRoot}images/testing/android_test_framework.png"/>
-<!-- Something about test tools in Eclipse and in other IDEs -->
-<p>
- In Android, test applications are themselves Android applications, so you write them in much the same way as the application you are testing. The SDK tools
- help you create a main application project and its test project at the same time. You can run Android tests within Eclipse with ADT or from the command line.
- Eclipse with ADT provides an extensive set of tools for creating tests, running them, and viewing their results. You can also use the <code>adb</code> tool to
- run tests, or use a built-in Ant target.
-</p>
-<p>
- To learn how to set up and run tests in Eclipse, please refer to <a href="{@docRoot}guide/developing/testing_eclipse.html">Testing in Eclipse, with ADT</a>.
- If you're not working in Eclipse, refer to <a href="{@docRoot}guide/developing/testing_otheride.html">Testing in Other IDEs</a>.
-</p>
-<p>
- If you want a step-by-step introduction to Android testing, try one of the testing tutorials:
-</p>
- <ul>
- <li>
- The <a href="{@docRoot}resources/tutorials/testing/helloandroid_test.html">Hello, Testing</a> tutorial introduces basic testing concepts and procedures in the
- context of the Hello, World application.
- </li>
- <li>
- The <a href="{@docRoot}resources/tutorials/testing/activity_test.html">Activity Testing</a> tutorial is an excellent follow-up to the Hello, Testing tutorial.
- It guides you through a more complex testing scenario that you develop against a more realistic application.
- </li>
- </ul>
+
+<p>In Android, test applications are themselves Android applications, so you
+write them in much the same way as the application you are testing. The SDK
+tools help you create a main application project and its test project at the same
+time. You can run Android tests within Eclipse with ADT or from the command
+line. Eclipse with ADT provides an extensive set of tools for creating tests,
+running them, and viewing their results. You can also use the <code>adb</code>
+tool to run tests, or use a built-in Ant target.</p>
+
+<p>To learn how to set up and run tests in Eclipse, please refer to <a
+href="{@docRoot}guide/developing/testing/testing_eclipse.html">Testing in
+Eclipse, with ADT</a>. If you're not working in Eclipse, refer to <a
+href="{@docRoot}guide/developing/testing/testing_otheride.html">Testing in Other
+IDEs</a>.</p>
+
+<p>If you want a step-by-step introduction to Android testing, try one of the
+testing tutorials:</p>
+
+<ul>
+ <li>The <a
+href="{@docRoot}resources/tutorials/testing/helloandroid_test.html">Hello,
+Testing</a> tutorial introduces basic testing concepts and procedures in the
+context of the Hello, World application.</li>
+ <li>The <a
+href="{@docRoot}resources/tutorials/testing/activity_test.html">Activity
+Testing</a> tutorial is an excellent follow-up to the Hello, Testing tutorial.
+It guides you through a more complex testing scenario that you develop against a
+more realistic application.</li>
+</ul>
+
<h2 id="TestAPI">The Testing API</h2>
<p>
For writing tests and test applications in the Java programming language, Android provides a
@@ -277,15 +300,15 @@ The following diagram summarizes the Android testing environment:
</p>
<p>
The tools and procedures you use with testing depend on the development environment you are using. If you use Eclipse, then the ADT plug in for Eclipse provides tools that
- allow you to develop and run tests entirely within Eclipse. This is documented in the topic <a href="{@docRoot}guide/developing/testing_eclipse.html">Testing in Eclipse, with ADT</a>.
- If you use another development environment, then you use Android's command-line tools, as documented in the topic <a href="{@docRoot}guide/developing/testing_otheride.html">Testing in Other IDEs</a>.
+ allow you to develop and run tests entirely within Eclipse. This is documented in the topic <a href="{@docRoot}guide/developing/testing/testing_eclipse.html">Testing in Eclipse, with ADT</a>.
+ If you use another development environment, then you use Android's command-line tools, as documented in the topic <a href="{@docRoot}guide/developing/testing/testing_otheride.html">Testing in Other IDEs</a>.
</p>
<h3 id="TestProjects">Working with test projects</h3>
<p>
To start testing an Android application, you create a test project for it using Android tools. The tools create the project directory and the files and subdirectories needed.
The tools also create a manifest file that links the application in the test project to the application under test. The procedure for creating a test project in Eclipse with
- ADT is documented in <a href="{@docRoot}guide/developing/testing_eclipse.html">Testing in Eclipse, with ADT</a>. The procedure for creating a test project for use with development
- tools other than Eclipse is documented in <a href="{@docRoot}guide/developing/testing_otheride.html">Testing in Other IDEs</a>.
+ ADT is documented in <a href="{@docRoot}guide/developing/testing/testing_eclipse.html">Testing in Eclipse, with ADT</a>. The procedure for creating a test project for use with development
+ tools other than Eclipse is documented in <a href="{@docRoot}guide/developing/testing/testing_otheride.html">Testing in Other IDEs</a>.
</p>
<h3 id="TestClasses">Working with test case classes</h3>
<p>
diff --git a/docs/html/images/home/io-logo.png b/docs/html/images/home/io-logo.png
new file mode 100644
index 0000000..f579ca2
--- /dev/null
+++ b/docs/html/images/home/io-logo.png
Binary files differ
diff --git a/docs/html/index.jd b/docs/html/index.jd
index dd42ced..bb76d28 100644
--- a/docs/html/index.jd
+++ b/docs/html/index.jd
@@ -11,10 +11,13 @@ home=true
</div><!-- end homeTitle -->
<div id="announcement-block">
<!-- total max width is 520px -->
- <img src="{@docRoot}assets/images/home/gdc-logo.png" alt="Android at GDC 2010" width="203px" style="padding-left:22px;padding-bottom:28px;padding-top:22px;"/>
- <div id="announcement" style="width:275px">
-<p>Thanks to everyone who attended our sessions at the <a href="http://www.gdconf.com/">2010 Game Developers Conference</a> in San Francisco. We're looking forward to seeing your games running on Android!</p>
-<p><a href="http://android-developers.blogspot.com/2010/03/android-at-game-developers-conference.html">Learn more &raquo;</a></p>
+ <img src="{@docRoot}images/home/io-logo.png" alt="Google IO
+2010" width="200" height="41" style="padding:22px 12px;"/>
+ <div id="announcement" style="width:295px">
+<p>Google I/O is happening now! To those of you with us, welcome! If you couldn't make it to the
+event, stay tuned for videos and slides from the Android sessions, which will be posted at the
+Google I/O web site.</p><p><a
+href="http://code.google.com/events/io/2010/sessions.html#Android">Learn more &raquo;</a></p>
</div> <!-- end annoucement -->
</div> <!-- end annoucement-block -->
</div><!-- end topAnnouncement -->
@@ -125,17 +128,17 @@ href="{@docRoot}resources/dashboard/platform-versions.html">Learn more &raquo;</
'sdk': {
'layout':"imgLeft",
'icon':"sdk-small.png",
- 'name':"Android 2.1",
- 'img':"sdk-large.png",
- 'title':"Android 2.1 is now available",
- 'desc': "<p>Android 2.1 is a small feature release that includes new developer APIs "
- + "and documentation. For information about what's included in the platform, "
- + "read the <a href='{@docRoot}sdk/android-2.1.html'>Android 2.1 "
- + "version notes</a>.</p>"
- + "<p>You can update your existing development environment "
- + "by installing the Android 2.1 platform as an "
- + "<a href='{@docRoot}sdk/adding-components.html'>SDK "
- + "component</a>."
+ 'name':"Android 2.2",
+ 'img':"froyo-android.png",
+ 'title':"Get Android 2.2!",
+ 'desc': "<p>The Android 2.2 platform is now available for the Android SDK, along with new "
++ "tools, documentation, and a new NDK. "
++ "For information about new features and APIs, read the "
++ "<a href='{@docRoot}sdk/android-2.2.html'>version notes</a>.</p>"
++ "<p>If you have an existing SDK, add Android 2.2 as an "
++ "<a href='{@docRoot}sdk/adding-components.html'>SDK "
++ "component</a>. If you're new to Android, install the "
++ "<a href='{@docRoot}sdk/index.html'>SDK starter package</a>."
},
'adc2': {
@@ -179,10 +182,10 @@ href="{@docRoot}resources/dashboard/platform-versions.html">Learn more &raquo;</
'io': {
'layout':"imgLeft",
'icon':"io-small.png",
- 'name':"Google I/O",
+ 'name':"Google I/O '09'",
'img':"io-large.png",
- 'title':"Google I/O Developer Conference",
- 'desc': "<p>The Google I/O developer conference took place May 27-28 in San Francisco. If you missed the conference, you can experience the Android sessions by viewing YouTube videos.</p><p><a href='{@docRoot}videos/index.html'>See the sessions from Google I/O &raquo;</a></p>"
+ 'title':"2009 Google I/O Developer Conference",
+ 'desc': "<p>The 2009 Google I/O developer conference took place May 27-28, 2009, in San Francisco. If you missed the conference, you can experience the Android sessions by viewing YouTube videos.</p><p><a href='{@docRoot}videos/index.html'>See the sessions from Google I/O &raquo;</a></p>"
}
}
diff --git a/docs/html/resources/tutorials/testing/helloandroid_test.jd b/docs/html/resources/tutorials/testing/helloandroid_test.jd
index f06d5af..b47c334 100644
--- a/docs/html/resources/tutorials/testing/helloandroid_test.jd
+++ b/docs/html/resources/tutorials/testing/helloandroid_test.jd
@@ -86,7 +86,7 @@ page.title=Hello, Testing
</p>
<p>
If you aren't developing in Eclipse with ADT or you would like to run tests directly from the
- command line, please see the topic <a href="{@docRoot}guide/developing/testing_otheride.html">Testing in Other IDEs</a>
+ command line, please see the topic <a href="{@docRoot}guide/developing/testing/testing_otheride.html">Testing in Other IDEs</a>
for instructions.
</p>
<h2 id="CreateTestProject">Creating the Test Project</h2>
diff --git a/docs/html/sdk/ndk/index.jd b/docs/html/sdk/ndk/index.jd
index fa2e712..93c5fb8 100644
--- a/docs/html/sdk/ndk/index.jd
+++ b/docs/html/sdk/ndk/index.jd
@@ -1,16 +1,16 @@
ndk=true
-ndk.win_download=android-ndk-r3-windows.zip
-ndk.win_bytes=36473391
-ndk.win_checksum=4ce5c93a15f261b6dcade1b69da00902
+ndk.win_download=android-ndk-r4-windows.zip
+ndk.win_bytes=
+ndk.win_checksum=
-ndk.mac_download=android-ndk-r3-darwin-x86.zip
-ndk.mac_bytes=38258228
-ndk.mac_checksum=a083ccc36aa9a3a35404861e7d51d1ae
+ndk.mac_download=android-ndk-r4-darwin-x86.zip
+ndk.mac_bytes=
+ndk.mac_checksum=
-ndk.linux_download=android-ndk-r3-linux-x86.zip
-ndk.linux_bytes=37403241
-ndk.linux_checksum=f3b1700a195aae3a6e9b5637e5c49359
+ndk.linux_download=android-ndk-r4-linux-x86.zip
+ndk.linux_bytes=
+ndk.linux_checksum=
page.title=Android NDK
@jd:body
@@ -38,20 +38,19 @@ function toggleDiv(link) {
}
</script>
<style>
-
.toggleable {
padding: .25em 1em;
-xfont-size:.95em;
}
-
.toggleme {
- xmargin:1em;
padding: 1em 1em 0 2em;
-line-height:1em;
+ line-height:1em;
}
.toggleable a {
text-decoration:none;
}
+.toggleme a {
+ text-decoration:underline;
+}
.toggleable.closed .toggleme {
display:none;
}
@@ -63,6 +62,58 @@ line-height:1em;
<div class="toggleable open">
<a href="#" onclick="return toggleDiv(this)">
<img src="{@docRoot}assets/images/triangle-opened.png" class="toggle-img" height="9px" width="9px" />
+Android NDK, Revision 4</a> <em>(May 2010)</em>
+ <div class="toggleme">
+
+<dl>
+<dt>General notes:</dt>
+
+<dd>
+<ul>
+<li>Provides a simplified build system through the new <code>ndk-build</code> build
+command. </li>
+<li>Adds support for easy native debugging of generated machine code through the new
+<code>ndk-gdb</code> command.</li>
+<li>Adds a new Android-specific ABI for ARM-based CPU architectures,
+<code>armeabi-v7a</code>. The new ABI extends the existing <code>armeabi</code>
+ABI to include these CPU instruction set extensions:
+<ul>
+<li>Thumb-2 instructions</li>
+<li>VFP hardware FPU instructions (VFPv3-D16)</li>
+<li>Optional support for ARM Advanced SIMD (NEON) GCC intrinsics and VFPv3-D32.
+Supported by devices such as Verizon Droid, Google Nexus One, and others.</li>
+</ul>
+<li>Adds a new <code>cpufeatures</code> static library (with sources) that lets
+your app detect the host device's CPU features at runtime. Specifically,
+applications can check for ARMv7-A support, as well as VFPv3-D32 and NEON
+support, then provide separate code paths as needed.</li>
+<li>Adds a sample application, <code>hello-neon</code>, that illustrates how to
+use the <code>cpufeatures</code> library to check CPU features and then provide
+an optimized code path using NEON instrinsics, if
+supported by the CPU.</li>
+<li>Lets you generate machine code for either or both of the instruction sets
+supported by the NDK. For example, you can build for both ARMv5 and ARMv7-A
+architectures at the same time and have everything stored to your application's
+final <code>.apk</code>.</li>
+<li>To ensure that your applications are available to users only if their
+devices are capable of running them, Android Market now filters applications
+based on the instruction set information included in your application &mdash; no
+action is needed on your part to enable the filtering. Additionally, the Android
+system itself also checks your application at install time and allows the
+installation to continue only if the application provides a library that is
+compiled for the device's CPU architecture.</li>
+<li>Adds support for Android 2.2, including a new stable API for accessing
+the pixel buffers of {@link android.graphics.Bitmap} objects from native
+code.</li>
+</ul>
+</dd>
+</dl>
+</div>
+</div>
+
+<div class="toggleable closed">
+ <a href="#" onclick="return toggleDiv(this)">
+ <img src="{@docRoot}assets/images/triangle-opened.png" class="toggle-img" height="9px" width="9px" />
Android NDK, Revision 3</a> <em>(March 2010)</em>
<div class="toggleme">
@@ -142,17 +193,34 @@ in the form of reuse of existing code and in some cases increased speed.</p>
<ul>
<li>A set of tools and build files used to generate native code libraries from C
and C++ sources</li>
-<li>A way to embed the corresponding native libraries into application package
-files (.apks) that can be deployed on Android devices</li>
+<li>A way to embed the corresponding native libraries into an application package
+file (<code>.apk</code>) that can be deployed on Android devices</li>
<li>A set of native system headers and libraries that will be supported in all
future versions of the Android platform, starting from Android 1.5 </li>
<li>Documentation, samples, and tutorials</li>
</ul>
-<p>This release of the NDK supports the ARMv5TE machine instruction set and
-provides stable headers for libc (the C library), libm (the Math library),
-OpenGL ES (3D graphics library), the JNI interface, and other libraries, as
-listed in the section below.</p>
+<p>The latest release of the NDK supports these ARM instruction sets:</p>
+<ul>
+<li>ARMv5TE (including Thumb-1 instructions)</li>
+<li>ARMv7-A (including Thumb-2 and VFPv3-D16 instructions, with
+optional support for NEON/VFPv3-D32 instructions)</li>
+</ul>
+
+<p>ARMv5TE machine code will run on all ARM-based Android devices. ARMv7-A will
+run only on devices such as the Verizon Droid or Google Nexus One that have a
+compatible CPU. The main difference between the two instruction sets is that
+ARMv7-A supports hardware FPU, Thumb-2, and NEON instructions. You can target
+either or both of the instruction sets &mdash; ARMv5TE is the default, but
+switching to ARMv7-A is as easy as adding a single line to the application's
+Application.mk file, without needing to change anything else in the file. You
+can also build for both architectures at the same time and have everything
+stored in the final <code>.apk</code>. Complete information is provided in the
+CPU-ARCH-ABIS.TXT in the NDK package. </p>
+
+<p>The NDK provides stable headers for libc (the C library), libm (the Math
+library), OpenGL ES (3D graphics library), the JNI interface, and other
+libraries, as listed in the section below.</p>
<p>The NDK will not benefit most applications. As a developer, you will need
to balance its benefits against its drawbacks; notably, using native code does
@@ -184,6 +252,7 @@ guaranteed to be supported in all later releases of the platform:</p>
<li>libz (Zlib compression) headers</li>
<li>liblog (Android logging) header</li>
<li>OpenGL ES 1.1 and OpenGL ES 2.0 (3D graphics libraries) headers</li>
+<li>libjnigraphics (Pixel buffer access) header (for Android 2.2 and above).</li>
<li>A Minimal set of headers for C++ support</li>
</ul>
@@ -224,6 +293,11 @@ that you should be aware of, if you are developing using the NDK. </li>
by headers in the NDK.</li>
<li>CPU-ARCH-ABIS.TXT &mdash; a description of supported CPU architectures
and how to target them. </li>
+<li>CPU-FEATURES.TXT &mdash; a description of the <code>cpufeatures</code>
+static library that lets your application code detect the target device's
+CPU family and the optional features at runtime. </li>
+<li>CPU-ARM-NEON.TXT &mdash; a description of how to build with optional
+ARM NEON / VFPv3-D32 instructions. </li>
<li>CHANGES.TXT &mdash; a complete list of changes to the NDK across all
releases.</li>
</ul>
@@ -268,8 +342,10 @@ required.</li>
<ul>
<li>For all development platforms, GNU Make 3.81 or later is required. Earlier
versions of GNU Make might work but have not been tested.</li>
- <li>For Windows, a recent release of <a
-href="http://www.cygwin.com">Cygwin</a> is required. </li>
+ <li>A recent version of awk (either GNU Awk or Nawk) is also required.</li>
+ <li>For Windows, <a
+href="http://www.cygwin.com">Cygwin</a> 1.7 or higher is required. The NDK
+will <em>not</em> work with Cygwin 1.5 installations.</li>
</ul>
<h4>Android platform compatibility</h4>
@@ -294,7 +370,7 @@ value of "3" or higher. For example:
&lt;/manifest&gt;</pre>
</li>
-<li>Additionally, if you use this NDK to create a native library that uses the
+<li>If you use this NDK to create a native library that uses the
OpenGL ES APIs, the application containing the library can be deployed only to
devices running the minimum platform versions described in the table below.
To ensure compatibility, make sure that your application declares the proper
@@ -310,16 +386,42 @@ To ensure compatibility, make sure that your application declares the proper
<tr><td>OpenGL ES 2.0</td><td>Android 2.0 and higher</td><td><code>android:minSdkVersion="5"</code></td></tr>
</table>
-<p>For more information about API Level and its relationship to Android
+<p>For more information about API Level and its relationship to Android
platform versions, see <a href="{@docRoot}guide/appendix/api-levels.html">
Android API Levels</a>.</p></li>
+
+<li>Additionally, an application using the OpenGL ES APIs should declare a
+<code>&lt;uses-feature&gt;</code> element in its manifest, with an
+<code>android:glEsVersion</code> attribute that specifies the minimum OpenGl ES
+version required by the application. This ensures that Android Market will show
+your application only to users whose devices are capable of supporting your
+application. For example:
+
+<pre style="margin:1em;">&lt;manifest&gt;
+ ...
+<!-- Declare that the application uses the OpenGL ES 2.0 API and is designed
+ to run only on devices that support OpenGL ES 2.0 or higher. -->
+ &lt;uses-feature android:glEsVersion="0x00020000" /&gt;
+ ...
+&lt;/manifest&gt;</pre>
+
+<p>For more information, see the <a
+href="{@docRoot}guide/topics/manifest/uses-feature-element.html"><code>&lt;uses-feature&gt;</code></a>
+documentation.</p></li>
+
+<li>If you use this NDK to create a native library that uses the API to access
+Android {@link android.graphics.Bitmap} pixel buffers, the application
+containing the library can be deployed only to devices running Android 2.2 (API
+level 8) or higher. To ensure compatibility, make sure that your application
+declares <code>&lt;uses-sdk android:minSdkVersion="8" /&gt;</code>attribute
+value in its manifest.</li>
</ul>
<h2 id="installing">Installing the NDK</h2>
<p>Installing the NDK on your development computer is straightforward and
-involves extracting the NDK from its download package and running a host-setup
-script. </p>
+involves extracting the NDK from its download package. Unlike previous releases,
+there is no need to run a host-setup script.</p>
<p>Before you get started make sure that you have downloaded the latest <a
href="{@docRoot}sdk/index.html">Android SDK</a> and upgraded your applications
@@ -337,21 +439,9 @@ When uncompressed, the NDK files are contained in a directory called
<code>android-ndk-&lt;version&gt;</code>. You can rename the NDK directory if
necessary and you can move it to any location on your computer. This
documentation refers to the NDK directory as <code>&lt;ndk&gt;</code>. </li>
-<li>Open a terminal, change to the NDK directory, and run the host-setup script.
-The script sets up your environment and generates a host configuration file used
-later, when building your shared libraries. The path to the host-setup script
-is:
-
-<p><code>&lt;ndk&gt;/build/host-setup.sh</code></p>
-
-<p>If the script completes successfully, it prints a "Host setup complete."
-message. If it fails, it prints instructions that you can follow to correct any
-problems. </p>
-</li>
</ol>
-<p>Once you have run the host-setup script, you are ready start working with the
-NDK. </p>
+<p>You are now ready start working with the NDK. </p>
<h2 id="gettingstarted">Getting Started with the NDK</h2>
@@ -371,17 +461,14 @@ list of NDK changes in the CHANGES.TXT document. </p>
<code>&lt;project&gt;/jni/...</code></li>
<li>Create <code>&lt;project&gt;/jni/Android.mk</code> to
describe your native sources to the NDK build system</li>
-<li>Create <code>&lt;ndk&gt;/apps/&lt;my_app&gt;/Application.mk</code> to
-describe your Android application and native sources it needs to the NDK build
-system. This file sets up the link between an Android SDK application project
-and any number of shared libraries defined in the
-<code>&lt;project&gt;/jni/</code> folder and it specifies the path to the
-application project that will receive the shared library built from the
-sources.</li>
-<li>Build your native code by running this make command from the top-level NDK
-directory:
-
-<p><code>$ make APP=&lt;my_app&gt;</code></p>
+<li>Optional: Create <code>&lt;project&gt;/jni/Application.mk</code>.</li>
+<li>Build your native code by running the 'ndk-build' script from your projet's directory.
+It is located in the top-level NDK directory:
+
+<p><pre>
+$ cd &lt;project&gt;
+$ &lt;ndk&gt;/ndk-build
+</pre></p>
<p>The build tools copy the stripped, shared libraries needed by your
application to the proper location in the application's project directory.</p>
@@ -389,7 +476,7 @@ application to the proper location in the application's project directory.</p>
<li>Finally, compile your application using the SDK tools in the usual way. The
SDK build tools will package the shared libraries in the application's
-deployable .apk file. </p></li>
+deployable <code>.apk</code> file. </p></li>
</ol>
@@ -399,7 +486,7 @@ documentation included with the NDK package. </p>
<h2 id="samples">Using the Sample Applications</h2>
-<p>The NDK includes four sample applications that illustrate how to use native
+<p>The NDK includes sample applications that illustrate how to use native
code in your Android applications:</p>
<ul>
@@ -415,36 +502,27 @@ graphics through the native OpenGL ES APIs, while managing activity lifecycle
with a {@link android.opengl.GLSurfaceView} object. </li>
<li><code>hello-gl2</code> &mdash; a simple application that renders a triangle
using OpenGL ES 2.0 vertex and fragment shaders.</li>
+<li><code>hello-neon</code> &mdash; a simple application that shows how to use
+the <code>cpufeatures</code> library to check CPU capabilities at runtime,
+then use NEON intrinsics if supported by the CPU. Specifically, the
+application implements two versions of a tiny benchmark for a FIR filter
+loop, a C version and a NEON-optimized version for devices that support it.</li>
+<li><code>bitmap-plasma</code> &mdash; a simple application that demonstrates
+how to access the pixel buffers of Android {@link android.graphics.Bitmap}
+objects from native code, and uses this to generate an old-school "plasma"
+effect. </li>
</ul>
-<p>For each sample, the NDK includes an Android application project, as well as
-the corresponding C source code and the necessary Android.mk and Application.mk
-files. The application projects are provided in
-<code>&lt;ndk&gt;/apps/&lt;app_name&gt;/project/</code> and the C source for
-each application is provided in
-<code>&lt;ndk&gt;/apps/&lt;app_name&gt;/project/jni/</code>.</p>
+<p>For each sample, the NDK includes the corresponding C source code and the
+necessary Android.mk and Application.mk files. There are located under
+<code>&lt;ndk&gt;/samples/&lt;name&gt;/</code> and their source code can be found under
+<code>&lt;ndk&gt;/samples/&lt;name&gt;/jni/</code>. </p>
-<p>Once you have installed the NDK and run <code>$ build/host-setup.sh</code> from
-the root of the NDK directory, you can build the shared libraries for the
-sample apps by using these commands:</p>
-<ul>
-<li><code>$ make APP=hello-jni</code> &mdash; compiles
-<code>hello-jni.c</code> and outputs a shared library to
-<code>&lt;ndk&gt;/apps/hello-jni/project/libs/armeabi/libhello-jni.so</code>.
-</li>
-<li><code>$ make APP=two-libs</code> &mdash; compiles
-<code>first.c</code> and <code>second.c</code> and outputs a shared library to
-<code>&lt;ndk&gt;/apps/two-libs/project/libs/armeabi/libtwolib-second.so</code>.
-</li>
-<li><code>$ make APP=san-angeles</code> &mdash; compiles
-<code>importgl.c</code>, <code>demo.c</code>,and <code>app-android.c</code> and
-outputs a shared library to <code>&lt;ndk&gt;/apps/san-angeles/project/libs/armeabi/libsangeles.so</code>.
-</li>
-<li><code>$ make APP=hello-gl2</code> &mdash; compiles
-<code>gl_code.cpp</code> and outputs a shared library to
-<code>&lt;ndk&gt;/apps/hello-gl2/project/libs/armeabi/libgl2jni.so</code>.
-</li>
-</ul>
+<p>You can build the shared libraries for the sample apps by going into <code>&lt;ndk&gt;/samples/&lt;name&gt;/</code>
+then calling the <code>ndk-build</code> command. The generated shared libraries will be located under
+<code>&lt;ndk&gt;/samples/&lt;name&gt;/libs/armeabi/</code> for (ARMv5TE machine code) and/or
+<code>&lt;ndk&gt;/samples/&lt;name&gt;/libs/armeabi-v7a/</code> for (ARMv7 machine code).
+</p>
<p>Next, build the sample Android applications that use the shared
libraries:</p>
@@ -475,3 +553,4 @@ href="http://groups.google.com/group/android-ndk">android-ndk</a> group and
mailing list.</p>
+
diff --git a/docs/html/sdk/sdk_toc.cs b/docs/html/sdk/sdk_toc.cs
index a845e55..5a72491 100644
--- a/docs/html/sdk/sdk_toc.cs
+++ b/docs/html/sdk/sdk_toc.cs
@@ -123,7 +123,7 @@
<span style="display:none" class="zh-TW"></span>
</h2>
<ul>
- <li><a href="<?cs var:toroot ?>sdk/ndk/index.html">Android NDK, r3</a>
+ <li><a href="<?cs var:toroot ?>sdk/ndk/index.html">Android NDK, r4</a>
<span class="new">new!</span></li>
</ul>
</li>
diff --git a/include/camera/CameraParameters.h b/include/camera/CameraParameters.h
index 3b0e9e5..5ea83a5 100644
--- a/include/camera/CameraParameters.h
+++ b/include/camera/CameraParameters.h
@@ -39,23 +39,16 @@ public:
int getInt(const char *key) const;
float getFloat(const char *key) const;
- /* preview-size=176x144 */
+ void remove(const char *key);
+
void setPreviewSize(int width, int height);
void getPreviewSize(int *width, int *height) const;
-
- /* preview-fps=15 */
void setPreviewFrameRate(int fps);
int getPreviewFrameRate() const;
-
- /* preview-format=rgb565|yuv422 */
void setPreviewFormat(const char *format);
const char *getPreviewFormat() const;
-
- /* picture-size=1024x768 */
void setPictureSize(int width, int height);
void getPictureSize(int *width, int *height) const;
-
- /* picture-format=yuv422|jpeg */
void setPictureFormat(const char *format);
const char *getPictureFormat() const;
diff --git a/include/media/stagefright/HTTPDataSource.h b/include/media/stagefright/HTTPDataSource.h
index f3b44fd..0400bea 100644
--- a/include/media/stagefright/HTTPDataSource.h
+++ b/include/media/stagefright/HTTPDataSource.h
@@ -91,6 +91,7 @@ private:
void initHeaders(const KeyedVector<String8, String8> *overrides);
status_t connectWithRedirectsAndRange(off_t rangeStart);
+ void applyTimeoutResponse();
HTTPDataSource(const HTTPDataSource &);
HTTPDataSource &operator=(const HTTPDataSource &);
diff --git a/libs/camera/CameraParameters.cpp b/libs/camera/CameraParameters.cpp
index b50d4d2..65fd7ac 100644
--- a/libs/camera/CameraParameters.cpp
+++ b/libs/camera/CameraParameters.cpp
@@ -253,6 +253,11 @@ float CameraParameters::getFloat(const char *key) const
return strtof(v, 0);
}
+void CameraParameters::remove(const char *key)
+{
+ mMap.removeItem(String8(key));
+}
+
static int parse_size(const char *str, int &width, int &height)
{
// Find the width.
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java
index 47e2da2..bbbba74 100644
--- a/media/java/android/media/AudioManager.java
+++ b/media/java/android/media/AudioManager.java
@@ -1382,7 +1382,11 @@ public class AudioManager {
}
/**
- * Register a listener for audio focus updates.
+ * @hide
+ * Registers a listener to be called when audio focus changes. Calling this method is optional
+ * before calling {@link #requestAudioFocus(OnAudioFocusChangeListener, int, int)}, as it
+ * will register the listener as well if it wasn't registered already.
+ * @param l the listener to be notified of audio focus changes.
*/
public void registerAudioFocusListener(OnAudioFocusChangeListener l) {
synchronized(mFocusListenerLock) {
@@ -1394,16 +1398,12 @@ public class AudioManager {
}
/**
- * TODO document for SDK
+ * @hide
+ * Causes the specified listener to not be called anymore when focus is gained or lost.
+ * @param l the listener to unregister.
*/
public void unregisterAudioFocusListener(OnAudioFocusChangeListener l) {
- // notify service to remove it from audio focus stack
- IAudioService service = getService();
- try {
- service.unregisterAudioFocusClient(getIdForAudioFocusListener(l));
- } catch (RemoteException e) {
- Log.e(TAG, "Can't call unregisterFocusClient() from AudioService due to "+e);
- }
+
// remove locally
synchronized(mFocusListenerLock) {
mAudioFocusIdListenerMap.remove(getIdForAudioFocusListener(l));
@@ -1412,18 +1412,18 @@ public class AudioManager {
/**
- * TODO document for SDK
+ * A failed focus change request.
*/
public static final int AUDIOFOCUS_REQUEST_FAILED = 0;
/**
- * TODO document for SDK
+ * A successful focus change request.
*/
public static final int AUDIOFOCUS_REQUEST_GRANTED = 1;
/**
* Request audio focus.
- * Send a request to obtain the audio focus for a specific stream type
+ * Send a request to obtain the audio focus
* @param l the listener to be notified of audio focus changes
* @param streamType the main audio stream type affected by the focus request
* @param durationHint use {@link #AUDIOFOCUS_GAIN_TRANSIENT} to indicate this focus request
@@ -1456,13 +1456,13 @@ public class AudioManager {
/**
- * TODO document for SDK
- * Abandon audio focus.
+ * Abandon audio focus. Causes the previous focus owner, if any, to receive focus.
+ * @param l the listener with which focus was requested.
* @return {@link #AUDIOFOCUS_REQUEST_FAILED} or {@link #AUDIOFOCUS_REQUEST_GRANTED}
*/
public int abandonAudioFocus(OnAudioFocusChangeListener l) {
int status = AUDIOFOCUS_REQUEST_FAILED;
- registerAudioFocusListener(l);
+ unregisterAudioFocusListener(l);
IAudioService service = getService();
try {
status = service.abandonAudioFocus(mAudioFocusDispatcher,
@@ -1477,7 +1477,7 @@ public class AudioManager {
//====================================================================
// Remote Control
/**
- * TODO document for SDK
+ * Register a component to be the sole receiver of MEDIA_BUTTON intents.
* @param eventReceiver identifier of a {@link android.content.BroadcastReceiver}
* that will receive the media button intent. This broadcast receiver must be declared
* in the application manifest.
@@ -1493,7 +1493,9 @@ public class AudioManager {
}
/**
- * TODO document for SDK
+ * Unregister the receiver of MEDIA_BUTTON intents.
+ * @param eventReceiver identifier of a {@link android.content.BroadcastReceiver}
+ * that was registered with {@link #registerMediaButtonEventReceiver(ComponentName)}.
*/
public void unregisterMediaButtonEventReceiver(ComponentName eventReceiver) {
IAudioService service = getService();
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index d55d0a5..5c278d9 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -1930,6 +1930,8 @@ public class AudioService extends IAudioService.Stub {
*/
private final static String IN_VOICE_COMM_FOCUS_ID = "AudioFocus_For_Phone_Ring_And_Calls";
+ private final static Object mAudioFocusLock = new Object();
+
private PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
@Override
public void onCallStateChanged(int state, String incomingNumber) {
@@ -2000,7 +2002,7 @@ public class AudioService extends IAudioService.Stub {
*/
private void dumpFocusStack(PrintWriter pw) {
pw.println("\nAudio Focus stack entries:");
- synchronized(mFocusStack) {
+ synchronized(mAudioFocusLock) {
Iterator<FocusStackEntry> stackIterator = mFocusStack.iterator();
while(stackIterator.hasNext()) {
FocusStackEntry fse = stackIterator.next();
@@ -2091,7 +2093,7 @@ public class AudioService extends IAudioService.Stub {
}
public void binderDied() {
- synchronized(mFocusStack) {
+ synchronized(mAudioFocusLock) {
Log.w(TAG, " AudioFocus audio focus client died");
removeFocusStackEntryForClient(mCb);
}
@@ -2117,11 +2119,11 @@ public class AudioService extends IAudioService.Stub {
return AudioManager.AUDIOFOCUS_REQUEST_FAILED;
}
- if (!canReassignAudioFocus()) {
- return AudioManager.AUDIOFOCUS_REQUEST_FAILED;
- }
+ synchronized(mAudioFocusLock) {
+ if (!canReassignAudioFocus()) {
+ return AudioManager.AUDIOFOCUS_REQUEST_FAILED;
+ }
- synchronized(mFocusStack) {
if (!mFocusStack.empty() && mFocusStack.peek().mClientId.equals(clientId)) {
// if focus is already owned by this client and the reason for acquiring the focus
// hasn't changed, don't do anything
@@ -2151,7 +2153,7 @@ public class AudioService extends IAudioService.Stub {
// push focus requester at the top of the audio focus stack
mFocusStack.push(new FocusStackEntry(mainStreamType, focusChangeHint, false, fd, cb,
clientId));
- }//synchronized(mFocusStack)
+ }//synchronized(mAudioFocusLock)
// handle the potential premature death of the new holder of the focus
// (premature death == death before abandoning focus) for a client which is not the
@@ -2173,10 +2175,17 @@ public class AudioService extends IAudioService.Stub {
/** @see AudioManager#abandonAudioFocus(IAudioFocusDispatcher) */
public int abandonAudioFocus(IAudioFocusDispatcher fl, String clientId) {
Log.i(TAG, " AudioFocus abandonAudioFocus() from " + clientId);
-
- // this will take care of notifying the new focus owner if needed
- synchronized(mFocusStack) {
- removeFocusStackEntry(clientId, true);
+ try {
+ // this will take care of notifying the new focus owner if needed
+ synchronized(mAudioFocusLock) {
+ removeFocusStackEntry(clientId, true);
+ }
+ } catch (java.util.ConcurrentModificationException cme) {
+ // Catching this exception here is temporary. It is here just to prevent
+ // a crash seen when the "Silent" notification is played. This is believed to be fixed
+ // but this try catch block is left just to be safe.
+ Log.e(TAG, "FATAL EXCEPTION AudioFocus abandonAudioFocus() caused " + cme);
+ cme.printStackTrace();
}
return AudioManager.AUDIOFOCUS_REQUEST_GRANTED;
@@ -2184,7 +2193,7 @@ public class AudioService extends IAudioService.Stub {
public void unregisterAudioFocusClient(String clientId) {
- synchronized(mFocusStack) {
+ synchronized(mAudioFocusLock) {
removeFocusStackEntry(clientId, false);
}
}
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java
index e80ece6..013f8fc 100644
--- a/media/java/android/media/MediaScanner.java
+++ b/media/java/android/media/MediaScanner.java
@@ -869,12 +869,15 @@ public class MediaScanner
values.put(MediaStore.Images.ImageColumns.DATA, "");
String [] pathSpec = new String[] {path + '%'};
try {
+ // These tables have DELETE_FILE triggers that delete the file from the
+ // sd card when deleting the database entry. We don't want to do this in
+ // this case, since it would cause those files to be removed if a .nomedia
+ // file was added after the fact, when in that case we only want the database
+ // entries to be removed.
mMediaProvider.update(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values,
MediaStore.Images.ImageColumns.DATA + " LIKE ?", pathSpec);
mMediaProvider.update(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, values,
MediaStore.Images.ImageColumns.DATA + " LIKE ?", pathSpec);
- mMediaProvider.update(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, values,
- MediaStore.Images.ImageColumns.DATA + " LIKE ?", pathSpec);
} catch (RemoteException e) {
throw new RuntimeException();
}
diff --git a/media/libstagefright/HTTPDataSource.cpp b/media/libstagefright/HTTPDataSource.cpp
index 8e26c37e..f72a6cc 100644
--- a/media/libstagefright/HTTPDataSource.cpp
+++ b/media/libstagefright/HTTPDataSource.cpp
@@ -84,6 +84,7 @@ status_t HTTPDataSource::connectWithRedirectsAndRange(off_t rangeStart) {
}
if (httpStatus >= 200 && httpStatus < 300) {
+ applyTimeoutResponse();
return OK;
}
@@ -133,6 +134,22 @@ status_t HTTPDataSource::connectWithRedirectsAndRange(off_t rangeStart) {
return ERROR_IO;
}
+void HTTPDataSource::applyTimeoutResponse() {
+ string timeout;
+ if (mHttp->find_header_value("X-SocketTimeout", &timeout)) {
+ const char *s = timeout.c_str();
+ char *end;
+ long tmp = strtol(s, &end, 10);
+ if (end == s || *end != '\0') {
+ LOGW("Illegal X-SocketTimeout value given.");
+ return;
+ }
+
+ LOGI("overriding default timeout, new timeout is %ld seconds", tmp);
+ mHttp->setReceiveTimeout(tmp);
+ }
+}
+
HTTPDataSource::HTTPDataSource(
const char *uri, const KeyedVector<String8, String8> *headers) {
CHECK(!strncasecmp("http://", uri, 7));
diff --git a/media/libstagefright/HTTPStream.cpp b/media/libstagefright/HTTPStream.cpp
index 6145ec2..9c99866 100644
--- a/media/libstagefright/HTTPStream.cpp
+++ b/media/libstagefright/HTTPStream.cpp
@@ -68,10 +68,7 @@ status_t HTTPStream::connect(const char *server, int port) {
return UNKNOWN_ERROR;
}
- struct timeval tv;
- tv.tv_usec = 0;
- tv.tv_sec = 5;
- CHECK_EQ(0, setsockopt(mSocket, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)));
+ setReceiveTimeout(5); // Time out reads after 5 secs by default
mState = CONNECTING;
@@ -329,5 +326,17 @@ bool HTTPStream::find_header_value(const string &key, string *value) const {
return true;
}
+void HTTPStream::setReceiveTimeout(int seconds) {
+ if (seconds < 0) {
+ // Disable the timeout.
+ seconds = 0;
+ }
+
+ struct timeval tv;
+ tv.tv_usec = 0;
+ tv.tv_sec = seconds;
+ CHECK_EQ(0, setsockopt(mSocket, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)));
+}
+
} // namespace android
diff --git a/media/libstagefright/OggExtractor.cpp b/media/libstagefright/OggExtractor.cpp
index 699b955..d0d1b14 100644
--- a/media/libstagefright/OggExtractor.cpp
+++ b/media/libstagefright/OggExtractor.cpp
@@ -94,6 +94,8 @@ private:
size_t mCurrentPageSize;
size_t mNextLaceIndex;
+ off_t mFirstDataOffset;
+
vorbis_info mVi;
vorbis_comment mVc;
@@ -183,7 +185,8 @@ MyVorbisExtractor::MyVorbisExtractor(const sp<DataSource> &source)
: mSource(source),
mOffset(0),
mCurrentPageSize(0),
- mNextLaceIndex(0) {
+ mNextLaceIndex(0),
+ mFirstDataOffset(-1) {
mCurrentPage.mNumSegments = 0;
}
@@ -222,6 +225,12 @@ status_t MyVorbisExtractor::findNextPage(
}
status_t MyVorbisExtractor::seekToOffset(off_t offset) {
+ if (mFirstDataOffset >= 0 && offset < mFirstDataOffset) {
+ // Once we know where the actual audio data starts (past the headers)
+ // don't ever seek to anywhere before that.
+ offset = mFirstDataOffset;
+ }
+
off_t pageOffset;
status_t err = findNextPage(offset, &pageOffset);
@@ -438,6 +447,8 @@ void MyVorbisExtractor::init() {
verifyHeader(packet, 5);
packet->release();
packet = NULL;
+
+ mFirstDataOffset = mOffset + mCurrentPageSize;
}
void MyVorbisExtractor::verifyHeader(
diff --git a/media/libstagefright/codecs/vorbis/dec/VorbisDecoder.cpp b/media/libstagefright/codecs/vorbis/dec/VorbisDecoder.cpp
index 5485f25..df3f16a 100644
--- a/media/libstagefright/codecs/vorbis/dec/VorbisDecoder.cpp
+++ b/media/libstagefright/codecs/vorbis/dec/VorbisDecoder.cpp
@@ -173,18 +173,19 @@ int VorbisDecoder::decodePacket(MediaBuffer *packet, MediaBuffer *out) {
pack.granulepos = 0;
pack.packetno = 0;
+ int numFrames = 0;
+
int err = vorbis_dsp_synthesis(mState, &pack, 1);
if (err != 0) {
LOGW("vorbis_dsp_synthesis returned %d", err);
- return 0;
- }
-
- int numFrames = vorbis_dsp_pcmout(
- mState, (int16_t *)out->data(), kMaxNumSamplesPerBuffer);
+ } else {
+ numFrames = vorbis_dsp_pcmout(
+ mState, (int16_t *)out->data(), kMaxNumSamplesPerBuffer);
- if (numFrames < 0) {
- LOGE("vorbis_dsp_pcmout returned %d", numFrames);
- return 0;
+ if (numFrames < 0) {
+ LOGE("vorbis_dsp_pcmout returned %d", numFrames);
+ numFrames = 0;
+ }
}
out->set_range(0, numFrames * sizeof(int16_t) * mNumChannels);
@@ -203,6 +204,7 @@ status_t VorbisDecoder::read(
CHECK(seekTimeUs >= 0);
mNumFramesOutput = 0;
+ vorbis_dsp_restart(mState);
} else {
seekTimeUs = -1;
}
diff --git a/media/libstagefright/include/HTTPStream.h b/media/libstagefright/include/HTTPStream.h
index 5d638f3..35b0865 100644
--- a/media/libstagefright/include/HTTPStream.h
+++ b/media/libstagefright/include/HTTPStream.h
@@ -52,6 +52,9 @@ public:
bool find_header_value(
const string &key, string *value) const;
+ // Pass a negative value to disable the timeout.
+ void setReceiveTimeout(int seconds);
+
private:
enum State {
READY,
diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java
index ef57056..65f4194 100644
--- a/services/java/com/android/server/LocationManagerService.java
+++ b/services/java/com/android/server/LocationManagerService.java
@@ -1644,7 +1644,7 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
synchronized (mLock) {
for (int i = mProviders.size() - 1; i >= 0; i--) {
LocationProviderInterface provider = mProviders.get(i);
- if (provider.isEnabled() && provider.requiresNetwork()) {
+ if (provider.requiresNetwork()) {
provider.updateNetworkState(mNetworkState, info);
}
}
diff --git a/services/java/com/android/server/NotificationPlayer.java b/services/java/com/android/server/NotificationPlayer.java
index 0b1a03b..52d2381 100644
--- a/services/java/com/android/server/NotificationPlayer.java
+++ b/services/java/com/android/server/NotificationPlayer.java
@@ -88,12 +88,15 @@ public class NotificationPlayer implements OnCompletionListener {
player.setDataSource(mCmd.context, mCmd.uri);
player.setLooping(mCmd.looping);
player.prepare();
- if (mCmd.looping) {
- audioManager.requestAudioFocus(null, mCmd.stream,
- AudioManager.AUDIOFOCUS_GAIN);
- } else {
- audioManager.requestAudioFocus(null, mCmd.stream,
- AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK);
+ if ((mCmd.uri != null) && (mCmd.uri.getEncodedPath() != null)
+ && (mCmd.uri.getEncodedPath().length() > 0)) {
+ if (mCmd.looping) {
+ audioManager.requestAudioFocus(null, mCmd.stream,
+ AudioManager.AUDIOFOCUS_GAIN);
+ } else {
+ audioManager.requestAudioFocus(null, mCmd.stream,
+ AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK);
+ }
}
player.setOnCompletionListener(NotificationPlayer.this);
player.start();
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 948d292..022eccf 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -7858,18 +7858,18 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
r.conProviders.put(cpr, new Integer(cnt.intValue()+1));
}
cpr.clients.add(r);
- } else {
- cpr.externals++;
- }
-
- if (cpr.app != null) {
- if (r.setAdj >= VISIBLE_APP_ADJ) {
+ if (cpr.app != null && r.setAdj >= VISIBLE_APP_ADJ) {
// If this is a visible app accessing the provider,
// make sure to count it as being accessed and thus
// back up on the LRU list. This is good because
// content providers are often expensive to start.
updateLruProcessLocked(cpr.app, false, true);
}
+ } else {
+ cpr.externals++;
+ }
+
+ if (cpr.app != null) {
updateOomAdjLocked(cpr.app);
}