Merge "docs: deprecate thingy"
diff --git a/Android.mk b/Android.mk
index 5a40318..a38723a 100644
--- a/Android.mk
+++ b/Android.mk
@@ -464,6 +464,8 @@
 		            resources/samples/USB "USB" \
 		-samplecode $(sample_dir)/WeatherListWidget \
 		            resources/samples/WeatherListWidget "Weather List Widget" \
+		-samplecode $(sample_dir)/WiFiDirectDemo \
+                            resources/samples/WiFiDirectDemo "Wi-Fi Direct Demo" \
 		-samplecode $(sample_dir)/Wiktionary \
 		            resources/samples/Wiktionary "Wiktionary" \
 		-samplecode $(sample_dir)/WiktionarySimple \
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 1c85279..9381437 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -115,6 +115,7 @@
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/media/audio/)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/fonts/DroidSans*)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/media/audio/)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/fonts/DroidSans*)
 # ************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
 # ************************************************
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index ea29ad1..44688b8 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -2010,10 +2010,10 @@
         if (nativeUpdateLayers(mLastDrawData.mBaseLayer)) {
             // If anything more complex than position has been touched, let's do a full draw
             webkitDraw();
-        } else {
-            Message.obtain(mWebView.mPrivateHandler,
-                    WebView.INVAL_RECT_MSG_ID).sendToTarget();
         }
+        mWebView.mPrivateHandler.removeMessages(WebView.INVAL_RECT_MSG_ID);
+        mWebView.mPrivateHandler.sendMessageAtFrontOfQueue(mWebView.mPrivateHandler
+                .obtainMessage(WebView.INVAL_RECT_MSG_ID));
     }
 
     private void webkitDraw() {
diff --git a/core/tests/coretests/src/android/accessibilityservice/InterrogationActivityTest.java b/core/tests/coretests/src/android/accessibilityservice/InterrogationActivityTest.java
index cd8dcb9..3521296 100644
--- a/core/tests/coretests/src/android/accessibilityservice/InterrogationActivityTest.java
+++ b/core/tests/coretests/src/android/accessibilityservice/InterrogationActivityTest.java
@@ -19,14 +19,10 @@
 import static android.view.accessibility.AccessibilityNodeInfo.ACTION_FOCUS;
 import static android.view.accessibility.AccessibilityNodeInfo.ACTION_SELECT;
 
-import com.android.frameworks.coretests.R;
-
 import android.content.Context;
 import android.graphics.Rect;
-import android.os.RemoteException;
 import android.os.ServiceManager;
 import android.os.SystemClock;
-import android.provider.Settings;
 import android.test.ActivityInstrumentationTestCase2;
 import android.test.suitebuilder.annotation.LargeTest;
 import android.util.Log;
@@ -36,8 +32,8 @@
 import android.view.accessibility.AccessibilityNodeInfo;
 import android.view.accessibility.IAccessibilityManager;
 
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
+import com.android.frameworks.coretests.R;
+
 import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
@@ -55,14 +51,9 @@
 
     private static String LOG_TAG = "InterrogationActivityTest";
 
-    // Timeout before give up wait for the system to process an accessibility setting change.
+    // Timeout before give up wait for the system to process an accessibility setting change.       
     private static final int TIMEOUT_PROPAGATE_ACCESSIBLITY_SETTING = 2000;
 
-    // Helpers to figure out the first and last test methods
-    // This is a workaround for the lack of such support in JUnit3
-    private static int sTestMethodCount;
-    private static int sExecutedTestMethodCount;
-
     // Handle to a connection to the AccessibilityManagerService
     private static IAccessibilityServiceConnection sConnection;
 
@@ -71,19 +62,20 @@
 
     public InterrogationActivityTest() {
         super(InterrogationActivity.class);
-        sTestMethodCount = getTestMethodCount();
     }
 
     @LargeTest
     public void testFindAccessibilityNodeInfoByViewId() throws Exception {
-        beforeClassIfNeeded();
         final long startTimeMillis = SystemClock.uptimeMillis();
         try {
+            // hook into the system first
+            IAccessibilityServiceConnection connection = getConnection();
+
             // bring up the activity
             getActivity();
 
             AccessibilityNodeInfo button = AccessibilityInteractionClient.getInstance()
-                .findAccessibilityNodeInfoByViewIdInActiveWindow(getConnection(), R.id.button5);
+                .findAccessibilityNodeInfoByViewIdInActiveWindow(connection, R.id.button5);
             assertNotNull(button);
             assertEquals(0, button.getChildCount());
 
@@ -116,7 +108,6 @@
             assertEquals(ACTION_FOCUS | ACTION_SELECT | ACTION_CLEAR_SELECTION,
                 button.getActions());
         } finally {
-            afterClassIfNeeded();
             if (DEBUG) {
                 final long elapsedTimeMillis = SystemClock.uptimeMillis() - startTimeMillis;
                 Log.i(LOG_TAG, "testFindAccessibilityNodeInfoByViewId: "
@@ -127,18 +118,19 @@
 
     @LargeTest
     public void testFindAccessibilityNodeInfoByViewText() throws Exception {
-        beforeClassIfNeeded();
         final long startTimeMillis = SystemClock.uptimeMillis();
         try {
+            // hook into the system first
+            IAccessibilityServiceConnection connection = getConnection();
+
             // bring up the activity
             getActivity();
 
             // find a view by text
             List<AccessibilityNodeInfo> buttons =  AccessibilityInteractionClient.getInstance()
-                .findAccessibilityNodeInfosByViewTextInActiveWindow(getConnection(), "butto");
+                .findAccessibilityNodeInfosByViewTextInActiveWindow(connection, "butto");
             assertEquals(9, buttons.size());
         } finally {
-            afterClassIfNeeded();
             if (DEBUG) {
                 final long elapsedTimeMillis = SystemClock.uptimeMillis() - startTimeMillis;
                 Log.i(LOG_TAG, "testFindAccessibilityNodeInfoByViewText: "
@@ -149,19 +141,20 @@
 
     @LargeTest
     public void testFindAccessibilityNodeInfoByViewTextContentDescription() throws Exception {
-        beforeClassIfNeeded();
         final long startTimeMillis = SystemClock.uptimeMillis();
         try {
+            // hook into the system first
+            IAccessibilityServiceConnection connection = getConnection();
+
             // bring up the activity
             getActivity();
 
             // find a view by text
             List<AccessibilityNodeInfo> buttons =  AccessibilityInteractionClient.getInstance()
-                .findAccessibilityNodeInfosByViewTextInActiveWindow(getConnection(),
+                .findAccessibilityNodeInfosByViewTextInActiveWindow(connection,
                         "contentDescription");
             assertEquals(1, buttons.size());
         } finally {
-            afterClassIfNeeded();
             if (DEBUG) {
                 final long elapsedTimeMillis = SystemClock.uptimeMillis() - startTimeMillis;
                 Log.i(LOG_TAG, "testFindAccessibilityNodeInfoByViewTextContentDescription: "
@@ -172,9 +165,11 @@
 
     @LargeTest
     public void testTraverseAllViews() throws Exception {
-        beforeClassIfNeeded();
         final long startTimeMillis = SystemClock.uptimeMillis();
         try {
+            // hook into the system first
+            IAccessibilityServiceConnection connection = getConnection();
+
             // bring up the activity
             getActivity();
 
@@ -195,7 +190,7 @@
             classNameAndTextList.add("android.widget.ButtonButton9");
 
             AccessibilityNodeInfo root = AccessibilityInteractionClient.getInstance()
-                .findAccessibilityNodeInfoByViewIdInActiveWindow(getConnection(), R.id.root);
+                .findAccessibilityNodeInfoByViewIdInActiveWindow(connection, R.id.root);
             assertNotNull("We must find the existing root.", root);
 
             Queue<AccessibilityNodeInfo> fringe = new LinkedList<AccessibilityNodeInfo>();
@@ -221,7 +216,6 @@
                 }
             }
         } finally {
-            afterClassIfNeeded();
             if (DEBUG) {
                 final long elapsedTimeMillis = SystemClock.uptimeMillis() - startTimeMillis;
                 Log.i(LOG_TAG, "testTraverseAllViews: " + elapsedTimeMillis + "ms");
@@ -231,15 +225,17 @@
 
     @LargeTest
     public void testPerformAccessibilityActionFocus() throws Exception {
-        beforeClassIfNeeded();
         final long startTimeMillis = SystemClock.uptimeMillis();
         try {
+            // hook into the system first
+            IAccessibilityServiceConnection connection = getConnection();
+
             // bring up the activity
             getActivity();
 
             // find a view and make sure it is not focused
             AccessibilityNodeInfo button = AccessibilityInteractionClient.getInstance()
-                .findAccessibilityNodeInfoByViewIdInActiveWindow(getConnection(), R.id.button5);
+                .findAccessibilityNodeInfoByViewIdInActiveWindow(connection, R.id.button5);
             assertFalse(button.isFocused());
 
             // focus the view
@@ -247,10 +243,9 @@
 
             // find the view again and make sure it is focused
             button =  AccessibilityInteractionClient.getInstance()
-                .findAccessibilityNodeInfoByViewIdInActiveWindow(getConnection(), R.id.button5);
+                .findAccessibilityNodeInfoByViewIdInActiveWindow(connection, R.id.button5);
             assertTrue(button.isFocused());
         } finally {
-            afterClassIfNeeded();
             if (DEBUG) {
                 final long elapsedTimeMillis = SystemClock.uptimeMillis() - startTimeMillis;
                 Log.i(LOG_TAG, "testPerformAccessibilityActionFocus: " + elapsedTimeMillis + "ms");
@@ -260,15 +255,17 @@
 
     @LargeTest
     public void testPerformAccessibilityActionClearFocus() throws Exception {
-        beforeClassIfNeeded();
         final long startTimeMillis = SystemClock.uptimeMillis();
         try {
+            // hook into the system first
+            IAccessibilityServiceConnection connection = getConnection();
+
             // bring up the activity
             getActivity();
 
             // find a view and make sure it is not focused
             AccessibilityNodeInfo button = AccessibilityInteractionClient.getInstance()
-                .findAccessibilityNodeInfoByViewIdInActiveWindow(getConnection(), R.id.button5);
+                .findAccessibilityNodeInfoByViewIdInActiveWindow(connection, R.id.button5);
             assertFalse(button.isFocused());
 
             // focus the view
@@ -276,7 +273,7 @@
 
             // find the view again and make sure it is focused
             button = AccessibilityInteractionClient.getInstance()
-                .findAccessibilityNodeInfoByViewIdInActiveWindow(getConnection(), R.id.button5);
+                .findAccessibilityNodeInfoByViewIdInActiveWindow(connection, R.id.button5);
             assertTrue(button.isFocused());
 
             // unfocus the view
@@ -284,10 +281,9 @@
 
             // find the view again and make sure it is not focused
             button = AccessibilityInteractionClient.getInstance()
-                .findAccessibilityNodeInfoByViewIdInActiveWindow(getConnection(), R.id.button5);
+                .findAccessibilityNodeInfoByViewIdInActiveWindow(connection, R.id.button5);
             assertFalse(button.isFocused());
         } finally {
-            afterClassIfNeeded();
             if (DEBUG) {
                 final long elapsedTimeMillis = SystemClock.uptimeMillis() - startTimeMillis;
                 Log.i(LOG_TAG, "testPerformAccessibilityActionClearFocus: "
@@ -298,15 +294,17 @@
 
     @LargeTest
     public void testPerformAccessibilityActionSelect() throws Exception {
-        beforeClassIfNeeded();
         final long startTimeMillis = SystemClock.uptimeMillis();
         try {
+            // hook into the system first
+            IAccessibilityServiceConnection connection = getConnection();
+
             // bring up the activity
             getActivity();
 
             // find a view and make sure it is not selected
             AccessibilityNodeInfo button = AccessibilityInteractionClient.getInstance()
-                .findAccessibilityNodeInfoByViewIdInActiveWindow(getConnection(), R.id.button5);
+                .findAccessibilityNodeInfoByViewIdInActiveWindow(connection, R.id.button5);
             assertFalse(button.isSelected());
 
             // select the view
@@ -314,10 +312,9 @@
 
             // find the view again and make sure it is selected
             button = AccessibilityInteractionClient.getInstance()
-                .findAccessibilityNodeInfoByViewIdInActiveWindow(getConnection(), R.id.button5);
+                .findAccessibilityNodeInfoByViewIdInActiveWindow(connection, R.id.button5);
             assertTrue(button.isSelected());
         } finally {
-            afterClassIfNeeded();
             if (DEBUG) {
                 final long elapsedTimeMillis = SystemClock.uptimeMillis() - startTimeMillis;
                 Log.i(LOG_TAG, "testPerformAccessibilityActionSelect: " + elapsedTimeMillis + "ms");
@@ -327,15 +324,17 @@
 
     @LargeTest
     public void testPerformAccessibilityActionClearSelection() throws Exception {
-        beforeClassIfNeeded();
         final long startTimeMillis = SystemClock.uptimeMillis();
         try {
+            // hook into the system first
+            IAccessibilityServiceConnection connection = getConnection();
+
             // bring up the activity
             getActivity();
 
             // find a view and make sure it is not selected
             AccessibilityNodeInfo button = AccessibilityInteractionClient.getInstance()
-                .findAccessibilityNodeInfoByViewIdInActiveWindow(getConnection(), R.id.button5);
+                .findAccessibilityNodeInfoByViewIdInActiveWindow(connection, R.id.button5);
             assertFalse(button.isSelected());
 
             // select the view
@@ -343,7 +342,7 @@
 
             // find the view again and make sure it is selected
             button = AccessibilityInteractionClient.getInstance()
-                .findAccessibilityNodeInfoByViewIdInActiveWindow(getConnection(), R.id.button5);
+                .findAccessibilityNodeInfoByViewIdInActiveWindow(connection, R.id.button5);
             assertTrue(button.isSelected());
 
             // unselect the view
@@ -351,10 +350,9 @@
 
             // find the view again and make sure it is not selected
             button =  AccessibilityInteractionClient.getInstance()
-                .findAccessibilityNodeInfoByViewIdInActiveWindow(getConnection(), R.id.button5);
+                .findAccessibilityNodeInfoByViewIdInActiveWindow(connection, R.id.button5);
             assertFalse(button.isSelected());
         } finally {
-            afterClassIfNeeded();
             if (DEBUG) {
                 final long elapsedTimeMillis = SystemClock.uptimeMillis() - startTimeMillis;
                 Log.i(LOG_TAG, "testPerformAccessibilityActionClearSelection: "
@@ -365,15 +363,17 @@
 
     @LargeTest
     public void testAccessibilityEventGetSource() throws Exception {
-        beforeClassIfNeeded();
         final long startTimeMillis = SystemClock.uptimeMillis();
         try {
+            // hook into the system first
+            IAccessibilityServiceConnection connection = getConnection();
+
             // bring up the activity
-            getActivity();
+            getActivity();  
 
             // find a view and make sure it is not focused
             AccessibilityNodeInfo button = AccessibilityInteractionClient.getInstance()
-                .findAccessibilityNodeInfoByViewIdInActiveWindow(getConnection(), R.id.button5);
+                .findAccessibilityNodeInfoByViewIdInActiveWindow(connection, R.id.button5);
             assertFalse(button.isSelected());
 
             // focus the view
@@ -419,7 +419,6 @@
             assertSame(button.isCheckable(), source.isCheckable());
             assertSame(button.isChecked(), source.isChecked());
         } finally {
-            afterClassIfNeeded();
             if (DEBUG) {
                 final long elapsedTimeMillis = SystemClock.uptimeMillis() - startTimeMillis;
                 Log.i(LOG_TAG, "testAccessibilityEventGetSource: " + elapsedTimeMillis + "ms");
@@ -429,15 +428,17 @@
 
     @LargeTest
     public void testObjectContract() throws Exception {
-        beforeClassIfNeeded();
         final long startTimeMillis = SystemClock.uptimeMillis();
         try {
+            // hook into the system first
+            IAccessibilityServiceConnection connection = getConnection();
+
             // bring up the activity
             getActivity();
 
             // find a view and make sure it is not focused
             AccessibilityNodeInfo button = AccessibilityInteractionClient.getInstance()
-                .findAccessibilityNodeInfoByViewIdInActiveWindow(getConnection(), R.id.button5);
+                .findAccessibilityNodeInfoByViewIdInActiveWindow(connection, R.id.button5);
             AccessibilityNodeInfo parent = button.getParent();
             final int childCount = parent.getChildCount();
             for (int i = 0; i < childCount; i++) {
@@ -451,7 +452,6 @@
             }
             fail("Parent's children do not have the info whose parent is the parent.");
         } finally {
-            afterClassIfNeeded();
             if (DEBUG) {
                 final long elapsedTimeMillis = SystemClock.uptimeMillis() - startTimeMillis;
                 Log.i(LOG_TAG, "testObjectContract: " + elapsedTimeMillis + "ms");
@@ -464,90 +464,10 @@
         /* intentionally do not scrub */
     }
 
-    /**
-     * Sets accessibility in a given state by writing the state to the
-     * settings and waiting until the accessibility manager service picks
-     * it up for max {@link #TIMEOUT_PROPAGATE_ACCESSIBLITY_SETTING}.
-     *
-     * @param state The accessibility state.
-     * @throws Exception If any error occurs.
-     */
-    private void ensureAccessibilityState(boolean state) throws Exception {
-        Context context = getInstrumentation().getContext();
-        // If the local manager ready => nothing to do.
-        AccessibilityManager accessibilityManager = AccessibilityManager.getInstance(context);
-        if (accessibilityManager.isEnabled() == state) {
-            return;
-        }
-        synchronized (this) {
-            // Check if the system already knows about the desired state. 
-            final boolean currentState = Settings.Secure.getInt(context.getContentResolver(),
-                    Settings.Secure.ACCESSIBILITY_ENABLED) == 1;
-            if (currentState != state) {
-                // Make sure we wake ourselves as the desired state is propagated.
-                accessibilityManager.addAccessibilityStateChangeListener(
-                        new AccessibilityManager.AccessibilityStateChangeListener() {
-                            public void onAccessibilityStateChanged(boolean enabled) {
-                                synchronized (this) {
-                                    notifyAll();
-                                }
-                            }
-                        });
-                Settings.Secure.putInt(context.getContentResolver(),
-                        Settings.Secure.ACCESSIBILITY_ENABLED, state ? 1 : 0);
-            }
-            // No while one attempt and that is it.
-            try {
-                wait(TIMEOUT_PROPAGATE_ACCESSIBLITY_SETTING);
-            } catch (InterruptedException ie) {
-                /* ignore */
-            }
-        }
-        if (accessibilityManager.isEnabled() != state) {
-            throw new IllegalStateException("Could not set accessibility state to: " + state);
-        }
-    }
-
-    /**
-     * Execute some set up code before any test method.
-     *
-     * NOTE: I miss Junit4's @BeforeClass
-     *
-     * @throws Exception If an error occurs.
-     */
-    private void beforeClassIfNeeded() throws Exception {
-        sExecutedTestMethodCount++;
-        if (sExecutedTestMethodCount == 1) {
-            ensureAccessibilityState(true);
-        }
-    }
-
-    /**
-     * Execute some clean up code after all test methods.
-     *
-     * NOTE: I miss Junit4's @AfterClass
-     *
-     * @throws Exception If an error occurs.
-     */
-    public void afterClassIfNeeded() throws Exception {
-        if (sExecutedTestMethodCount == sTestMethodCount) {
-            sExecutedTestMethodCount = 0;
-            ensureAccessibilityState(false);
-        }
-    }
-
-    private static IAccessibilityServiceConnection getConnection() throws Exception {
+    private IAccessibilityServiceConnection getConnection() throws Exception {
         if (sConnection == null) {
             IEventListener listener = new IEventListener.Stub() {
-                public void setConnection(IAccessibilityServiceConnection connection)
-                        throws RemoteException {
-                    AccessibilityServiceInfo info = new AccessibilityServiceInfo();
-                    info.eventTypes = AccessibilityEvent.TYPES_ALL_MASK;
-                    info.feedbackType = AccessibilityServiceInfo.FEEDBACK_SPOKEN;
-                    info.notificationTimeout = 0;
-                    info.flags = AccessibilityServiceInfo.DEFAULT;
-                    connection.setServiceInfo(info);
-                }
+                public void setConnection(IAccessibilityServiceConnection connection) {}
 
                 public void onInterrupt() {}
 
@@ -560,26 +480,33 @@
                     }
                 }
             };
-            IAccessibilityManager manager = IAccessibilityManager.Stub.asInterface(
-                ServiceManager.getService(Context.ACCESSIBILITY_SERVICE));
-            sConnection = manager.registerEventListener(listener);
-        }
-        return sConnection;
-    }
 
-    /**
-     * @return The number of test methods.
-     */
-    private int getTestMethodCount() {
-        int testMethodCount = 0;
-        for (Method method : getClass().getMethods()) {
-            final int modifiers = method.getModifiers();
-            if (method.getName().startsWith("test")
-                    && (modifiers & Modifier.PUBLIC) != 0
-                    && (modifiers & Modifier.STATIC) == 0) {
-                testMethodCount++;
+            AccessibilityManager accessibilityManager =
+                AccessibilityManager.getInstance(getInstrumentation().getContext());
+
+            synchronized (this) {
+                if (!accessibilityManager.isEnabled()) {
+                    // Make sure we wake ourselves as the desired state is propagated.
+                    accessibilityManager.addAccessibilityStateChangeListener(
+                            new AccessibilityManager.AccessibilityStateChangeListener() {
+                                public void onAccessibilityStateChanged(boolean enabled) {
+                                    synchronized (this) {
+                                        notifyAll();
+                                    }
+                                }
+                            });
+                    IAccessibilityManager manager = IAccessibilityManager.Stub.asInterface(
+                        ServiceManager.getService(Context.ACCESSIBILITY_SERVICE));
+                    sConnection = manager.registerEventListener(listener);
+
+                    wait(TIMEOUT_PROPAGATE_ACCESSIBLITY_SETTING);
+                } else {
+                    IAccessibilityManager manager = IAccessibilityManager.Stub.asInterface(
+                          ServiceManager.getService(Context.ACCESSIBILITY_SERVICE));
+                    sConnection = manager.registerEventListener(listener);
+                }
             }
         }
-        return testMethodCount;
+        return sConnection;
     }
 }
diff --git a/data/fonts/Android.mk b/data/fonts/Android.mk
index db27cdc..02d2f3d 100644
--- a/data/fonts/Android.mk
+++ b/data/fonts/Android.mk
@@ -17,13 +17,56 @@
 
 LOCAL_PATH := $(call my-dir)
 
+##########################################
+# We may only afford small font footprint.
+##########################################
+# Use only symlinks.
+# Symlink: DroidSans.ttf -> Roboto-Regular.ttf
+LOCAL_MODULE := DroidSans.ttf
+font_symlink_src := $(PRODUCT_OUT)/system/fonts/Roboto-Regular.ttf
+font_symlink := $(dir $(font_symlink_src))$(LOCAL_MODULE)
+$(font_symlink) : $(font_symlink_src)
+	@echo "Symlink: $@ -> $<"
+	@mkdir -p $(dir $@)
+	@rm -rf $@
+	$(hide) ln -sf $(notdir $<) $@
+
+# this magic makes LOCAL_REQUIRED_MODULES work
+ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
+    $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(font_symlink)
+
+################################
+# Symlink: DroidSans-Bold.ttf -> Roboto-Bold.ttf
+LOCAL_MODULE := DroidSans-Bold.ttf
+font_symlink_src := $(PRODUCT_OUT)/system/fonts/Roboto-Bold.ttf
+font_symlink := $(dir $(font_symlink_src))$(LOCAL_MODULE)
+$(font_symlink) : $(font_symlink_src)
+	@echo "Symlink: $@ -> $<"
+	@mkdir -p $(dir $@)
+	@rm -rf $@
+	$(hide) ln -sf $(notdir $<) $@
+
+# this magic makes LOCAL_REQUIRED_MODULES work
+ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
+    $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(font_symlink)
+
+################################
+include $(CLEAR_VARS)
+LOCAL_MODULE := DroidSansEthiopic-Regular.ttf
+LOCAL_SRC_FILES := $(LOCAL_MODULE)
+LOCAL_MODULE_CLASS := ETC
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_PATH := $(TARGET_OUT)/fonts
+include $(BUILD_PREBUILT)
+
+################################
 ifeq ($(SMALLER_FONT_FOOTPRINT),true)
 droidsans_fallback_src := DroidSansFallback.ttf
-extra_droidsans_fonts :=
+extra_droidsans_fonts := DroidSans.ttf DroidSans-Bold.ttf
 else
 droidsans_fallback_src := DroidSansFallbackFull.ttf
 extra_droidsans_fonts := DroidSans.ttf DroidSans-Bold.ttf DroidSansEthiopic-Regular.ttf
-endif
+endif  # SMALLER_FONT_FOOTPRINT
 
 include $(CLEAR_VARS)
 LOCAL_MODULE := DroidSansFallback.ttf
@@ -32,30 +75,9 @@
 LOCAL_MODULE_TAGS := optional
 LOCAL_MODULE_PATH := $(TARGET_OUT)/fonts
 LOCAL_REQUIRED_MODULES := $(extra_droidsans_fonts)
+include $(BUILD_PREBUILT)
+
+font_symlink_src :=
+font_symlink :=
 droidsans_fallback_src :=
 extra_droidsans_fonts :=
-include $(BUILD_PREBUILT)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := DroidSans.ttf
-LOCAL_SRC_FILES := $(LOCAL_MODULE)
-LOCAL_MODULE_CLASS := ETC
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_PATH := $(TARGET_OUT)/fonts
-include $(BUILD_PREBUILT)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := DroidSans-Bold.ttf
-LOCAL_SRC_FILES := $(LOCAL_MODULE)
-LOCAL_MODULE_CLASS := ETC
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_PATH := $(TARGET_OUT)/fonts
-include $(BUILD_PREBUILT)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := DroidSansEthiopic-Regular.ttf
-LOCAL_SRC_FILES := $(LOCAL_MODULE)
-LOCAL_MODULE_CLASS := ETC
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_PATH := $(TARGET_OUT)/fonts
-include $(BUILD_PREBUILT)
diff --git a/docs/html/resources/resources-data.js b/docs/html/resources/resources-data.js
index c0a2284..3e673a5 100644
--- a/docs/html/resources/resources-data.js
+++ b/docs/html/resources/resources-data.js
@@ -728,6 +728,16 @@
     }
   },
   {
+    tags: ['sample','newfeature', 'new'],
+    path: 'samples/WiFiDirectDemo/index.html',
+    title: {
+      en: 'Wi-Fi Direct Demo'
+    },
+    description: {
+      en: 'A demo application to demonstrate how to use Wi-Fi Direct APIs.'
+    }
+  },
+  {
     tags: ['sample', 'ui', 'widgets'],
     path: 'samples/Wiktionary/index.html',
     title: {
diff --git a/docs/html/resources/samples/images/WifiDirect.png b/docs/html/resources/samples/images/WifiDirect.png
new file mode 100644
index 0000000..86f7f2f
--- /dev/null
+++ b/docs/html/resources/samples/images/WifiDirect.png
Binary files differ
diff --git a/services/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/java/com/android/server/accessibility/AccessibilityManagerService.java
index ed8fa40..fd528cc 100644
--- a/services/java/com/android/server/accessibility/AccessibilityManagerService.java
+++ b/services/java/com/android/server/accessibility/AccessibilityManagerService.java
@@ -298,16 +298,7 @@
                     super.onChange(selfChange);
 
                     synchronized (mLock) {
-                        mIsAccessibilityEnabled = Settings.Secure.getInt(
-                                mContext.getContentResolver(),
-                                Settings.Secure.ACCESSIBILITY_ENABLED, 0) == 1;
-                        if (mIsAccessibilityEnabled) {
-                            manageServicesLocked();
-                        } else {
-                            unbindAllServicesLocked();
-                        }
-                        updateInputFilterLocked();
-                        sendStateToClientsLocked();
+                        handleAccessibilityEnabledSettingChangedLocked();
                     }
                 }
             });
@@ -354,6 +345,7 @@
             client.asBinder().linkToDeath(new DeathRecipient() {
                 public void binderDied() {
                     synchronized (mLock) {
+                        addedClient.asBinder().unlinkToDeath(this, 0);
                         mClients.remove(addedClient);
                     }
                 }
@@ -445,10 +437,12 @@
             IAccessibilityInteractionConnection connection) throws RemoteException {
         synchronized (mLock) {
             final IWindow addedWindowToken = windowToken;
+            final IAccessibilityInteractionConnection addedConnection = connection;
             final int windowId = sNextWindowId++;
-            connection.asBinder().linkToDeath(new DeathRecipient() {
+            addedConnection.asBinder().linkToDeath(new DeathRecipient() {
                 public void binderDied() {
                     synchronized (mLock) {
+                        addedConnection.asBinder().unlinkToDeath(this, 0);
                         removeAccessibilityInteractionConnection(addedWindowToken);
                     }
                 }
@@ -485,21 +479,23 @@
         ComponentName componentName = new ComponentName("foo.bar",
                 "AutomationAccessibilityService");
         synchronized (mLock) {
-            Service oldService = mComponentNameToServiceMap.get(componentName);
-            if (oldService != null) {
-                tryRemoveServiceLocked(oldService);
+            // If an automation services is connected to the system all services are stopped
+            // so the automation one is the only one running. Settings are not changed so when
+            // the automation service goes away the state is restored from the settings.
+
+            // Disable all services.
+            final int runningServiceCount = mServices.size();
+            for (int i = 0; i < runningServiceCount; i++) {
+                Service runningService = mServices.get(i);
+                runningService.unbind();
             }
-            // Now this service is enabled.
-            mEnabledServices.add(componentName);
-            // Also make sure this service is the only one.
-            Settings.Secure.putString(mContext.getContentResolver(),
-                    Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,
-                    componentName.flattenToString());
-            // This API is intended for testing so enable accessibility to make
-            // sure clients can start poking with the window content.
-            Settings.Secure.putInt(mContext.getContentResolver(),
-                    Settings.Secure.ACCESSIBILITY_ENABLED, 1);
+            // If necessary enable accessibility and announce that.
+            if (!mIsAccessibilityEnabled) {
+                mIsAccessibilityEnabled = true;
+                sendStateToClientsLocked();
+            }
         }
+        // Hook the automation service up.
         AccessibilityServiceInfo accessibilityServiceInfo = new AccessibilityServiceInfo();
         accessibilityServiceInfo.eventTypes = AccessibilityEvent.TYPES_ALL_MASK;
         accessibilityServiceInfo.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
@@ -717,11 +713,12 @@
      * Manages services by starting enabled ones and stopping disabled ones.
      */
     private void manageServicesLocked() {
+        unbindAutomationService();
         populateEnabledServicesLocked(mEnabledServices);
         final int enabledInstalledServicesCount = updateServicesStateLocked(mInstalledServices,
                 mEnabledServices);
         // No enabled installed services => disable accessibility to avoid
-        // sending accessibility events with no recipient across processes. 
+        // sending accessibility events with no recipient across processes.
         if (mIsAccessibilityEnabled && enabledInstalledServicesCount == 0) {
             Settings.Secure.putInt(mContext.getContentResolver(),
                     Settings.Secure.ACCESSIBILITY_ENABLED, 0);
@@ -744,6 +741,21 @@
     }
 
     /**
+     * Unbinds the automation service if such is running.
+     */
+    private void unbindAutomationService() {
+        List<Service> runningServices = mServices;
+        int runningServiceCount = mServices.size();
+        for (int i = 0; i < runningServiceCount; i++) {
+            Service service = runningServices.get(i);
+            if (service.mIsAutomation) {
+                 service.unbind();
+                 return;
+            }
+        }
+    }
+
+    /**
      * Populates a list with the {@link ComponentName}s of all enabled
      * {@link AccessibilityService}s.
      *
@@ -868,6 +880,22 @@
     }
 
     /**
+     * Updated the state based on the accessibility enabled setting.
+     */
+    private void handleAccessibilityEnabledSettingChangedLocked() {
+        mIsAccessibilityEnabled = Settings.Secure.getInt(
+                mContext.getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_ENABLED, 0) == 1;
+        if (mIsAccessibilityEnabled) {
+            manageServicesLocked();
+        } else {
+            unbindAllServicesLocked();
+        }
+        updateInputFilterLocked();
+        sendStateToClientsLocked();
+    }
+
+    /**
      * This class represents an accessibility service. It stores all per service
      * data required for the service management, provides API for starting/stopping the
      * service and is responsible for adding/removing the service in the data structures
@@ -1171,7 +1199,13 @@
 
         public void binderDied() {
             synchronized (mLock) {
+                mService.unlinkToDeath(this, 0);
                 tryRemoveServiceLocked(this);
+                // We no longer have an automation service, so restore
+                // the state based on values in the settings database.
+                if (mIsAutomation) {
+                    handleAccessibilityEnabledSettingChangedLocked();
+                }
             }
         }
 
diff --git a/tests/GridLayoutTest/AndroidManifest.xml b/tests/GridLayoutTest/AndroidManifest.xml
index 1b72357..141e8fa 100644
--- a/tests/GridLayoutTest/AndroidManifest.xml
+++ b/tests/GridLayoutTest/AndroidManifest.xml
@@ -35,20 +35,6 @@
             </intent-filter>
         </activity>
 
-        <activity android:name="Activity2" android:label="Activity2">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN"/>
-                <category android:name="android.intent.category.LAUNCHER"/>
-            </intent-filter>
-        </activity>
-
-        <activity android:name="Activity3" android:label="Activity3">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN"/>
-                <category android:name="android.intent.category.LAUNCHER"/>
-            </intent-filter>
-        </activity>
-
         <activity android:name="Activity4" android:label="Activity4">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN"/>
diff --git a/tests/GridLayoutTest/res/layout/grid3.xml b/tests/GridLayoutTest/res/layout/grid3.xml
deleted file mode 100644
index 0e53613..0000000
--- a/tests/GridLayoutTest/res/layout/grid3.xml
+++ /dev/null
@@ -1,87 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<GridLayout
-        xmlns:android="http://schemas.android.com/apk/res/android"
-
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-
-        android:useDefaultMargins="true"
-        android:alignmentMode="alignBounds"
-        android:rowOrderPreserved="false"
-
-        android:columnCount="4"
-        >
-
-    <TextView
-            android:text="Email setup"
-            android:textSize="32dip"
-
-            android:layout_columnSpan="4"
-            android:layout_gravity="center_horizontal"
-            />
-
-    <TextView
-            android:text="You can configure email in just a few steps:"
-            android:textSize="16dip"
-
-            android:layout_columnSpan="4"
-            android:layout_gravity="left"
-            />
-
-    <TextView
-            android:text="Email address:"
-
-            android:layout_gravity="right"
-            />
-
-    <EditText
-            android:ems="10"
-            />
-
-    <TextView
-            android:text="Password:"
-
-            android:layout_column="0"
-            android:layout_gravity="right"
-            />
-
-    <EditText
-            android:ems="8"
-            />
-
-    <Space
-            android:layout_row="2"
-            android:layout_rowSpan="3"
-            android:layout_column="2"
-            android:layout_gravity="fill"
-            />
-
-    <Button
-            android:text="Manual setup"
-
-            android:layout_row="5"
-            android:layout_column="3"
-            />
-
-    <Button
-            android:text="Next"
-
-            android:layout_column="3"
-            android:layout_gravity="fill_horizontal"
-            />
-</GridLayout>
diff --git a/tests/GridLayoutTest/src/com/android/test/layout/Activity2.java b/tests/GridLayoutTest/src/com/android/test/layout/Activity2.java
deleted file mode 100644
index 8974f37..0000000
--- a/tests/GridLayoutTest/src/com/android/test/layout/Activity2.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.test.layout;
-
-import android.app.Activity;
-import android.content.Context;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.GridLayout;
-import android.widget.Space;
-import android.widget.TextView;
-
-import static android.text.InputType.TYPE_CLASS_TEXT;
-import static android.view.inputmethod.EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
-import static android.view.inputmethod.EditorInfo.TYPE_TEXT_VARIATION_PASSWORD;
-import static android.widget.GridLayout.*;
-
-public class Activity2 extends Activity {
-
-    public static View create(Context context) {
-        GridLayout p = new GridLayout(context);
-        p.setUseDefaultMargins(true);
-        p.setAlignmentMode(ALIGN_BOUNDS);
-        p.setRowOrderPreserved(false);
-
-        Spec row1 = spec(0);
-        Spec row2 = spec(1);
-        Spec row3 = spec(2, BASELINE);
-        Spec row4 = spec(3, BASELINE);
-        Spec row5 = spec(2, 3, FILL); // allow the last two rows to overlap the middle two
-        Spec row6 = spec(5);
-        Spec row7 = spec(6);
-
-        Spec col1a = spec(0, 4, CENTER);
-        Spec col1b = spec(0, 4, LEFT);
-        Spec col1c = spec(0, RIGHT);
-        Spec col2 = spec(1, LEFT);
-        Spec col3 = spec(2, FILL);
-        Spec col4a = spec(3);
-        Spec col4b = spec(3, FILL);
-
-        {
-            TextView c = new TextView(context);
-            c.setTextSize(32);
-            c.setText("Email setup");
-            p.addView(c, new LayoutParams(row1, col1a));
-        }
-        {
-            TextView c = new TextView(context);
-            c.setTextSize(16);
-            c.setText("You can configure email in just a few steps:");
-            p.addView(c, new LayoutParams(row2, col1b));
-        }
-        {
-            TextView c = new TextView(context);
-            c.setText("Email address:");
-            p.addView(c, new LayoutParams(row3, col1c));
-        }
-        {
-            EditText c = new EditText(context);
-            c.setEms(10);
-            c.setInputType(TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
-            p.addView(c, new LayoutParams(row3, col2));
-        }
-        {
-            TextView c = new TextView(context);
-            c.setText("Password:");
-            p.addView(c, new LayoutParams(row4, col1c));
-        }
-        {
-            TextView c = new EditText(context);
-            c.setEms(8);
-            c.setInputType(TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_PASSWORD);
-            p.addView(c, new LayoutParams(row4, col2));
-        }
-        {
-            Space c = new Space(context);
-            LayoutParams lp = new LayoutParams(row5, col3);
-            p.addView(c, lp);
-        }
-        {
-            Button c = new Button(context);
-            c.setText("Manual setup");
-            p.addView(c, new LayoutParams(row6, col4a));
-        }
-        {
-            Button c = new Button(context);
-            c.setText("Next");
-            p.addView(c, new LayoutParams(row7, col4b));
-        }
-
-        return p;
-    }
-
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(create(getBaseContext()));
-    }
-
-}
\ No newline at end of file
diff --git a/tests/GridLayoutTest/src/com/android/test/layout/Activity3.java b/tests/GridLayoutTest/src/com/android/test/layout/Activity3.java
deleted file mode 100644
index fc0b382..0000000
--- a/tests/GridLayoutTest/src/com/android/test/layout/Activity3.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.test.layout;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-public class Activity3 extends Activity {
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.grid3);
-    }
-}