Merge "Make AtomicFile a public API. It's about time!" into jb-mr1-dev
diff --git a/cmds/installd/commands.c b/cmds/installd/commands.c
index 5878619..d94daf7 100644
--- a/cmds/installd/commands.c
+++ b/cmds/installd/commands.c
@@ -1093,7 +1093,12 @@
rc = -errno;
goto out;
}
-
+ if (chmod(libdir, 0755) < 0) {
+ ALOGE("cannot chmod dir '%s': %s\n", libdir, strerror(errno));
+ unlink(libdir);
+ rc = -errno;
+ goto out;
+ }
if (chown(libdir, AID_SYSTEM, AID_SYSTEM) < 0) {
ALOGE("cannot chown dir '%s': %s\n", libdir, strerror(errno));
unlink(libdir);
diff --git a/core/java/android/accounts/AccountManagerService.java b/core/java/android/accounts/AccountManagerService.java
index 079b9bd..22e454f 100644
--- a/core/java/android/accounts/AccountManagerService.java
+++ b/core/java/android/accounts/AccountManagerService.java
@@ -220,8 +220,6 @@
sThis.set(this);
- UserAccounts accounts = initUser(0);
-
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
intentFilter.addDataScheme("package");
@@ -242,6 +240,11 @@
}, userFilter);
}
+ public void systemReady() {
+ mAuthenticatorCache.generateServicesMap();
+ initUser(0);
+ }
+
private UserAccounts initUser(int userId) {
synchronized (mUsers) {
UserAccounts accounts = mUsers.get(userId);
diff --git a/core/java/android/accounts/IAccountAuthenticatorCache.java b/core/java/android/accounts/IAccountAuthenticatorCache.java
index 618771f..20dd585 100644
--- a/core/java/android/accounts/IAccountAuthenticatorCache.java
+++ b/core/java/android/accounts/IAccountAuthenticatorCache.java
@@ -60,4 +60,9 @@
*/
void setListener(RegisteredServicesCacheListener<AuthenticatorDescription> listener,
Handler handler);
+
+ /**
+ * Refreshes the authenticator cache.
+ */
+ void generateServicesMap();
}
\ No newline at end of file
diff --git a/core/java/android/content/ContentService.java b/core/java/android/content/ContentService.java
index f827c3d..1a07504 100644
--- a/core/java/android/content/ContentService.java
+++ b/core/java/android/content/ContentService.java
@@ -132,6 +132,9 @@
/*package*/ ContentService(Context context, boolean factoryTest) {
mContext = context;
mFactoryTest = factoryTest;
+ }
+
+ public void systemReady() {
getSyncManager();
}
@@ -524,7 +527,7 @@
}
}
- public static IContentService main(Context context, boolean factoryTest) {
+ public static ContentService main(Context context, boolean factoryTest) {
ContentService service = new ContentService(context, factoryTest);
ServiceManager.addService(ContentResolver.CONTENT_SERVICE_NAME, service);
return service;
diff --git a/core/java/android/content/pm/RegisteredServicesCache.java b/core/java/android/content/pm/RegisteredServicesCache.java
index 0d84d73c..0bc0f91 100644
--- a/core/java/android/content/pm/RegisteredServicesCache.java
+++ b/core/java/android/content/pm/RegisteredServicesCache.java
@@ -251,7 +251,7 @@
return false;
}
- void generateServicesMap() {
+ public void generateServicesMap() {
PackageManager pm = mContext.getPackageManager();
ArrayList<ServiceInfo<V>> serviceInfos = new ArrayList<ServiceInfo<V>>();
List<ResolveInfo> resolveInfos = pm.queryIntentServices(new Intent(mInterfaceName),
diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java
index ebc54f4..1711154 100644
--- a/core/java/android/widget/ScrollView.java
+++ b/core/java/android/widget/ScrollView.java
@@ -460,6 +460,13 @@
return true;
}
+ /*
+ * Don't try to intercept touch if we can't scroll anyway.
+ */
+ if (getScrollY() == 0 && !canScrollVertically(1)) {
+ return false;
+ }
+
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_MOVE: {
/*
diff --git a/core/java/android/widget/Toast.java b/core/java/android/widget/Toast.java
index 9e074f0..7dcbc3e 100644
--- a/core/java/android/widget/Toast.java
+++ b/core/java/android/widget/Toast.java
@@ -19,12 +19,12 @@
import android.app.INotificationManager;
import android.app.ITransientNotification;
import android.content.Context;
+import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.PixelFormat;
import android.os.Handler;
import android.os.RemoteException;
import android.os.ServiceManager;
-import android.util.LocaleUtil;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
@@ -34,8 +34,6 @@
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
-import java.util.Locale;
-
/**
* A toast is a view containing a quick little message for the user. The toast class
* helps you create and show those.
@@ -376,9 +374,8 @@
mWM = WindowManagerImpl.getDefault();
// We can resolve the Gravity here by using the Locale for getting
// the layout direction
- final Locale locale = mView.getContext().getResources().getConfiguration().locale;
- final int layoutDirection = LocaleUtil.getLayoutDirectionFromLocale(locale);
- final int gravity = Gravity.getAbsoluteGravity(mGravity, layoutDirection);
+ final Configuration config = mView.getContext().getResources().getConfiguration();
+ final int gravity = Gravity.getAbsoluteGravity(mGravity, config.layoutDirection);
mParams.gravity = gravity;
if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.FILL_HORIZONTAL) {
mParams.horizontalWeight = 1.0f;
diff --git a/core/java/com/android/internal/view/menu/ActionMenuItemView.java b/core/java/com/android/internal/view/menu/ActionMenuItemView.java
index 96d486b..563effe 100644
--- a/core/java/com/android/internal/view/menu/ActionMenuItemView.java
+++ b/core/java/com/android/internal/view/menu/ActionMenuItemView.java
@@ -141,19 +141,21 @@
public void setIcon(Drawable icon) {
mIcon = icon;
- int width = icon.getIntrinsicWidth();
- int height = icon.getIntrinsicHeight();
- if (width > mMaxIconSize) {
- final float scale = (float) mMaxIconSize / width;
- width = mMaxIconSize;
- height *= scale;
+ if (icon != null) {
+ int width = icon.getIntrinsicWidth();
+ int height = icon.getIntrinsicHeight();
+ if (width > mMaxIconSize) {
+ final float scale = (float) mMaxIconSize / width;
+ width = mMaxIconSize;
+ height *= scale;
+ }
+ if (height > mMaxIconSize) {
+ final float scale = (float) mMaxIconSize / height;
+ height = mMaxIconSize;
+ width *= scale;
+ }
+ icon.setBounds(0, 0, width, height);
}
- if (height > mMaxIconSize) {
- final float scale = (float) mMaxIconSize / height;
- height = mMaxIconSize;
- width *= scale;
- }
- icon.setBounds(0, 0, width, height);
setCompoundDrawables(icon, null, null, null);
updateTextButtonVisibility();
diff --git a/core/res/res/values-w720dp/bools.xml b/core/res/res/values-w720dp/bools.xml
index c87f689..cd595ad 100644
--- a/core/res/res/values-w720dp/bools.xml
+++ b/core/res/res/values-w720dp/bools.xml
@@ -16,5 +16,5 @@
<resources>
<bool name="action_bar_expanded_action_views_exclusive">false</bool>
- <bool name="show_ongoing_ime_switcher">false</bool>
+ <bool name="show_ongoing_ime_switcher">true</bool>
</resources>
diff --git a/core/tests/coretests/src/android/accounts/AccountManagerServiceTest.java b/core/tests/coretests/src/android/accounts/AccountManagerServiceTest.java
index 6efc61a..33a73b5 100644
--- a/core/tests/coretests/src/android/accounts/AccountManagerServiceTest.java
+++ b/core/tests/coretests/src/android/accounts/AccountManagerServiceTest.java
@@ -216,6 +216,10 @@
final RegisteredServicesCacheListener<AuthenticatorDescription> listener,
final Handler handler) {
}
+
+ @Override
+ public void generateServicesMap() {
+ }
}
static public class MyMockContext extends MockContext {
diff --git a/docs/html/about/versions/android-2.2.jd b/docs/html/about/versions/android-2.2.jd
index 361e8b6..b1ddb7c 100644
--- a/docs/html/about/versions/android-2.2.jd
+++ b/docs/html/about/versions/android-2.2.jd
@@ -1,4 +1,4 @@
-page.title=Android 2.2 Platform
+page.title=Android 2.2 APIs
sdk.platform.version=2.2
sdk.platform.apiLevel=8
sdk.platform.majorMinor=minor
diff --git a/docs/html/about/versions/android-2.3.3.jd b/docs/html/about/versions/android-2.3.3.jd
index 55ff346..2704aee 100644
--- a/docs/html/about/versions/android-2.3.3.jd
+++ b/docs/html/about/versions/android-2.3.3.jd
@@ -1,4 +1,4 @@
-page.title=Android 2.3.3 Platform
+page.title=Android 2.3.3 APIs
sdk.platform.version=2.3.3
sdk.platform.apiLevel=10
diff --git a/docs/html/about/versions/android-2.3.4.jd b/docs/html/about/versions/android-2.3.4.jd
index bb4feec..3bb0d7b 100644
--- a/docs/html/about/versions/android-2.3.4.jd
+++ b/docs/html/about/versions/android-2.3.4.jd
@@ -1,4 +1,4 @@
-page.title=Android 2.3.4 Platform
+page.title=Android 2.3.4 APIs
sdk.platform.version=2.3.4
sdk.platform.apiLevel=10
diff --git a/docs/html/about/versions/android-2.3.jd b/docs/html/about/versions/android-2.3.jd
index 2afa564..c0dc4ae 100644
--- a/docs/html/about/versions/android-2.3.jd
+++ b/docs/html/about/versions/android-2.3.jd
@@ -1,4 +1,4 @@
-page.title=Android 2.3 Platform
+page.title=Android 2.3 APIs
sdk.platform.version=2.3
sdk.platform.apiLevel=9
diff --git a/docs/html/about/versions/android-3.0.jd b/docs/html/about/versions/android-3.0.jd
index 76e0795..5bfdffc 100644
--- a/docs/html/about/versions/android-3.0.jd
+++ b/docs/html/about/versions/android-3.0.jd
@@ -1,4 +1,4 @@
-page.title=Android 3.0 Platform
+page.title=Android 3.0 APIs
sdk.platform.version=3.0
sdk.platform.apiLevel=11
@jd:body
diff --git a/docs/html/about/versions/android-3.1.jd b/docs/html/about/versions/android-3.1.jd
index 2a845f0..b0e2f08 100644
--- a/docs/html/about/versions/android-3.1.jd
+++ b/docs/html/about/versions/android-3.1.jd
@@ -1,4 +1,4 @@
-page.title=Android 3.1 Platform
+page.title=Android 3.1 APIs
sdk.platform.version=3.1
sdk.platform.apiLevel=12
@jd:body
diff --git a/docs/html/about/versions/android-3.2.jd b/docs/html/about/versions/android-3.2.jd
index 02111a0..e0f0125 100644
--- a/docs/html/about/versions/android-3.2.jd
+++ b/docs/html/about/versions/android-3.2.jd
@@ -1,4 +1,4 @@
-page.title=Android 3.2 Platform
+page.title=Android 3.2 APIs
sdk.platform.version=3.2
sdk.platform.apiLevel=13
@jd:body
diff --git a/docs/html/about/versions/android-4.0.3.jd b/docs/html/about/versions/android-4.0.3.jd
index a8c7e83..a773b6e 100644
--- a/docs/html/about/versions/android-4.0.3.jd
+++ b/docs/html/about/versions/android-4.0.3.jd
@@ -1,4 +1,4 @@
-page.title=Android 4.0.3 Platform
+page.title=Android 4.0.3 APIs
sdk.platform.version=4.0.3
sdk.platform.apiLevel=15
@jd:body
diff --git a/docs/html/about/versions/android-4.0.jd b/docs/html/about/versions/android-4.0.jd
index 99ab9cb..8595eee 100644
--- a/docs/html/about/versions/android-4.0.jd
+++ b/docs/html/about/versions/android-4.0.jd
@@ -1,4 +1,4 @@
-page.title=Android 4.0 Platform
+page.title=Android 4.0 APIs
sdk.platform.version=4.0
sdk.platform.apiLevel=14
@jd:body
diff --git a/docs/html/design/design_toc.cs b/docs/html/design/design_toc.cs
index c0c843a..17e08f2 100644
--- a/docs/html/design/design_toc.cs
+++ b/docs/html/design/design_toc.cs
@@ -38,6 +38,7 @@
<li><a href="<?cs var:toroot ?>design/patterns/settings.html">Settings</a></li>
<li><a href="<?cs var:toroot ?>design/patterns/help.html">Help</a></li>
<li><a href="<?cs var:toroot ?>design/patterns/compatibility.html">Compatibility</a></li>
+ <li><a href="<?cs var:toroot ?>design/patterns/accessibility.html">Accessibility</a></li>
<li><a href="<?cs var:toroot ?>design/patterns/pure-android.html">Pure Android</a></li>
</ul>
</li>
diff --git a/docs/html/design/media/accessibility_contentdesc.png b/docs/html/design/media/accessibility_contentdesc.png
new file mode 100644
index 0000000..b4a5c2d
--- /dev/null
+++ b/docs/html/design/media/accessibility_contentdesc.png
Binary files differ
diff --git a/docs/html/design/media/actionbar_drawer.png b/docs/html/design/media/actionbar_drawer.png
new file mode 100644
index 0000000..95e04f5
--- /dev/null
+++ b/docs/html/design/media/actionbar_drawer.png
Binary files differ
diff --git a/docs/html/design/media/dialogs_popups_example.png b/docs/html/design/media/dialogs_popups_example.png
index 2deb00d..c7536f3 100644
--- a/docs/html/design/media/dialogs_popups_example.png
+++ b/docs/html/design/media/dialogs_popups_example.png
Binary files differ
diff --git a/docs/html/design/media/help_better.png b/docs/html/design/media/help_better.png
new file mode 100644
index 0000000..fde5cb2
--- /dev/null
+++ b/docs/html/design/media/help_better.png
Binary files differ
diff --git a/docs/html/design/media/help_cling.png b/docs/html/design/media/help_cling.png
new file mode 100644
index 0000000..c91d189
--- /dev/null
+++ b/docs/html/design/media/help_cling.png
Binary files differ
diff --git a/docs/html/design/media/help_dont.png b/docs/html/design/media/help_dont.png
new file mode 100644
index 0000000..a1c9841
--- /dev/null
+++ b/docs/html/design/media/help_dont.png
Binary files differ
diff --git a/docs/html/design/media/help_evenbetter.png b/docs/html/design/media/help_evenbetter.png
new file mode 100644
index 0000000..beb88f8
--- /dev/null
+++ b/docs/html/design/media/help_evenbetter.png
Binary files differ
diff --git a/docs/html/design/media/help_overflow.png b/docs/html/design/media/help_overflow.png
new file mode 100644
index 0000000..fb2bc0a
--- /dev/null
+++ b/docs/html/design/media/help_overflow.png
Binary files differ
diff --git a/docs/html/design/media/help_solo_overflow.png b/docs/html/design/media/help_solo_overflow.png
new file mode 100644
index 0000000..9423ede
--- /dev/null
+++ b/docs/html/design/media/help_solo_overflow.png
Binary files differ
diff --git a/docs/html/design/media/tabs_youtube.png b/docs/html/design/media/tabs_youtube.png
index 69e9268..4ea6c1c 100644
--- a/docs/html/design/media/tabs_youtube.png
+++ b/docs/html/design/media/tabs_youtube.png
Binary files differ
diff --git a/docs/html/design/patterns/accessibility.jd b/docs/html/design/patterns/accessibility.jd
new file mode 100644
index 0000000..a41397f
--- /dev/null
+++ b/docs/html/design/patterns/accessibility.jd
@@ -0,0 +1,61 @@
+page.title=Accessibility
+@jd:body
+
+<p>One of Android's missions is to organize the world's information and make it universally accessible and useful. Accessibility is the measure of how successfully a product can be used by people with varying abilities. Our mission applies to all users-including people with disabilities such as visual impairment, color deficiency, hearing loss, and limited dexterity.</p>
+<p><a href="https://www.google.com/#hl=en&q=universal+design&fp=1">Universal design</a> is the practice of making products that are inherently accessible to all users, regardless of ability. The Android design patterns were created in accordance with universal design principles, and following them will help your app meet basic usability standards. Adhering to universal design and enabling Android's accessibility tools will make your app as accessible as possible.</p>
+<p>Robust support for accessibility will increase your app's user base. It may also be required for adoption by some organizations.</p>
+<p><a href="http://www.google.com/accessibility/">Learn more about Google and accessibility.</a></p>
+
+<h2 id="tools">Android's Accessibility Tools</h2>
+<p>Android includes several features that support access for users with visual impairments; they don't require drastic visual changes to your app.</p>
+
+<ul>
+ <li><strong><a href="https://play.google.com/store/apps/details?id=com.google.android.marvin.talkback">TalkBack</a></strong> is a pre-installed screen reader service provided by Google. It uses spoken feedback to describe the results of actions such as launching an app, and events such as notifications.</li>
+ <li><strong>Explore by Touch</strong> is a system feature that works with TalkBack, allowing you to touch your device's screen and hear what's under your finger via spoken feedback. This feature is helpful to users with low vision.</li>
+ <li><strong>Accessibility settings</strong> let you modify your device's display and sound options, such as increasing the text size, changing the speed at which text is spoken, and more.</li>
+</ul>
+
+<p>Some users use hardware or software directional controllers (such as a D-pad, trackball, keyboard) to jump from selection to selection on a screen. They interact with the structure of your app in a linear fashion, similar to 4-way remote control navigation on a television.</p>
+
+<h2 id="tools">Guidelines</h2>
+<p>The Android design principle "I should always know where I am" is key for accessibility concerns. As a user navigates through an application, they need feedback and a mental model of where they are. All users benefit from a strong sense of information hierarchy and an architecture that makes sense. Most users benefit from visual and haptic feedback during their navigation (such as labels, colors, icons, touch feedback) Low vision users benefit from explicit verbal descriptions and large visuals with high contrast.</p>
+<p>As you design your app, think about the labels and notations needed to navigate your app by sound. When using Explore by Touch, the user enables an invisible but audible layer of structure in your application. Like any other aspect of app design, this structure can be simple, elegant, and robust. The following are Android's recommended guidelines to enable effective navigation for all users.</p>
+
+<h4>Make navigation intuitive</h4>
+<p>Design well-defined, clear task flows with minimal navigation steps, especially for major user tasks. Make sure those tasks are navigable via focus controls. </p>
+
+<h4>Use recommended touch target sizes</h4>
+<p>48 dp is the recommended touch target size for on screen elements. Read about <a href="{@docRoot}design/style/metrics-grids.html">Android Metrics and Grids</a> to learn about implementation strategies to help most of your users. For certain users, it may be appropriate to use larger touch targets. An example of this is educational apps, where buttons larger than the minimum recommendations are appropriate for children with developing motor skills and people with manual dexterity challenges.</p>
+
+
+<h4>Label visual UI elements meaningfully</h4>
+<p>In your wireframes, <a href="{@docRoot}guide/topics/ui/accessibility/apps.html#label-ui">label functional UI components</a> that have no visible text. Those components might be buttons, icons, tabs with icons, and icons with state (like stars). Developers can use the <code><a href="{@docRoot}guide/topics/ui/accessibility/apps.html#label-ui">contentDescription</a></code> attribute to set the label.</p>
+
+<img src="{@docRoot}design/media/accessibility_contentdesc.png">
+
+<h4>Provide alternatives to affordances that time out</h4>
+<p>Your app may have icons or controls that disappear after a certain amount of time. For example, five seconds after starting a video, playback controls may fade from the screen.</p>
+
+<p>Due to the way that TalkBack works, those controls are not read out loud unless they are focused on. If they fade out from the screen quickly, your user may not even be aware that they are available. Therefore, make sure that you are not relying on timed out controls for high priority task flows. (This is a good universal design guideline too.) If the controls enable an important function, make sure that the user can turn on the controls again and/or their function is duplicated elsewhere. You can also change the behavior of your app when accessibility services are turned on. Your developer may be able to make sure that timed-out controls won't disappear.</p>
+
+<h4>Use standard framework controls or enable TalkBack for custom controls</h4>
+<p>Standard Android framework controls work automatically with accessibility services and have ContentDescriptions built in by default.</p>
+
+<p>An oft-overlooked system control is font size. Users can turn on a system-wide large font size in Settings; using the default system font size in your application will enable the user's preferences in your app as well. To enable system font size in your app, mark text and their associated containers to be measured in <a href="{@docRoot}guide/practices/screens_support.html#screen-independence">scale pixels</a>.</p>
+
+<p>Also, keep in mind that when users have large fonts enabled or speak a different language than you, their type might be larger than the space you've allotted for it. Read <a href="{@docRoot}design/style/devices-displays.html">Devices and Displays</a> and <a href="http://developer.android.com/guide/practices/screens_support.html">Supporting Multiple Screens</a> for design strategies.</p>
+
+<p>If you use custom controls, Android has the developer tools in place to allow adherence to the above guidelines and provide meaningful descriptions about the UI. Provide adequate notation on your wireframes and direct your developer to the <a href="{@docRoot}guide/topics/ui/accessibility/apps.html#custom-views">Custom Views</a> documentation.</p>
+
+<h4>Try it out yourself</h4>
+<p>Turn on the TalkBack service in <strong>Settings > Accessibility</strong> and navigate your application using directional controls or eyes-free navigation.</p>
+
+<h2>Checklist</h2>
+<ul>
+ <li>Make navigation intuitive</li>
+ <li>Use recommended touch target sizes</li>
+ <li>Label visual UI elements meaningfully</li>
+ <li>Provide alternatives to affordances that time out</li>
+ <li>Use standard framework controls or enable TalkBack for custom controls</li>
+ <li>Try it out yourself</li>
+</ul>
\ No newline at end of file
diff --git a/docs/html/design/patterns/actionbar.jd b/docs/html/design/patterns/actionbar.jd
index 21e8583..80aa77d 100644
--- a/docs/html/design/patterns/actionbar.jd
+++ b/docs/html/design/patterns/actionbar.jd
@@ -234,12 +234,7 @@
</div>
<div class="layout-content-col span-7">
-
- <img src="{@docRoot}design/media/action_bar_pattern_default_tabs.png">
- <div class="figure-caption">
- Default fixed tabs shown in Holo Dark & Light.
- </div>
-
+ <img src="{@docRoot}design/media/actionbar_drawer.png">
</div>
</div>
diff --git a/docs/html/design/patterns/help.jd b/docs/html/design/patterns/help.jd
index fef7a94..4a92c7b 100644
--- a/docs/html/design/patterns/help.jd
+++ b/docs/html/design/patterns/help.jd
@@ -23,17 +23,17 @@
<div class="layout-content-row">
<div class="layout-content-col span-8">
<ol>
- <li><h4>High value</h4>
+ <li><strong>High value</strong>
<p>Without it, users wouldn't be able to customize the most frequently-visited Android screen to meet their needs.</p></li>
- <li><h4>Available only through a gesture</h4>
+ <li><strong>Available only through a gesture</strong>
<p>Users can't do this through a button or a menu.</p></li>
- <li><h4>Atypical for the gesture</h4>
+ <li><strong>Atypical for the gesture</strong>
<p>Many high value functions invoked through a gesture - like scrolling, swiping tabs, and turning pages - are common and yield expected results. Users will be able to discover them in your app, and unsolicited help is unnecessary. But here, the gesture does something unexpected: press and hold doesn't just select an app, it also immediately navigates to the Home Screen and creates a shortcut to the app that can then be dragged around.</p></li>
</ol>
<p>However, this is an exceptional case. Most functionality doesn't meet all three of these criteria.</p>
</div>
<div class="layout-content-col span-5">
- <img src="{@docRoot}design/media/swipe_views.png">
+ <img src="{@docRoot}design/media/help_cling.png">
<div class="figure-caption">
The first time each user visits the All Apps screen, a semi-transparent overlay appears to teach an important gesture.
</div>
@@ -47,10 +47,10 @@
<div class="layout-content-row">
<div class="layout-content-col span-7">
- <img src="{@docRoot}design/media/swipe_views2.png">
+ <img src="{@docRoot}design/media/help_overflow.png">
</div>
<div class="layout-content-col span-6">
- <img src="{@docRoot}design/media/swipe_views2.png">
+ <img src="{@docRoot}design/media/help_solo_overflow.png">
<div class="figure-caption">
Even if your screen has no other action overflow items, "Help" should appear there and not be promoted to the action bar.
</div>
@@ -69,35 +69,31 @@
<p>When someone chooses "Help":</p>
<div class="layout-content-row">
- <div class="layout-content-col span-7">
- <h4 class="do-dont-label bad">Don't</h4>
-
- <p>Present a dialog asking them to choose between help and other options.</p>
+ <div class="layout-content-col span-4">
+ <img src="{@docRoot}design/media/help_dont.png">
</div>
- <div class="layout-content-col span-6">
- <img src="{@docRoot}design/media/swipe_views2.png">
+ <div class="layout-content-col span-4">
+ <img src="{@docRoot}design/media/help_better.png">
</div>
+ <div class="layout-content-col span-5">
+ <img src="{@docRoot}design/media/help_evenbetter.png">
+ </div>
</div>
<div class="layout-content-row">
- <div class="layout-content-col span-7">
+ <div class="layout-content-col span-4">
+ <h4 class="do-dont-label bad">Don't</h4>
+ <p>Present a dialog asking them to choose between help and other options.</p>
+ </div>
+ <div class="layout-content-col span-4">
<h4 class="do-dont-label good">Better</h4>
<p>Immediately launch a web browser with help content. Place other options in a footer.</p>
</div>
- <div class="layout-content-col span-6">
- <img src="{@docRoot}design/media/swipe_views2.png">
- </div>
-</div>
-
-<div class="layout-content-row">
- <div class="layout-content-col span-7">
+ <div class="layout-content-col span-5">
<h4 class="do-dont-label good">Even Better</h4>
<p>Build a help screen in your app and offer other options in the action bar.</p>
<p>This requires more development work than launching a web browser, but it's a nicer experience for users because they don't leave your app to get the help they need and doesn't require a network connection.</p>
</div>
- <div class="layout-content-col span-6">
- <img src="{@docRoot}design/media/swipe_views2.png">
- </div>
</div>
<h2>Principles for Writing On-Screen Help Content</h2>
diff --git a/docs/html/distribute/googleplay/strategies/app-quality.jd b/docs/html/distribute/googleplay/strategies/app-quality.jd
index 26d71d7..6ea862b 100644
--- a/docs/html/distribute/googleplay/strategies/app-quality.jd
+++ b/docs/html/distribute/googleplay/strategies/app-quality.jd
@@ -67,7 +67,7 @@
<p>
A great way to improve UI performance is to minimize the complexity of your layouts. If you open up <a href="{@docRoot}tools/help/hierarchy-viewer.html">hierarchyviewer</a> and see that your layouts are more than 5 levels deep, it may be time to simplify your layout. Consider refactoring those deeply nested LinearLayouts into RelativeLayout. The impact of View objects is cumulative — each one costs about 1 to 2 KB of memory, so large view hierarchies can be a recipe for disaster, causing frequent VM garbage collection passes which block the main (UI) thread. You can learn more in <a href="http://www.youtube.com/watch?v=wDBM6wVEO70">World of ListView</a>, another session at Google I/O.</p>
<p>
-Lastly, pointed out in the blog post <a href="http://android-developers.blogspot.com/2010/10/traceview-war-story.html">Traceview War Story</a>, tools like <a href="{@docRoot}tools/traceview.html">traceview</code> and <a href="{@docRoot}tools/ddms.html">ddms</a> can be your best friends in improving your app by profiling method calls and monitoring VM memory allocations, respectively.</p>
+Lastly, pointed out in the blog post <a href="http://android-developers.blogspot.com/2010/10/traceview-war-story.html">Traceview War Story</a>, tools like <a href="{@docRoot}tools/help/traceview.html">traceview</code> and <a href="{@docRoot}tools/help/ddms.html">ddms</a> can be your best friends in improving your app by profiling method calls and monitoring VM memory allocations, respectively.</p>
<h2 id="usability">Improve Usability</h2>
@@ -93,7 +93,7 @@
<p>
There's no substitute for a real user interface designer — ideally one who's well-versed in mobile and Android, and ideally handy with both interaction and visual design. One popular venue to post openings for designers is <a href="http://jobs.smashingmagazine.com">jobs.smashingmagazine.com</a>, and leveraging social connections on Twitter and LinkedIn can surface great talent.</p>
<p>
-If you don't have the luxury of working with a UI designer, there are some ways in which you can improve your app's appearance yourself. First, get familiar with Adobe Photoshop, Adobe Fireworks, or some other raster image editing tool. Mastering the art of the pixel in these apps takes time, but honing this skill can help build polish across your interface designs. Also, master the resources framework by studying <a href="http://android.git.kernel.org/?p=platform/frameworks/base.git;a=tree;f=core/res/res;h=a3562fe1af94134486a8a899f02a9c2f7986c8dd;hb=master">the framework UI</a> assets and layouts and reading through the new <a href="{@docRoot}guide/components/resources/available-resources.html">resources documentation</a>. Techniques such as 9-patches and resource directory qualifiers are somewhat unique to Android, and are crucial in building flexible yet aesthetic UIs.</p>
+If you don't have the luxury of working with a UI designer, there are some ways in which you can improve your app's appearance yourself. First, get familiar with Adobe Photoshop, Adobe Fireworks, or some other raster image editing tool. Mastering the art of the pixel in these apps takes time, but honing this skill can help build polish across your interface designs. Also, master the resources framework by studying <a href="http://android.git.kernel.org/?p=platform/frameworks/base.git;a=tree;f=core/res/res;h=a3562fe1af94134486a8a899f02a9c2f7986c8dd;hb=master">the framework UI</a> assets and layouts and reading through the new <a href="{@docRoot}guide/topics/resources/index.html">resources documentation</a>. Techniques such as 9-patches and resource directory qualifiers are somewhat unique to Android, and are crucial in building flexible yet aesthetic UIs.</p>
<p>
Before you get too far in designing your app and writing the code, make sure to visit the Android Design site and learn about the vision, the building blocks, and the tools of designing beautiful and inspiring user interfaces.</p>
@@ -105,7 +105,7 @@
<h2 id="integrate">Integrate with the System and Third-Party apps</h2>
<p>
-A great way to deliver a delightful user experience is to integrate tightly with the operating system. Features like <a href="{@docRoot}guide/topics/appwidgets/index.html">Home screen widgets</a>, <a href={@docRoot}design/patterns/notifications.html">rich notifications</a>, <a href="{@docRoot}guide/topics/search/index.html">global search integration</a>, and {@link android.widget.QuickContactBadge Quick Contacts} are fairly low-hanging fruit in this regard. </p>
+A great way to deliver a delightful user experience is to integrate tightly with the operating system. Features like <a href="{@docRoot}guide/topics/appwidgets/index.html">Home screen widgets</a>, <a href="{@docRoot}design/patterns/notifications.html">rich notifications</a>, <a href="{@docRoot}guide/topics/search/index.html">global search integration</a>, and {@link android.widget.QuickContactBadge Quick Contacts} are fairly low-hanging fruit in this regard. </p>
<p>For some app categories, basic features like home screen widgets are par for the course. Not including them is a sure-fire way to tarnish an otherwise positive user experience. Some apps can achieve even tighter OS integration with Android's contacts, accounts, and sync APIs. </p>
<p>
diff --git a/docs/html/guide/components/services.jd b/docs/html/guide/components/services.jd
index ba5e1f0..b89914a 100644
--- a/docs/html/guide/components/services.jd
+++ b/docs/html/guide/components/services.jd
@@ -49,13 +49,6 @@
LocalService}</a></li>
</ol>
-<h2>Articles</h2>
-<ol>
- <li><a href="{@docRoot}resources/articles/multitasking-android-way.html">Multitasking the Android Way</a></li>
- <li><a href="{@docRoot}resources/articles/service-api-changes-starting-with.html">Service API changes starting
- with Android 2.0</a></li>
-</ol>
-
<h2>See also</h2>
<ol>
<li><a href="{@docRoot}guide/components/bound-services.html">Bound Services</a></li>
diff --git a/docs/html/guide/practices/security.jd b/docs/html/guide/practices/security.jd
index 48ccdeb..ce59a9d 100644
--- a/docs/html/guide/practices/security.jd
+++ b/docs/html/guide/practices/security.jd
@@ -134,9 +134,8 @@
<p>To provide additional protection for sensitive data, some applications
choose to encrypt local files using a key that is not accessible to the
-application. (For example, a key can be placed in a <code><a
-href="{@docRoot}reference/java/security/KeyStore.html">KeyStore</a></code> and
-protected with a user password that is not stored on the device). While this
+application. (For example, a key can be placed in a {@link java.security.KeyStore}
+and protected with a user password that is not stored on the device). While this
does not protect data from a root compromise that can monitor the user
inputting the password, it can provide protection for a lost device without <a
href="http://source.android.com/tech/encryption/index.html">file system
@@ -716,8 +715,7 @@
AccountManager</a></code> using <code><a
href="{@docRoot}reference/android/content/pm/PackageManager.html#checkSignatures(java.lang.String,%20java.lang.String)">checkSignature()</a></code>.
Alternatively, if only one application will use the credential, you might use a
-<code><a
-href={@docRoot}reference/java/security/KeyStore.html">KeyStore</a></code> for
+{@link java.security.KeyStore} for
storage.</p>
<a name="Crypto"></a>
@@ -751,8 +749,8 @@
number generator significantly weakens the strength of the algorithm, and may
allow offline attacks.</p>
-<p>If you need to store a key for repeated use, use a mechanism like <code><a
-href="{@docRoot}reference/java/security/KeyStore.html">KeyStore</a></code> that
+<p>If you need to store a key for repeated use, use a mechanism like
+ {@link java.security.KeyStore} that
provides a mechanism for long term storage and retrieval of cryptographic
keys.</p>
diff --git a/docs/html/guide/practices/ui_guidelines/icon_design_launcher_archive.jd b/docs/html/guide/practices/ui_guidelines/icon_design_launcher_archive.jd
index f6c2247..4529797 100644
--- a/docs/html/guide/practices/ui_guidelines/icon_design_launcher_archive.jd
+++ b/docs/html/guide/practices/ui_guidelines/icon_design_launcher_archive.jd
@@ -58,7 +58,7 @@
<h2 id="market">Application Icons on Google Play</h2>
-<p>If you are <a href="{@docRoot}tools/publishing/publishing.html">publishing
+<p>If you are <a href="{@docRoot}distribute/index.html">publishing
your application on Google Play</a>, you will also need to provide a 512x512
pixel, high-resolution application icon in the <a
href="http://play.google.com/apps/publish">developer console</a> at upload-time.
diff --git a/docs/html/guide/samples/index.html b/docs/html/guide/samples/index.html
index f4acdbf..959eaf5 100644
--- a/docs/html/guide/samples/index.html
+++ b/docs/html/guide/samples/index.html
@@ -1,10 +1,10 @@
<html>
<head>
-<meta http-equiv="refresh" content="0;url=http://developer.android.com/resources/browser.html?tag=sample">
+<meta http-equiv="refresh" content="0;url=http://developer.android.com/tools/samples/index.html">
<title>Redirecting...</title>
</head>
<body>
<p>You should have been redirected. Please <a
-href="http://developer.android.com/resources/browser.html?tag=sample">click here</a>.</p>
+href="http://developer.android.com/tools/samples/index.html">click here</a>.</p>
</body>
</html>
\ No newline at end of file
diff --git a/docs/html/guide/topics/data/backup.jd b/docs/html/guide/topics/data/backup.jd
index 602b6e8..598b08a 100644
--- a/docs/html/guide/topics/data/backup.jd
+++ b/docs/html/guide/topics/data/backup.jd
@@ -187,10 +187,7 @@
available only on devices running API Level 8 (Android 2.2) or greater, so you should also
set your <a
href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code android:minSdkVersion}</a>
-attribute to "8". However, if you implement proper <a
-href="{@docRoot}resources/articles/backward-compatibility.html">backward compatibility</a> in
-your application, you can support this feature for devices running API Level 8 or greater, while
-remaining compatible with older devices.</p>
+attribute to "8".</p>
diff --git a/docs/html/guide/topics/data/install-location.jd b/docs/html/guide/topics/data/install-location.jd
index 19c4b39..5abdced 100644
--- a/docs/html/guide/topics/data/install-location.jd
+++ b/docs/html/guide/topics/data/install-location.jd
@@ -111,10 +111,7 @@
<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 compatibility 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>
+provide backward compatibility in your code.</p>
@@ -141,17 +138,13 @@
<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
+ <dd>Your <a href="{@docRoot}guide/topics/text/creating-input-method.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>
+ <dd>Your running <a href="http://android-developers.blogspot.com/2010/02/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
@@ -174,7 +167,7 @@
<dt>Copy Protection</dt>
<dd>Your application cannot be installed to a device's SD card if it uses Google Play's
Copy Protection feature. However, if you use Google Play's
- <a href="{@docRoot}guide/google/play/licensing.html">Application Licensing</a> instead, your
+ <a href="{@docRoot}guide/google/play/licensing/index.html">Application Licensing</a> instead, your
application <em>can</em> be installed to internal or external storage, including SD cards.</dd>
</dl>
diff --git a/docs/html/guide/topics/manifest/manifest-element.jd b/docs/html/guide/topics/manifest/manifest-element.jd
index a3d4a95..7a7020a 100644
--- a/docs/html/guide/topics/manifest/manifest-element.jd
+++ b/docs/html/guide/topics/manifest/manifest-element.jd
@@ -152,7 +152,7 @@
<p class="caution"><strong>Caution:</strong> If your application uses Google Play's Copy
Protection feature, it cannot be installed to a device's SD card. However, if you use Google
- Play's <a href="{@docRoot}guide/google/play/licensing.html">Application Licensing</a> instead,
+ Play's <a href="{@docRoot}guide/google/play/licensing/index.html">Application Licensing</a> instead,
your application <em>can</em> be installed to internal or external storage, including SD cards.</p>
<p class="note"><strong>Note:</strong> By default, your application will be installed on the
diff --git a/docs/html/guide/topics/providers/content-provider-basics.jd b/docs/html/guide/topics/providers/content-provider-basics.jd
index 7999033..f5e4805 100644
--- a/docs/html/guide/topics/providers/content-provider-basics.jd
+++ b/docs/html/guide/topics/providers/content-provider-basics.jd
@@ -1031,11 +1031,11 @@
<code><a href="{@docRoot}guide/topics/manifest/provider-element.html#gprmsn">
android:grantUriPermission</a></code>
attribute of the
- {@code <a href="guide/topics/manifest/provider-element.html"><provider></a>}
+ {@code <a href="{@docRoot}guide/topics/manifest/provider-element.html"><provider></a>}
element, as well as the
- {@code <a href="guide/topics/manifest/grant-uri-permission-element.html">
+ {@code <a href="{@docRoot}guide/topics/manifest/grant-uri-permission-element.html">
<grant-uri-permission></a>} child element of the
- {@code <a href="guide/topics/manifest/provider-element.html"><provider></a>}
+ {@code <a href="{@docRoot}guide/topics/manifest/provider-element.html"><provider></a>}
element. The URI permissions mechanism is explained in more detail in the
<a href="{@docRoot}guide/topics/security/security.html">Security and Permissions</a> guide,
in the section "URI Permissions".
diff --git a/docs/html/guide/topics/resources/layout-resource.jd b/docs/html/guide/topics/resources/layout-resource.jd
index c653b0c..cd88ae9 100644
--- a/docs/html/guide/topics/resources/layout-resource.jd
+++ b/docs/html/guide/topics/resources/layout-resource.jd
@@ -169,8 +169,8 @@
<p>Another way to include a layout is to use {@link android.view.ViewStub}. It is a lightweight
View that consumes no layout space until you explicitly inflate it, at which point, it includes a
layout file defined by its {@code android:layout} attribute. For more information about using {@link
-android.view.ViewStub}, read <a href="{@docRoot}resources/articles/layout-tricks-stubs.html">Layout
-Tricks: ViewStubs</a>.</p>
+android.view.ViewStub}, read <a href="{@docRoot}training/improving-layouts/loading-ondemand.html">Loading
+ Views On Demand</a>.</p>
</dd>
<dt id="merge-element"><code><merge></code></dt>
@@ -181,8 +181,7 @@
in another layout file using <a href="#include-element"><code><include></code></a> and
this layout doesn't require a different {@link android.view.ViewGroup} container. For more
information about merging layouts, read <a
-href="{@docRoot}resources/articles/layout-tricks-merge.html">Layout
-Tricks: Merging</a>.</dd>
+href="{@docRoot}training/improving-layouts/reusing-layouts.html">Re-using Layouts with <include/></a>.</dd>
</dl>
diff --git a/docs/html/guide/topics/resources/runtime-changes.jd b/docs/html/guide/topics/resources/runtime-changes.jd
index f5475b4..5f39aa5 100644
--- a/docs/html/guide/topics/resources/runtime-changes.jd
+++ b/docs/html/guide/topics/resources/runtime-changes.jd
@@ -16,8 +16,8 @@
<ol>
<li><a href="providing-resources.html">Providing Resources</a></li>
<li><a href="accessing-resources.html">Accessing Resources</a></li>
- <li><a href="{@docRoot}resources/articles/faster-screen-orientation-change.html">Faster Screen
-Orientation Change</a></li>
+ <li><a href="http://android-developers.blogspot.com/2009/02/faster-screen-orientation-change.html">Faster
+ Screen Orientation Change</a></li>
</ol>
</div>
</div>
diff --git a/docs/html/guide/topics/sensors/index.jd b/docs/html/guide/topics/sensors/index.jd
index a045899..726476a 100644
--- a/docs/html/guide/topics/sensors/index.jd
+++ b/docs/html/guide/topics/sensors/index.jd
@@ -18,7 +18,7 @@
issues that we’ve noticed causing problems in some apps.</p>
</a>
- <a href="android-developers.blogspot.com/2011/06/deep-dive-into-location.html">
+ <a href="http://android-developers.blogspot.com/2011/06/deep-dive-into-location.html">
<h4>A Deep Dive Into Location</h4>
<p>I’ve written an open-source reference app that incorporates all of the tips, tricks, and
cheats I know to reduce the time between opening an app and seeing an up-to-date list of nearby
diff --git a/docs/html/guide/topics/sensors/sensors_overview.jd b/docs/html/guide/topics/sensors/sensors_overview.jd
index e38a843..a162ccf 100644
--- a/docs/html/guide/topics/sensors/sensors_overview.jd
+++ b/docs/html/guide/topics/sensors/sensors_overview.jd
@@ -662,7 +662,7 @@
<h4>Using Google Play filters to target specific sensor configurations</h4>
<p>If you are publishing your application on Google Play you can use the
- <a href="{@docRoot}guide//topics/manifest/uses-feature-element.html"><code><uses-feature>
+ <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html"><code><uses-feature>
</code></a> element in your manifest file to filter your application from devices that do not
have the appropriate sensor configuration for your application. The
<code><uses-feature></code> element has several hardware descriptors that let you filter
diff --git a/docs/html/guide/topics/text/creating-input-method.jd b/docs/html/guide/topics/text/creating-input-method.jd
index e49610f..7086824 100644
--- a/docs/html/guide/topics/text/creating-input-method.jd
+++ b/docs/html/guide/topics/text/creating-input-method.jd
@@ -1,6 +1,5 @@
page.title=Creating an Input Method
parent.title=Articles
-parent.link=../browser.html?tag=article
@jd:body
<div id="qv-wrapper">
@@ -162,8 +161,8 @@
In this example, {@code MyKeyboardView} is an instance of a custom implementation of
{@link android.inputmethodservice.KeyboardView} that renders a
{@link android.inputmethodservice.Keyboard}. If you’re building a traditional QWERTY keyboard,
- see the <a href=”{@docRoot}resources/samples/SoftKeyboard/index.html”>Soft Keyboard</a> sample
- app for an example of how to extend the {@link android.inputmethodservice.KeyboardView} class.
+ see the Soft Keyboard <a href="{@docRoot}tools/samples/index.html">sample
+ app</a> for an example of how to extend the {@link android.inputmethodservice.KeyboardView} class.
</p>
<h3 id="CandidateView">Candidates view</h3>
<p>
@@ -175,7 +174,8 @@
default behavior, so you don’t have to implement this if you don’t provide suggestions).</p>
<p>
For an example implementation that provides user suggestions, see the
- <a href=”{@docRoot}resources/samples/SoftKeyboard/index.html”>Soft Keyboard</a> sample app.
+ Soft Keyboard <a href="{@docRoot}tools/samples/index.html">sample
+ app</a>.
</p>
<h3 id="DesignConsiderations">UI design considerations</h3>
<p>
@@ -388,8 +388,8 @@
To intercept hardware keys, override
{@link android.inputmethodservice.InputMethodService#onKeyDown(int, KeyEvent) onKeyDown()}
and {@link android.inputmethodservice.InputMethodService#onKeyUp(int, KeyEvent) onKeyUp()}.
- See the <a href=”{@docRoot}resources/samples/SoftKeyboard/index.html”>Soft Keyboard</a> sample
- app for an example.
+ See the Soft Keyboard <a href="{@docRoot}tools/samples/index.html">sample
+ app</a> for an example.
</p>
<p>
Remember to call the <code>super()</code> method for keys you don't want to handle yourself.
diff --git a/docs/html/guide/topics/text/spell-checker-framework.jd b/docs/html/guide/topics/text/spell-checker-framework.jd
index 1c2e211..7f7a0b8 100644
--- a/docs/html/guide/topics/text/spell-checker-framework.jd
+++ b/docs/html/guide/topics/text/spell-checker-framework.jd
@@ -1,6 +1,5 @@
page.title=Spelling Checker Framework
parent.title=Articles
-parent.link=../browser.html?tag=article
@jd:body
<div id="qv-wrapper">
<div id="qv">
diff --git a/docs/html/guide/topics/ui/accessibility/services.jd b/docs/html/guide/topics/ui/accessibility/services.jd
index 0c1d065..7d36181 100644
--- a/docs/html/guide/topics/ui/accessibility/services.jd
+++ b/docs/html/guide/topics/ui/accessibility/services.jd
@@ -10,7 +10,7 @@
<ol>
<li><a href="#manifest">Manifest Declarations and Permissions</a>
<ol>
- <li><a href="service-declaration">Accessibility service declaration</a></li>
+ <li><a href="#service-declaration">Accessibility service declaration</a></li>
<li><a href="#service-config">Accessibility service configuration</a></li>
</ol>
</li>
diff --git a/docs/html/guide/topics/ui/layout/relative.jd b/docs/html/guide/topics/ui/layout/relative.jd
index ee6cf02..47f9417 100644
--- a/docs/html/guide/topics/ui/layout/relative.jd
+++ b/docs/html/guide/topics/ui/layout/relative.jd
@@ -44,19 +44,19 @@
include:</p>
<dl>
<dt><a
-href="{docRoot}reference/android/widget/RelativeLayout.LayoutParams.html#attr_android:layout_alignParentTop"
+href="{@docRoot}reference/android/widget/RelativeLayout.LayoutParams.html#attr_android:layout_alignParentTop"
>{@code android:layout_alignParentTop}</a></dt>
<dd>If {@code "true"}, makes the top edge of this view match the top edge of the parent. </dd>
<dt><a
-href="{docRoot}reference/android/widget/RelativeLayout.LayoutParams.html#attr_android:layout_centerVertical"
+href="{@docRoot}reference/android/widget/RelativeLayout.LayoutParams.html#attr_android:layout_centerVertical"
>{@code android:layout_centerVertical}</a></dt>
<dd>If {@code "true"}, centers this child vertically within its parent.</dd>
<dt><a
-href="{docRoot}reference/android/widget/RelativeLayout.LayoutParams.html#attr_android:layout_below"
+href="{@docRoot}reference/android/widget/RelativeLayout.LayoutParams.html#attr_android:layout_below"
>{@code android:layout_below}</a></dt>
<dd>Positions the top edge of this view below the view specified with a resource ID.</dd>
<dt><a
-href="{docRoot}reference/android/widget/RelativeLayout.LayoutParams.html#attr_android:layout_toRightOf"
+href="{@docRoot}reference/android/widget/RelativeLayout.LayoutParams.html#attr_android:layout_toRightOf"
>{@code android:layout_toRightOf}</a></dt>
<dd>Positions the left edge of this view to the right of the view specified with a resource ID.</dd>
</dl>
diff --git a/docs/html/shareables/training/nsdchat.zip b/docs/html/shareables/training/nsdchat.zip
new file mode 100644
index 0000000..a106975
--- /dev/null
+++ b/docs/html/shareables/training/nsdchat.zip
Binary files differ
diff --git a/docs/html/tools/adk/aoa2.jd b/docs/html/tools/adk/aoa2.jd
index 2a3b2f0..bbccfc3 100644
--- a/docs/html/tools/adk/aoa2.jd
+++ b/docs/html/tools/adk/aoa2.jd
@@ -20,7 +20,7 @@
</div>
<p>This document describes the changes to the Android Open Accessory (AOA) protocol since its
-initial release, and is a supplement to the documentation of the <a href="oap.html">first
+initial release, and is a supplement to the documentation of the <a href="aoa.html">first
release of AOA</a>.</p>
<p>The Android Open Accessory Protocol 2.0 adds two new features: audio output (from the Android
diff --git a/docs/html/tools/help/gltracer.jd b/docs/html/tools/help/gltracer.jd
index 35c405e..700ee39 100644
--- a/docs/html/tools/help/gltracer.jd
+++ b/docs/html/tools/help/gltracer.jd
@@ -5,9 +5,9 @@
<div id="qv">
<h2>In this document</h2>
<ol>
- <li><a href="running">Running Tracer</a></li>
- <li><a href="generating">Generating a Trace</a></li>
- <li><a href="analyzing">Analyzing a Trace</a></li>
+ <li><a href="#running">Running Tracer</a></li>
+ <li><a href="#generating">Generating a Trace</a></li>
+ <li><a href="#analyzing">Analyzing a Trace</a></li>
</ol>
<h2>See also</h2>
<ol>
diff --git a/docs/html/tools/revisions/platforms.jd b/docs/html/tools/revisions/platforms.jd
index 6163fbc..62ec422 100644
--- a/docs/html/tools/revisions/platforms.jd
+++ b/docs/html/tools/revisions/platforms.jd
@@ -870,7 +870,7 @@
<dt>Tools:</dt>
<dd>
-<p>Adds support for building with Android library projects. See <a href="tools-notes.html">SDK
+<p>Adds support for building with Android library projects. See <a href="{@docRoot}tools/sdk/tools-notes.html">SDK
Tools, r6</a> for information.</p>
</dd>
diff --git a/docs/html/tools/sdk/installing.jd b/docs/html/tools/sdk/installing.jd
index 126d992..d7f19577 100644
--- a/docs/html/tools/sdk/installing.jd
+++ b/docs/html/tools/sdk/installing.jd
@@ -375,7 +375,7 @@
<td colspan="3"><code>docs/</code></td>
<td>A full set of documentation in HTML format, including the Developer's Guide,
API Reference, and other information. To read the documentation, load the
-file <code>offline.html</code> in a web browser.</td>
+file <code>index.html</code> in a web browser.</td>
</tr>
<tr>
<td colspan="3"><code>platform-tools/</code></td>
diff --git a/docs/html/training/accessibility/service.jd b/docs/html/training/accessibility/service.jd
index f62506b..80ecbc7 100644
--- a/docs/html/training/accessibility/service.jd
+++ b/docs/html/training/accessibility/service.jd
@@ -281,6 +281,6 @@
<p>Now you have a complete, functioning accessibility service. Try configuring
how it interacts with the user, by adding Android's <a
- href="http://developer.android.com/resources/articles/tts.html">text-to-speech
+ href="http://android-developers.blogspot.com/2009/09/introduction-to-text-to-speech-in.html">text-to-speech
engine</a>, or using a {@link android.os.Vibrator} to provide haptic
feedback!</p>
diff --git a/docs/html/training/basics/network-ops/connecting.jd b/docs/html/training/basics/network-ops/connecting.jd
index f70cf58..ac8d993 100644
--- a/docs/html/training/basics/network-ops/connecting.jd
+++ b/docs/html/training/basics/network-ops/connecting.jd
@@ -66,7 +66,7 @@
Remember, the device may be out of range of a
network, or the user may have disabled both Wi-Fi and mobile data access.
For more discussion of this topic, see the lesson <a
-href="{@docRoot}training/network-ops/managing.html">Managing Network
+href="{@docRoot}training/basics/network-ops/managing.html">Managing Network
Usage</a>.</p>
<pre>
diff --git a/docs/html/training/connect-devices-wirelessly/index.jd b/docs/html/training/connect-devices-wirelessly/index.jd
new file mode 100644
index 0000000..37cf633
--- /dev/null
+++ b/docs/html/training/connect-devices-wirelessly/index.jd
@@ -0,0 +1,62 @@
+page.title=Connecting Devices Wirelessly
+
+trainingnavtop=true
+startpage=true
+next.title=Using Network Service Discovery
+next.link=nsd.html
+
+@jd:body
+
+
+<div id="tb-wrapper">
+<div id="tb">
+
+<h2>Dependencies and prerequisites</h2>
+<ul>
+ <li>Android 4.1 or higher</li>
+</ul>
+
+<h2>You should also read</h2>
+<ul>
+ <li><a href="{@docRoot}guide/topics/connectivity/wifip2p.html">Wi-Fi Direct</a></li>
+</ul>
+
+
+</div>
+</div>
+
+
+<p>Besides enabling communication with the cloud, Android's wireless APIs also
+enable communication with other devices on the same local network, and even
+devices which are not on a network, but are physically nearby. The addition of
+Network Service Discovery (NSD) takes this further by allowing an application to
+seek out a nearby device running services with which it can communicate.
+Integrating this functionality into your application helps you provide a wide range
+of features, such as playing games with users in the same room, pulling
+images from a networked NSD-enabled webcam, or remotely logging into
+other machines on the same network.</p>
+<p>This class describes the key APIs for finding and
+connecting to other devices from your application. Specifically, it
+describes the NSD API for discovering available services and the Wi-Fi
+Direct™ API for doing peer-to-peer wireless connections. This class also
+shows you how to use NSD and Wi-Fi Direct in
+combination to detect the services offered by a device and connect to the
+device when neither device is connected to a network.
+</p>
+<h2>Lessons</h2>
+
+<dl>
+ <dt><strong><a href="nsd.html">Using Network Service Discovery</a></strong></dt>
+ <dd>Learn how to broadcast services offered by your own application, discover
+ services offered on the local network, and use NSD to determine the connection
+ details for the service you wish to connect to.</dd>
+ <dt><strong><a href="wifi-direct.html">Connecting with Wi-Fi Direct</a></strong></dt>
+ <dd>Learn how to fetch a list of nearby peer devices, create an access point
+ for legacy devices, and connect to other devices capable of Wi-Fi Direct
+ connections.</dd>
+ <dt><strong><a href="nsd-wifi-direct.html">Using Wi-Fi Direct for Service
+ Discovery</a></strong></dt>
+ <dd>Learn how to discover services published by nearby devices without being
+ on the same network, using Wi-Fi Direct.</dd>
+</dl>
+
diff --git a/docs/html/training/connect-devices-wirelessly/nsd-wifi-direct.jd b/docs/html/training/connect-devices-wirelessly/nsd-wifi-direct.jd
new file mode 100644
index 0000000..5e276de
--- /dev/null
+++ b/docs/html/training/connect-devices-wirelessly/nsd-wifi-direct.jd
@@ -0,0 +1,252 @@
+page.title=Using Wi-Fi Direct for Service Discovery
+parent.title=Connecting Devices Wirelessly
+parent.link=index.html
+
+trainingnavtop=true
+
+@jd:body
+
+<div id="tb-wrapper">
+ <div id="tb">
+ <h2>This lesson teaches you to</h2>
+ <ol>
+ <li><a href="#manifest">Set Up the Manifest</a></li>
+ <li><a href="#register">Add a Local Service</a></li>
+ <li><a href="#discover">Discover Nearby Services</a></li>
+ </ol>
+ <!--
+ <h2>You should also read</h2>
+ <ul>
+ <li><a href="#"></a></li>
+ </ul>
+ -->
+ </div>
+</div>
+
+<p>The first lesson in this class, <a href="nsd.html">Using Network Service
+ Discovery</a>, showed you
+how to discover services that are connected to a local network. However, using
+Wi-Fi Direct&trad; Service Discovery allows you to discover the services of nearby devices directly,
+without being connected to a network. You can also advertise the services
+running on your device. These capabilities help you communicate between apps,
+even when no local network or hotspot is available.</p>
+<p>While this set of APIs is similar in purpose to the Network Service Discovery
+APIs outlined in a previous lesson, implementing them in code is very different.
+This lesson shows you how to discover services available from other devices,
+using Wi-Fi Direct™. The lesson assumes that you're already familiar with the
+<a href="{@docRoot}guide/topics/connectivity/wifip2p.html">Wi-Fi Direct</a> API.</p>
+
+
+<h2 id="manifest">Set Up the Manifest</h2>
+<p>In order to use Wi-Fi Direct, add the {@link
+android.Manifest.permission#CHANGE_WIFI_STATE}, {@link
+android.Manifest.permission#ACCESS_WIFI_STATE},
+and {@link android.Manifest.permission#INTERNET}
+permissions to your manifest. Even though Wi-Fi Direct doesn't require an
+Internet connection, it uses standard Java sockets, and using these in Android
+requires the requested permissions.</p>
+
+<pre>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.android.nsdchat"
+ ...
+
+ <uses-permission
+ android:required="true"
+ android:name="android.permission.ACCESS_WIFI_STATE"/>
+ <uses-permission
+ android:required="true"
+ android:name="android.permission.CHANGE_WIFI_STATE"/>
+ <uses-permission
+ android:required="true"
+ android:name="android.permission.INTERNET"/>
+ ...
+</pre>
+
+<h2 id="register">Add a Local Service</h2>
+<p>If you're providing a local service, you need to register it for
+service discovery. Once your local service is registered, the framework
+automatically responds to service discovery requests from peers.</p>
+
+<p>To create a local service:</p>
+
+<ol>
+ <li>Create a
+{@link android.net.wifi.p2p.nsd.WifiP2pServiceInfo} object.</li>
+ <li>Populate it with information about your service.</li>
+ <li>Call {@link
+android.net.wifi.p2p.WifiP2pManager#addLocalService(WifiP2pManager.Channel,
+WifiP2pServiceInfo, WifiP2pManager.ActionListener) addLocalService()} to register the local
+service for service discovery.</li>
+</ol>
+
+<pre>
+ private void startRegistration() {
+ // Create a string map containing information about your service.
+ Map<String,String> record = new HashMap<String,String>();
+ record.put("listenport", String.valueOf(SERVER_PORT));
+ record.put("buddyname", "John Doe" + (int) (Math.random() * 1000));
+ record.put("available", "visible");
+
+ // Service information. Pass it an instance name, service type
+ // _protocol._transportlayer , and the map containing
+ // information other devices will want once they connect to this one.
+ WifiP2pDnsSdServiceInfo serviceInfo =
+ WifiP2pDnsSdServiceInfo.newInstance("_test", "_presence._tcp", record);
+
+ // Add the local service, sending the service info, network channel,
+ // and listener that will be used to indicate success or failure of
+ // the request.
+ mManager.addLocalService(channel, serviceInfo, new ActionListener() {
+ @Override
+ public void onSuccess() {
+ // Command successful! Code isn't necessarily needed here,
+ // Unless you want to update the UI or add logging statements.
+ }
+
+ @Override
+ public void onFailure(int arg0) {
+ // Command failed. Check for P2P_UNSUPPORTED, ERROR, or BUSY
+ }
+ });
+ }
+</pre>
+
+<h2 id="discover">Discover Nearby Services</h2>
+<p>Android uses callback methods to notify your application of available services, so
+the first thing to do is set those up. Create a {@link
+android.net.wifi.p2p.WifiP2pManager.DnsSdTxtRecordListener} to listen for
+incoming records. This record can optionally be broadcast by other
+devices. When one comes in, copy the device address and any other
+relevant information you want into a data structure external to the current
+method, so you can access it later. The following example assumes that the
+record contains a "buddyname" field, populated with the user's identity.</p>
+
+<pre>
+final HashMap<String, String> buddies = new HashMap<String, String>();
+...
+private void discoverService() {
+ DnsSdTxtRecordListener txtListener = new DnsSdTxtRecordListener() {
+ @Override
+ /* Callback includes:
+ * fullDomain: full domain name: e.g "printer._ipp._tcp.local."
+ * record: TXT record dta as a map of key/value pairs.
+ * device: The device running the advertised service.
+ */
+
+ public void onDnsSdTxtRecordAvailable(
+ String fullDomain, Map<String,String> record, WifiP2pDevice device) {
+ Log.d(TAG, "DnsSdTxtRecord available -" + record.toString());
+ buddies.put(device.deviceAddress, record.get("buddyname"));
+ }
+ };
+ ...
+}
+</pre>
+
+<p>To get the service information, create a {@link
+android.net.wifi.p2p.WifiP2pManager.DnsSdServiceResponseListener}. This
+receives the actual description and connection information. The previous code
+snippet implemented a {@link java.util.Map} object to pair a device address with the buddy
+name. The service response listener uses this to link the DNS record with the
+corresponding service information. Once both
+listeners are implemented, add them to the {@link
+android.net.wifi.p2p.WifiP2pManager} using the {@link
+android.net.wifi.p2p.WifiP2pManager#setDnsSdResponseListeners(WifiP2pManager.Channel,
+WifiP2pManager.DnsSdServiceResponseListener,
+WifiP2pManager.DnsSdTxtRecordListener) setDnsSdResponseListeners()} method.</p>
+
+<pre>
+private void discoverService() {
+...
+
+ DnsSdServiceResponseListener servListener = new DnsSdServiceResponseListener() {
+ @Override
+ public void onDnsSdServiceAvailable(String instanceName, String registrationType,
+ WifiP2pDevice resourceType) {
+
+ // Update the device name with the human-friendly version from
+ // the DnsTxtRecord, assuming one arrived.
+ resourceType.deviceName = buddies
+ .containsKey(resourceType.deviceAddress) ? buddies
+ .get(resourceType.deviceAddress) : resourceType.deviceName;
+
+ // Add to the custom adapter defined specifically for showing
+ // wifi devices.
+ WiFiDirectServicesList fragment = (WiFiDirectServicesList) getFragmentManager()
+ .findFragmentById(R.id.frag_peerlist);
+ WiFiDevicesAdapter adapter = ((WiFiDevicesAdapter) fragment
+ .getListAdapter());
+
+ adapter.add(resourceType);
+ adapter.notifyDataSetChanged();
+ Log.d(TAG, "onBonjourServiceAvailable " + instanceName);
+ }
+ };
+
+ mManager.setDnsSdResponseListeners(channel, servListener, txtListener);
+ ...
+}
+</pre>
+
+<p>Now create a service request and call {@link
+android.net.wifi.p2p.WifiP2pManager#addServiceRequest(WifiP2pManager.Channel,
+WifiP2pServiceRequest, WifiP2pManager.ActionListener) addServiceRequest()}.
+This method also takes a listener to report success or failure.</p>
+
+<pre>
+ serviceRequest = WifiP2pDnsSdServiceRequest.newInstance();
+ mManager.addServiceRequest(channel,
+ serviceRequest,
+ new ActionListener() {
+ @Override
+ public void onSuccess() {
+ // Success!
+ }
+
+ @Override
+ public void onFailure(int code) {
+ // Command failed. Check for P2P_UNSUPPORTED, ERROR, or BUSY
+ }
+ });
+</pre>
+
+<p>Finally, make the call to {@link
+android.net.wifi.p2p.WifiP2pManager#discoverServices(WifiP2pManager.Channel,
+WifiP2pManager.ActionListener) discoverServices()}.</p>
+
+<pre>
+ mManager.discoverServices(channel, new ActionListener() {
+
+ @Override
+ public void onSuccess() {
+ // Success!
+ }
+
+ @Override
+ public void onFailure(int code) {
+ // Command failed. Check for P2P_UNSUPPORTED, ERROR, or BUSY
+ if (code == WifiP2pManager.P2P_UNSUPPORTED) {
+ Log.d(TAG, "P2P isn't supported on this device.");
+ else if(...)
+ ...
+ }
+ });
+</pre>
+
+<p>If all goes well, hooray, you're done! If you encounter problems, remember
+that the asynchronous calls you've made take an
+{@link android.net.wifi.p2p.WifiP2pManager.ActionListener} as an argument, and
+this provides you with callbacks indicating success or failure. To diagnose
+problems, put debugging code in {@link
+android.net.wifi.p2p.WifiP2pManager.ActionListener#onFailure(int) onFailure()}. The error code
+provided by the method hints at the problem. Here are the possible error values
+and what they mean</p>
+<dl>
+ <dt> {@link android.net.wifi.p2p.WifiP2pManager#P2P_UNSUPPORTED}</dt>
+ <dd> Wi-Fi Direct isn't supported on the device running the app.</dd>
+ <dt> {@link android.net.wifi.p2p.WifiP2pManager#BUSY}</dt>
+ <dd> The system is to busy to process the request.</dd>
+ <dt> {@link android.net.wifi.p2p.WifiP2pManager#ERROR}</dt>
+ <dd> The operation failed due to an internal error.</dd>
+</dl>
diff --git a/docs/html/training/connect-devices-wirelessly/nsd.jd b/docs/html/training/connect-devices-wirelessly/nsd.jd
new file mode 100644
index 0000000..d2b01a1
--- /dev/null
+++ b/docs/html/training/connect-devices-wirelessly/nsd.jd
@@ -0,0 +1,373 @@
+page.title=Using Network Service Discovery
+parent.title=Connecting Devices Wirelessly
+parent.link=index.html
+
+trainingnavtop=true
+next.title=Connecting with Wi-Fi Direct
+next.link=wifi-direct.html
+
+@jd:body
+
+<div id="tb-wrapper">
+<div id="tb">
+
+<!-- table of contents -->
+<h2>This lesson teaches you how to</h2>
+<ol>
+ <li><a href="#register">Register Your Service on the Network</a></li>
+ <li><a href="#discover">Discover Services on the Network</a></li>
+ <li><a href="#connect">Connect to Services on the Network</a></li>
+ <li><a href="#teardown">Unregister Your Service on Application Close</a></li>
+</ol>
+
+<!--
+<h2>You should also read</h2>
+ <ul>
+ </ul>
+-->
+<h2>Try it out</h2>
+
+<div class="download-box">
+ <a href="{@docRoot}shareables/training/nsdchat.zip" class="button">Download
+ the sample app</a>
+ <p class="filename">nsdchat.zip</p>
+</div>
+</p>
+
+</div>
+</div>
+
+<p>Adding Network Service Discovery (NSD) to your app allows your users to
+identify other devices on the local network that support the services your app
+requests. This is useful for a variety of peer-to-peer applications such as file
+sharing or multi-player gaming. Android's NSD APIs simplify the effort required
+for you to implement such features.</p>
+
+<p>This lesson shows you how to build an application that can broadcast its
+name and connection information to the local network and scan for information
+from other applications doing the same. Finally, this lesson shows you how
+to connect to the same application running on another device.</p>
+
+<h2 id="register">Register Your Service on the Network</h2>
+
+<p class="note"><strong>Note: </strong>This step is optional. If
+you don't care about broadcasting your app's services over the local network,
+you can skip forward to the
+next section, <a href="#discover">Discover Services on the Network</a>.</p>
+
+<p>To register your service on the local network, first create a {@link
+android.net.nsd.NsdServiceInfo} object. This object provides the information
+that other devices on the network use when they're deciding whether to connect to your
+service. </p>
+
+<pre>
+public void registerService(int port) {
+ // Create the NsdServiceInfo object, and populate it.
+ NsdServiceInfo serviceInfo = new NsdServiceInfo();
+
+ // The name is subject to change based on conflicts
+ // with other services advertised on the same network.
+ serviceInfo.setServiceName("NsdChat");
+ serviceInfo.setServiceType("_http._tcp.");
+ serviceInfo.setPort(port);
+ ....
+}
+</pre>
+
+<p>This code snippet sets the service name to "NsdChat".
+The name is visible to any device on the network that is using NSD to look for
+local services. Keep in mind that the name must be unique for any service on the
+network, and Android automatically handles conflict resolution. If
+two devices on the network both have the NsdChat application installed, one of
+them changes the service name automatically, to something like "NsdChat
+(1)".</p>
+
+<p>The second parameter sets the service type, specifies which protocol and transport
+layer the application uses. The syntax is
+"_<protocol>._<transportlayer>". In the
+code snippet, the service uses HTTP protocol running over TCP. An application
+offering a printer service (for instance, a network printer) would set the
+service type to "_ipp._tcp".</p>
+
+<p class="note"><strong>Note: </strong> The International Assigned Numbers
+Authority (IANA) manages a centralized,
+authoritative list of service types used by service discovery protocols such as NSD and Bonjour.
+You can download the list from <a
+ href="http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml">the
+IANA list of service names and port numbers</a>.
+If you intend to use a new service type, you should reserve it by filling out
+the <a
+ href="http://www.iana.org/form/ports-services">IANA Ports and Service
+ registration form</a>.</p>
+
+<p>When setting the port for your service, avoid hardcoding it as this
+conflicts with other applications. For instance, assuming
+that your application always uses port 1337 puts it in potential conflict with
+other installed applications that use the same port. Instead, use the device's
+next available port. Because this information is provided to other apps by a
+service broadcast, there's no need for the port your application uses to be
+known by other applications at compile-time. Instead, the applications can get
+this information from your service broadcast, right before connecting to your
+service.</p>
+
+<p>If you're working with sockets, here's how you can initialize a socket to any
+available port simply by setting it to 0.</p>
+
+<pre>
+public void initializeServerSocket() {
+ // Initialize a server socket on the next available port.
+ mServerSocket = new ServerSocket(0);
+
+ // Store the chosen port.
+ mLocalPort = mServerSocket.getLocalPort();
+ ...
+}
+</pre>
+
+<p>Now that you've defined the {@link android.net.nsd.NsdServiceInfo
+NsdServiceInfo} object, you need to implement the {@link
+android.net.nsd.NsdManager.RegistrationListener RegistrationListener} interface. This
+interface contains callbacks used by Android to alert your application of the
+success or failure of service registration and unregistration.
+</p>
+<pre>
+public void initializeRegistrationListener() {
+ mRegistrationListener = new NsdManager.RegistrationListener() {
+
+ @Override
+ public void onServiceRegistered(NsdServiceInfo NsdServiceInfo) {
+ // Save the service name. Android may have changed it in order to
+ // resolve a conflict, so update the name you initially requested
+ // with the name Android actually used.
+ mServiceName = NsdServiceInfo.getServiceName();
+ }
+
+ @Override
+ public void onRegistrationFailed(NsdServiceInfo serviceInfo, int errorCode) {
+ // Registration failed! Put debugging code here to determine why.
+ }
+
+ @Override
+ public void onServiceUnregistered(NsdServiceInfo arg0) {
+ // Service has been unregistered. This only happens when you call
+ // NsdManager.unregisterService() and pass in this listener.
+ }
+
+ @Override
+ public void onUnregistrationFailed(NsdServiceInfo serviceInfo, int errorCode) {
+ // Unregistration failed. Put debugging code here to determine why.
+ }
+ };
+}
+</pre>
+
+<p>Now you have all the pieces to register your service. Call the method
+{@link android.net.nsd.NsdManager#registerService registerService()}.
+</p>
+
+<p>Note that this method is asynchronous, so any code that needs to run
+after the service has been registered must go in the {@link
+android.net.nsd.NsdManager.RegistrationListener#onServiceRegistered(NsdServiceInfo)
+onServiceRegistered()} method.</p>
+
+<pre>
+public void registerService(int port) {
+ NsdServiceInfo serviceInfo = new NsdServiceInfo();
+ serviceInfo.setServiceName("NsdChat");
+ serviceInfo.setServiceType("_http._tcp.");
+ serviceInfo.setPort(port);
+
+ mNsdManager = Context.getSystemService(Context.NSD_SERVICE);
+
+ mNsdManager.registerService(
+ serviceInfo, NsdManager.PROTOCOL_DNS_SD, mRegistrationListener);
+}
+</pre>
+
+<h2 id="discover">Discover Services on the Network</h2>
+<p>The network is teeming with life, from the beastly network printers to the
+docile network webcams, to the brutal, fiery battles of nearby tic-tac-toe
+players. The key to letting your application see this vibrant ecosystem of
+functionality is service discovery. Your application needs to listen to service
+broadcasts on the network to see what services are available, and filter out
+anything the application can't work with.</p>
+
+<p>Service discovery, like service registration, has two steps:
+ setting up a discovery listener with the relevant callbacks, and making a single asynchronous
+API call to {@link android.net.nsd.NsdManager#discoverServices(String
+, int , NsdManager.DiscoveryListener) discoverServices()}.</p>
+
+<p>First, instantiate an anonymous class that implements {@link
+android.net.nsd.NsdManager.DiscoveryListener}. The following snippet shows a
+simple example:</p>
+
+<pre>
+public void initializeDiscoveryListener() {
+
+ // Instantiate a new DiscoveryListener
+ mDiscoveryListener = new NsdManager.DiscoveryListener() {
+
+ // Called as soon as service discovery begins.
+ @Override
+ public void onDiscoveryStarted(String regType) {
+ Log.d(TAG, "Service discovery started");
+ }
+
+ @Override
+ public void onServiceFound(NsdServiceInfo service) {
+ // A service was found! Do something with it.
+ Log.d(TAG, "Service discovery success" + service);
+ if (!service.getServiceType().equals(SERVICE_TYPE)) {
+ // Service type is the string containing the protocol and
+ // transport layer for this service.
+ Log.d(TAG, "Unknown Service Type: " + service.getServiceType());
+ } else if (service.getServiceName().equals(mServiceName)) {
+ // The name of the service tells the user what they'd be
+ // connecting to. It could be "Bob's Chat App".
+ Log.d(TAG, "Same machine: " + mServiceName);
+ } else if (service.getServiceName().contains("NsdChat")){
+ mNsdManager.resolveService(service, mResolveListener);
+ }
+ }
+
+ @Override
+ public void onServiceLost(NsdServiceInfo service) {
+ // When the network service is no longer available.
+ // Internal bookkeeping code goes here.
+ Log.e(TAG, "service lost" + service);
+ }
+
+ @Override
+ public void onDiscoveryStopped(String serviceType) {
+ Log.i(TAG, "Discovery stopped: " + serviceType);
+ }
+
+ @Override
+ public void onStartDiscoveryFailed(String serviceType, int errorCode) {
+ Log.e(TAG, "Discovery failed: Error code:" + errorCode);
+ mNsdManager.stopServiceDiscovery(this);
+ }
+
+ @Override
+ public void onStopDiscoveryFailed(String serviceType, int errorCode) {
+ Log.e(TAG, "Discovery failed: Error code:" + errorCode);
+ mNsdManager.stopServiceDiscovery(this);
+ }
+ };
+}
+</pre>
+
+<p>The NSD API uses the methods in this interface to inform your application when discovery
+is started, when it fails, and when services are found and lost (lost means "is
+no longer available"). Notice that this snippet does several checks
+when a service is found.</p>
+<ol>
+ <li>The service name of the found service is compared to the service
+name of the local service to determine if the device just picked up its own
+broadcast (which is valid).</li>
+<li>The service type is checked, to verify it's a type of service your
+application can connect to.</li>
+<li>The service name is checked to verify connection to the correct
+application.</li>
+</ol>
+
+<p>Checking the service name isn't always necessary, and is only relevant if you
+want to connect to a specific application. For instance, the application might
+only want to connect to instances of itself running on other devices. However, if the
+application wants to connect to a network printer, it's enough to see that the service type
+is "_ipp._tcp".</p>
+
+<p>After setting up the listener, call {@link android.net.nsd.NsdManager#discoverServices(String, int,
+NsdManager.DiscoveryListener) discoverServices()}, passing in the service type
+your application should look for, the discovery protocol to use, and the
+listener you just created.</p>
+
+<pre>
+ mNsdManager.discoverServices(
+ SERVICE_TYPE, NsdManager.PROTOCOL_DNS_SD, mDiscoveryListener);
+</pre>
+
+
+<h2 id="connect">Connect to Services on the Network</h2>
+<p>When your application finds a service on the network to connect to, it
+must first determine the connection information for that service, using the
+{@link android.net.nsd.NsdManager#resolveService resolveService()} method.
+Implement a {@link android.net.nsd.NsdManager.ResolveListener} to pass into this
+method, and use it to get a {@link android.net.nsd.NsdServiceInfo} containing
+the connection information.</p>
+
+<pre>
+public void initializeResolveListener() {
+ mResolveListener = new NsdManager.ResolveListener() {
+
+ @Override
+ public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {
+ // Called when the resolve fails. Use the error code to debug.
+ Log.e(TAG, "Resolve failed" + errorCode);
+ }
+
+ @Override
+ public void onServiceResolved(NsdServiceInfo serviceInfo) {
+ Log.e(TAG, "Resolve Succeeded. " + serviceInfo);
+
+ if (serviceInfo.getServiceName().equals(mServiceName)) {
+ Log.d(TAG, "Same IP.");
+ return;
+ }
+ mService = serviceInfo;
+ int port = mService.getPort();
+ InetAddress host = mService.getHost();
+ }
+ };
+}
+</pre>
+
+<p>Once the service is resolved, your application receives detailed
+service information including an IP address and port number. This is everything
+you need to create your own network connection to the service.</p>
+
+
+<h2 id="teardown">Unregister Your Service on Application Close</h2>
+<p>It's important to enable and disable NSD
+functionality as appropriate during the application's
+lifecycle. Unregistering your application when it closes down helps prevent
+other applications from thinking it's still active and attempting to connect to
+it. Also, service discovery is an expensive operation, and should be stopped
+when the parent Activity is paused, and re-enabled when the Activity is
+resumed. Override the lifecycle methods of your main Activity and insert code
+to start and stop service broadcast and discovery as appropriate.</p>
+
+<pre>
+//In your application's Activity
+
+ @Override
+ protected void onPause() {
+ if (mNsdHelper != null) {
+ mNsdHelper.tearDown();
+ }
+ super.onPause();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ if (mNsdHelper != null) {
+ mNsdHelper.registerService(mConnection.getLocalPort());
+ mNsdHelper.discoverServices();
+ }
+ }
+
+ @Override
+ protected void onDestroy() {
+ mNsdHelper.tearDown();
+ mConnection.tearDown();
+ super.onDestroy();
+ }
+
+ // NsdHelper's tearDown method
+ public void tearDown() {
+ mNsdManager.unregisterService(mRegistrationListener);
+ mNsdManager.stopServiceDiscovery(mDiscoveryListener);
+ }
+</pre>
+
diff --git a/docs/html/training/connect-devices-wirelessly/wifi-direct.jd b/docs/html/training/connect-devices-wirelessly/wifi-direct.jd
new file mode 100644
index 0000000..99bb243
--- /dev/null
+++ b/docs/html/training/connect-devices-wirelessly/wifi-direct.jd
@@ -0,0 +1,372 @@
+page.title=Connecting with Wi-Fi Direct
+parent.title=Connecting Devices Wirelessly
+parent.link=index.html
+
+trainingnavtop=true
+previous.title=Using Network Service Discovery
+previous.link=nsd.html
+next.title=Service Discovery with Wi-Fi Direct
+next.link=nsd-wifi-direct.html
+
+@jd:body
+
+<div id="tb-wrapper">
+ <div id="tb">
+ <h2>This lesson teaches you how to</h2>
+ <ol>
+ <li><a href="#permissions">Set Up Application Permissions</a></li>
+ <li><a href="#receiver">Set Up the Broadcast Receiver and Peer-to-Peer
+ Manager</a></li>
+ <li><a href="#discover">Initiate Peer Discovery</a></li>
+ <li><a href="#fetch">Fetch the List of Peers</a></li>
+ <li><a href="#connect">Connect to a Peer</a></li>
+ </ol>
+ </div>
+</div>
+
+<p>The Wi-Fi Direct™ APIs allow applications to connect to nearby devices without
+needing to connect to a network or hotspot. This allows your application to quickly
+find and interact with nearby devices, at a range beyond the capabilities of Bluetooth.
+</p>
+<p>
+This lesson shows you how to find and connect to nearby devices using Wi-Fi Direct.
+</p>
+<h2 id="permissions">Set Up Application Permissions</h2>
+<p>In order to use Wi-Fi Direct, add the {@link
+android.Manifest.permission#CHANGE_WIFI_STATE}, {@link
+android.Manifest.permission#ACCESS_WIFI_STATE},
+and {@link android.Manifest.permission#INTERNET}
+permissions to your manifest. Wi-Fi Direct doesn't require an internet connection,
+but it does use standard Java sockets, which require the {@link
+android.Manifest.permission#INTERNET} permission.
+So you need the following permissions to use Wi-Fi Direct.</p>
+
+<pre>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.android.nsdchat"
+ ...
+
+ <uses-permission
+ android:required="true"
+ android:name="android.permission.ACCESS_WIFI_STATE"/>
+ <uses-permission
+ android:required="true"
+ android:name="android.permission.CHANGE_WIFI_STATE"/>
+ <uses-permission
+ android:required="true"
+ android:name="android.permission.INTERNET"/>
+ ...
+</pre>
+
+<h2 id="receiver">Set Up a Broadcast Receiver and Peer-to-Peer Manager</h2>
+<p>To use Wi-Fi Direct, you need to listen for broadcast intents that tell your
+application when certain events have occurred. In your application, instantiate
+an {@link
+android.content.IntentFilter} and set it to listen for the following:</p>
+<dl>
+ <dt>{@link android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_STATE_CHANGED_ACTION}</dt>
+ <dd>Indicates whether Wi-Fi Peer-To-Peer (P2P) is enabled</dd>
+ <dt>{@link android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_PEERS_CHANGED_ACTION}</dt>
+ <dd>Indicates that the available peer list has changed.</dd>
+ <dt>{@link android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_CONNECTION_CHANGED_ACTION}</dt>
+ <dd>Indicates the state of Wi-Fi P2P connectivity has changed.</dd>
+ <dt>{@link android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_THIS_DEVICE_CHANGED_ACTION}</dt>
+ <dd>Indicates this device's configuration details have changed.</dd>
+<pre>
+private final IntentFilter intentFilter = new IntentFilter();
+...
+@Override
+public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ // Indicates a change in the Wi-Fi Peer-to-Peer status.
+ intentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
+
+ // Indicates a change in the list of available peers.
+ intentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
+
+ // Indicates the state of Wi-Fi P2P connectivity has changed.
+ intentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
+
+ // Indicates this device's details have changed.
+ intentFilter.addAction(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION);
+
+ ...
+}
+</pre>
+
+ <p>At the end of the {@link android.app.Activity#onCreate onCreate()} method, get an instance of the {@link
+android.net.wifi.p2p.WifiP2pManager}, and call its {@link
+android.net.wifi.p2p.WifiP2pManager#initialize(Context, Looper, WifiP2pManager.ChannelListener) initialize()}
+method. This method returns a {@link
+android.net.wifi.p2p.WifiP2pManager.Channel} object, which you'll use later to
+connect your app to the Wi-Fi Direct Framework.</p>
+
+<pre>
+@Override
+
+Channel mChannel;
+
+public void onCreate(Bundle savedInstanceState) {
+ ....
+ mManager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
+ mChannel = mManager.initialize(this, getMainLooper(), null);
+}
+</pre>
+<p>Now create a new {@link
+android.content.BroadcastReceiver} class that you'll use to listen for changes
+to the System's Wi-Fi P2P state. In the {@link
+android.content.BroadcastReceiver#onReceive(Context, Intent) onReceive()}
+method, add a condition to handle each P2P state change listed above.</p>
+
+<pre>
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ if (WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION.equals(action)) {
+ // Determine if Wifi Direct mode is enabled or not, alert
+ // the Activity.
+ int state = intent.getIntExtra(WifiP2pManager.EXTRA_WIFI_STATE, -1);
+ if (state == WifiP2pManager.WIFI_P2P_STATE_ENABLED) {
+ activity.setIsWifiP2pEnabled(true);
+ } else {
+ activity.setIsWifiP2pEnabled(false);
+ }
+ } else if (WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION.equals(action)) {
+
+ // The peer list has changed! We should probably do something about
+ // that.
+
+ } else if (WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION.equals(action)) {
+
+ // Connection state changed! We should probably do something about
+ // that.
+
+ } else if (WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION.equals(action)) {
+ DeviceListFragment fragment = (DeviceListFragment) activity.getFragmentManager()
+ .findFragmentById(R.id.frag_list);
+ fragment.updateThisDevice((WifiP2pDevice) intent.getParcelableExtra(
+ WifiP2pManager.EXTRA_WIFI_P2P_DEVICE));
+
+ }
+ }
+</pre>
+
+<p>Finally, add code to register the intent filter and broadcast receiver when
+your main activity is active, and unregister them when the activity is paused.
+The best place to do this is the {@link android.app.Activity#onResume()} and
+{@link android.app.Activity#onPause()} methods.
+
+<pre>
+ /** register the BroadcastReceiver with the intent values to be matched */
+ @Override
+ public void onResume() {
+ super.onResume();
+ receiver = new WiFiDirectBroadcastReceiver(mManager, mChannel, this);
+ registerReceiver(receiver, intentFilter);
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ unregisterReceiver(receiver);
+ }
+</pre>
+
+
+<h2 id="discover">Initiate Peer Discovery</h2>
+<p>To start searching for nearby devices with Wi-Fi Direct, call {@link
+android.net.wifi.p2p.WifiP2pManager#discoverPeers(WifiP2pManager.Channel,
+WifiP2pManager.ActionListener) discoverPeers()}. This method takes the
+following arguments:</p>
+<ul>
+ <li>The {@link android.net.wifi.p2p.WifiP2pManager.Channel} you
+ received back when you initialized the peer-to-peer mManager</li>
+ <li>An implementation of {@link android.net.wifi.p2p.WifiP2pManager.ActionListener} with methods
+ the system invokes for successful and unsuccessful discovery.</li>
+</ul>
+
+<pre>
+mManager.discoverPeers(mChannel, new WifiP2pManager.ActionListener() {
+
+ @Override
+ public void onSuccess() {
+ // Code for when the discovery initiation is successful goes here.
+ // No services have actually been discovered yet, so this method
+ // can often be left blank. Code for peer discovery goes in the
+ // onReceive method, detailed below.
+ }
+
+ @Override
+ public void onFailure(int reasonCode) {
+ // Code for when the discovery initiation fails goes here.
+ // Alert the user that something went wrong.
+ }
+});
+</pre>
+
+<p>Keep in mind that this only <em>initiates</em> peer discovery. The
+{@link android.net.wifi.p2p.WifiP2pManager#discoverPeers(WifiP2pManager.Channel,
+WifiP2pManager.ActionListener) discoverPeers()} method starts the discovery process and then
+immediately returns. The system notifies you if the peer discovery process is
+successfully initiated by calling methods in the provided action listener.
+Also, discovery will remain active until a connection is initiated or a P2P group is
+formed.</p>
+
+<h2 id="fetch">Fetch the List of Peers</h2>
+<p>Now write the code that fetches and processes the list of peers. First
+implement the {@link android.net.wifi.p2p.WifiP2pManager.PeerListListener}
+interface, which provides information about the peers that Wi-Fi Direct has
+detected. The following code snippet illustrates this.</p>
+
+<pre>
+ private List<WifiP2pDevice> peers = new ArrayList<WifiP2pDevice>();
+ ...
+
+ private PeerListListener peerListListener = new PeerListListener() {
+ @Override
+ public void onPeersAvailable(WifiP2pDeviceList peerList) {
+
+ // Out with the old, in with the new.
+ peers.clear();
+ peers.addAll(peerList.getDeviceList());
+
+ // If an AdapterView is backed by this data, notify it
+ // of the change. For instance, if you have a ListView of available
+ // peers, trigger an update.
+ ((WiFiPeerListAdapter) getListAdapter()).notifyDataSetChanged();
+ if (peers.size() == 0) {
+ Log.d(WiFiDirectActivity.TAG, "No devices found");
+ return;
+ }
+ }
+ }
+</pre>
+
+<p>Now modify your broadcast receiver's {@link
+android.content.BroadcastReceiver#onReceive(Context, Intent) onReceive()}
+method to call {@link android.net.wifi.p2p.WifiP2pManager#requestPeers
+requestPeers()} when an intent with the action {@link
+android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_PEERS_CHANGED_ACTION} is received. You
+need to pass this listener into the receiver somehow. One way is to send it
+as an argument to the broadcast receiver's constructor.
+</p>
+
+<pre>
+public void onReceive(Context context, Intent intent) {
+ ...
+ else if (WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION.equals(action)) {
+
+ // Request available peers from the wifi p2p manager. This is an
+ // asynchronous call and the calling activity is notified with a
+ // callback on PeerListListener.onPeersAvailable()
+ if (mManager != null) {
+ mManager.requestPeers(mChannel, peerListener);
+ }
+ Log.d(WiFiDirectActivity.TAG, "P2P peers changed");
+ }...
+}
+</pre>
+
+<p>Now, an intent with the action {@link
+android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_PEERS_CHANGED_ACTION} intent will
+trigger a request for an updated peer list. </p>
+
+<h2 id="connect">Connect to a Peer</h2>
+<p>In order to connect to a peer, create a new {@link
+android.net.wifi.p2p.WifiP2pConfig} object, and copy data into it from the
+{@link android.net.wifi.p2p.WifiP2pDevice} representing the device you want to
+connect to. Then call the {@link
+android.net.wifi.p2p.WifiP2pManager#connect(WifiP2pManager.Channel,
+WifiP2pConfig, WifiP2pManager.ActionListener) connect()}
+method.</p>
+
+<pre>
+ @Override
+ public void connect() {
+ // Picking the first device found on the network.
+ WifiP2pDevice device = peers.get(0);
+
+ WifiP2pConfig config = new WifiP2pConfig();
+ config.deviceAddress = device.deviceAddress;
+ config.wps.setup = WpsInfo.PBC;
+
+ mManager.connect(mChannel, config, new ActionListener() {
+
+ @Override
+ public void onSuccess() {
+ // WiFiDirectBroadcastReceiver will notify us. Ignore for now.
+ }
+
+ @Override
+ public void onFailure(int reason) {
+ Toast.makeText(WiFiDirectActivity.this, "Connect failed. Retry.",
+ Toast.LENGTH_SHORT).show();
+ }
+ });
+ }
+</pre>
+
+<p>The {@link android.net.wifi.p2p.WifiP2pManager.ActionListener} implemented in
+this snippet only notifies you when the <em>initiation</em> succeeds or fails.
+To listen for <em>changes</em> in connection state, implement the {@link
+android.net.wifi.p2p.WifiP2pManager.ConnectionInfoListener} interface. Its {@link
+android.net.wifi.p2p.WifiP2pManager.ConnectionInfoListener#onConnectionInfoAvailable(WifiP2pInfo)
+onConnectionInfoAvailable()}
+callback will notify you when the state of the connection changes. In cases
+where multiple devices are going to be connected to a single device (like a game with
+3 or more players, or a chat app), one device will be designated the "group
+owner".</p>
+
+<pre>
+ @Override
+ public void onConnectionInfoAvailable(final WifiP2pInfo info) {
+
+ // InetAddress from WifiP2pInfo struct.
+ InetAddress groupOwnerAddress = info.groupOwnerAddress.getHostAddress());
+
+ // After the group negotiation, we can determine the group owner.
+ if (info.groupFormed && info.isGroupOwner) {
+ // Do whatever tasks are specific to the group owner.
+ // One common case is creating a server thread and accepting
+ // incoming connections.
+ } else if (info.groupFormed) {
+ // The other device acts as the client. In this case,
+ // you'll want to create a client thread that connects to the group
+ // owner.
+ }
+ }
+</pre>
+
+<p>Now go back to the {@link
+android.content.BroadcastReceiver#onReceive(Context, Intent) onReceive()} method of the broadcast receiver, and modify the section
+that listens for a {@link
+android.net.wifi.p2p.WifiP2pManager#WIFI_P2P_CONNECTION_CHANGED_ACTION} intent.
+When this intent is received, call {@link
+android.net.wifi.p2p.WifiP2pManager#requestConnectionInfo(WifiP2pManager.Channel,
+WifiP2pManager.ConnectionInfoListener) requestConnectionInfo()}. This is an
+asynchronous call, so results will be received by the connection info listener
+you provide as a parameter.
+
+<pre>
+ ...
+ } else if (WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION.equals(action)) {
+
+ if (mManager == null) {
+ return;
+ }
+
+ NetworkInfo networkInfo = (NetworkInfo) intent
+ .getParcelableExtra(WifiP2pManager.EXTRA_NETWORK_INFO);
+
+ if (networkInfo.isConnected()) {
+
+ // We are connected with the other device, request connection
+ // info to find group owner IP
+
+ mManager.requestConnectionInfo(mChannel, connectionListener);
+ }
+ ...
+</pre>
diff --git a/docs/html/training/custom-views/create-view.jd b/docs/html/training/custom-views/create-view.jd
index b0bc8b4..674bcc9 100644
--- a/docs/html/training/custom-views/create-view.jd
+++ b/docs/html/training/custom-views/create-view.jd
@@ -61,7 +61,7 @@
existing view
subclasses, such as {@link android.widget.Button}.</p>
-<p>To allow the <a href=”{@docRoot}guide/developing/tools/adt.html”>Android Developer Tools
+<p>To allow the <a href="{@docRoot}guide/developing/tools/adt.html">Android Developer Tools
</a> to interact with your view, at a minimum you must provide a constructor that takes a
{@link android.content.Context} and an {@link android.util.AttributeSet} object as parameters.
This constructor allows the layout editor to create and edit an instance of your view.</p>
@@ -105,7 +105,7 @@
<pre>
<resources>;
- <declare-styleable name="PieChart">
+ <declare-styleable name="PieChart">
<attr name="showText" format="boolean" />
<attr name="labelPosition" format="enum">
<enum name="left" value="0"/>
@@ -276,6 +276,6 @@
</ul>
<p>For more information on creating accessible views, see
- <a href=”{@docRoot}guide/topics/ui/accessibility/apps.html#custom-views”>
+ <a href="{@docRoot}guide/topics/ui/accessibility/apps.html#custom-views">
Making Applications Accessible</a> in the Android Developers Guide.
</p>
diff --git a/docs/html/training/custom-views/optimizing-view.jd b/docs/html/training/custom-views/optimizing-view.jd
index 1f489dd..7f2e762 100644
--- a/docs/html/training/custom-views/optimizing-view.jd
+++ b/docs/html/training/custom-views/optimizing-view.jd
@@ -19,7 +19,7 @@
<h2>You should also read</h2>
<ul>
- <li><a href=”{@docRoot}guide/topics/graphics/hardware-accel.html”>
+ <li><a href="{@docRoot}guide/topics/graphics/hardware-accel.html">
Hardware Acceleration
</a>
</li>
diff --git a/docs/html/training/implementing-navigation/lateral.jd b/docs/html/training/implementing-navigation/lateral.jd
index 76acf03..b59bab2 100644
--- a/docs/html/training/implementing-navigation/lateral.jd
+++ b/docs/html/training/implementing-navigation/lateral.jd
@@ -119,7 +119,7 @@
<h2 id="horizontal-paging">Implement Horizontal Paging (Swipe Views)</h2>
-<p>Horizontal paging, or swipe views, allow users to <a href="{@docRoot}design/patterns/swipe-views">swipe</a> horizontally on the current screen to navigate to adjacent screens. This pattern can be implemented using the {@link android.support.v4.view.ViewPager} widget, currently available as part of the <a href="{@docRoot}tools/extras/support-library.html">Android Support Package</a>. For navigating between sibling screens representing a fixed number of sections, it's best to provide the {@link android.support.v4.view.ViewPager} with a {@link android.support.v4.app.FragmentPagerAdapter}. For horizontal paging across collections of objects, it's best to use a {@link android.support.v4.app.FragmentStatePagerAdapter}, which destroys fragments as the user navigates to other pages, minimizing memory usage.</p>
+<p>Horizontal paging, or swipe views, allow users to <a href="{@docRoot}design/patterns/swipe-views.html">swipe</a> horizontally on the current screen to navigate to adjacent screens. This pattern can be implemented using the {@link android.support.v4.view.ViewPager} widget, currently available as part of the <a href="{@docRoot}tools/extras/support-library.html">Android Support Package</a>. For navigating between sibling screens representing a fixed number of sections, it's best to provide the {@link android.support.v4.view.ViewPager} with a {@link android.support.v4.app.FragmentPagerAdapter}. For horizontal paging across collections of objects, it's best to use a {@link android.support.v4.app.FragmentStatePagerAdapter}, which destroys fragments as the user navigates to other pages, minimizing memory usage.</p>
<p>Below is an example of using a {@link android.support.v4.view.ViewPager} to swipe across a collection of objects.</p>
diff --git a/docs/html/training/improving-layouts/reusing-layouts.jd b/docs/html/training/improving-layouts/reusing-layouts.jd
index 095b0dd..fdd3333 100644
--- a/docs/html/training/improving-layouts/reusing-layouts.jd
+++ b/docs/html/training/improving-layouts/reusing-layouts.jd
@@ -25,12 +25,9 @@
<!-- other docs (NOT javadocs) -->
<h2>You should also read</h2>
<ul>
- <li><a href="{@docRoot}resources/articles/layout-tricks-reuse.html">Creating Reusable UI
-Components</a></li>
- <li><a href="{@docRoot}resources/articles/layout-tricks-merge.html">Merging Layouts</a></li>
<li><a
href="{@docRoot}guide/topics/resources/layout-resource.html#include-element">Layout
-Resource</a></li>
+Resources</a></li>
</ul>
</div>
diff --git a/docs/html/training/improving-layouts/smooth-scrolling.jd b/docs/html/training/improving-layouts/smooth-scrolling.jd
index 0afa929..2a1ffba 100644
--- a/docs/html/training/improving-layouts/smooth-scrolling.jd
+++ b/docs/html/training/improving-layouts/smooth-scrolling.jd
@@ -22,8 +22,8 @@
<!-- other docs (NOT javadocs) -->
<h2>You should also read</h2>
<ul>
- <li><a href="{@docRoot}resources/articles/listview-backgrounds.html">ListView
-Backgrounds: An Optimization</a></li>
+ <li><a href="http://android-developers.blogspot.com/2009/01/why-is-my-list-black-android.html">Why
+ is my list black? An Android optimization</a></li>
</ul>
</div>
diff --git a/docs/html/training/notepad/index.jd b/docs/html/training/notepad/index.jd
index 87a57d1..64ba144 100644
--- a/docs/html/training/notepad/index.jd
+++ b/docs/html/training/notepad/index.jd
@@ -1,6 +1,5 @@
page.title=Notepad Tutorial
parent.title=Tutorials
-parent.link=../../browser.html?tag=tutorial
@jd:body
diff --git a/docs/html/training/training_toc.cs b/docs/html/training/training_toc.cs
index 37b69d4..b70ba3f 100644
--- a/docs/html/training/training_toc.cs
+++ b/docs/html/training/training_toc.cs
@@ -673,6 +673,27 @@
</li>
+ <li class="nav-section">
+ <div class="nav-section-header"><a href="<?cs var:toroot ?>training/connect-devices-wirelessly/index.html">
+ <span class="en">Connecting Devices Wirelessly</span>
+ </a></div>
+ <ul>
+ <li><a href="<?cs var:toroot ?>training/connect-devices-wirelessly/nsd.html">
+ <span class="en">Using Network Service Discovery</span>
+ </a>
+ </li>
+ <li><a href="<?cs var:toroot ?>training/connect-devices-wirelessly/wifi-direct.html">
+ <span class="en">Connecting with Wi-Fi Direct</span>
+ </a>
+ </li>
+ <li><a href="<?cs var:toroot ?>training/connect-devices-wirelessly/nsd-wifi-direct.html">
+ <span class="en">Using Wi-Fi Direct for Service Discovery</span>
+ </a>
+ </li>
+ </ul>
+ </li>
+
+
</ul>
</li>
</ul><!-- nav -->
diff --git a/keystore/java/android/security/KeyStore.java b/keystore/java/android/security/KeyStore.java
index a32e469..f49c429 100644
--- a/keystore/java/android/security/KeyStore.java
+++ b/keystore/java/android/security/KeyStore.java
@@ -22,8 +22,9 @@
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
+import java.io.UTFDataFormatException;
import java.nio.charset.Charsets;
+import java.nio.charset.ModifiedUtf8;
import java.util.ArrayList;
/**
@@ -75,7 +76,7 @@
}
public byte[] get(String key) {
- return get(getBytes(key));
+ return get(getKeyBytes(key));
}
private boolean put(byte[] key, byte[] value) {
@@ -84,7 +85,7 @@
}
public boolean put(String key, byte[] value) {
- return put(getBytes(key), value);
+ return put(getKeyBytes(key), value);
}
private boolean delete(byte[] key) {
@@ -93,7 +94,7 @@
}
public boolean delete(String key) {
- return delete(getBytes(key));
+ return delete(getKeyBytes(key));
}
private boolean contains(byte[] key) {
@@ -102,7 +103,7 @@
}
public boolean contains(String key) {
- return contains(getBytes(key));
+ return contains(getKeyBytes(key));
}
public byte[][] saw(byte[] prefix) {
@@ -111,13 +112,13 @@
}
public String[] saw(String prefix) {
- byte[][] values = saw(getBytes(prefix));
+ byte[][] values = saw(getKeyBytes(prefix));
if (values == null) {
return null;
}
String[] strings = new String[values.length];
for (int i = 0; i < values.length; ++i) {
- strings[i] = toString(values[i]);
+ strings[i] = toKeyString(values[i]);
}
return strings;
}
@@ -133,7 +134,7 @@
}
public boolean password(String password) {
- return password(getBytes(password));
+ return password(getPasswordBytes(password));
}
public boolean lock() {
@@ -147,7 +148,7 @@
}
public boolean unlock(String password) {
- return unlock(getBytes(password));
+ return unlock(getPasswordBytes(password));
}
public boolean isEmpty() {
@@ -161,7 +162,7 @@
}
public boolean generate(String key) {
- return generate(getBytes(key));
+ return generate(getKeyBytes(key));
}
private boolean importKey(byte[] keyName, byte[] key) {
@@ -170,7 +171,7 @@
}
public boolean importKey(String keyName, byte[] key) {
- return importKey(getBytes(keyName), key);
+ return importKey(getKeyBytes(keyName), key);
}
private byte[] getPubkey(byte[] key) {
@@ -179,7 +180,7 @@
}
public byte[] getPubkey(String key) {
- return getPubkey(getBytes(key));
+ return getPubkey(getKeyBytes(key));
}
private boolean delKey(byte[] key) {
@@ -188,7 +189,7 @@
}
public boolean delKey(String key) {
- return delKey(getBytes(key));
+ return delKey(getKeyBytes(key));
}
private byte[] sign(byte[] keyName, byte[] data) {
@@ -197,7 +198,7 @@
}
public byte[] sign(String key, byte[] data) {
- return sign(getBytes(key), data);
+ return sign(getKeyBytes(key), data);
}
private boolean verify(byte[] keyName, byte[] data, byte[] signature) {
@@ -206,7 +207,7 @@
}
public boolean verify(String key, byte[] data, byte[] signature) {
- return verify(getBytes(key), data, signature);
+ return verify(getKeyBytes(key), data, signature);
}
private boolean grant(byte[] key, byte[] uid) {
@@ -215,7 +216,7 @@
}
public boolean grant(String key, int uid) {
- return grant(getBytes(key), Integer.toString(uid).getBytes());
+ return grant(getKeyBytes(key), getUidBytes(uid));
}
private boolean ungrant(byte[] key, byte[] uid) {
@@ -224,7 +225,7 @@
}
public boolean ungrant(String key, int uid) {
- return ungrant(getBytes(key), Integer.toString(uid).getBytes());
+ return ungrant(getKeyBytes(key), getUidBytes(uid));
}
public int getLastError() {
@@ -291,11 +292,34 @@
return null;
}
- private static byte[] getBytes(String string) {
- return string.getBytes(Charsets.UTF_8);
+ /**
+ * ModifiedUtf8 is used for key encoding to match the
+ * implementation of NativeCrypto.ENGINE_load_private_key.
+ */
+ private static byte[] getKeyBytes(String string) {
+ try {
+ int utfCount = (int) ModifiedUtf8.countBytes(string, false);
+ byte[] result = new byte[utfCount];
+ ModifiedUtf8.encode(result, 0, string);
+ return result;
+ } catch (UTFDataFormatException e) {
+ throw new RuntimeException(e);
+ }
}
- private static String toString(byte[] bytes) {
- return new String(bytes, Charsets.UTF_8);
+ private static String toKeyString(byte[] bytes) {
+ try {
+ return ModifiedUtf8.decode(bytes, new char[bytes.length], 0, bytes.length);
+ } catch (UTFDataFormatException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static byte[] getPasswordBytes(String password) {
+ return password.getBytes(Charsets.UTF_8);
+ }
+
+ private static byte[] getUidBytes(int uid) {
+ return Integer.toString(uid).getBytes(Charsets.UTF_8);
}
}
diff --git a/keystore/tests/src/android/security/KeyStoreTest.java b/keystore/tests/src/android/security/KeyStoreTest.java
index 91c56d6..32cd6e2 100755
--- a/keystore/tests/src/android/security/KeyStoreTest.java
+++ b/keystore/tests/src/android/security/KeyStoreTest.java
@@ -37,7 +37,7 @@
private static final String TEST_PASSWD2 = "87654321";
private static final String TEST_KEYNAME = "test-key";
private static final String TEST_KEYNAME1 = "test-key.1";
- private static final String TEST_KEYNAME2 = "test-key.2";
+ private static final String TEST_KEYNAME2 = "test-key\02";
private static final byte[] TEST_KEYVALUE = "test value".getBytes(Charsets.UTF_8);
// "Hello, World" in Chinese
diff --git a/opengl/java/android/opengl/Matrix.java b/opengl/java/android/opengl/Matrix.java
index 7c72ae4..3f07337 100644
--- a/opengl/java/android/opengl/Matrix.java
+++ b/opengl/java/android/opengl/Matrix.java
@@ -312,7 +312,6 @@
* @param near
* @param far
*/
-
public static void frustumM(float[] m, int offset,
float left, float right, float bottom, float top,
float near, float far) {
@@ -336,10 +335,10 @@
final float r_depth = 1.0f / (near - far);
final float x = 2.0f * (near * r_width);
final float y = 2.0f * (near * r_height);
- final float A = 2.0f * ((right + left) * r_width);
+ final float A = (right + left) * r_width;
final float B = (top + bottom) * r_height;
- final float C = (far + near) * r_depth;
- final float D = 2.0f * (far * near * r_depth);
+ final float C = -(far + near) * r_depth;
+ final float D = -2.0f * (far * near * r_depth);
m[offset + 0] = x;
m[offset + 5] = y;
m[offset + 8] = A;
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index d766afd..cd00255 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -114,6 +114,8 @@
: Integer.parseInt(factoryTestStr);
final boolean headless = "1".equals(SystemProperties.get("ro.config.headless", "0"));
+ AccountManagerService accountManager = null;
+ ContentService contentService = null;
LightsService lights = null;
PowerManagerService power = null;
DisplayManagerService display = null;
@@ -195,14 +197,14 @@
// The AccountManager must come before the ContentService
try {
Slog.i(TAG, "Account Manager");
- ServiceManager.addService(Context.ACCOUNT_SERVICE,
- new AccountManagerService(context));
+ accountManager = new AccountManagerService(context);
+ ServiceManager.addService(Context.ACCOUNT_SERVICE, accountManager);
} catch (Throwable e) {
Slog.e(TAG, "Failure starting Account Manager", e);
}
Slog.i(TAG, "Content Manager");
- ContentService.main(context,
+ contentService = ContentService.main(context,
factoryTest == SystemServer.FACTORY_TEST_LOW_LEVEL);
Slog.i(TAG, "System Content Providers");
@@ -457,6 +459,20 @@
}
try {
+ if (accountManager != null)
+ accountManager.systemReady();
+ } catch (Throwable e) {
+ reportWtf("making Account Manager Service ready", e);
+ }
+
+ try {
+ if (contentService != null)
+ contentService.systemReady();
+ } catch (Throwable e) {
+ reportWtf("making Content Service ready", e);
+ }
+
+ try {
Slog.i(TAG, "Notification Manager");
notification = new NotificationManagerService(context, statusBar, lights);
ServiceManager.addService(Context.NOTIFICATION_SERVICE, notification);
diff --git a/telephony/java/android/telephony/SignalStrength.java b/telephony/java/android/telephony/SignalStrength.java
index d80425c..d0a2e11 100644
--- a/telephony/java/android/telephony/SignalStrength.java
+++ b/telephony/java/android/telephony/SignalStrength.java
@@ -27,7 +27,7 @@
public class SignalStrength implements Parcelable {
private static final String LOG_TAG = "SignalStrength";
- private static final boolean DBG = true;
+ private static final boolean DBG = false;
/** @hide */
public static final int SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette.rsh b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette.rsh
index 77ead9c..9429564 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette.rsh
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette.rsh
@@ -17,6 +17,7 @@
static float2 scale;
static float2 center, dimensions;
static float range, inv_max_dist, shade, slope;
+static float2 overDimensions;
void init_vignette(uint32_t dim_x, uint32_t dim_y, float center_x, float center_y,
float desired_scale, float desired_shade, float desired_slope) {
@@ -43,20 +44,21 @@
range = 1.3 - 0.7*sqrt(desired_scale);
shade = desired_shade;
slope = desired_slope;
+
+ overDimensions = ((float2)1.f) / dimensions;
}
void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) {
// Convert x and y to floating point coordinates with center as origin
- const float4 fin = rsUnpackColor8888(*in);
- float2 coord;
- coord.x = (float)x / dimensions.x;
- coord.y = (float)y / dimensions.y;
+ const float4 fin = convert_float4(*in);
+ float2 coord = {(float)x, (float)y};
+ coord *= overDimensions;
coord -= center;
const float dist = length(scale * coord);
const float lumen = shade / (1.0 + exp((dist * inv_max_dist - range) * slope)) + (1.0 - shade);
float4 fout;
fout.rgb = fin.rgb * lumen;
fout.w = fin.w;
- *out = rsPackColorTo8888(fout);
+ *out = convert_uchar4(fout);
}