Merge change 22493 into eclair

* changes:
  Add resources to specify display rotation when in keyboard open or docked state.
diff --git a/Android.mk b/Android.mk
index 3db8982..3653c7b 100644
--- a/Android.mk
+++ b/Android.mk
@@ -141,7 +141,6 @@
 	core/java/com/android/internal/view/IInputMethodClient.aidl \
 	core/java/com/android/internal/view/IInputMethodManager.aidl \
 	core/java/com/android/internal/view/IInputMethodSession.aidl \
-	im/java/android/im/IImPlugin.aidl \
 	location/java/android/location/IGeocodeProvider.aidl \
 	location/java/android/location/IGpsStatusListener.aidl \
 	location/java/android/location/IGpsStatusProvider.aidl \
@@ -228,7 +227,6 @@
 	frameworks/base/graphics/java/android/graphics/Bitmap.aidl \
 	frameworks/base/graphics/java/android/graphics/Rect.aidl \
 	frameworks/base/graphics/java/android/graphics/Region.aidl \
-	frameworks/base/im/java/android/im/IImPlugin.aidl \
 	frameworks/base/location/java/android/location/Criteria.aidl \
 	frameworks/base/location/java/android/location/Location.aidl \
 	frameworks/base/telephony/java/android/telephony/ServiceState.aidl \
@@ -339,7 +337,7 @@
     -since ./frameworks/base/api/1.xml 1 \
     -since ./frameworks/base/api/2.xml 2 \
     -since ./frameworks/base/api/3.xml 3 \
-    -since ./frameworks/base/api/current.xml Donut \
+    -since ./frameworks/base/api/4.xml 4 \
 		-error 1 -error 2 -warning 3 -error 4 -error 6 -error 8 \
 		-overview $(LOCAL_PATH)/core/java/overview.html
 
@@ -351,10 +349,18 @@
 		-hdf android.hasSamples 1 \
 		-samplecode $(sample_dir)/ApiDemos \
 		            guide/samples/ApiDemos "API Demos" \
+		-samplecode $(sample_dir)/Home \
+		            guide/samples/Home "Home" \
+		-samplecode $(sample_dir)/JetBoy \
+		            guide/samples/JetBoy "JetBoy" \
 		-samplecode $(sample_dir)/LunarLander \
 		            guide/samples/LunarLander "Lunar Lander" \
 		-samplecode $(sample_dir)/NotePad \
-		            guide/samples/NotePad "Note Pad"
+		            guide/samples/NotePad "Note Pad" \
+		-samplecode $(sample_dir)/Snake \
+		            guide/samples/Snake "Snake" \
+		-samplecode $(sample_dir)/SoftKeyboard \
+		            guide/samples/SoftKeyboard "Soft Keyboard"
 
 ## SDK version identifiers used in the published docs
   # major[.minor] version for current SDK. (full releases only)
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 588068e..decf6fc 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -2935,8 +2935,8 @@
          * it so the UI can give it some special treatment when displaying the "time sent" for
          * it. This setting is to control what x is.
          */
-        public static final String GTALK_OLD_CHAT_MESSAGE_THREADHOLD_IN_SEC =
-                "gtalk_old_chat_msg_threadhold_in_sec";
+        public static final String GTALK_OLD_CHAT_MESSAGE_THRESHOLD_IN_SEC =
+                "gtalk_old_chat_msg_threshold_in_sec";
 
         /**
          * a setting to control the max connection history record GTalkService stores.
diff --git a/core/java/android/provider/Telephony.java b/core/java/android/provider/Telephony.java
index 7a6f6bb..0207330 100644
--- a/core/java/android/provider/Telephony.java
+++ b/core/java/android/provider/Telephony.java
@@ -1264,6 +1264,21 @@
         }
 
         /**
+         * Returns true if the number is a Phone number
+         *
+         * @param number the input number to be tested
+         * @return true if number is a Phone number
+         */
+        public static boolean isPhoneNumber(String number) {
+            if (TextUtils.isEmpty(number)) {
+                return false;
+            }
+
+            Matcher match = Regex.PHONE_PATTERN.matcher(number);
+            return match.matches();
+        }
+
+        /**
          * Contains all MMS messages in the MMS app's inbox.
          */
         public static final class Inbox implements BaseMmsColumns {
diff --git a/core/java/android/webkit/BrowserFrame.java b/core/java/android/webkit/BrowserFrame.java
index afa2c35..ce27fd7f9 100644
--- a/core/java/android/webkit/BrowserFrame.java
+++ b/core/java/android/webkit/BrowserFrame.java
@@ -343,17 +343,16 @@
         switch (msg.what) {
             case FRAME_COMPLETED: {
                 if (mSettings.getSavePassword() && hasPasswordField()) {
-                    if (DebugFlags.BROWSER_FRAME) {
-                        Assert.assertNotNull(mCallbackProxy.getBackForwardList()
-                                .getCurrentItem());
-                    }
-                    WebAddress uri = new WebAddress(
-                            mCallbackProxy.getBackForwardList().getCurrentItem()
-                            .getUrl());
-                    String schemePlusHost = uri.mScheme + uri.mHost;
-                    String[] up = mDatabase.getUsernamePassword(schemePlusHost);
-                    if (up != null && up[0] != null) {
-                        setUsernamePassword(up[0], up[1]);
+                    WebHistoryItem item = mCallbackProxy.getBackForwardList()
+                            .getCurrentItem();
+                    if (item != null) {
+                        WebAddress uri = new WebAddress(item.getUrl());
+                        String schemePlusHost = uri.mScheme + uri.mHost;
+                        String[] up =
+                                mDatabase.getUsernamePassword(schemePlusHost);
+                        if (up != null && up[0] != null) {
+                            setUsernamePassword(up[0], up[1]);
+                        }
                     }
                 }
                 CacheManager.trimCacheIfNeeded();
diff --git a/core/java/android/webkit/CallbackProxy.java b/core/java/android/webkit/CallbackProxy.java
index e77d29b..6abf4c1 100644
--- a/core/java/android/webkit/CallbackProxy.java
+++ b/core/java/android/webkit/CallbackProxy.java
@@ -70,9 +70,6 @@
     private final WebBackForwardList mBackForwardList;
     // Used to call startActivity during url override.
     private final Context mContext;
-    // Stores the URL being loaded and the viewing mode to switch into when
-    // the URL finishes loading.
-    private ChangeViewModeOnFinishedLoad mChange;
 
     // Message Ids
     private static final int PAGE_STARTED                        = 100;
@@ -181,35 +178,15 @@
 
     /**
      * Tell the host application that the WebView has changed viewing modes.
-     * @param toZoomedOut If true, the WebView has zoomed out so that the page
-     *          fits the screen.  If false, it is zoomed to the setting
-     *          specified by the user.
+     * @param newViewingMode  One of the values described in WebView as possible
+     *                        values for the viewing mode
      */
-    /* package */ void uiOnChangeViewingMode(boolean toZoomOverview) {
+    /* package */ void uiOnChangeViewingMode(int newViewingMode) {
         if (mWebChromeClient != null) {
-            mWebChromeClient.onChangeViewingMode(toZoomOverview);
+            mWebChromeClient.onChangeViewingMode(mWebView, newViewingMode);
         }
     }
 
-    private static class ChangeViewModeOnFinishedLoad {
-        boolean mToZoomOverView;
-        String mOriginalUrl;
-        ChangeViewModeOnFinishedLoad(boolean toZoomOverview,
-                String originalUrl) {
-            mToZoomOverView = toZoomOverview;
-            mOriginalUrl = originalUrl;
-        }
-    }
-
-    /**
-     * Keep track of the url and the viewing mode to change into.  If/when that
-     * url finishes loading, this will change the viewing mode.
-     */
-    /* package */ void uiChangeViewingModeOnFinishedLoad(
-            boolean toZoomOverview, String originalUrl) {
-        if (mWebChromeClient == null) return;
-        mChange = new ChangeViewModeOnFinishedLoad(toZoomOverview, originalUrl);
-    }
     /**
      * Called by the UI side.  Calling overrideUrlLoading from the WebCore
      * side will post a message to call this method.
@@ -271,15 +248,6 @@
                 if (mWebViewClient != null) {
                     mWebViewClient.onPageFinished(mWebView, (String) msg.obj);
                 }
-                if (mChange != null) {
-                    if (mWebView.getOriginalUrl().equals(mChange.mOriginalUrl)) {
-                        uiOnChangeViewingMode(mChange.mToZoomOverView);
-                    } else {
-                        // The user has gone to a different page, so there is
-                        // no need to hang on to the old object.
-                        mChange = null;
-                    }
-                }
                 break;
                 
             case RECEIVED_ICON:
diff --git a/core/java/android/webkit/WebChromeClient.java b/core/java/android/webkit/WebChromeClient.java
index e1c8d4d..e2d5d24 100644
--- a/core/java/android/webkit/WebChromeClient.java
+++ b/core/java/android/webkit/WebChromeClient.java
@@ -24,12 +24,12 @@
 
     /**
      * Tell the host application that the WebView has changed viewing modes.
-     * @param toZoomedOut If true, the WebView has zoomed out so that the page
-     *          fits the screen.  If false, it is zoomed to the setting
-     *          specified by the user.
+     * @param view The WebView that initiated the callback.
+     * @param newViewingMode  One of the values described in WebView as possible
+     *                        values for the viewing mode
      * @hide
      */
-    public void onChangeViewingMode(boolean toZoomedOut) {}
+    public void onChangeViewingMode(WebView view, int newViewingMode) {}
 
     /**
      * Tell the host application the current progress of loading a page.
diff --git a/core/java/android/webkit/WebSettings.java b/core/java/android/webkit/WebSettings.java
index 4bdd488..e8b2702 100644
--- a/core/java/android/webkit/WebSettings.java
+++ b/core/java/android/webkit/WebSettings.java
@@ -172,6 +172,7 @@
     private long            mAppCacheMaxSize = Long.MAX_VALUE;
     private String          mAppCachePath = "";
     private String          mDatabasePath = "";
+    private String          mGeolocationDatabasePath = "";
     // Don't need to synchronize the get/set methods as they
     // are basic types, also none of these values are used in
     // native WebCore code.
@@ -978,6 +979,21 @@
     }
 
     /**
+     * Set the path where the Geolocation permissions database should be saved.
+     * This will update WebCore when the Sync runs in the C++ side.
+     * @param databasePath String path to the directory where the Geolocation
+     *     permissions database should be saved. May be the empty string but
+     *     should never be null.
+     * @hide pending api council approval
+     */
+    public synchronized void setGeolocationDatabasePath(String databasePath) {
+        if (databasePath != null && !databasePath.equals(mDatabasePath)) {
+            mGeolocationDatabasePath = databasePath;
+            postSync();
+        }
+    }
+
+    /**
      * Tell the WebView to enable Application Caches API.
      * @param flag True if the WebView should enable Application Caches.
      * @hide pending api council approval
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index f49aab1..196c66b 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -522,6 +522,48 @@
     // the last zoom scale.
     boolean mInZoomOverview = false;
 
+    // The viewing mode of this webview.  Reported back to the WebChromeClient
+    // so we can hide and display the title bar as appropriate.
+    private int mViewingMode;
+    /**
+     * Not supporting overview vs reading mode
+     * @hide
+     */
+    public final static int NO_VIEWING_MODE = 0;
+    /**
+     * Zoom overview mode.  The page is zoomed all the way out, mInZoomOverview
+     * is true, and the title bar is showing.  Double tapping will change to
+     * reading mode.
+     * @hide
+     */
+    public final static int OVERVIEW_MODE = 1;
+    /**
+     * Reading mode. The page is at the level specified by the user,
+     * mInZoomOverview is false, and the title bar is not showing.  Double
+     * tapping will change to zoom overview mode.
+     * @hide
+     */
+    public final static int READING_MODE = 2;
+    /**
+     * Modified reading mode, which shows the title bar.  mInZoomOverview is
+     * false, and double tapping will change to zoom overview mode.  However,
+     * if the scrolling will change to reading mode.  Used when swiping a
+     * tab into view which was in reading mode, unless it was a mobile site
+     * with zero scroll.
+     * @hide
+     */
+    public final static int READING_MODE_WITH_TITLE_BAR = 3;
+    /**
+     * Another modified reading mode.  For loading a mobile site, or swiping a
+     * tab into view which was displaying a mobile site in reading mode
+     * with zero scroll
+     * @hide
+     */
+    public final static int TITLE_BAR_DISMISS_MODE = 4;
+    // Whether the current site is a mobile site.  Determined when we receive
+    // NEW_PICTURE_MSG_ID to help determine how to handle double taps
+    private boolean mMobileSite;
+
     // ideally mZoomOverviewWidth should be mContentWidth. But sites like espn,
     // engadget always have wider mContentWidth no matter what viewport size is.
     int mZoomOverviewWidth = WebViewCore.DEFAULT_VIEWPORT_WIDTH;
@@ -1135,6 +1177,7 @@
             if (mInZoomOverview) {
                 b.putFloat("lastScale", mLastScale);
             }
+            b.putBoolean("mobile", mMobileSite);
             return true;
         }
         return false;
@@ -1180,12 +1223,20 @@
                 // correctly
                 mActualScale = scale;
                 float lastScale = b.getFloat("lastScale", -1.0f);
+                mMobileSite = b.getBoolean("mobile", false);
                 if (lastScale > 0) {
                     mInZoomOverview = true;
+                    mViewingMode = OVERVIEW_MODE;
                     mLastScale = lastScale;
                 } else {
                     mInZoomOverview = false;
+                    if (mMobileSite && (mScrollX | mScrollY) == 0) {
+                        mViewingMode = TITLE_BAR_DISMISS_MODE;
+                    } else {
+                        mViewingMode = READING_MODE_WITH_TITLE_BAR;
+                    }
                 }
+                mCallbackProxy.uiOnChangeViewingMode(mViewingMode);
                 invalidate();
                 return true;
             }
@@ -3674,8 +3725,10 @@
     protected void onSizeChanged(int w, int h, int ow, int oh) {
         super.onSizeChanged(w, h, ow, oh);
         // Center zooming to the center of the screen.
-        mZoomCenterX = getViewWidth() * .5f;
-        mZoomCenterY = getViewHeight() * .5f;
+        if (mZoomScale == 0) { // unless we're already zooming
+            mZoomCenterX = getViewWidth() * .5f;
+            mZoomCenterY = getViewHeight() * .5f;
+        }
 
         // update mMinZoomScale if the minimum zoom scale is not fixed
         if (!mMinZoomScaleFixed) {
@@ -3693,6 +3746,12 @@
     protected void onScrollChanged(int l, int t, int oldl, int oldt) {
         super.onScrollChanged(l, t, oldl, oldt);
 
+        if (mViewingMode == READING_MODE_WITH_TITLE_BAR
+                || mViewingMode == TITLE_BAR_DISMISS_MODE) {
+            mViewingMode = READING_MODE;
+            mCallbackProxy.uiOnChangeViewingMode(mViewingMode);
+        }
+
         sendOurVisibleRect();
     }
 
@@ -3907,6 +3966,13 @@
                 deltaY = newScrollY - mScrollY;
                 boolean done = false;
                 if (deltaX == 0 && deltaY == 0) {
+                    // The user attempted to pan the page, so dismiss the title
+                    // bar
+                    if (mViewingMode == READING_MODE_WITH_TITLE_BAR
+                            || mViewingMode == TITLE_BAR_DISMISS_MODE) {
+                        mViewingMode = READING_MODE;
+                        mCallbackProxy.uiOnChangeViewingMode(mViewingMode);
+                    }
                     done = true;
                 } else {
                     if (mSnapScrollMode == SNAP_X || mSnapScrollMode == SNAP_Y) {
@@ -4681,14 +4747,42 @@
         }
     }
 
+    /**
+     * Called when the Tabs are used to slide this WebView's tab into view.
+     * @hide
+     */
+    public void slideIntoFocus() {
+        if (mViewingMode == READING_MODE) {
+            if (!mMobileSite || (mScrollX | mScrollY) != 0) {
+                mViewingMode = READING_MODE_WITH_TITLE_BAR;
+            } else {
+                mViewingMode = TITLE_BAR_DISMISS_MODE;
+            }
+            mCallbackProxy.uiOnChangeViewingMode(mViewingMode);
+        }
+    }
+
     private void doDoubleTap() {
-        if (mWebViewCore.getSettings().getUseWideViewPort() == false) {
+        if (mWebViewCore.getSettings().getUseWideViewPort() == false ||
+                mViewingMode == NO_VIEWING_MODE) {
             return;
         }
+        if (mViewingMode == TITLE_BAR_DISMISS_MODE) {
+            mViewingMode = READING_MODE;
+            // mInZoomOverview will not change, so change the viewing mode
+            // and return
+            mCallbackProxy.uiOnChangeViewingMode(mViewingMode);
+            return;
+        }
+        if (mViewingMode == READING_MODE_WITH_TITLE_BAR && mMobileSite) {
+            scrollTo(0,0);
+        }
+        // READING_MODE_WITH_TITLE_BAR will go to OVERVIEW_MODE here.
         mZoomCenterX = mLastTouchX;
         mZoomCenterY = mLastTouchY;
         mInZoomOverview = !mInZoomOverview;
-        mCallbackProxy.uiOnChangeViewingMode(mInZoomOverview);
+        mViewingMode = mInZoomOverview ? OVERVIEW_MODE : READING_MODE;
+        mCallbackProxy.uiOnChangeViewingMode(mViewingMode);
         // remove the zoom control after double tap
         if (getSettings().getBuiltInZoomControls()) {
             if (mZoomButtonsController.isVisible()) {
@@ -5033,21 +5127,27 @@
                         } else {
                             mMaxZoomScale = restoreState.mMaxScale;
                         }
-                        if (useWideViewport && restoreState.mViewScale == 0) {
-                            mInZoomOverview = ENABLE_DOUBLETAP_ZOOM
-                                    && settings.getLoadWithOverviewMode();
-                        }
-                        mCallbackProxy.uiOnChangeViewingMode(true);
-                        if (!mInZoomOverview) {
-                            // We are going to start zoomed in.  However, we
-                            // truly want to show the title bar, and then hide
-                            // it once the page has loaded
-                            mCallbackProxy.uiChangeViewingModeOnFinishedLoad(
-                                    false, getOriginalUrl());
-                        }
                         setNewZoomScale(mLastScale, false);
                         setContentScrollTo(restoreState.mScrollX,
                                 restoreState.mScrollY);
+                        if (!ENABLE_DOUBLETAP_ZOOM
+                                || !settings.getLoadWithOverviewMode()) {
+                            mMobileSite = false;
+                            mViewingMode = NO_VIEWING_MODE;
+                        } else {
+                            mMobileSite = restoreState.mMobileSite;
+                            if (useWideViewport
+                                    && restoreState.mViewScale == 0) {
+                                mViewingMode = OVERVIEW_MODE;
+                                mInZoomOverview = true;
+                            } else if (mMobileSite
+                                    && (mScrollX | mScrollY) == 0) {
+                                mViewingMode = TITLE_BAR_DISMISS_MODE;
+                            } else {
+                                mViewingMode = READING_MODE_WITH_TITLE_BAR;
+                            }
+                        }
+                        mCallbackProxy.uiOnChangeViewingMode(mViewingMode);
                         // As we are on a new page, remove the WebTextView. This
                         // is necessary for page loads driven by webkit, and in
                         // particular when the user was on a password field, so
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index dee62b4..d6a9cff 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -1505,6 +1505,7 @@
         float mTextWrapScale;
         int mScrollX;
         int mScrollY;
+        boolean mMobileSite;
     }
 
     static class DrawData {
@@ -1859,6 +1860,7 @@
         mRestoreState.mMaxScale = mViewportMaximumScale / 100.0f;
         mRestoreState.mScrollX = mRestoredX;
         mRestoreState.mScrollY = mRestoredY;
+        mRestoreState.mMobileSite = (0 == mViewportWidth);
         if (mRestoredScale > 0) {
             if (mRestoredScreenWidthScale > 0) {
                 mRestoreState.mTextWrapScale =
diff --git a/docs/html/guide/guide_toc.cs b/docs/html/guide/guide_toc.cs
index 0b33739..459ad37 100644
--- a/docs/html/guide/guide_toc.cs
+++ b/docs/html/guide/guide_toc.cs
@@ -387,17 +387,30 @@
           <li><a href="<?cs var:toroot ?>guide/samples/ApiDemos/index.html">
                 <span class="en">API Demos</span>
               </a></li>
+          <li><a href="<?cs var:toroot ?>guide/samples/Home/index.html">
+                <span class="en">Home</span>
+              </a></li>
+          <li><a href="<?cs var:toroot ?>guide/samples/JetBoy/index.html">
+                <span class="en">JetBoy</span>
+              </a></li>
           <li><a href="<?cs var:toroot ?>guide/samples/LunarLander/index.html">
                 <span class="en">Lunar Lander</span>
               </a></li>
           <li><a href="<?cs var:toroot ?>guide/samples/NotePad/index.html">
-                <span class="en">NotePad</span>
+                <span class="en">Note Pad</span>
+              </a></li>
+          <li><a href="<?cs var:toroot ?>guide/samples/Snake/index.html">
+                <span class="en">Snake</span>
+              </a></li>
+          <li><a href="<?cs var:toroot ?>guide/samples/SoftKeyboard/index.html">
+                <span class="en">Soft Keyboard</span>
               </a></li>
         </ul>
       </li>
     <?cs /if ?>
     </ul>
   </li>
+  
 
   <li>
     <h2><span class="en">Appendix</span>
diff --git a/docs/html/guide/samples/images/HomeSample.png b/docs/html/guide/samples/images/HomeSample.png
new file mode 100644
index 0000000..990bebb
--- /dev/null
+++ b/docs/html/guide/samples/images/HomeSample.png
Binary files differ
diff --git a/docs/html/guide/samples/images/JetBoy.png b/docs/html/guide/samples/images/JetBoy.png
new file mode 100644
index 0000000..3da0448
--- /dev/null
+++ b/docs/html/guide/samples/images/JetBoy.png
Binary files differ
diff --git a/docs/html/guide/samples/images/Snake.png b/docs/html/guide/samples/images/Snake.png
new file mode 100644
index 0000000..c5211d8
--- /dev/null
+++ b/docs/html/guide/samples/images/Snake.png
Binary files differ
diff --git a/docs/html/guide/samples/images/SoftKeyboard.png b/docs/html/guide/samples/images/SoftKeyboard.png
new file mode 100644
index 0000000..8a4ec63
--- /dev/null
+++ b/docs/html/guide/samples/images/SoftKeyboard.png
Binary files differ
diff --git a/docs/html/guide/samples/images/sample_lunarlander.png b/docs/html/guide/samples/images/sample_lunarlander.png
new file mode 100644
index 0000000..a2ff75a
--- /dev/null
+++ b/docs/html/guide/samples/images/sample_lunarlander.png
Binary files differ
diff --git a/docs/html/guide/samples/images/sample_note.png b/docs/html/guide/samples/images/sample_note.png
new file mode 100644
index 0000000..8fc9dcc
--- /dev/null
+++ b/docs/html/guide/samples/images/sample_note.png
Binary files differ
diff --git a/docs/html/guide/samples/images/sample_notepad.png b/docs/html/guide/samples/images/sample_notepad.png
new file mode 100644
index 0000000..46f2211
--- /dev/null
+++ b/docs/html/guide/samples/images/sample_notepad.png
Binary files differ
diff --git a/docs/html/guide/samples/index.jd b/docs/html/guide/samples/index.jd
index 365284d..d8bbc41 100644
--- a/docs/html/guide/samples/index.jd
+++ b/docs/html/guide/samples/index.jd
@@ -15,11 +15,28 @@
 <p>You can easily add these applications as projects in your development environment, so that you 
 can modify them and watch them execute. </p>
 <dl>
+
  <dt><a href="ApiDemos/index.html">API Demos</a></dt>
-  <dd>A variety of small applications that demonstrate simple views and widgets.</dd>
+  <dd>A variety of small applications that demonstrate an extensive collection of framework topics.</dd>
+  
+ <dt><a href="Home/index.html">Home</a></dt>
+  <dd>An application for saving notes. Similar (but not identical) to the 
+    <a href="{@docRoot}guide/tutorials/notepad/index.html">Notepad tutorial</a>.</dd>
+  
+ <dt><a href="JetBoy/index.html">JetBoy</a></dt>
+  <dd>JetBoy is a game that demonstrates the SONiVOX JET interactive music technology, with {@link android.media.JetPlayer}.</dd>
+    
  <dt><a href="LunarLander/index.html">Lunar Lander</a></dt>
   <dd>A classic Lunar Lander game.</dd>
+  
  <dt><a href="NotePad/index.html">Note Pad</a></dt>
   <dd>An application for saving notes. Similar (but not identical) to the 
     <a href="{@docRoot}guide/tutorials/notepad/index.html">Notepad tutorial</a>.</dd>
+  
+ <dt><a href="Snake/index.html">Snake</a></dt>
+  <dd>An implementation of the classic game "Snake."</dd>
+  
+ <dt><a href="SoftKeyboard/index.html">Soft Keyboard</a></dt>
+  <dd>An example of writing an input method for a software keyboard.</dd>
+    
 </dl>
diff --git a/im/java/android/im/BrandingResourceIDs.java b/im/java/android/im/BrandingResourceIDs.java
deleted file mode 100644
index 9960722..0000000
--- a/im/java/android/im/BrandingResourceIDs.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package android.im;
-
-/**
- * @hide
- * Defines the IDs of branding resources.
- */
-public interface BrandingResourceIDs {
-    /**
-     * The logo icon of the provider which is displayed in the landing page.
-     */
-    public static final int DRAWABLE_LOGO                = 100;
-    /**
-     * The icon of online presence status.
-     */
-    public static final int DRAWABLE_PRESENCE_ONLINE     = 102;
-    /**
-     * The icon of busy presence status.
-     */
-    public static final int DRAWABLE_PRESENCE_BUSY       = 103;
-    /**
-     * The icon of away presence status.
-     */
-    public static final int DRAWABLE_PRESENCE_AWAY       = 104;
-    /**
-     * The icon of invisible presence status.
-     */
-    public static final int DRAWABLE_PRESENCE_INVISIBLE  = 105;
-    /**
-     * The icon of offline presence status.
-     */
-    public static final int DRAWABLE_PRESENCE_OFFLINE    = 106;
-    /**
-     * The label of the menu to go to the contact list screen.
-     */
-    public static final int STRING_MENU_CONTACT_LIST     = 107;
-
-}
diff --git a/im/java/android/im/IImPlugin.aidl b/im/java/android/im/IImPlugin.aidl
deleted file mode 100644
index 229cd0e..0000000
--- a/im/java/android/im/IImPlugin.aidl
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package android.im;
-
-/**
- * @hide
- */
-interface IImPlugin {
-    /**
-     * Notify the plugin the front door activity is created. This gives the plugin a chance to
-     * start its own servics, etc.
-     */
-    void onStart();
-    
-    /**
-     * Notify the plugin the front door activity is stopping.
-     */
-    void onStop();
-
-    /**
-     * Sign in to the service for the account passed in.
-     *
-     * @param account the account id for the accont to be signed into.
-     */
-    void signIn(long account);
-
-    /**
-     * Sign out of the service for the account passed in.
-     *
-     * @param account the account id for the accont to be signed out of.
-     */
-    void signOut(long account);
-
-    /**
-     * Returns the package name used to load the resources for the given provider name.
-     *
-     * @return The package name to load the resourcs for the given provider.
-     */
-    String getResourcePackageNameForProvider(String providerName);
-
-    /**
-     * Returns a map of branding resources for the given provider. The keys are defined
-     * in {@link android.im.BrandingResourceIDs}. The values are the resource identifiers generated
-     * by the aapt tool.
-     *
-     * @return The map of branding resources for the given provider.
-     */
-    Map getResourceMapForProvider(String providerName);
-
-    /*
-     * Returns a list of supported IM providers.
-     *
-     * @return a List of supported providers.
-     */
-    List getSupportedProviders();
-}
diff --git a/im/java/android/im/ImPluginConsts.java b/im/java/android/im/ImPluginConsts.java
deleted file mode 100644
index 416493ff..0000000
--- a/im/java/android/im/ImPluginConsts.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.im;
-
-/**
- * @hide
- */
-public class ImPluginConsts {
-    /**
-     * The intent action name for the plugin service.
-     */
-    public static final String PLUGIN_ACTION_NAME = "android.im.plugin";
-}
\ No newline at end of file
diff --git a/libs/rs/java/Galaxy/AndroidManifest.xml b/libs/rs/java/Galaxy/AndroidManifest.xml
deleted file mode 100644
index 6da1e0f..0000000
--- a/libs/rs/java/Galaxy/AndroidManifest.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="com.android.galaxy.rs">
-
-    <application android:label="GalaxyRS">
-
-        <activity
-            android:screenOrientation="portrait"
-            android:name="Galaxy"
-            android:theme="@android:style/Theme.NoTitleBar">
-
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.LAUNCHER" />
-            </intent-filter>
-
-        </activity>
-
-    </application>
-
-</manifest>
diff --git a/libs/rs/java/Galaxy/res/drawable-hdpi/flares.png b/libs/rs/java/Galaxy/res/drawable-hdpi/flares.png
deleted file mode 100644
index 3a5c970..0000000
--- a/libs/rs/java/Galaxy/res/drawable-hdpi/flares.png
+++ /dev/null
Binary files differ
diff --git a/libs/rs/java/Galaxy/res/drawable-hdpi/light1.png b/libs/rs/java/Galaxy/res/drawable-hdpi/light1.png
deleted file mode 100644
index 4ffb1ee..0000000
--- a/libs/rs/java/Galaxy/res/drawable-hdpi/light1.png
+++ /dev/null
Binary files differ
diff --git a/libs/rs/java/Galaxy/res/drawable-hdpi/space.jpg b/libs/rs/java/Galaxy/res/drawable-hdpi/space.jpg
deleted file mode 100644
index b61f6a3..0000000
--- a/libs/rs/java/Galaxy/res/drawable-hdpi/space.jpg
+++ /dev/null
Binary files differ
diff --git a/libs/rs/java/Galaxy/res/raw/galaxy.c b/libs/rs/java/Galaxy/res/raw/galaxy.c
deleted file mode 100644
index 9ff449f..0000000
--- a/libs/rs/java/Galaxy/res/raw/galaxy.c
+++ /dev/null
@@ -1,126 +0,0 @@
-// Copyright (C) 2009 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.
-
-#pragma version(1)
-#pragma stateVertex(PVBackground)
-#pragma stateFragment(PFBackground)
-#pragma stateFragmentStore(PFSBackground)
-
-#define RSID_PARTICLES 1
-
-#define PARTICLE_STRUCT_FIELDS_COUNT 6
-#define PARTICLE_STRUCT_ANGLE 0
-#define PARTICLE_STRUCT_DISTANCE 1
-#define PARTICLE_STRUCT_SPEED 2
-#define PARTICLE_STRUCT_RADIUS 3
-#define PARTICLE_STRUCT_S 4
-#define PARTICLE_STRUCT_T 5
-
-#define RSID_PARTICLES_BUFFER 2
-#define PARTICLE_BUFFER_COMPONENTS_COUNT 5
-
-#define PARTICLES_TEXTURES_COUNT 2
-
-#define ELLIPSE_RATIO 0.892f
-
-void drawSpace(int width, int height) {
-    bindTexture(NAMED_PFBackground, 0, NAMED_TSpace);
-    drawQuadTexCoords(
-            0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
-            width, 0.0f, 0.0f, 2.0f, 1.0f,
-            width, height, 0.0f, 2.0f, 0.0f,
-            0.0f, height, 0.0f, 0.0f, 0.0f);
-}
-
-void drawLights(int width, int height) {
-    float x = (width - 512.0f) * 0.5f;
-    float y = (height - 512.0f) * 0.5f;
-    
-    // increase the size of the texture by 5% on each side
-    x -= 512.0f * 0.05f;
-
-    bindProgramFragment(NAMED_PFBackground);
-    bindTexture(NAMED_PFBackground, 0, NAMED_TLight1);
-    drawQuad(x + 512.0f * 1.1f, y         , 0.0f,
-             x                , y         , 0.0f,
-             x                , y + 512.0f, 0.0f,
-             x + 512.0f * 1.1f, y + 512.0f, 0.0f);
-}
-
-void drawParticle(float *particle, float *particleBuffer, float w, float h) {
-    float distance = particle[PARTICLE_STRUCT_DISTANCE];
-    float angle = particle[PARTICLE_STRUCT_ANGLE];
-    float speed = particle[PARTICLE_STRUCT_SPEED];
-    float r = particle[PARTICLE_STRUCT_RADIUS];
-
-    float a = angle + speed;
-    float x = distance * sinf_fast(a);
-    float y = distance * cosf_fast(a) * ELLIPSE_RATIO;
-    float s = particle[PARTICLE_STRUCT_S];
-    float t = particle[PARTICLE_STRUCT_T];
-
-    float sX = t * x + s * y + w;
-    float sY = s * x - t * y + h;
-
-    // lower left vertex of the particle's triangle
-    particleBuffer[1] = sX - r;     // X
-    particleBuffer[2] = sY + r;     // Y
-
-    // lower right vertex of the particle's triangle
-    particleBuffer[6] = sX + r;     // X
-    particleBuffer[7] = sY + r;     // Y
-
-    // upper middle vertex of the particle's triangle
-    particleBuffer[11] = sX;         // X
-    particleBuffer[12] = sY - r;     // Y
-
-    particle[PARTICLE_STRUCT_ANGLE] = a;
-}
-
-void drawParticles(int width, int height) {
-    bindProgramFragment(NAMED_PFLighting);
-    bindProgramFragmentStore(NAMED_PFSLights);    
-    bindTexture(NAMED_PFLighting, 0, NAMED_TFlares);
-
-    int radius = State_galaxyRadius;
-    int particlesCount = State_particlesCount;
-
-    float *particle = loadArrayF(RSID_PARTICLES, 0);
-    float *particleBuffer = loadArrayF(RSID_PARTICLES_BUFFER, 0);
-
-    float w = width * 0.5f;
-    float h = height * 0.5f;
-
-    int i = 0;
-    for ( ; i < particlesCount; i++) {
-        drawParticle(particle, particleBuffer, w, h);
-        particle += PARTICLE_STRUCT_FIELDS_COUNT;
-        // each particle is a triangle (3 vertices) of 5 properties (ABGR, X, Y, S, T)
-        particleBuffer += 3 * PARTICLE_BUFFER_COMPONENTS_COUNT;
-    }
-
-    uploadToBufferObject(NAMED_ParticlesBuffer);
-    drawSimpleMeshRange(NAMED_ParticlesMesh, 0, particlesCount * 3);
-}
-
-int main(int index) {
-    int width = State_width;
-    int height = State_height;
-
-    drawSpace(width, height);
-    drawParticles(width, height);
-    drawLights(width, height);
-
-    return 1;
-}
diff --git a/libs/rs/java/Galaxy/src/com/android/galaxy/rs/Galaxy.java b/libs/rs/java/Galaxy/src/com/android/galaxy/rs/Galaxy.java
deleted file mode 100644
index 27d333c..0000000
--- a/libs/rs/java/Galaxy/src/com/android/galaxy/rs/Galaxy.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2009 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.galaxy.rs;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-public class Galaxy extends Activity {
-    private GalaxyView mView;
-
-    @Override
-    public void onCreate(Bundle icicle) {
-        super.onCreate(icicle);
-
-        mView = new GalaxyView(this);
-        setContentView(mView);
-    }
-
-    @Override
-    protected void onResume() {
-        super.onResume();
-        mView.onResume();
-    }
-
-    @Override
-    protected void onPause() {
-        super.onPause();
-        mView.onPause();
-
-        Runtime.getRuntime().exit(0);
-    }
-}
\ No newline at end of file
diff --git a/libs/rs/java/Galaxy/src/com/android/galaxy/rs/GalaxyRS.java b/libs/rs/java/Galaxy/src/com/android/galaxy/rs/GalaxyRS.java
deleted file mode 100644
index fae92f7..0000000
--- a/libs/rs/java/Galaxy/src/com/android/galaxy/rs/GalaxyRS.java
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
- * Copyright (C) 2009 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.galaxy.rs;
-
-import android.content.res.Resources;
-import android.renderscript.RenderScript;
-import android.renderscript.ScriptC;
-import android.renderscript.ProgramFragment;
-import android.renderscript.ProgramStore;
-import android.renderscript.ProgramVertex;
-import android.renderscript.Allocation;
-import android.renderscript.Sampler;
-import android.renderscript.Element;
-import android.renderscript.SimpleMesh;
-import android.renderscript.Primitive;
-import android.renderscript.Type;
-import static android.renderscript.Sampler.Value.LINEAR;
-import static android.renderscript.Sampler.Value.NEAREST;
-import static android.renderscript.Sampler.Value.WRAP;
-import static android.renderscript.ProgramStore.DepthFunc.*;
-import static android.renderscript.ProgramStore.BlendDstFunc;
-import static android.renderscript.ProgramStore.BlendSrcFunc;
-import static android.renderscript.ProgramFragment.EnvMode.*;
-import static android.renderscript.Element.*;
-import android.graphics.BitmapFactory;
-import android.graphics.Bitmap;
-import static android.util.MathUtils.*;
-
-import java.util.TimeZone;
-
-@SuppressWarnings({"FieldCanBeLocal"})
-class GalaxyRS {
-    private static final int GALAXY_RADIUS = 300;
-    private static final int PARTICLES_COUNT = 12000;
-    private static final float ELLIPSE_TWIST = 0.023333333f;
-
-    private static final int RSID_STATE = 0;
-
-    private static final int TEXTURES_COUNT = 3;
-    private static final int RSID_TEXTURE_SPACE = 0;
-    private static final int RSID_TEXTURE_LIGHT1 = 1;
-    private static final int RSID_TEXTURE_FLARES = 2;
-
-    private static final int RSID_PARTICLES = 1;
-    private static final int PARTICLE_STRUCT_FIELDS_COUNT = 6;
-    private static final int PARTICLE_STRUCT_ANGLE = 0;
-    private static final int PARTICLE_STRUCT_DISTANCE = 1;
-    private static final int PARTICLE_STRUCT_SPEED = 2;
-    private static final int PARTICLE_STRUCT_RADIUS = 3;
-    private static final int PARTICLE_STRUCT_S = 4;
-    private static final int PARTICLE_STRUCT_T = 5;
-
-    private static final int RSID_PARTICLES_BUFFER = 2;
-
-    private Resources mResources;
-    private RenderScript mRS;
-
-    private final BitmapFactory.Options mOptionsARGB = new BitmapFactory.Options();
-
-    private final int mWidth;
-    private final int mHeight;
-
-    private ScriptC mScript;
-    private Sampler mSampler;
-    private Sampler mLightSampler;
-    private ProgramFragment mPfBackground;
-    private ProgramFragment mPfLighting;
-    private ProgramStore mPfsBackground;
-    private ProgramStore mPfsLights;
-    private ProgramVertex mPvBackground;
-    private ProgramVertex.MatrixAllocation mPvOrthoAlloc;
-
-    private Allocation[] mTextures;
-
-    private Type mStateType;
-    private Allocation mState;
-    private Allocation mParticles;
-    private Allocation mParticlesBuffer;
-    private SimpleMesh mParticlesMesh;
-
-    private final float[] mFloatData5 = new float[5];
-
-    public GalaxyRS(int width, int height) {
-        mWidth = width;
-        mHeight = height;
-        mOptionsARGB.inScaled = false;
-        mOptionsARGB.inPreferredConfig = Bitmap.Config.ARGB_8888;
-    }
-
-    public void init(RenderScript rs, Resources res) {
-        mRS = rs;
-        mResources = res;
-        initRS();
-    }
-
-    private void initRS() {
-        createProgramVertex();
-        createProgramFragmentStore();
-        createProgramFragment();
-        createScriptStructures();
-        loadTextures();
-
-        ScriptC.Builder sb = new ScriptC.Builder(mRS);
-        sb.setType(mStateType, "State", RSID_STATE);
-        sb.setScript(mResources, R.raw.galaxy);
-        sb.setRoot(true);
-
-        mScript = sb.create();
-        mScript.setClearColor(0.0f, 0.0f, 0.0f, 1.0f);
-        mScript.setTimeZone(TimeZone.getDefault().getID());
-
-        mScript.bindAllocation(mState, RSID_STATE);
-        mScript.bindAllocation(mParticles, RSID_PARTICLES);
-        mScript.bindAllocation(mParticlesBuffer, RSID_PARTICLES_BUFFER);
-
-        mRS.contextBindRootScript(mScript);
-    }
-
-    private void createScriptStructures() {
-        createState();
-        createParticlesMesh();
-        createParticles();
-    }
-
-    private void createParticlesMesh() {
-        final Element.Builder elementBuilder = new Element.Builder(mRS);
-        elementBuilder.addUNorm8RGBA();
-        elementBuilder.addFloatXY();
-        elementBuilder.addFloatST();
-        final Element vertexElement = elementBuilder.create();
-
-        final SimpleMesh.Builder meshBuilder = new SimpleMesh.Builder(mRS);
-        final int vertexSlot = meshBuilder.addVertexType(vertexElement, PARTICLES_COUNT * 3);
-        meshBuilder.setPrimitive(Primitive.TRIANGLE);
-        mParticlesMesh = meshBuilder.create();
-        mParticlesMesh.setName("ParticlesMesh");
-
-        mParticlesBuffer = mParticlesMesh.createVertexAllocation(vertexSlot);
-        mParticlesBuffer.setName("ParticlesBuffer");
-        mParticlesMesh.bindVertexAllocation(mParticlesBuffer, 0);
-    }
-
-    static class GalaxyState {
-        public int frameCount;
-        public int width;
-        public int height;
-        public int particlesCount;
-        public int galaxyRadius;
-    }
-
-    private void createState() {
-        GalaxyState state = new GalaxyState();
-        state.width = mWidth;
-        state.height = mHeight;
-        state.particlesCount = PARTICLES_COUNT;
-        state.galaxyRadius = GALAXY_RADIUS;
-
-        mStateType = Type.createFromClass(mRS, GalaxyState.class, 1, "GalaxyState");
-        mState = Allocation.createTyped(mRS, mStateType);
-        mState.data(state);
-    }
-
-    private void createParticles() {
-        final float[] particles = new float[PARTICLES_COUNT * PARTICLE_STRUCT_FIELDS_COUNT];
-
-        int bufferIndex = 0;
-
-        for (int i = 0; i < particles.length; i += PARTICLE_STRUCT_FIELDS_COUNT) {
-            createParticle(particles, i, bufferIndex);
-            bufferIndex += 3;            
-        }
-
-        mParticles = Allocation.createSized(mRS, USER_FLOAT, particles.length);
-        mParticles.data(particles);
-    }
-
-    @SuppressWarnings({"PointlessArithmeticExpression"})
-    private void createParticle(float[] particles, int index, int bufferIndex) {
-        float d = abs(randomGauss()) * GALAXY_RADIUS / 2.0f + random(-4.0f, 4.0f);
-        float z = randomGauss() * 0.5f * 0.8f * ((GALAXY_RADIUS - d) / (float) GALAXY_RADIUS);
-        z += 1.0f;
-        float p = d * ELLIPSE_TWIST;
-
-        particles[index + PARTICLE_STRUCT_ANGLE] = random(0.0f, (float) (Math.PI * 2.0));
-        particles[index + PARTICLE_STRUCT_DISTANCE] = d;
-        particles[index + PARTICLE_STRUCT_SPEED] = random(0.0015f, 0.0025f) *
-                (0.5f + (0.5f * (float) GALAXY_RADIUS / d)) * 0.7f;
-        particles[index + PARTICLE_STRUCT_RADIUS] = z * random(1.2f, 2.1f);
-        particles[index + PARTICLE_STRUCT_S] = (float) Math.cos(p);
-        particles[index + PARTICLE_STRUCT_T] = (float) Math.sin(p);
-        
-        int red, green, blue;
-        if (d < GALAXY_RADIUS / 3.0f) {
-            red = (int) (220 + (d / (float) GALAXY_RADIUS) * 35);
-            green = 220;
-            blue = 220;
-        } else {
-            red = 180;
-            green = 180;
-            blue = (int) constrain(140 + (d / (float) GALAXY_RADIUS) * 115, 140, 255);
-        }
-        
-        final int color = red | green << 8 | blue << 16 | 0xff000000;
-
-        final float[] floatData = mFloatData5;
-        final Allocation buffer = mParticlesBuffer;
-        
-        floatData[0] = Float.intBitsToFloat(color);
-        floatData[3] = 0.0f;
-        floatData[4] = 1.0f;
-        buffer.subData1D(bufferIndex, 1, floatData);
-
-        bufferIndex++;
-        floatData[3] = 1.0f;
-        floatData[4] = 1.0f;
-        buffer.subData1D(bufferIndex, 1, floatData);
-
-        bufferIndex++;
-        floatData[3] = 0.5f;
-        floatData[4] = 0.0f;
-        buffer.subData1D(bufferIndex, 1, floatData);
-    }
-
-    private static float randomGauss() {
-        float x1;
-        float x2;
-        float w;
-
-        do {
-            x1 = 2.0f * random(0.0f, 1.0f) - 1.0f;
-            x2 = 2.0f * random(0.0f, 1.0f) - 1.0f;
-            w = x1 * x1 + x2 * x2;
-        } while (w >= 1.0f);
-
-        w = (float) Math.sqrt(-2.0 * log(w) / w);
-        return x1 * w;
-    }
-    
-    private void loadTextures() {
-        mTextures = new Allocation[TEXTURES_COUNT];
-
-        final Allocation[] textures = mTextures;
-        textures[RSID_TEXTURE_SPACE] = loadTexture(R.drawable.space, "TSpace");
-        textures[RSID_TEXTURE_LIGHT1] = loadTextureARGB(R.drawable.light1, "TLight1");
-        textures[RSID_TEXTURE_FLARES] = loadTextureARGB(R.drawable.flares, "TFlares");
-
-        final int count = textures.length;
-        for (int i = 0; i < count; i++) {
-            final Allocation texture = textures[i];
-            texture.uploadToTexture(0);
-        }
-    }
-
-    private Allocation loadTexture(int id, String name) {
-        final Allocation allocation = Allocation.createFromBitmapResource(mRS, mResources,
-                id, RGB_565, false);
-        allocation.setName(name);
-        return allocation;
-    }
-
-    private Allocation loadTextureARGB(int id, String name) {
-        Bitmap b = BitmapFactory.decodeResource(mResources, id, mOptionsARGB);
-        final Allocation allocation = Allocation.createFromBitmap(mRS, b, RGBA_8888, false);
-        allocation.setName(name);
-        return allocation;
-    }    
-
-    private void createProgramFragment() {
-        Sampler.Builder sampleBuilder = new Sampler.Builder(mRS);
-        sampleBuilder.setMin(LINEAR);
-        sampleBuilder.setMag(LINEAR);
-        sampleBuilder.setWrapS(WRAP);
-        sampleBuilder.setWrapT(WRAP);
-        mSampler = sampleBuilder.create();
-
-        ProgramFragment.Builder builder = new ProgramFragment.Builder(mRS, null, null);
-        builder.setTexEnable(true, 0);
-        builder.setTexEnvMode(REPLACE, 0);
-        mPfBackground = builder.create();
-        mPfBackground.setName("PFBackground");
-        mPfBackground.bindSampler(mSampler, 0);
-
-        sampleBuilder = new Sampler.Builder(mRS);
-        sampleBuilder.setMin(NEAREST);
-        sampleBuilder.setMag(NEAREST);
-        sampleBuilder.setWrapS(WRAP);
-        sampleBuilder.setWrapT(WRAP);
-        mLightSampler = sampleBuilder.create();
-
-        builder = new ProgramFragment.Builder(mRS, null, null);
-        builder.setTexEnable(true, 0);
-        builder.setTexEnvMode(MODULATE, 0);
-        mPfLighting = builder.create();
-        mPfLighting.setName("PFLighting");
-        mPfLighting.bindSampler(mLightSampler, 0);
-    }
-
-    private void createProgramFragmentStore() {
-        ProgramStore.Builder builder = new ProgramStore.Builder(mRS, null, null);
-        builder.setDepthFunc(ALWAYS);
-        builder.setBlendFunc(BlendSrcFunc.ONE, BlendDstFunc.ZERO);
-        builder.setDitherEnable(false);
-        mPfsBackground = builder.create();
-        mPfsBackground.setName("PFSBackground");
-        
-        builder = new ProgramStore.Builder(mRS, null, null);
-        builder.setDepthFunc(ALWAYS);
-        builder.setBlendFunc(BlendSrcFunc.ONE, BlendDstFunc.ONE);
-        builder.setDitherEnable(false);
-        mPfsLights = builder.create();
-        mPfsLights.setName("PFSLights");
-    }
-
-    private void createProgramVertex() {
-        mPvOrthoAlloc = new ProgramVertex.MatrixAllocation(mRS);
-        //mPvOrthoAlloc.setupProjectionNormalized(mWidth, mHeight);
-        mPvOrthoAlloc.setupOrthoWindow(mWidth, mHeight);        
-
-        ProgramVertex.Builder builder = new ProgramVertex.Builder(mRS, null, null);
-        mPvBackground = builder.create();
-        mPvBackground.bindAllocation(mPvOrthoAlloc);
-        mPvBackground.setName("PVBackground");
-    }
-}
diff --git a/libs/rs/java/Galaxy/src/com/android/galaxy/rs/GalaxyView.java b/libs/rs/java/Galaxy/src/com/android/galaxy/rs/GalaxyView.java
deleted file mode 100644
index 4f6d3f0..0000000
--- a/libs/rs/java/Galaxy/src/com/android/galaxy/rs/GalaxyView.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2009 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.galaxy.rs;
-
-import android.content.Context;
-import android.view.SurfaceHolder;
-import android.renderscript.RenderScript;
-import android.renderscript.RSSurfaceView;
-
-class GalaxyView extends RSSurfaceView {
-    public GalaxyView(Context context) {
-        super(context);
-        setFocusable(true);
-        setFocusableInTouchMode(true);
-    }
-
-    public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
-        super.surfaceChanged(holder, format, w, h);
-
-        RenderScript RS = createRenderScript();
-        GalaxyRS render = new GalaxyRS(w, h);
-        render.init(RS, getResources());
-    }
-}
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaPlayerApiTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaPlayerApiTest.java
index ea42f53..dcb8c43 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaPlayerApiTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaPlayerApiTest.java
@@ -435,6 +435,13 @@
     @LargeTest
     public void testLocalMp3PrepareAsyncCallback() throws Exception {
         boolean onPrepareSuccess = 
+            CodecTest.prepareAsyncCallback(MediaNames.MP3CBR, false);
+        assertTrue("LocalMp3prepareAsyncCallback", onPrepareSuccess);
+    }
+
+    @LargeTest
+    public void testLocalH263AMRPrepareAsyncCallback() throws Exception {
+        boolean onPrepareSuccess =
             CodecTest.prepareAsyncCallback(MediaNames.VIDEO_H263_AMR, false);
         assertTrue("LocalMp3prepareAsyncCallback", onPrepareSuccess);
     }
diff --git a/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsProvider.java b/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsProvider.java
index d87f5e7..120b4a3 100644
--- a/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsProvider.java
+++ b/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsProvider.java
@@ -16,6 +16,7 @@
 
 package com.android.providers.subscribedfeeds;
 
+import android.accounts.Account;
 import android.content.UriMatcher;
 import android.content.*;
 import android.database.Cursor;
@@ -123,6 +124,14 @@
     }
 
     @Override
+    protected void onAccountsChanged(Account[] accountsArray) {
+        super.onAccountsChanged(accountsArray);
+        for (Account account : accountsArray) {
+            ContentResolver.setSyncAutomatically(account, "subscribedfeeds", true);
+        }
+    }
+
+    @Override
     protected void onDatabaseOpened(SQLiteDatabase db) {
         db.markTableSyncable("feeds", "_deleted_feeds");
     }
diff --git a/libs/rs/java/Galaxy/Android.mk b/tests/BrowserTestPlugin/Android.mk
similarity index 60%
rename from libs/rs/java/Galaxy/Android.mk
rename to tests/BrowserTestPlugin/Android.mk
index 0884e18..968d9e6 100644
--- a/libs/rs/java/Galaxy/Android.mk
+++ b/tests/BrowserTestPlugin/Android.mk
@@ -1,4 +1,3 @@
-#
 # Copyright (C) 2009 The Android Open Source Project
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,12 +13,24 @@
 # limitations under the License.
 #
 
-LOCAL_PATH := $(call my-dir)
+TOP_LOCAL_PATH:= $(call my-dir)
+
+# Build application
+
+LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
 
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-#LOCAL_STATIC_JAVA_LIBRARIES := android.renderscript
+LOCAL_MODULE_TAGS := tests
 
-LOCAL_PACKAGE_NAME := GalaxyRS
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+
+LOCAL_PACKAGE_NAME := BrowserTestPlugin
+
+LOCAL_JNI_SHARED_LIBRARIES := libtestplugin
 
 include $(BUILD_PACKAGE)
+
+# ============================================================
+
+# Also build all of the sub-targets under this one: the shared library.
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/BrowserTestPlugin/AndroidManifest.xml b/tests/BrowserTestPlugin/AndroidManifest.xml
new file mode 100644
index 0000000..f071ab6
--- /dev/null
+++ b/tests/BrowserTestPlugin/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+      package="com.android.testplugin"
+      android:versionCode="1"
+      android:versionName="1.0">
+
+    <uses-permission android:name="android.webkit.permission.PLUGIN"/>
+
+    <uses-sdk android:minSdkVersion="3" />
+
+    <application android:icon="@drawable/browser_test_plugin"
+                android:label="Browser Test Plugin">
+        <service android:name="TestPlugin">
+            <intent-filter>
+                <action android:name="android.webkit.PLUGIN" />
+            </intent-filter>
+        </service>
+    </application>
+
+</manifest>
diff --git a/tests/BrowserTestPlugin/MODULE_LICENSE_APACHE2 b/tests/BrowserTestPlugin/MODULE_LICENSE_APACHE2
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/BrowserTestPlugin/MODULE_LICENSE_APACHE2
diff --git a/tests/BrowserTestPlugin/NOTICE b/tests/BrowserTestPlugin/NOTICE
new file mode 100644
index 0000000..9df2554
--- /dev/null
+++ b/tests/BrowserTestPlugin/NOTICE
@@ -0,0 +1,190 @@
+
+   Copyright (c) 2005-2009, 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.
+
+   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.
+
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
diff --git a/tests/BrowserTestPlugin/jni/Android.mk b/tests/BrowserTestPlugin/jni/Android.mk
new file mode 100644
index 0000000..95a21e9
--- /dev/null
+++ b/tests/BrowserTestPlugin/jni/Android.mk
@@ -0,0 +1,49 @@
+##
+##
+## Copyright 2009, The Android Open Source Project
+##
+## Redistribution and use in source and binary forms, with or without
+## modification, are permitted provided that the following conditions
+## are met:
+##  * Redistributions of source code must retain the above copyright
+##    notice, this list of conditions and the following disclaimer.
+##  * Redistributions in binary form must reproduce the above copyright
+##    notice, this list of conditions and the following disclaimer in the
+##    documentation and/or other materials provided with the distribution.
+##
+## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+## PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+##
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	main.cpp \
+	PluginObject.cpp \
+	event/EventPlugin.cpp \
+
+LOCAL_C_INCLUDES += \
+	$(LOCAL_PATH) \
+	$(LOCAL_PATH)/event \
+	external/webkit/WebCore/bridge \
+	external/webkit/WebCore/plugins \
+	external/webkit/WebCore/platform/android/JavaVM \
+	external/webkit/WebKit/android/plugins
+
+LOCAL_CFLAGS += -fvisibility=hidden 
+LOCAL_PRELINK_MODULE := false
+
+LOCAL_MODULE := libtestplugin
+LOCAL_MODULE_TAGS := tests
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/BrowserTestPlugin/jni/PluginObject.cpp b/tests/BrowserTestPlugin/jni/PluginObject.cpp
new file mode 100644
index 0000000..68fca60
--- /dev/null
+++ b/tests/BrowserTestPlugin/jni/PluginObject.cpp
@@ -0,0 +1,202 @@
+/*
+ * Copyright 2009, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc. ("Apple") in
+ consideration of your agreement to the following terms, and your use, installation,
+ modification or redistribution of this Apple software constitutes acceptance of these
+ terms.  If you do not agree with these terms, please do not use, install, modify or
+ redistribute this Apple software.
+
+ In consideration of your agreement to abide by the following terms, and subject to these
+ terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in
+ this original Apple software (the "Apple Software"), to use, reproduce, modify and
+ redistribute the Apple Software, with or without modifications, in source and/or binary
+ forms; provided that if you redistribute the Apple Software in its entirety and without
+ modifications, you must retain this notice and the following text and disclaimers in all
+ such redistributions of the Apple Software.  Neither the name, trademarks, service marks
+ or logos of Apple Computer, Inc. may be used to endorse or promote products derived from
+ the Apple Software without specific prior written permission from Apple. Except as expressly
+ stated in this notice, no other rights or licenses, express or implied, are granted by Apple
+ herein, including but not limited to any patent rights that may be infringed by your
+ derivative works or by other works in which the Apple Software may be incorporated.
+
+ The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO WARRANTIES,
+ EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT,
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS
+ USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+          OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE,
+ REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND
+ WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR
+ OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include "main.h"
+#include "PluginObject.h"
+
+static void pluginInvalidate(NPObject *obj);
+static bool pluginHasProperty(NPObject *obj, NPIdentifier name);
+static bool pluginHasMethod(NPObject *obj, NPIdentifier name);
+static bool pluginGetProperty(NPObject *obj, NPIdentifier name, NPVariant *variant);
+static bool pluginSetProperty(NPObject *obj, NPIdentifier name, const NPVariant *variant);
+static bool pluginInvoke(NPObject *obj, NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result);
+static bool pluginInvokeDefault(NPObject *obj, const NPVariant *args, uint32_t argCount, NPVariant *result);
+static NPObject *pluginAllocate(NPP npp, NPClass *theClass);
+static void pluginDeallocate(NPObject *obj);
+static bool pluginRemoveProperty(NPObject *npobj, NPIdentifier name);
+static bool pluginEnumerate(NPObject *npobj, NPIdentifier **value, uint32_t *count);
+
+
+
+static NPClass pluginClass = {
+    NP_CLASS_STRUCT_VERSION,
+    pluginAllocate,
+    pluginDeallocate,
+    pluginInvalidate,
+    pluginHasMethod,
+    pluginInvoke,
+    pluginInvokeDefault,
+    pluginHasProperty,
+    pluginGetProperty,
+    pluginSetProperty,
+    pluginRemoveProperty,
+    pluginEnumerate
+};
+
+NPClass *getPluginClass(void)
+{
+    return &pluginClass;
+}
+
+static bool identifiersInitialized = false;
+
+#define ID_TESTFILE_PROPERTY            0
+#define NUM_PROPERTY_IDENTIFIERS        1
+
+static NPIdentifier pluginPropertyIdentifiers[NUM_PROPERTY_IDENTIFIERS];
+static const NPUTF8 *pluginPropertyIdentifierNames[NUM_PROPERTY_IDENTIFIERS] = {
+    "testfile"
+};
+
+#define ID_GETTESTFILE_METHOD                   0
+#define NUM_METHOD_IDENTIFIERS                  1
+
+static NPIdentifier pluginMethodIdentifiers[NUM_METHOD_IDENTIFIERS];
+static const NPUTF8 *pluginMethodIdentifierNames[NUM_METHOD_IDENTIFIERS] = {
+    "getTestFile"
+};
+
+static void initializeIdentifiers(void)
+{
+    browser->getstringidentifiers(pluginPropertyIdentifierNames, NUM_PROPERTY_IDENTIFIERS, pluginPropertyIdentifiers);
+    browser->getstringidentifiers(pluginMethodIdentifierNames, NUM_METHOD_IDENTIFIERS, pluginMethodIdentifiers);
+}
+
+static bool pluginHasProperty(NPObject *obj, NPIdentifier name)
+{
+    int i;
+    for (i = 0; i < NUM_PROPERTY_IDENTIFIERS; i++)
+        if (name == pluginPropertyIdentifiers[i])
+            return true;
+    return false;
+}
+
+static bool pluginHasMethod(NPObject *obj, NPIdentifier name)
+{
+    int i;
+    for (i = 0; i < NUM_METHOD_IDENTIFIERS; i++)
+        if (name == pluginMethodIdentifiers[i])
+            return true;
+    return false;
+}
+
+static bool pluginGetProperty(NPObject *obj, NPIdentifier name, NPVariant *variant)
+{
+    PluginObject *plugin = (PluginObject *)obj;
+    if (name == pluginPropertyIdentifiers[ID_TESTFILE_PROPERTY]) {
+        BOOLEAN_TO_NPVARIANT(true, *variant);
+        return true;
+    }
+    return false;
+}
+
+static bool pluginSetProperty(NPObject *obj, NPIdentifier name, const NPVariant *variant)
+{
+    return false;
+}
+
+static bool pluginInvoke(NPObject *obj, NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result)
+{
+    PluginObject *plugin = (PluginObject *)obj;
+    if (name == pluginMethodIdentifiers[ID_GETTESTFILE_METHOD]) {
+        return true;
+    }
+    return false;
+}
+
+static bool pluginInvokeDefault(NPObject *obj, const NPVariant *args, uint32_t argCount, NPVariant *result)
+{
+    return false;
+}
+
+static void pluginInvalidate(NPObject *obj)
+{
+    // Release any remaining references to JavaScript objects.
+}
+
+static NPObject *pluginAllocate(NPP npp, NPClass *theClass)
+{
+    PluginObject *newInstance = (PluginObject*) malloc(sizeof(PluginObject));
+    newInstance->header._class = theClass;
+    newInstance->header.referenceCount = 1;
+
+    if (!identifiersInitialized) {
+        identifiersInitialized = true;
+        initializeIdentifiers();
+    }
+
+    newInstance->npp = npp;
+
+    return &newInstance->header;
+}
+
+static void pluginDeallocate(NPObject *obj)
+{
+    free(obj);
+}
+
+static bool pluginRemoveProperty(NPObject *npobj, NPIdentifier name)
+{
+    return false;
+}
+
+static bool pluginEnumerate(NPObject *npobj, NPIdentifier **value, uint32_t *count)
+{
+    return false;
+}
diff --git a/tests/BrowserTestPlugin/jni/PluginObject.h b/tests/BrowserTestPlugin/jni/PluginObject.h
new file mode 100644
index 0000000..a058d4a
--- /dev/null
+++ b/tests/BrowserTestPlugin/jni/PluginObject.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2009, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc. ("Apple") in
+ consideration of your agreement to the following terms, and your use, installation,
+ modification or redistribution of this Apple software constitutes acceptance of these
+ terms.  If you do not agree with these terms, please do not use, install, modify or
+ redistribute this Apple software.
+
+ In consideration of your agreement to abide by the following terms, and subject to these
+ terms, Apple grants you a personal, non-exclusive license, under AppleÕs copyrights in
+ this original Apple software (the "Apple Software"), to use, reproduce, modify and
+ redistribute the Apple Software, with or without modifications, in source and/or binary
+ forms; provided that if you redistribute the Apple Software in its entirety and without
+ modifications, you must retain this notice and the following text and disclaimers in all
+ such redistributions of the Apple Software.  Neither the name, trademarks, service marks
+ or logos of Apple Computer, Inc. may be used to endorse or promote products derived from
+ the Apple Software without specific prior written permission from Apple. Except as expressly
+ stated in this notice, no other rights or licenses, express or implied, are granted by Apple
+ herein, including but not limited to any patent rights that may be infringed by your
+ derivative works or by other works in which the Apple Software may be incorporated.
+
+ The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO WARRANTIES,
+ EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT,
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS
+ USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+          OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE,
+ REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND
+ WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR
+ OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PluginObject__DEFINED
+#define PluginObject__DEFINED
+
+#include "main.h"
+
+class SubPlugin {
+public:
+    SubPlugin(NPP inst) : m_inst(inst) {}
+    virtual ~SubPlugin() {}
+    virtual int16 handleEvent(const ANPEvent* evt) = 0;
+
+    NPP inst() const { return m_inst; }
+
+private:
+    NPP m_inst;
+};
+
+typedef struct PluginObject {
+    NPObject header;
+    NPP npp;
+    NPWindow* window;
+
+    SubPlugin* subPlugin;
+
+} PluginObject;
+
+NPClass *getPluginClass(void);
+
+#endif // PluginObject__DEFINED
diff --git a/tests/BrowserTestPlugin/jni/event/EventPlugin.cpp b/tests/BrowserTestPlugin/jni/event/EventPlugin.cpp
new file mode 100644
index 0000000..1263204
--- /dev/null
+++ b/tests/BrowserTestPlugin/jni/event/EventPlugin.cpp
@@ -0,0 +1,198 @@
+/*
+ * Copyright 2009, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "EventPlugin.h"
+#include "android_npapi.h"
+
+#include <stdio.h>
+#include <sys/time.h>
+#include <time.h>
+#include <math.h>
+#include <string.h>
+
+extern NPNetscapeFuncs*        browser;
+extern ANPCanvasInterfaceV0    gCanvasI;
+extern ANPLogInterfaceV0       gLogI;
+extern ANPPaintInterfaceV0     gPaintI;
+extern ANPSurfaceInterfaceV0   gSurfaceI;
+extern ANPTypefaceInterfaceV0  gTypefaceI;
+
+///////////////////////////////////////////////////////////////////////////////
+
+EventPlugin::EventPlugin(NPP inst) : SubPlugin(inst) {
+
+    // initialize the drawing surface
+    m_surfaceReady = false;
+    m_surface = gSurfaceI.newRasterSurface(inst, kRGB_565_ANPBitmapFormat, false);
+    if(!m_surface)
+        gLogI.log(inst, kError_ANPLogType, "----%p Unable to create Raster surface", inst);
+}
+
+EventPlugin::~EventPlugin() {
+    gSurfaceI.deleteSurface(m_surface);
+}
+
+void EventPlugin::drawPlugin(int surfaceWidth, int surfaceHeight) {
+
+    gLogI.log(inst(), kDebug_ANPLogType, " ------ %p drawing the plugin (%d,%d)", inst(), surfaceWidth, surfaceHeight);
+
+    // get the plugin's dimensions according to the DOM
+    PluginObject *obj = (PluginObject*) inst()->pdata;
+    const int W = obj->window->width;
+    const int H = obj->window->height;
+
+    // compute the current zoom level
+    const float zoomFactorW = static_cast<float>(surfaceWidth) / W;
+    const float zoomFactorH = static_cast<float>(surfaceHeight) / H;
+
+    // check to make sure the zoom level is uniform
+    if (zoomFactorW + .01 < zoomFactorH && zoomFactorW - .01 > zoomFactorH)
+        gLogI.log(inst(), kError_ANPLogType, " ------ %p zoom is out of sync (%f,%f)",
+                  inst(), zoomFactorW, zoomFactorH);
+
+    // scale the variables based on the zoom level
+    const int fontSize = (int)(zoomFactorW * 16);
+    const int leftMargin = (int)(zoomFactorW * 10);
+
+    // lock the surface
+    ANPBitmap bitmap;
+    if (!m_surfaceReady || !gSurfaceI.lock(m_surface, &bitmap, NULL)) {
+        gLogI.log(inst(), kError_ANPLogType, " ------ %p unable to lock the plugin", inst());
+        return;
+    }
+
+    // create a canvas
+    ANPCanvas* canvas = gCanvasI.newCanvas(&bitmap);
+    gCanvasI.drawColor(canvas, 0xFFFFFFFF);
+
+    // configure the paint
+    ANPPaint* paint = gPaintI.newPaint();
+    gPaintI.setFlags(paint, gPaintI.getFlags(paint) | kAntiAlias_ANPPaintFlag);
+    gPaintI.setColor(paint, 0xFF0000FF);
+    gPaintI.setTextSize(paint, fontSize);
+
+    // configure the font
+    ANPTypeface* tf = gTypefaceI.createFromName("serif", kItalic_ANPTypefaceStyle);
+    gPaintI.setTypeface(paint, tf);
+    gTypefaceI.unref(tf);
+
+    // retrieve the font metrics
+    ANPFontMetrics fm;
+    gPaintI.getFontMetrics(paint, &fm);
+
+    // write text on the canvas
+    const char c[] = "Browser Test Plugin";
+    gCanvasI.drawText(canvas, c, sizeof(c)-1, leftMargin, -fm.fTop, paint);
+
+    // clean up variables and unlock the surface
+    gPaintI.deletePaint(paint);
+    gCanvasI.deleteCanvas(canvas);
+    gSurfaceI.unlock(m_surface);
+}
+
+void EventPlugin::printToDiv(const char* text, int length) {
+    // Get the plugin's DOM object
+    NPObject* windowObject = NULL;
+    browser->getvalue(inst(), NPNVWindowNPObject, &windowObject);
+
+    if (!windowObject)
+        gLogI.log(inst(), kError_ANPLogType, " ------ %p Unable to retrieve DOM Window", inst());
+
+    // create a string (JS code) that is stored in memory allocated by the browser
+    const char* jsBegin = "var outputDiv = document.getElementById('eventOutput'); outputDiv.innerHTML += ' ";
+    const char* jsEnd = "';";
+
+    // allocate memory and configure pointers
+    int totalLength = strlen(jsBegin) + length + strlen(jsEnd);
+    char* beginMem = (char*)browser->memalloc(totalLength);
+    char* middleMem = beginMem + strlen(jsBegin);
+    char* endMem = middleMem + length;
+
+    // copy into the allocated memory
+    memcpy(beginMem, jsBegin, strlen(jsBegin));
+    memcpy(middleMem, text, length);
+    memcpy(endMem, jsEnd, strlen(jsEnd));
+
+    gLogI.log(inst(), kError_ANPLogType, "text: %.*s\n", totalLength, (char*)beginMem);
+
+    // execute the javascript in the plugin's DOM object
+    NPString script = { (char*)beginMem, totalLength };
+    NPVariant scriptVariant;
+    if (!browser->evaluate(inst(), windowObject, &script, &scriptVariant))
+        gLogI.log(inst(), kError_ANPLogType, " ------ %p Unable to eval the JS.", inst());
+
+    // free the memory allocated within the browser
+    browser->memfree(beginMem);
+}
+
+int16 EventPlugin::handleEvent(const ANPEvent* evt) {
+    switch (evt->eventType) {
+        case kDraw_ANPEventType:
+            gLogI.log(inst(), kError_ANPLogType, " ------ %p the plugin did not request draw events", inst());
+            break;
+        case kSurface_ANPEventType:
+            switch (evt->data.surface.action) {
+                case kCreated_ANPSurfaceAction:
+                    m_surfaceReady = true;
+                    return 1;
+                case kDestroyed_ANPSurfaceAction:
+                    m_surfaceReady = false;
+                    return 1;
+                case kChanged_ANPSurfaceAction:
+                    drawPlugin(evt->data.surface.data.changed.width,
+                               evt->data.surface.data.changed.height);
+                    return 1;
+            }
+            break;
+        case kLifecycle_ANPEventType:
+            switch (evt->data.lifecycle.action) {
+                case kOnLoad_ANPLifecycleAction: {
+                    char msg[] = "lifecycle-onLoad";
+                    printToDiv(msg, strlen(msg));
+                    break;
+                }
+                case kGainFocus_ANPLifecycleAction: {
+                    char msg[] = "lifecycle-gainFocus";
+                    printToDiv(msg, strlen(msg));
+                    break;
+                }
+                case kLoseFocus_ANPLifecycleAction: {
+                    char msg[] = "lifecycle-loseFocus";
+                    printToDiv(msg, strlen(msg));
+                    break;
+                }
+            }
+            return 1;
+        case kTouch_ANPEventType:
+            gLogI.log(inst(), kError_ANPLogType, " ------ %p the plugin did not request touch events", inst());
+            break;
+        case kKey_ANPEventType:
+            gLogI.log(inst(), kError_ANPLogType, " ------ %p the plugin did not request key events", inst());
+            break;
+        default:
+            break;
+    }
+    return 0;   // unknown or unhandled event
+}
diff --git a/tests/BrowserTestPlugin/jni/event/EventPlugin.h b/tests/BrowserTestPlugin/jni/event/EventPlugin.h
new file mode 100644
index 0000000..73dd6ea
--- /dev/null
+++ b/tests/BrowserTestPlugin/jni/event/EventPlugin.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2009, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "PluginObject.h"
+
+#ifndef eventPlugin__DEFINED
+#define eventPlugin__DEFINED
+
+class EventPlugin : public SubPlugin {
+public:
+    EventPlugin(NPP inst);
+    virtual ~EventPlugin();
+    virtual int16 handleEvent(const ANPEvent* evt);
+
+private:
+    void drawPlugin(int surfaceWidth, int surfaceHeight);
+    void printToDiv(const char* text, int length);
+
+    bool        m_surfaceReady;
+    ANPSurface* m_surface;
+};
+
+#endif // eventPlugin__DEFINED
diff --git a/tests/BrowserTestPlugin/jni/main.cpp b/tests/BrowserTestPlugin/jni/main.cpp
new file mode 100644
index 0000000..056ec4d
--- /dev/null
+++ b/tests/BrowserTestPlugin/jni/main.cpp
@@ -0,0 +1,280 @@
+/*
+ * Copyright 2009, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include "android_npapi.h"
+#include "main.h"
+#include "PluginObject.h"
+#include "EventPlugin.h"
+
+NPNetscapeFuncs* browser;
+#define EXPORT __attribute__((visibility("default")))
+
+NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
+        char* argn[], char* argv[], NPSavedData* saved);
+NPError NPP_Destroy(NPP instance, NPSavedData** save);
+NPError NPP_SetWindow(NPP instance, NPWindow* window);
+NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream,
+        NPBool seekable, uint16* stype);
+NPError NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason);
+int32   NPP_WriteReady(NPP instance, NPStream* stream);
+int32   NPP_Write(NPP instance, NPStream* stream, int32 offset, int32 len,
+        void* buffer);
+void    NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname);
+void    NPP_Print(NPP instance, NPPrint* platformPrint);
+int16   NPP_HandleEvent(NPP instance, void* event);
+void    NPP_URLNotify(NPP instance, const char* URL, NPReason reason,
+        void* notifyData);
+NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value);
+NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value);
+
+extern "C" {
+EXPORT NPError NP_Initialize(NPNetscapeFuncs* browserFuncs, NPPluginFuncs* pluginFuncs, void *java_env, void *application_context);
+EXPORT NPError NP_GetValue(NPP instance, NPPVariable variable, void *value);
+EXPORT const char* NP_GetMIMEDescription(void);
+EXPORT void NP_Shutdown(void);
+};
+
+ANPAudioTrackInterfaceV0    gSoundI;
+ANPBitmapInterfaceV0        gBitmapI;
+ANPCanvasInterfaceV0        gCanvasI;
+ANPLogInterfaceV0           gLogI;
+ANPPaintInterfaceV0         gPaintI;
+ANPPathInterfaceV0          gPathI;
+ANPSurfaceInterfaceV0       gSurfaceI;
+ANPSystemInterfaceV0        gSystemI;
+ANPTypefaceInterfaceV0      gTypefaceI;
+ANPWindowInterfaceV0        gWindowI;
+
+#define ARRAY_COUNT(array)      (sizeof(array) / sizeof(array[0]))
+
+NPError NP_Initialize(NPNetscapeFuncs* browserFuncs, NPPluginFuncs* pluginFuncs, void *java_env, void *application_context)
+{
+    // Make sure we have a function table equal or larger than we are built against.
+    if (browserFuncs->size < sizeof(NPNetscapeFuncs)) {
+        return NPERR_GENERIC_ERROR;
+    }
+
+    // Copy the function table (structure)
+    browser = (NPNetscapeFuncs*) malloc(sizeof(NPNetscapeFuncs));
+    memcpy(browser, browserFuncs, sizeof(NPNetscapeFuncs));
+
+    // Build the plugin function table
+    pluginFuncs->version = 11;
+    pluginFuncs->size = sizeof(pluginFuncs);
+    pluginFuncs->newp = NPP_New;
+    pluginFuncs->destroy = NPP_Destroy;
+    pluginFuncs->setwindow = NPP_SetWindow;
+    pluginFuncs->newstream = NPP_NewStream;
+    pluginFuncs->destroystream = NPP_DestroyStream;
+    pluginFuncs->asfile = NPP_StreamAsFile;
+    pluginFuncs->writeready = NPP_WriteReady;
+    pluginFuncs->write = (NPP_WriteProcPtr)NPP_Write;
+    pluginFuncs->print = NPP_Print;
+    pluginFuncs->event = NPP_HandleEvent;
+    pluginFuncs->urlnotify = NPP_URLNotify;
+    pluginFuncs->getvalue = NPP_GetValue;
+    pluginFuncs->setvalue = NPP_SetValue;
+
+    static const struct {
+        NPNVariable     v;
+        uint32_t        size;
+        ANPInterface*   i;
+    } gPairs[] = {
+        { kAudioTrackInterfaceV0_ANPGetValue,   sizeof(gSoundI),    &gSoundI },
+        { kBitmapInterfaceV0_ANPGetValue,       sizeof(gBitmapI),   &gBitmapI },
+        { kCanvasInterfaceV0_ANPGetValue,       sizeof(gCanvasI),   &gCanvasI },
+        { kLogInterfaceV0_ANPGetValue,          sizeof(gLogI),      &gLogI },
+        { kPaintInterfaceV0_ANPGetValue,        sizeof(gPaintI),    &gPaintI },
+        { kPathInterfaceV0_ANPGetValue,         sizeof(gPathI),     &gPathI },
+        { kSurfaceInterfaceV0_ANPGetValue,      sizeof(gSurfaceI),  &gSurfaceI },
+        { kSystemInterfaceV0_ANPGetValue,       sizeof(gSystemI),   &gSystemI },
+        { kTypefaceInterfaceV0_ANPGetValue,     sizeof(gTypefaceI), &gTypefaceI },
+        { kWindowInterfaceV0_ANPGetValue,       sizeof(gWindowI),   &gWindowI },
+    };
+    for (size_t i = 0; i < ARRAY_COUNT(gPairs); i++) {
+        gPairs[i].i->inSize = gPairs[i].size;
+        NPError err = browser->getvalue(NULL, gPairs[i].v, gPairs[i].i);
+        if (err) {
+            return err;
+        }
+    }
+
+    return NPERR_NO_ERROR;
+}
+
+void NP_Shutdown(void)
+{
+
+}
+
+const char *NP_GetMIMEDescription(void)
+{
+    return "application/x-browsertestplugin:btp:Android Browser Test Plugin";
+}
+
+NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
+                char* argn[], char* argv[], NPSavedData* saved)
+{
+
+
+    gLogI.log(instance, kDebug_ANPLogType, "creating plugin");
+
+    PluginObject *obj = NULL;
+
+    // Scripting functions appeared in NPAPI version 14
+    if (browser->version >= 14) {
+    instance->pdata = browser->createobject (instance, getPluginClass());
+    obj = static_cast<PluginObject*>(instance->pdata);
+    bzero(obj, sizeof(*obj));
+    } else {
+        return NPERR_GENERIC_ERROR;
+    }
+
+    // select the drawing model
+    ANPDrawingModel model = kSurface_ANPDrawingModel;
+
+    // notify the plugin API of the drawing model we wish to use. This must be
+    // done prior to creating certain subPlugin objects (e.g. surfaceViews)
+    NPError err = browser->setvalue(instance, kRequestDrawingModel_ANPSetValue,
+                            reinterpret_cast<void*>(model));
+    if (err) {
+        gLogI.log(instance, kError_ANPLogType, "request model %d err %d", model, err);
+        return err;
+    }
+
+    // create the sub-plugin
+    obj->subPlugin = new EventPlugin(instance);
+
+    return NPERR_NO_ERROR;
+}
+
+NPError NPP_Destroy(NPP instance, NPSavedData** save)
+{
+    PluginObject *obj = (PluginObject*) instance->pdata;
+    delete obj->subPlugin;
+
+    return NPERR_NO_ERROR;
+}
+
+NPError NPP_SetWindow(NPP instance, NPWindow* window)
+{
+    PluginObject *obj = (PluginObject*) instance->pdata;
+
+    // Do nothing if browser didn't support NPN_CreateObject which would have created the PluginObject.
+    if (obj != NULL) {
+        obj->window = window;
+    }
+
+    return NPERR_NO_ERROR;
+}
+
+NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype)
+{
+    *stype = NP_ASFILEONLY;
+    return NPERR_NO_ERROR;
+}
+
+NPError NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason)
+{
+    return NPERR_NO_ERROR;
+}
+
+int32 NPP_WriteReady(NPP instance, NPStream* stream)
+{
+    return 0;
+}
+
+int32 NPP_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer)
+{
+    return 0;
+}
+
+void NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
+{
+}
+
+void NPP_Print(NPP instance, NPPrint* platformPrint)
+{
+}
+
+int16 NPP_HandleEvent(NPP instance, void* event)
+{
+    PluginObject *obj = reinterpret_cast<PluginObject*>(instance->pdata);
+    const ANPEvent* evt = reinterpret_cast<const ANPEvent*>(event);
+
+    if(!obj->subPlugin) {
+        gLogI.log(instance, kError_ANPLogType, "the sub-plugin is null.");
+        return 0; // unknown or unhandled event
+    }
+    else {
+        return obj->subPlugin->handleEvent(evt);
+    }
+}
+
+void NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
+{
+}
+
+EXPORT NPError NP_GetValue(NPP instance, NPPVariable variable, void *value) {
+
+    if (variable == NPPVpluginNameString) {
+        const char **str = (const char **)value;
+        *str = "Browser Test Plugin";
+        return NPERR_NO_ERROR;
+    }
+
+    if (variable == NPPVpluginDescriptionString) {
+        const char **str = (const char **)value;
+        *str = "Description of Browser Test Plugin";
+        return NPERR_NO_ERROR;
+    }
+
+    return NPERR_GENERIC_ERROR;
+}
+
+NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value)
+{
+    if (variable == NPPVpluginScriptableNPObject) {
+        void **v = (void **)value;
+        PluginObject *obj = (PluginObject*) instance->pdata;
+
+        if (obj)
+            browser->retainobject((NPObject*)obj);
+
+        *v = obj;
+        return NPERR_NO_ERROR;
+    }
+
+    return NPERR_GENERIC_ERROR;
+}
+
+NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value)
+{
+    return NPERR_GENERIC_ERROR;
+}
+
diff --git a/tests/BrowserTestPlugin/jni/main.h b/tests/BrowserTestPlugin/jni/main.h
new file mode 100644
index 0000000..e6e8c73
--- /dev/null
+++ b/tests/BrowserTestPlugin/jni/main.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2009, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <npapi.h>
+#include <npfunctions.h>
+#include <npruntime.h>
+#include "android_npapi.h"
+
+extern NPNetscapeFuncs* browser;
diff --git a/tests/BrowserTestPlugin/res/drawable/browser_test_plugin.png b/tests/BrowserTestPlugin/res/drawable/browser_test_plugin.png
new file mode 100755
index 0000000..47c79d1
--- /dev/null
+++ b/tests/BrowserTestPlugin/res/drawable/browser_test_plugin.png
Binary files differ
diff --git a/tests/BrowserTestPlugin/src/com/android/testplugin/TestPlugin.java b/tests/BrowserTestPlugin/src/com/android/testplugin/TestPlugin.java
new file mode 100644
index 0000000..94a18fd
--- /dev/null
+++ b/tests/BrowserTestPlugin/src/com/android/testplugin/TestPlugin.java
@@ -0,0 +1,15 @@
+package com.android.testplugin;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+
+public class TestPlugin extends Service {
+
+    @Override
+    public IBinder onBind(Intent intent) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}