Merge change Ieab4c75b into eclair

* changes:
  Fix type in Java enums.  Not currently used, easier to fix now than when apps are using it.
diff --git a/api/current.xml b/api/current.xml
index 47dc08a..936e67e 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -13804,6 +13804,8 @@
 </parameter>
 <parameter name="options" type="android.os.Bundle">
 </parameter>
+<exception name="NetworkErrorException" type="android.accounts.NetworkErrorException">
+</exception>
 </method>
 <method name="editProperties"
  return="android.os.Bundle"
@@ -13853,7 +13855,7 @@
 </parameter>
 <parameter name="authTokenType" type="java.lang.String">
 </parameter>
-<parameter name="loginOptions" type="android.os.Bundle">
+<parameter name="options" type="android.os.Bundle">
 </parameter>
 <exception name="NetworkErrorException" type="android.accounts.NetworkErrorException">
 </exception>
@@ -13917,8 +13919,10 @@
 </parameter>
 <parameter name="authTokenType" type="java.lang.String">
 </parameter>
-<parameter name="loginOptions" type="android.os.Bundle">
+<parameter name="options" type="android.os.Bundle">
 </parameter>
+<exception name="NetworkErrorException" type="android.accounts.NetworkErrorException">
+</exception>
 </method>
 </class>
 <class name="Account"
@@ -14183,7 +14187,7 @@
 </parameter>
 <parameter name="password" type="java.lang.String">
 </parameter>
-<parameter name="extras" type="android.os.Bundle">
+<parameter name="userdata" type="android.os.Bundle">
 </parameter>
 </method>
 <method name="addOnAccountsUpdatedListener"
@@ -14349,7 +14353,7 @@
 </parameter>
 <parameter name="authTokenType" type="java.lang.String">
 </parameter>
-<parameter name="loginOptions" type="android.os.Bundle">
+<parameter name="options" type="android.os.Bundle">
 </parameter>
 <parameter name="activity" type="android.app.Activity">
 </parameter>
@@ -14399,7 +14403,7 @@
 </parameter>
 <parameter name="addAccountOptions" type="android.os.Bundle">
 </parameter>
-<parameter name="loginOptions" type="android.os.Bundle">
+<parameter name="getAuthTokenOptions" type="android.os.Bundle">
 </parameter>
 <parameter name="callback" type="android.accounts.AccountManagerCallback&lt;android.os.Bundle&gt;">
 </parameter>
@@ -14568,7 +14572,7 @@
 </parameter>
 <parameter name="authTokenType" type="java.lang.String">
 </parameter>
-<parameter name="loginOptions" type="android.os.Bundle">
+<parameter name="options" type="android.os.Bundle">
 </parameter>
 <parameter name="activity" type="android.app.Activity">
 </parameter>
diff --git a/camera/libcameraservice/CameraService.cpp b/camera/libcameraservice/CameraService.cpp
index 6880144..29531ca 100644
--- a/camera/libcameraservice/CameraService.cpp
+++ b/camera/libcameraservice/CameraService.cpp
@@ -865,7 +865,11 @@
 }
 
 // snapshot taken
-void CameraService::Client::handleShutter()
+void CameraService::Client::handleShutter(
+    image_rect_type *size // The width and height of yuv picture for
+                          // registerBuffer. If this is NULL, use the picture
+                          // size from parameters.
+)
 {
     // Play shutter sound.
     if (mMediaPlayerClick.get() != NULL) {
@@ -889,12 +893,21 @@
     if (mSurface != 0 && !mUseOverlay) {
         int w, h;
         CameraParameters params(mHardware->getParameters());
-        params.getPictureSize(&w, &h);
         uint32_t transform = 0;
         if (params.getOrientation() == CameraParameters::CAMERA_ORIENTATION_PORTRAIT) {
             LOGV("portrait mode");
             transform = ISurface::BufferHeap::ROT_90;
         }
+
+        if (size == NULL) {
+            params.getPictureSize(&w, &h);
+        } else {
+            w = size->width;
+            h = size->height;
+            w &= ~1;
+            h &= ~1;
+            LOGD("Snapshot image width=%d, height=%d", w, h);
+        }
         ISurface::BufferHeap buffers(w, h, w, h,
             PIXEL_FORMAT_YCbCr_420_SP, transform, 0, mHardware->getRawHeap());
 
@@ -1048,7 +1061,8 @@
 
     switch (msgType) {
         case CAMERA_MSG_SHUTTER:
-            client->handleShutter();
+            // ext1 is the dimension of the yuv picture.
+            client->handleShutter((image_rect_type *)ext1);
             break;
         default:
             sp<ICameraClient> c = client->mCameraClient;
diff --git a/camera/libcameraservice/CameraService.h b/camera/libcameraservice/CameraService.h
index 2fcf839..41c5d99 100644
--- a/camera/libcameraservice/CameraService.h
+++ b/camera/libcameraservice/CameraService.h
@@ -145,7 +145,7 @@
         static      sp<Client>  getClientFromCookie(void* user);
 
                     void        handlePreviewData(const sp<IMemory>&);
-                    void        handleShutter();
+                    void        handleShutter(image_rect_type *image);
                     void        handlePostview(const sp<IMemory>&);
                     void        handleRawPicture(const sp<IMemory>&);
                     void        handleCompressedPicture(const sp<IMemory>&);
diff --git a/core/java/android/accounts/AbstractAccountAuthenticator.java b/core/java/android/accounts/AbstractAccountAuthenticator.java
index ee6d748..0efeb1d 100644
--- a/core/java/android/accounts/AbstractAccountAuthenticator.java
+++ b/core/java/android/accounts/AbstractAccountAuthenticator.java
@@ -87,6 +87,9 @@
  * the {@link AccountAuthenticatorResponse} as {@link AccountManager#KEY_ACCOUNT_MANAGER_RESPONSE}.
  * The activity must then call {@link AccountAuthenticatorResponse#onResult} or
  * {@link AccountAuthenticatorResponse#onError} when it is complete.
+ * <li> If the authenticator cannot synchronously process the request and return a result then it
+ * may choose to return null and then use the {@link AccountManagerResponse} to send the result
+ * when it has completed the request.
  * </ul>
  * <p>
  * The following descriptions of each of the abstract authenticator methods will not describe the
@@ -111,44 +114,35 @@
                 String authTokenType, String[] requiredFeatures, Bundle options)
                 throws RemoteException {
             checkBinderPermission();
-            final Bundle result;
             try {
-                result = AbstractAccountAuthenticator.this.addAccount(
+                final Bundle result = AbstractAccountAuthenticator.this.addAccount(
                     new AccountAuthenticatorResponse(response),
                         accountType, authTokenType, requiredFeatures, options);
+                if (result != null) {
+                    response.onResult(result);
+                }
             } catch (NetworkErrorException e) {
                 response.onError(AccountManager.ERROR_CODE_NETWORK_ERROR, e.getMessage());
-                return;
             } catch (UnsupportedOperationException e) {
                 response.onError(AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION,
                         "addAccount not supported");
-                return;
-            }
-            if (result != null) {
-                response.onResult(result);
-            } else {
-                response.onError(AccountManager.ERROR_CODE_INVALID_RESPONSE,
-                        "no response from the authenticator");
             }
         }
 
         public void confirmCredentials(IAccountAuthenticatorResponse response,
                 Account account, Bundle options) throws RemoteException {
             checkBinderPermission();
-            final Bundle result;
             try {
-                result = AbstractAccountAuthenticator.this.confirmCredentials(
+                final Bundle result = AbstractAccountAuthenticator.this.confirmCredentials(
                     new AccountAuthenticatorResponse(response), account, options);
+                if (result != null) {
+                    response.onResult(result);
+                }
+            } catch (NetworkErrorException e) {
+                response.onError(AccountManager.ERROR_CODE_NETWORK_ERROR, e.getMessage());
             } catch (UnsupportedOperationException e) {
                 response.onError(AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION,
                         "confirmCredentials not supported");
-                return;
-            }
-            if (result != null) {
-                response.onResult(result);
-            } else {
-                response.onError(AccountManager.ERROR_CODE_INVALID_RESPONSE,
-                        "no response from the authenticator");
             }
         }
 
@@ -180,9 +174,6 @@
                         authTokenType, loginOptions);
                 if (result != null) {
                     response.onResult(result);
-                } else {
-                    response.onError(AccountManager.ERROR_CODE_INVALID_RESPONSE,
-                            "no response from the authenticator");
                 }
             } catch (UnsupportedOperationException e) {
                 response.onError(AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION,
@@ -195,64 +186,50 @@
         public void updateCredentials(IAccountAuthenticatorResponse response, Account account,
                 String authTokenType, Bundle loginOptions) throws RemoteException {
             checkBinderPermission();
-            final Bundle result;
             try {
-                result = AbstractAccountAuthenticator.this.updateCredentials(
+                final Bundle result = AbstractAccountAuthenticator.this.updateCredentials(
                     new AccountAuthenticatorResponse(response), account,
                         authTokenType, loginOptions);
+                if (result != null) {
+                    response.onResult(result);
+                }
+            } catch (NetworkErrorException e) {
+                response.onError(AccountManager.ERROR_CODE_NETWORK_ERROR, e.getMessage());
             } catch (UnsupportedOperationException e) {
                 response.onError(AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION,
                         "updateCredentials not supported");
-                return;
-            }
-            if (result != null) {
-                response.onResult(result);
-            } else {
-                response.onError(AccountManager.ERROR_CODE_INVALID_RESPONSE,
-                        "no response from the authenticator");
             }
         }
 
         public void editProperties(IAccountAuthenticatorResponse response,
                 String accountType) throws RemoteException {
             checkBinderPermission();
-            final Bundle result;
             try {
-                result = AbstractAccountAuthenticator.this.editProperties(
+                final Bundle result = AbstractAccountAuthenticator.this.editProperties(
                     new AccountAuthenticatorResponse(response), accountType);
+                if (result != null) {
+                    response.onResult(result);
+                }
             } catch (UnsupportedOperationException e) {
                 response.onError(AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION,
                         "editProperties not supported");
-                return;
-            }
-            if (result != null) {
-                response.onResult(result);
-            } else {
-                response.onError(AccountManager.ERROR_CODE_INVALID_RESPONSE,
-                        "no response from the authenticator");
             }
         }
 
         public void hasFeatures(IAccountAuthenticatorResponse response,
                 Account account, String[] features) throws RemoteException {
             checkBinderPermission();
-            final Bundle result;
             try {
-                result = AbstractAccountAuthenticator.this.hasFeatures(
+                final Bundle result = AbstractAccountAuthenticator.this.hasFeatures(
                     new AccountAuthenticatorResponse(response), account, features);
+                if (result != null) {
+                    response.onResult(result);
+                }
             } catch (UnsupportedOperationException e) {
                 response.onError(AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION,
                         "hasFeatures not supported");
-                return;
             } catch (NetworkErrorException e) {
                 response.onError(AccountManager.ERROR_CODE_NETWORK_ERROR, e.getMessage());
-                return;
-            }
-            if (result != null) {
-                response.onResult(result);
-            } else {
-                response.onError(AccountManager.ERROR_CODE_INVALID_RESPONSE,
-                        "no response from the authenticator");
             }
         }
 
@@ -264,9 +241,6 @@
                     new AccountAuthenticatorResponse(response), account);
                 if (result != null) {
                     response.onResult(result);
-                } else {
-                    response.onError(AccountManager.ERROR_CODE_INVALID_RESPONSE,
-                            "no response from the authenticator");
                 }
             } catch (UnsupportedOperationException e) {
                 response.onError(AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION,
@@ -347,16 +321,18 @@
      * <li> {@link AccountManager#KEY_ERROR_CODE} and {@link AccountManager#KEY_ERROR_MESSAGE} to
      * indicate an error
      * </ul>
+     * @throws NetworkErrorException if the authenticator could not honor the request due to a
+     * network error
      */
     public abstract Bundle confirmCredentials(AccountAuthenticatorResponse response,
-            Account account, Bundle options);
-
+            Account account, Bundle options)
+            throws NetworkErrorException;
     /**
      * Gets the authtoken for an account.
      * @param response to send the result back to the AccountManager, will never be null
      * @param account the account whose credentials are to be retrieved, will never be null
      * @param authTokenType the type of auth token to retrieve, will never be null
-     * @param loginOptions a Bundle of authenticator-specific options, may be null
+     * @param options a Bundle of authenticator-specific options, may be null
      * @return a Bundle result or null if the result is to be returned via the response. The result
      * will contain either:
      * <ul>
@@ -370,7 +346,7 @@
      * network error
      */
     public abstract Bundle getAuthToken(AccountAuthenticatorResponse response,
-            Account account, String authTokenType, Bundle loginOptions)
+            Account account, String authTokenType, Bundle options)
             throws NetworkErrorException;
 
     /**
@@ -386,7 +362,7 @@
      * @param account the account whose credentials are to be updated, will never be null
      * @param authTokenType the type of auth token to retrieve after updating the credentials,
      * may be null
-     * @param loginOptions a Bundle of authenticator-specific options, may be null
+     * @param options a Bundle of authenticator-specific options, may be null
      * @return a Bundle result or null if the result is to be returned via the response. The result
      * will contain either:
      * <ul>
@@ -397,9 +373,11 @@
      * <li> {@link AccountManager#KEY_ERROR_CODE} and {@link AccountManager#KEY_ERROR_MESSAGE} to
      * indicate an error
      * </ul>
+     * @throws NetworkErrorException if the authenticator could not honor the request due to a
+     * network error
      */
     public abstract Bundle updateCredentials(AccountAuthenticatorResponse response,
-            Account account, String authTokenType, Bundle loginOptions);
+            Account account, String authTokenType, Bundle options) throws NetworkErrorException;
     
     /**
      * Checks if the account supports all the specified authenticator specific features.
diff --git a/core/java/android/accounts/AccountAuthenticatorActivity.java b/core/java/android/accounts/AccountAuthenticatorActivity.java
index 3d7be48..5cce6da 100644
--- a/core/java/android/accounts/AccountAuthenticatorActivity.java
+++ b/core/java/android/accounts/AccountAuthenticatorActivity.java
@@ -56,14 +56,8 @@
     protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);
 
-        if (icicle == null) {
-            Intent intent = getIntent();
-            mAccountAuthenticatorResponse =
-                    intent.getParcelableExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE);
-        } else {
-            mAccountAuthenticatorResponse =
-                    icicle.getParcelable(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE);
-        }
+        mAccountAuthenticatorResponse =
+                getIntent().getParcelableExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE);
 
         if (mAccountAuthenticatorResponse != null) {
             mAccountAuthenticatorResponse.onRequestContinued();
@@ -71,16 +65,6 @@
     }
 
     /**
-     * Saves the AccountAuthenticatorResponse in the instance state.
-     * @param outState where to store any instance data
-     */
-    protected void onSaveInstanceState(Bundle outState) {
-        outState.putParcelable(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE,
-                mAccountAuthenticatorResponse);
-        super.onSaveInstanceState(outState);
-    }
-
-    /**
      * Sends the result or a Constants.ERROR_CODE_CANCELED error if a result isn't present.
      */
     public void finish() {
@@ -89,7 +73,8 @@
             if (mResultBundle != null) {
                 mAccountAuthenticatorResponse.onResult(mResultBundle);
             } else {
-                mAccountAuthenticatorResponse.onError(AccountManager.ERROR_CODE_CANCELED, "canceled");
+                mAccountAuthenticatorResponse.onError(AccountManager.ERROR_CODE_CANCELED,
+                        "canceled");
             }
             mAccountAuthenticatorResponse = null;
         }
diff --git a/core/java/android/accounts/AccountManager.java b/core/java/android/accounts/AccountManager.java
index 153d95f..46dc895 100644
--- a/core/java/android/accounts/AccountManager.java
+++ b/core/java/android/accounts/AccountManager.java
@@ -237,13 +237,13 @@
      * with the same UID as the Authenticator for the account.
      * @param account The account to add
      * @param password The password to associate with the account. May be null.
-     * @param extras A bundle of key/value pairs to set as the account's userdata. May be null.
+     * @param userdata A bundle of key/value pairs to set as the account's userdata. May be null.
      * @return true if the account was sucessfully added, false otherwise, for example,
      * if the account already exists or if the account is null
      */
-    public boolean addAccountExplicitly(Account account, String password, Bundle extras) {
+    public boolean addAccountExplicitly(Account account, String password, Bundle userdata) {
         try {
-            return mService.addAccount(account, password, extras);
+            return mService.addAccount(account, password, userdata);
         } catch (RemoteException e) {
             // won't ever happen
             throw new RuntimeException(e);
@@ -320,6 +320,12 @@
      * AccountManager, null otherwise.
      */
     public String peekAuthToken(final Account account, final String authTokenType) {
+        if (account == null) {
+            throw new IllegalArgumentException("the account must not be null");
+        }
+        if (authTokenType == null) {
+            return null;
+        }
         try {
             return mService.peekAuthToken(account, authTokenType);
         } catch (RemoteException e) {
@@ -339,6 +345,9 @@
      * @param password the password to set for the account. May be null.
      */
     public void setPassword(final Account account, final String password) {
+        if (account == null) {
+            throw new IllegalArgumentException("the account must not be null");
+        }
         try {
             mService.setPassword(account, password);
         } catch (RemoteException e) {
@@ -355,6 +364,9 @@
      * @param account the account whose password is to be cleared. Must not be null.
      */
     public void clearPassword(final Account account) {
+        if (account == null) {
+            throw new IllegalArgumentException("the account must not be null");
+        }
         try {
             mService.clearPassword(account);
         } catch (RemoteException e) {
@@ -375,6 +387,12 @@
      * @param value the value to set. May be null.
      */
     public void setUserData(final Account account, final String key, final String value) {
+        if (account == null) {
+            throw new IllegalArgumentException("the account must not be null");
+        }
+        if (key == null) {
+            throw new IllegalArgumentException("the key must not be null");
+        }
         try {
             mService.setUserData(account, key, value);
         } catch (RemoteException e) {
@@ -458,7 +476,7 @@
      * @param account The account whose credentials are to be updated.
      * @param authTokenType the auth token to retrieve as part of updating the credentials.
      * May be null.
-     * @param loginOptions authenticator specific options for the request
+     * @param options authenticator specific options for the request
      * @param activity If the authenticator returns a {@link #KEY_INTENT} in the result then
      * the intent will be started with this activity. If activity is null then the result will
      * be returned as-is.
@@ -474,7 +492,7 @@
      * If the user presses "back" then the request will be canceled.
      */
     public AccountManagerFuture<Bundle> getAuthToken(
-            final Account account, final String authTokenType, final Bundle loginOptions,
+            final Account account, final String authTokenType, final Bundle options,
             final Activity activity, AccountManagerCallback<Bundle> callback, Handler handler) {
         if (activity == null) throw new IllegalArgumentException("activity is null");
         if (authTokenType == null) throw new IllegalArgumentException("authTokenType is null");
@@ -482,7 +500,7 @@
             public void doWork() throws RemoteException {
                 mService.getAuthToken(mResponse, account, authTokenType,
                         false /* notifyOnAuthFailure */, true /* expectActivityLaunch */,
-                        loginOptions);
+                        options);
             }
         }.start();
     }
@@ -584,6 +602,9 @@
             final String authTokenType, final String[] requiredFeatures,
             final Bundle addAccountOptions,
             final Activity activity, AccountManagerCallback<Bundle> callback, Handler handler) {
+        if (accountType == null) {
+            throw new IllegalArgumentException();
+        }
         return new AmsTask(activity, handler, callback) {
             public void doWork() throws RemoteException {
                 mService.addAcount(mResponse, accountType, authTokenType,
@@ -683,7 +704,7 @@
      * @param account The account whose credentials are to be updated.
      * @param authTokenType the auth token to retrieve as part of updating the credentials.
      * May be null.
-     * @param loginOptions authenticator specific options for the request
+     * @param options authenticator specific options for the request
      * @param activity If the authenticator returns a {@link #KEY_INTENT} in the result then
      * the intent will be started with this activity. If activity is null then the result will
      * be returned as-is.
@@ -702,13 +723,13 @@
      */
     public AccountManagerFuture<Bundle> updateCredentials(final Account account,
             final String authTokenType,
-            final Bundle loginOptions, final Activity activity,
+            final Bundle options, final Activity activity,
             final AccountManagerCallback<Bundle> callback,
             final Handler handler) {
         return new AmsTask(activity, handler, callback) {
             public void doWork() throws RemoteException {
                 mService.updateCredentials(mResponse, account, authTokenType, activity != null,
-                        loginOptions);
+                        options);
             }
         }.start();
     }
@@ -1214,7 +1235,7 @@
      * @param activityForPrompting The activity used to start any account management
      * activities that are required to fulfill this request. This may be null.
      * @param addAccountOptions authenticator-specific options used if an account needs to be added
-     * @param loginOptions authenticator-specific options passed to getAuthToken
+     * @param getAuthTokenOptions authenticator-specific options passed to getAuthToken
      * @param callback A callback to invoke when the request completes. If null then
      * no callback is invoked.
      * @param handler The {@link Handler} to use to invoke the callback. If null then the
@@ -1232,13 +1253,13 @@
     public AccountManagerFuture<Bundle> getAuthTokenByFeatures(
             final String accountType, final String authTokenType, final String[] features,
             final Activity activityForPrompting, final Bundle addAccountOptions,
-            final Bundle loginOptions,
+            final Bundle getAuthTokenOptions,
             final AccountManagerCallback<Bundle> callback, final Handler handler) {
         if (accountType == null) throw new IllegalArgumentException("account type is null");
         if (authTokenType == null) throw new IllegalArgumentException("authTokenType is null");
         final GetAuthTokenByTypeAndFeaturesTask task =
                 new GetAuthTokenByTypeAndFeaturesTask(accountType, authTokenType, features,
-                activityForPrompting, addAccountOptions, loginOptions, callback, handler);
+                activityForPrompting, addAccountOptions, getAuthTokenOptions, callback, handler);
         task.start();
         return task;
     }
diff --git a/core/java/android/accounts/AccountManagerService.java b/core/java/android/accounts/AccountManagerService.java
index 3a11cb3..9c60141 100644
--- a/core/java/android/accounts/AccountManagerService.java
+++ b/core/java/android/accounts/AccountManagerService.java
@@ -154,6 +154,7 @@
     private static final boolean isDebuggableMonkeyBuild =
             SystemProperties.getBoolean("ro.monkey", false)
                     && SystemProperties.getBoolean("ro.debuggable", false);
+    private static final Account[] EMPTY_ACCOUNT_ARRAY = new Account[]{};
 
     static {
         ACCOUNTS_CHANGED_INTENT = new Intent(AccountManager.LOGIN_ACCOUNTS_CHANGED_ACTION);
@@ -268,6 +269,10 @@
     }
 
     private String readPasswordFromDatabase(Account account) {
+        if (account == null) {
+            return null;
+        }
+
         SQLiteDatabase db = mOpenHelper.getReadableDatabase();
         Cursor cursor = db.query(TABLE_ACCOUNTS, new String[]{ACCOUNTS_PASSWORD},
                 ACCOUNTS_NAME + "=? AND " + ACCOUNTS_TYPE+ "=?",
@@ -293,6 +298,10 @@
     }
 
     private String readUserDataFromDatabase(Account account, String key) {
+        if (account == null) {
+            return null;
+        }
+
         SQLiteDatabase db = mOpenHelper.getReadableDatabase();
         Cursor cursor = db.query(TABLE_EXTRAS, new String[]{EXTRAS_VALUE},
                 EXTRAS_ACCOUNTS_ID
@@ -364,6 +373,9 @@
         SQLiteDatabase db = mOpenHelper.getWritableDatabase();
         db.beginTransaction();
         try {
+            if (account == null) {
+                return false;
+            }
             boolean noBroadcast = false;
             if (account.type.equals(GOOGLE_ACCOUNT_TYPE)) {
                 // Look for the 'nobroadcast' flag and remove it since we don't want it to persist
@@ -417,6 +429,14 @@
         checkManageAccountsPermission();
         long identityToken = clearCallingIdentity();
         try {
+            if (account == null) {
+                try {
+                    response.onError(AccountManager.ERROR_CODE_BAD_ARGUMENTS, "null account");
+                } catch (RemoteException e) {
+                    // it doesn't matter if we are unable to deliver this error
+                }
+                return;
+            }
             new RemoveAccountSession(response, account).bind();
         } finally {
             restoreCallingIdentity(identityToken);
@@ -513,6 +533,9 @@
     }
 
     private boolean saveAuthTokenToDatabase(Account account, String type, String authToken) {
+        if (account == null || type == null) {
+            return false;
+        }
         cancelNotification(getSigninRequiredNotificationId(account));
         SQLiteDatabase db = mOpenHelper.getWritableDatabase();
         db.beginTransaction();
@@ -539,6 +562,9 @@
     }
 
     public String readAuthTokenFromDatabase(Account account, String authTokenType) {
+        if (account == null || authTokenType == null) {
+            return null;
+        }
         SQLiteDatabase db = mOpenHelper.getReadableDatabase();
         Cursor cursor = db.query(TABLE_AUTHTOKENS, new String[]{AUTHTOKENS_AUTHTOKEN},
                 AUTHTOKENS_ACCOUNTS_ID + "=(select _id FROM accounts WHERE name=? AND type=?) AND "
@@ -586,6 +612,9 @@
     }
 
     private void setPasswordInDB(Account account, String password) {
+        if (account == null) {
+            return;
+        }
         ContentValues values = new ContentValues();
         values.put(ACCOUNTS_PASSWORD, password);
         mOpenHelper.getWritableDatabase().update(TABLE_ACCOUNTS, values,
@@ -608,23 +637,12 @@
         }
     }
 
-    private void sendResult(IAccountManagerResponse response, Bundle bundle) {
-        if (response != null) {
-            try {
-                response.onResult(bundle);
-            } catch (RemoteException e) {
-                // if the caller is dead then there is no one to care about remote
-                // exceptions
-                if (Log.isLoggable(TAG, Log.VERBOSE)) {
-                    Log.v(TAG, "failure while notifying response", e);
-                }
-            }
-        }
-    }
-
     public void setUserData(Account account, String key, String value) {
         checkAuthenticateAccountsPermission(account);
         long identityToken = clearCallingIdentity();
+        if (account == null) {
+            return;
+        }
         if (account.type.equals(GOOGLE_ACCOUNT_TYPE) && key.equals("broadcast")) {
             sendAccountsChangedBroadcast();
             return;
@@ -637,6 +655,9 @@
     }
 
     private void writeUserdataIntoDatabase(Account account, String key, String value) {
+        if (account == null || key == null) {
+            return;
+        }
         SQLiteDatabase db = mOpenHelper.getWritableDatabase();
         db.beginTransaction();
         try {
@@ -685,6 +706,22 @@
 
         long identityToken = clearCallingIdentity();
         try {
+            try {
+                if (account == null) {
+                    response.onError(AccountManager.ERROR_CODE_BAD_ARGUMENTS,
+                            "account is null");
+                    return;
+                }
+                if (authTokenType == null) {
+                    response.onError(AccountManager.ERROR_CODE_BAD_ARGUMENTS,
+                            "authTokenType is null");
+                    return;
+                }
+            } catch (RemoteException e) {
+                // it doesn't matter if we can't deliver this error
+                return;
+            }
+
             // if the caller has permission, do the peek. otherwise go the more expensive
             // route of starting a Session
             if (permissionGranted) {
@@ -850,6 +887,16 @@
         checkManageAccountsPermission();
         long identityToken = clearCallingIdentity();
         try {
+            try {
+                if (authTokenType == null) {
+                    response.onError(AccountManager.ERROR_CODE_BAD_ARGUMENTS,
+                            "authTokenType is null");
+                    return;
+                }
+            } catch (RemoteException e) {
+                // it doesn't matter if we can't deliver this error
+                return;
+            }
             new Session(response, accountType, expectActivityLaunch) {
                 public void run() throws RemoteException {
                     mAuthenticator.addAccount(this, mAccountType, authTokenType, requiredFeatures,
@@ -875,6 +922,16 @@
         checkManageAccountsPermission();
         long identityToken = clearCallingIdentity();
         try {
+            try {
+                if (account == null) {
+                    response.onError(AccountManager.ERROR_CODE_BAD_ARGUMENTS,
+                            "account is null");
+                    return;
+                }
+            } catch (RemoteException e) {
+                // it doesn't matter if we can't deliver this error
+                return;
+            }
             new Session(response, account.type, expectActivityLaunch) {
                 public void run() throws RemoteException {
                     mAuthenticator.confirmCredentials(this, account, options);
@@ -895,6 +952,16 @@
         checkManageAccountsPermission();
         long identityToken = clearCallingIdentity();
         try {
+            try {
+                if (account == null) {
+                    response.onError(AccountManager.ERROR_CODE_BAD_ARGUMENTS,
+                            "account is null");
+                    return;
+                }
+            } catch (RemoteException e) {
+                // it doesn't matter if we can't deliver this error
+                return;
+            }
             new Session(response, account.type, expectActivityLaunch) {
                 public void run() throws RemoteException {
                     mAuthenticator.updateCredentials(this, account, authTokenType, loginOptions);
@@ -917,6 +984,16 @@
         checkManageAccountsPermission();
         long identityToken = clearCallingIdentity();
         try {
+            try {
+                if (accountType == null) {
+                    response.onError(AccountManager.ERROR_CODE_BAD_ARGUMENTS,
+                            "accountType is null");
+                    return;
+                }
+            } catch (RemoteException e) {
+                // it doesn't matter if we can't deliver this error
+                return;
+            }
             new Session(response, accountType, expectActivityLaunch) {
                 public void run() throws RemoteException {
                     mAuthenticator.editProperties(this, mAccountType);
@@ -1565,8 +1642,10 @@
     }
 
     private boolean permissionIsGranted(Account account, String authTokenType, int callerUid) {
-        final boolean fromAuthenticator = hasAuthenticatorUid(account.type, callerUid);
-        final boolean hasExplicitGrants = hasExplicitlyGrantedPermission(account, authTokenType);
+        final boolean fromAuthenticator = account != null
+                && hasAuthenticatorUid(account.type, callerUid);
+        final boolean hasExplicitGrants = account != null
+                && hasExplicitlyGrantedPermission(account, authTokenType);
         if (Log.isLoggable(TAG, Log.VERBOSE)) {
             Log.v(TAG, "checkGrantsOrCallingUidAgainstAuthenticator: caller uid "
                     + callerUid + ", account " + account
@@ -1610,7 +1689,7 @@
 
     private void checkCallingUidAgainstAuthenticator(Account account) {
         final int uid = Binder.getCallingUid();
-        if (!hasAuthenticatorUid(account.type, uid)) {
+        if (account == null || !hasAuthenticatorUid(account.type, uid)) {
             String msg = "caller uid " + uid + " is different than the authenticator's uid";
             Log.w(TAG, msg);
             throw new SecurityException(msg);
@@ -1641,6 +1720,9 @@
      * @hide
      */
     public void grantAppPermission(Account account, String authTokenType, int uid) {
+        if (account == null  || authTokenType == null) {
+            return;
+        }
         SQLiteDatabase db = mOpenHelper.getWritableDatabase();
         db.beginTransaction();
         try {
@@ -1668,6 +1750,9 @@
      * @hide
      */
     public void revokeAppPermission(Account account, String authTokenType, int uid) {
+        if (account == null  || authTokenType == null) {
+            return;
+        }
         SQLiteDatabase db = mOpenHelper.getWritableDatabase();
         db.beginTransaction();
         try {
diff --git a/core/java/android/content/ContentProviderOperation.java b/core/java/android/content/ContentProviderOperation.java
index 60b406d..0467516 100644
--- a/core/java/android/content/ContentProviderOperation.java
+++ b/core/java/android/content/ContentProviderOperation.java
@@ -545,7 +545,8 @@
                         "only updates, deletes, and asserts can have selections");
             }
             mSelection = selection;
-            mSelectionArgs = selectionArgs;
+            mSelectionArgs = new String[selectionArgs.length];
+            System.arraycopy(selectionArgs, 0, mSelectionArgs, 0, selectionArgs.length);
             return this;
         }
 
diff --git a/core/java/android/content/SyncManager.java b/core/java/android/content/SyncManager.java
index 9757ef6..ba18615 100644
--- a/core/java/android/content/SyncManager.java
+++ b/core/java/android/content/SyncManager.java
@@ -2294,8 +2294,8 @@
             }
 
             if (!mSyncStorageEngine.deleteFromPending(operationToRemove.pendingOperation)) {
-                throw new IllegalStateException("unable to find pending row for "
-                        + operationToRemove);
+                final String errorMessage = "unable to find pending row for " + operationToRemove;
+                Log.e(TAG, errorMessage, new IllegalStateException(errorMessage));
             }
 
             if (DEBUG_CHECK_DATA_CONSISTENCY) debugCheckDataStructures(true /* check the DB */);
@@ -2314,7 +2314,8 @@
             }
 
             if (!mSyncStorageEngine.deleteFromPending(operation.pendingOperation)) {
-                throw new IllegalStateException("unable to find pending row for " + operation);
+                final String errorMessage = "unable to find pending row for " + operation;
+                Log.e(TAG, errorMessage, new IllegalStateException(errorMessage));
             }
 
             if (DEBUG_CHECK_DATA_CONSISTENCY) debugCheckDataStructures(true /* check the DB */);
@@ -2336,8 +2337,8 @@
                 }
 
                 if (!mSyncStorageEngine.deleteFromPending(syncOperation.pendingOperation)) {
-                    throw new IllegalStateException("unable to find pending row for "
-                            + syncOperation);
+                    final String errorMessage = "unable to find pending row for " + syncOperation;
+                    Log.e(TAG, errorMessage, new IllegalStateException(errorMessage));
                 }
 
                 if (DEBUG_CHECK_DATA_CONSISTENCY) debugCheckDataStructures(true /* check the DB */);
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 54015c9..b798bde 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -201,11 +201,11 @@
                     }
                     pi.activities = new ActivityInfo[num];
                 }
-                for (int i=0; i<N; i++) {
+                for (int i=0, j=0; i<N; i++) {
                     final Activity activity = p.activities.get(i);
                     if (activity.info.enabled
                         || (flags&PackageManager.GET_DISABLED_COMPONENTS) != 0) {
-                        pi.activities[i] = generateActivityInfo(p.activities.get(i), flags);
+                        pi.activities[j++] = generateActivityInfo(p.activities.get(i), flags);
                     }
                 }
             }
@@ -222,11 +222,11 @@
                     }
                     pi.receivers = new ActivityInfo[num];
                 }
-                for (int i=0; i<N; i++) {
+                for (int i=0, j=0; i<N; i++) {
                     final Activity activity = p.receivers.get(i);
                     if (activity.info.enabled
                         || (flags&PackageManager.GET_DISABLED_COMPONENTS) != 0) {
-                        pi.receivers[i] = generateActivityInfo(p.receivers.get(i), flags);
+                        pi.receivers[j++] = generateActivityInfo(p.receivers.get(i), flags);
                     }
                 }
             }
@@ -243,11 +243,11 @@
                     }
                     pi.services = new ServiceInfo[num];
                 }
-                for (int i=0; i<N; i++) {
+                for (int i=0, j=0; i<N; i++) {
                     final Service service = p.services.get(i);
                     if (service.info.enabled
                         || (flags&PackageManager.GET_DISABLED_COMPONENTS) != 0) {
-                        pi.services[i] = generateServiceInfo(p.services.get(i), flags);
+                        pi.services[j++] = generateServiceInfo(p.services.get(i), flags);
                     }
                 }
             }
@@ -264,11 +264,11 @@
                     }
                     pi.providers = new ProviderInfo[num];
                 }
-                for (int i=0; i<N; i++) {
+                for (int i=0, j=0; i<N; i++) {
                     final Provider provider = p.providers.get(i);
                     if (provider.info.enabled
                         || (flags&PackageManager.GET_DISABLED_COMPONENTS) != 0) {
-                        pi.providers[i] = generateProviderInfo(p.providers.get(i), flags);
+                        pi.providers[j++] = generateProviderInfo(p.providers.get(i), flags);
                     }
                 }
             }
@@ -300,12 +300,10 @@
             }
         }
         if ((flags&PackageManager.GET_SIGNATURES) != 0) {
-            if (p.mSignatures != null) {
-                int N = p.mSignatures.length;
-                if (N > 0) {
-                    pi.signatures = new Signature[N];
-                    System.arraycopy(p.mSignatures, 0, pi.signatures, 0, N);
-                }
+           int N = (p.mSignatures != null) ? p.mSignatures.length : 0;
+           if (N > 0) {
+                pi.signatures = new Signature[N];
+                System.arraycopy(p.mSignatures, 0, pi.signatures, 0, N);
             }
         }
         return pi;
diff --git a/core/jni/android_text_format_Time.cpp b/core/jni/android_text_format_Time.cpp
index 98f4e03..fde6ca6 100644
--- a/core/jni/android_text_format_Time.cpp
+++ b/core/jni/android_text_format_Time.cpp
@@ -367,10 +367,12 @@
     if (c >= '0' && c <= '9') {
         return (c - '0') * mul;
     } else {
-        char msg[100];
-        sprintf(msg, "Parse error at pos=%d", spos);
-        jniThrowException(env, "android/util/TimeFormatException", msg);
-        *thrown = true;
+        if (!*thrown) {
+            char msg[100];
+            sprintf(msg, "Parse error at pos=%d", spos);
+            jniThrowException(env, "android/util/TimeFormatException", msg);
+            *thrown = true;
+        }
         return 0;
     }
 }
diff --git a/core/jni/android_util_Process.cpp b/core/jni/android_util_Process.cpp
index 5b6c7ea..7c627c1 100644
--- a/core/jni/android_util_Process.cpp
+++ b/core/jni/android_util_Process.cpp
@@ -51,6 +51,8 @@
 #undef __KERNEL__
 #endif
 
+#define POLICY_DEBUG 1
+
 using namespace android;
 
 static void signalExceptionForPriorityError(JNIEnv* env, jobject obj, int err)
@@ -212,6 +214,26 @@
         return;
     }
 
+#if POLICY_DEBUG
+    char cmdline[32];
+    int fd;
+
+    strcpy(cmdline, "unknown");
+
+    sprintf(proc_path, "/proc/%d/cmdline", pid);
+    fd = open(proc_path, O_RDONLY);
+    if (fd >= 0) {
+        int rc = read(fd, cmdline, sizeof(cmdline)-1);
+        cmdline[rc] = 0;
+        close(fd);
+    }
+    
+    if (grp == ANDROID_TGROUP_BG_NONINTERACT) {
+        LOGD("setProcessGroup: vvv pid %d (%s)", pid, cmdline);
+    } else {
+        LOGD("setProcessGroup: ^^^ pid %d (%s)", pid, cmdline);
+    }
+#endif
     sprintf(proc_path, "/proc/%d/task", pid);
     if (!(d = opendir(proc_path))) {
         // If the process exited on us, don't generate an exception
diff --git a/core/res/res/values-nb/strings.xml b/core/res/res/values-nb/strings.xml
index ef90da7..ced4f16 100644
--- a/core/res/res/values-nb/strings.xml
+++ b/core/res/res/values-nb/strings.xml
@@ -111,7 +111,7 @@
     <string name="httpErrorFile" msgid="8250549644091165175">"Kunne ikke åpne filen."</string>
     <string name="httpErrorFileNotFound" msgid="5588380756326017105">"Fant ikke den forespurte filen."</string>
     <string name="httpErrorTooManyRequests" msgid="1235396927087188253">"For mange forespørsler blir behandlet. Prøv igjen senere."</string>
-    <string name="notification_title" msgid="1259940370369187045">"Påloggingsfeil for <xliff:g id="ACCOUNT">%1$s</xliff:g>"</string>
+    <string name="notification_title" msgid="1259940370369187045">"Innloggingsfeil for <xliff:g id="ACCOUNT">%1$s</xliff:g>"</string>
     <string name="contentServiceSync" msgid="8353523060269335667">"Synkronisering"</string>
     <string name="contentServiceSyncNotificationTitle" msgid="397743349191901458">"Synkronisering"</string>
     <string name="contentServiceTooManyDeletesNotificationDesc" msgid="8100981435080696431">"For mange slettinger av <xliff:g id="CONTENT_TYPE">%s</xliff:g>."</string>
@@ -147,8 +147,8 @@
     <string name="permgroupdesc_location" msgid="2430258821648348660">"Overvåking av telefonens fysiske plassering"</string>
     <string name="permgrouplab_network" msgid="5808983377727109831">"Nettverkstilgang"</string>
     <string name="permgroupdesc_network" msgid="5035763698958415998">"Gir applikasjoner tilgang til diverse nettverksfunksjoner."</string>
-    <string name="permgrouplab_accounts" msgid="3359646291125325519">"Dine kontoer"</string>
-    <string name="permgroupdesc_accounts" msgid="4948732641827091312">"Gi tilgang til de tilgjengelige kontoene."</string>
+    <string name="permgrouplab_accounts" msgid="3359646291125325519">"Google-kontoer"</string>
+    <string name="permgroupdesc_accounts" msgid="4948732641827091312">"Tilgang til tilgjengelige Google-kontoer."</string>
     <string name="permgrouplab_hardwareControls" msgid="7998214968791599326">"Maskinvarekontroll"</string>
     <string name="permgroupdesc_hardwareControls" msgid="4357057861225462702">"Direkte tilgang til maskinvaren på telefonen."</string>
     <string name="permgrouplab_phoneCalls" msgid="9067173988325865923">"Telefonsamtaler"</string>
@@ -195,7 +195,7 @@
     <string name="permdesc_shutdown" msgid="7046500838746291775">"Lar applikasjonen sette aktivitetshåndtereren i avslutningstilstand. Slår ikke systemet helt av."</string>
     <string name="permlab_stopAppSwitches" msgid="4138608610717425573">"forhindre applikasjonsbytte"</string>
     <string name="permdesc_stopAppSwitches" msgid="3857886086919033794">"Lar applikasjonen forhindre brukeren fra å bytte til en annen applikasjon."</string>
-    <string name="permlab_runSetActivityWatcher" msgid="7811586187574696296">"Blokker popup-vinduer"</string>
+    <string name="permlab_runSetActivityWatcher" msgid="7811586187574696296">"overvåke og kontrollere all applikasjonsoppstart"</string>
     <string name="permdesc_runSetActivityWatcher" msgid="3228701938345388092">"Lar applikasjonen overvåke og kontrollere hvordan systemet starter applikasjoner. Ondsinnede applikasjoner kan ta over systemet helt. Denne rettigheten behøves bare for utvikling, aldri for vanlig bruk av telefonen."</string>
     <string name="permlab_broadcastPackageRemoved" msgid="2576333434893532475">"kringkaste melding om fjernet pakke"</string>
     <string name="permdesc_broadcastPackageRemoved" msgid="3453286591439891260">"Lar applikasjonen kringkaste en melding om at en applikasjonspakke er blitt fjernet. Ondsinnede applikasjoner kan bruke dette til å drepe vilkårlige andre kjørende applikasjoner."</string>
@@ -210,9 +210,9 @@
     <string name="permlab_batteryStats" msgid="7863923071360031652">"endre batteristatistikk"</string>
     <string name="permdesc_batteryStats" msgid="5847319823772230560">"Lar applikasjonen endre på innsamlet batteristatistikk. Ikke ment for vanlige applikasjoner."</string>
     <string name="permlab_backup" msgid="470013022865453920">"kontrollere backup og gjenoppretting"</string>
-    <string name="permdesc_backup" msgid="4837493065154256525">"Gir programmet tillatelse til å kontrollere systemets mekanismer for sikkerhetskopiering og·gjenoppretting. Ikke beregnet på vanlige programmer."</string>
-    <string name="permlab_backup_data" msgid="4057625941707926463">"sikkerhetskopier og gjenopprett programmets data"</string>
-    <string name="permdesc_backup_data" msgid="8274426305151227766">"Gir programmet tillatelse til å ta del i systemets mekanismer for sikkerhetskopiering og gjenoppretting."</string>
+    <string name="permdesc_backup" msgid="4837493065154256525">"Lar applikasjonen kontrollere systemets backup- og gjenopprettingsmekanisme. Ikke ment for vanlige applikasjoner."</string>
+    <string name="permlab_backup_data" msgid="4057625941707926463">"foreta backup og gjenoppretting av applikasjonens data"</string>
+    <string name="permdesc_backup_data" msgid="8274426305151227766">"Lar applikasjonen delta i systemets backup- og gjenopprettingsmekanisme."</string>
     <string name="permlab_internalSystemWindow" msgid="2148563628140193231">"vis uautoriserte vinduer"</string>
     <string name="permdesc_internalSystemWindow" msgid="5895082268284998469">"Tillater at det opprettes vinduer ment for bruk av systemets interne brukergrensesnitt. Ikke ment for vanlige applikasjoner."</string>
     <string name="permlab_systemAlertWindow" msgid="3372321942941168324">"vise advarsler på systemnivå"</string>
@@ -258,7 +258,7 @@
     <string name="permlab_writeSettings" msgid="1365523497395143704">"endre globale systeminnstillinger"</string>
     <string name="permdesc_writeSettings" msgid="838789419871034696">"Lar applikasjonen endre systemets innstillingsdata. Ondsinnede applikasjoner kan skade systemets innstillinger."</string>
     <string name="permlab_writeSecureSettings" msgid="204676251876718288">"endre sikre systeminnstillinger"</string>
-    <string name="permdesc_writeSecureSettings" msgid="5497873143539034724">"Gir programmet tillatelse til å endre systemets data for sikkerhetsinnstilling. Ikke beregnet på vanlige programmer."</string>
+    <string name="permdesc_writeSecureSettings" msgid="5497873143539034724">"Gir programmet tillatelse til å endre systemets data for sikkerhetsinnstilling. Ikke ment for vanlige programmer."</string>
     <string name="permlab_writeGservices" msgid="2149426664226152185">"redigere Google-tjenestekartet"</string>
     <string name="permdesc_writeGservices" msgid="6602362746516676175">"Lar applikasjonen redigere Google-tjenestekartet. Ikke ment for bruk av vanlige applikasjoner."</string>
     <string name="permlab_receiveBootCompleted" msgid="7776779842866993377">"starte automatisk sammen med systemet"</string>
@@ -315,8 +315,8 @@
     <string name="permdesc_callPhone" msgid="3369867353692722456">"Lar applikasjonen ringe telefonnummer uten inngripen fra brukeren. Ondsinnede applikasjoner kan forårsake uventede oppringinger på telefonregningen. Merk at dette ikke gir applikasjonen lov til å ringe nødnummer."</string>
     <string name="permlab_callPrivileged" msgid="4198349211108497879">"ringe vilkårlige telefonnummer direkte"</string>
     <string name="permdesc_callPrivileged" msgid="244405067160028452">"Lar applikasjonen ringe hvilket som helst telefonnummer, inkludert nødnummer, uten inngripen fra brukeren. Ondsinnede applikasjoner kan forårsake unødvendige og ulovlige samtaler til nødtjenester."</string>
-    <string name="permlab_performCdmaProvisioning" msgid="5604848095315421425">"start CDMA-telefonoppsett direkte"</string>
-    <string name="permdesc_performCdmaProvisioning" msgid="6457447676108355905">"Gir programmet tillatelse til å starte klargjøring av CDMA. Skadelige programmer kan starte klargjøring av CDMA uten grunn"</string>
+    <string name="permlab_performCdmaProvisioning" msgid="5604848095315421425">"begynne CDMA-telefonoppsett direkte"</string>
+    <string name="permdesc_performCdmaProvisioning" msgid="6457447676108355905">"Lar applikasjonen begynne CDMA-oppsett. Ondsinnede applikasjoner kan bruke dette til å starte CDMA-oppsett uten grunn."</string>
     <string name="permlab_locationUpdates" msgid="7785408253364335740">"kontrollere varsling for plasseringsendring"</string>
     <string name="permdesc_locationUpdates" msgid="2300018303720930256">"Lar applikasjonen slå av/på varsling om plasseringsendringer fra radioen. Ikke ment for vanlige applikasjoner."</string>
     <string name="permlab_checkinProperties" msgid="7855259461268734914">"få tilgang til egenskaper for innsjekking"</string>
@@ -432,56 +432,56 @@
     <item msgid="2506857312718630823">"ICQ"</item>
     <item msgid="1648797903785279353">"Jabber"</item>
   </string-array>
-    <string name="phoneTypeCustom" msgid="1644738059053355820">"Tilpasset"</string>
-    <string name="phoneTypeHome" msgid="2570923463033985887">"Privat"</string>
+    <string name="phoneTypeCustom" msgid="1644738059053355820">"Egendefinert"</string>
+    <string name="phoneTypeHome" msgid="2570923463033985887">"Hjemme"</string>
     <string name="phoneTypeMobile" msgid="6501463557754751037">"Mobil"</string>
     <string name="phoneTypeWork" msgid="8863939667059911633">"Arbeid"</string>
-    <string name="phoneTypeFaxWork" msgid="3517792160008890912">"Send faks (arbeid)"</string>
-    <string name="phoneTypeFaxHome" msgid="2067265972322971467">"Send faks (privat)"</string>
+    <string name="phoneTypeFaxWork" msgid="3517792160008890912">"Faks arbeid"</string>
+    <string name="phoneTypeFaxHome" msgid="2067265972322971467">"Faks hjemme"</string>
     <string name="phoneTypePager" msgid="7582359955394921732">"Personsøker"</string>
     <string name="phoneTypeOther" msgid="1544425847868765990">"Annen"</string>
-    <string name="phoneTypeCallback" msgid="2712175203065678206">"Tilbakeringing"</string>
+    <string name="phoneTypeCallback" msgid="2712175203065678206">"Tilbakering"</string>
     <string name="phoneTypeCar" msgid="8738360689616716982">"Bil"</string>
-    <string name="phoneTypeCompanyMain" msgid="540434356461478916">"Firma (sentralbord)"</string>
+    <string name="phoneTypeCompanyMain" msgid="540434356461478916">"Firma hoved"</string>
     <string name="phoneTypeIsdn" msgid="8022453193171370337">"ISDN"</string>
     <string name="phoneTypeMain" msgid="6766137010628326916">"Hoved"</string>
-    <string name="phoneTypeOtherFax" msgid="8587657145072446565">"Annen faks"</string>
+    <string name="phoneTypeOtherFax" msgid="8587657145072446565">"Faks annen"</string>
     <string name="phoneTypeRadio" msgid="4093738079908667513">"Radio"</string>
     <string name="phoneTypeTelex" msgid="3367879952476250512">"Teleks"</string>
-    <string name="phoneTypeTtyTdd" msgid="8606514378585000044">"TTY/TDD"</string>
-    <string name="phoneTypeWorkMobile" msgid="1311426989184065709">"Mobil (arbeid)"</string>
-    <string name="phoneTypeWorkPager" msgid="649938731231157056">"Personsøker (arbeid)"</string>
+    <string name="phoneTypeTtyTdd" msgid="8606514378585000044">"Teksttelefon"</string>
+    <string name="phoneTypeWorkMobile" msgid="1311426989184065709">"Mobil arbeid"</string>
+    <string name="phoneTypeWorkPager" msgid="649938731231157056">"Personsøker arbeid"</string>
     <string name="phoneTypeAssistant" msgid="5596772636128562884">"Assistent"</string>
     <string name="phoneTypeMms" msgid="7254492275502768992">"MMS"</string>
-    <string name="eventTypeBirthday" msgid="2813379844211390740">"Fødselsdag"</string>
-    <string name="eventTypeAnniversary" msgid="3876779744518284000">"Merkedag"</string>
-    <string name="eventTypeOther" msgid="5834288791948564594">"Aktivitet"</string>
-    <string name="emailTypeCustom" msgid="8525960257804213846">"Tilpasset"</string>
-    <string name="emailTypeHome" msgid="449227236140433919">"Privat"</string>
+    <string name="eventTypeBirthday" msgid="2813379844211390740">"Bursdag"</string>
+    <string name="eventTypeAnniversary" msgid="3876779744518284000">"Jubileum"</string>
+    <string name="eventTypeOther" msgid="5834288791948564594">"Akivitet"</string>
+    <string name="emailTypeCustom" msgid="8525960257804213846">"Egendefinert"</string>
+    <string name="emailTypeHome" msgid="449227236140433919">"Hjemme"</string>
     <string name="emailTypeWork" msgid="3548058059601149973">"Arbeid"</string>
     <string name="emailTypeOther" msgid="2923008695272639549">"Annen"</string>
     <string name="emailTypeMobile" msgid="119919005321166205">"Mobil"</string>
-    <string name="postalTypeCustom" msgid="8903206903060479902">"Tilpasset"</string>
-    <string name="postalTypeHome" msgid="8165756977184483097">"Privat"</string>
+    <string name="postalTypeCustom" msgid="8903206903060479902">"Egendefinert"</string>
+    <string name="postalTypeHome" msgid="8165756977184483097">"Hjemme"</string>
     <string name="postalTypeWork" msgid="5268172772387694495">"Arbeid"</string>
     <string name="postalTypeOther" msgid="2726111966623584341">"Annen"</string>
-    <string name="imTypeCustom" msgid="2074028755527826046">"Tilpasset"</string>
-    <string name="imTypeHome" msgid="6241181032954263892">"Privat"</string>
+    <string name="imTypeCustom" msgid="2074028755527826046">"Egendefinert"</string>
+    <string name="imTypeHome" msgid="6241181032954263892">"Hjemme"</string>
     <string name="imTypeWork" msgid="1371489290242433090">"Arbeid"</string>
     <string name="imTypeOther" msgid="5377007495735915478">"Annen"</string>
-    <string name="imProtocolCustom" msgid="6919453836618749992">"Tilpasset"</string>
+    <string name="imProtocolCustom" msgid="6919453836618749992">"Egendefinert"</string>
     <string name="imProtocolAim" msgid="7050360612368383417">"AIM"</string>
     <string name="imProtocolMsn" msgid="144556545420769442">"Windows Live"</string>
     <string name="imProtocolYahoo" msgid="8271439408469021273">"Yahoo"</string>
     <string name="imProtocolSkype" msgid="9019296744622832951">"Skype"</string>
-    <string name="imProtocolQq" msgid="8887484379494111884">"QQ"</string>
+    <string name="imProtocolQq" msgid="8887484379494111884">"OQ"</string>
     <string name="imProtocolGoogleTalk" msgid="3808393979157698766">"Google Talk"</string>
     <string name="imProtocolIcq" msgid="1574870433606517315">"ICQ"</string>
     <string name="imProtocolJabber" msgid="2279917630875771722">"Jabber"</string>
     <string name="imProtocolNetMeeting" msgid="8287625655986827971">"NetMeeting"</string>
     <string name="orgTypeWork" msgid="29268870505363872">"Arbeid"</string>
     <string name="orgTypeOther" msgid="3951781131570124082">"Annen"</string>
-    <string name="orgTypeCustom" msgid="225523415372088322">"Tilpasset"</string>
+    <string name="orgTypeCustom" msgid="225523415372088322">"Egendefinert"</string>
     <string name="contact_status_update_attribution" msgid="5112589886094402795">"via <xliff:g id="SOURCE">%1$s</xliff:g>"</string>
     <string name="contact_status_update_attribution_with_date" msgid="5945386376369979909">"<xliff:g id="DATE">%1$s</xliff:g> via <xliff:g id="SOURCE">%2$s</xliff:g>"</string>
     <string name="keyguard_password_enter_pin_code" msgid="3731488827218876115">"Skriv inn PIN-kode:"</string>
@@ -530,17 +530,17 @@
     <string name="battery_status_charging" msgid="756617993998772213">"Lader…"</string>
     <string name="battery_low_title" msgid="7923774589611311406">"Koble til en lader"</string>
     <string name="battery_low_subtitle" msgid="7388781709819722764">"Batteriet er nesten tomt:"</string>
-    <string name="battery_low_percent_format" msgid="696154104579022959">"<xliff:g id="NUMBER">%d%%</xliff:g> eller mindre gjenstår."</string>
+    <string name="battery_low_percent_format" msgid="696154104579022959">"mindre enn <xliff:g id="NUMBER">%d%%</xliff:g> igjen."</string>
     <string name="battery_low_why" msgid="7279169609518386372">"Batteribruk"</string>
-    <string name="factorytest_failed" msgid="5410270329114212041">"Factory test failed"</string>
+    <string name="factorytest_failed" msgid="5410270329114212041">"Fabrikktesten feilet"</string>
     <string name="factorytest_not_system" msgid="4435201656767276723">"The FACTORY_TEST action is only supported for packages installed in /system/app."</string>
     <string name="factorytest_no_action" msgid="872991874799998561">"No package was found that provides the FACTORY_TEST action."</string>
-    <string name="factorytest_reboot" msgid="6320168203050791643">"Reboot"</string>
+    <string name="factorytest_reboot" msgid="6320168203050791643">"Omstart"</string>
     <string name="js_dialog_title" msgid="8143918455087008109">"Siden \'<xliff:g id="TITLE">%s</xliff:g> sier:"</string>
     <string name="js_dialog_title_default" msgid="6961903213729667573">"JavaScript"</string>
     <string name="js_dialog_before_unload" msgid="1901675448179653089">"Naviger bort fra denne siden?"\n\n"<xliff:g id="MESSAGE">%s</xliff:g>"\n\n"Velg OK for å fortsette, eller Avbryt for å forbli på denne siden."</string>
     <string name="save_password_label" msgid="6860261758665825069">"Bekreft"</string>
-    <string name="double_tap_toast" msgid="1068216937244567247">"Tips: trykk to ganger for å zoome inn og ut."</string>
+    <string name="double_tap_toast" msgid="1068216937244567247">"Dobbelttrykk for å zoome inn og ut."</string>
     <string name="permlab_readHistoryBookmarks" msgid="1284843728203412135">"lese nettleserens logg og bokmerker"</string>
     <string name="permdesc_readHistoryBookmarks" msgid="4981489815467617191">"Lar applikasjonen lese alle adresser nettleseren har besøkt, og alle nettleserens bokmerker."</string>
     <string name="permlab_writeHistoryBookmarks" msgid="9009434109836280374">"skrive til nettleserens logg og bokmerker"</string>
@@ -623,7 +623,7 @@
     <item quantity="one" msgid="2178576254385739855">"i morgen"</item>
     <item quantity="other" msgid="2973062968038355991">"om <xliff:g id="COUNT">%d</xliff:g> d"</item>
   </plurals>
-    <string name="preposition_for_date" msgid="9093949757757445117">"den <xliff:g id="DATE">%s</xliff:g>"</string>
+    <string name="preposition_for_date" msgid="9093949757757445117">"<xliff:g id="DATE">%s</xliff:g>"</string>
     <string name="preposition_for_time" msgid="5506831244263083793">"kl. <xliff:g id="TIME">%s</xliff:g>"</string>
     <string name="preposition_for_year" msgid="5040395640711867177">"i <xliff:g id="YEAR">%s</xliff:g>"</string>
     <string name="day" msgid="8144195776058119424">"dag"</string>
@@ -675,24 +675,24 @@
     <string name="dialog_alert_title" msgid="2049658708609043103">"Merk"</string>
     <string name="capital_on" msgid="1544682755514494298">"På"</string>
     <string name="capital_off" msgid="6815870386972805832">"Av"</string>
-    <string name="whichApplication" msgid="4533185947064773386">"Complete action using"</string>
-    <string name="alwaysUse" msgid="4583018368000610438">"Use by default for this action."</string>
-    <string name="clearDefaultHintMsg" msgid="4815455344600932173">"Clear default in Home Settings &gt; Applications &gt; Manage applications."</string>
-    <string name="chooseActivity" msgid="1009246475582238425">"Select an action"</string>
-    <string name="noApplications" msgid="1691104391758345586">"No applications can perform this action."</string>
-    <string name="aerr_title" msgid="653922989522758100">"Sorry!"</string>
-    <string name="aerr_application" msgid="4683614104336409186">"The application <xliff:g id="APPLICATION">%1$s</xliff:g> (process <xliff:g id="PROCESS">%2$s</xliff:g>) has stopped unexpectedly. Please try again."</string>
-    <string name="aerr_process" msgid="1551785535966089511">"The process <xliff:g id="PROCESS">%1$s</xliff:g> has stopped unexpectedly. Please try again."</string>
-    <string name="anr_title" msgid="3100070910664756057">"Sorry!"</string>
-    <string name="anr_activity_application" msgid="3538242413112507636">"Activity <xliff:g id="ACTIVITY">%1$s</xliff:g> (in application <xliff:g id="APPLICATION">%2$s</xliff:g>) is not responding."</string>
-    <string name="anr_activity_process" msgid="5420826626009561014">"Activity <xliff:g id="ACTIVITY">%1$s</xliff:g> (in process <xliff:g id="PROCESS">%2$s</xliff:g>) is not responding."</string>
-    <string name="anr_application_process" msgid="4185842666452210193">"Application <xliff:g id="APPLICATION">%1$s</xliff:g> (in process <xliff:g id="PROCESS">%2$s</xliff:g>) is not responding."</string>
-    <string name="anr_process" msgid="1246866008169975783">"Process <xliff:g id="PROCESS">%1$s</xliff:g> is not responding."</string>
-    <string name="force_close" msgid="3653416315450806396">"Force close"</string>
+    <string name="whichApplication" msgid="4533185947064773386">"Fullfør med"</string>
+    <string name="alwaysUse" msgid="4583018368000610438">"Bruk som standardvalg."</string>
+    <string name="clearDefaultHintMsg" msgid="4815455344600932173">"Fjern standardvalg i Innstillinger &gt; Applikasjoner &gt; Installerte applikasjoner."</string>
+    <string name="chooseActivity" msgid="1009246475582238425">"Velg en aktivitet"</string>
+    <string name="noApplications" msgid="1691104391758345586">"Ingen applikasjoner kan gjøre dette."</string>
+    <string name="aerr_title" msgid="653922989522758100">"Beklager!"</string>
+    <string name="aerr_application" msgid="4683614104336409186">"Applikasjonen <xliff:g id="APPLICATION">%1$s</xliff:g> (prosess <xliff:g id="PROCESS">%2$s</xliff:g>) stoppet uventet. Prøv igjen."</string>
+    <string name="aerr_process" msgid="1551785535966089511">"Prosessen <xliff:g id="PROCESS">%1$s</xliff:g> stoppet uventet. Prøv igjen."</string>
+    <string name="anr_title" msgid="3100070910664756057">"Beklager!"</string>
+    <string name="anr_activity_application" msgid="3538242413112507636">"Aktiviteten <xliff:g id="ACTIVITY">%1$s</xliff:g> (i applikasjonen <xliff:g id="APPLICATION">%2$s</xliff:g>) svarer ikke."</string>
+    <string name="anr_activity_process" msgid="5420826626009561014">"Aktiviteten <xliff:g id="ACTIVITY">%1$s</xliff:g> (i prosessen <xliff:g id="PROCESS">%2$s</xliff:g>) svarer ikke."</string>
+    <string name="anr_application_process" msgid="4185842666452210193">"Applikasjonen <xliff:g id="APPLICATION">%1$s</xliff:g> (i prosessen <xliff:g id="PROCESS">%2$s</xliff:g>) svarer ikke."</string>
+    <string name="anr_process" msgid="1246866008169975783">"Prosessen <xliff:g id="PROCESS">%1$s</xliff:g> svarer ikke."</string>
+    <string name="force_close" msgid="3653416315450806396">"Tving avslutning"</string>
     <string name="report" msgid="4060218260984795706">"Rapportér"</string>
-    <string name="wait" msgid="7147118217226317732">"Wait"</string>
+    <string name="wait" msgid="7147118217226317732">"Vent"</string>
     <string name="debug" msgid="9103374629678531849">"Debug"</string>
-    <string name="sendText" msgid="5132506121645618310">"Select an action for text"</string>
+    <string name="sendText" msgid="5132506121645618310">"Velg mål for tekst"</string>
     <string name="volume_ringtone" msgid="6885421406845734650">"Ringetonevolum"</string>
     <string name="volume_music" msgid="5421651157138628171">"Medievolum"</string>
     <string name="volume_music_hint_playing_through_bluetooth" msgid="9165984379394601533">"Spiller over Bluetooth"</string>
@@ -740,12 +740,12 @@
     <string name="usb_storage_stop_message" msgid="2390958966725232848">"Før du slår av USB-lagring, sjekk at du har avmontert enheten i USB-verten. Velg «slå av» for å slå av USB-lagring."</string>
     <string name="usb_storage_stop_button_mount" msgid="1181858854166273345">"Slå av"</string>
     <string name="usb_storage_stop_button_unmount" msgid="3774611918660582898">"Avbryt"</string>
-    <string name="usb_storage_stop_error_message" msgid="3746037090369246731">"Det har oppstått et problem ved deaktiveringen av USB-lagring. Kontroller at du har frakoblet USB-verten, og prøv igjen."</string>
+    <string name="usb_storage_stop_error_message" msgid="3746037090369246731">"Det har oppstått et problem ved deaktiveringen av USB-lagring. Kontroller at du har demontert USB-verten, og prøv igjen."</string>
     <string name="extmedia_format_title" msgid="8663247929551095854">"Formatere minnekort"</string>
     <string name="extmedia_format_message" msgid="3621369962433523619">"Er du sikker på at du ønsker å formatere minnekortet? Alle data på kortet vil gå tapt."</string>
-    <string name="extmedia_format_button_format" msgid="4131064560127478695">"Format"</string>
+    <string name="extmedia_format_button_format" msgid="4131064560127478695">"Formatér"</string>
     <string name="adb_active_notification_title" msgid="6729044778949189918">"USB-debugging tilkoblet"</string>
-    <string name="adb_active_notification_message" msgid="8470296818270110396">"Velg for å deaktivere USB-feilsøking"</string>
+    <string name="adb_active_notification_message" msgid="8470296818270110396">"Velg for å deaktivere USB-debugging."</string>
     <string name="select_input_method" msgid="6865512749462072765">"Velg inndatametode"</string>
     <string name="fast_scroll_alphabet" msgid="5433275485499039199">" ABCDEFGHIJKLMNOPQRSTUVWXYZÆØÅ"</string>
     <string name="fast_scroll_numeric_alphabet" msgid="4030170524595123610">" 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZÆØÅ"</string>
@@ -777,19 +777,19 @@
     <string name="create_contact_using" msgid="4947405226788104538">"Lag kontakt"\n"med nummeret <xliff:g id="NUMBER">%s</xliff:g>"</string>
     <string name="accessibility_compound_button_selected" msgid="5612776946036285686">"valgt"</string>
     <string name="accessibility_compound_button_unselected" msgid="8864512895673924091">"ikke valgt"</string>
-    <string name="grant_credentials_permission_message_desc" msgid="6883276587034335667">"De·oppførte·programmene ber om tilgangstillatelse til påloggingsopplysningene for konto <xliff:g id="ACCOUNT">%1$s</xliff:g> fra <xliff:g id="APPLICATION">%2$s</xliff:g>. Vil du gi denne tillatelsen? I·så·fall·lagres·svaret,·og·du·blir·ikke·spurt·flere·ganger."</string>
-    <string name="grant_credentials_permission_message_with_authtokenlabel_desc" msgid="3159007601893584687">"De·oppførte·programmene ber om tilgangstillatelse til <xliff:g id="TYPE">%1$s</xliff:g>-påloggingsopplysningene for konto <xliff:g id="ACCOUNT">%2$s</xliff:g> fra <xliff:g id="APPLICATION">%3$s</xliff:g>. Vil du gi denne tillatelsen? I·så·fall·lagres·svaret,·og·du·blir·ikke·spurt·flere·ganger."</string>
+    <string name="grant_credentials_permission_message_desc" msgid="6883276587034335667">"Det nevnte programmet ber om tilgangstillatelse til påloggingsopplysningene for konto <xliff:g id="ACCOUNT">%1$s</xliff:g> fra <xliff:g id="APPLICATION">%2$s</xliff:g>. Vil du gi denne tillatelsen? I så fall vil svaret ditt bli lagret, og du vil ikke bli spurt flere ganger."</string>
+    <string name="grant_credentials_permission_message_with_authtokenlabel_desc" msgid="3159007601893584687">"Det nevnte programmet ber om tilgangstillatelse til <xliff:g id="TYPE">%1$s</xliff:g>-påloggingsopplysningene for konto <xliff:g id="ACCOUNT">%2$s</xliff:g> fra <xliff:g id="APPLICATION">%3$s</xliff:g>. Vil du gi denne tillatelsen? I så fall vil svaret ditt bli lagret, og du vil ikke bli spurt flere ganger."</string>
     <string name="allow" msgid="7225948811296386551">"Tillat"</string>
     <string name="deny" msgid="2081879885755434506">"Avslå"</string>
     <string name="permission_request_notification_title" msgid="5390555465778213840">"Tillatelse forespurt"</string>
-    <string name="permission_request_notification_with_subtitle" msgid="4325409589686688000">"Tillatelse forespurt"\n"for konto <xliff:g id="ACCOUNT">%s</xliff:g>"</string>
+    <string name="permission_request_notification_with_subtitle" msgid="4325409589686688000">"Trenger tillatelse"\n"for konto <xliff:g id="ACCOUNT">%s</xliff:g>"</string>
     <string name="input_method_binding_label" msgid="1283557179944992649">"Inndatametode"</string>
     <string name="sync_binding_label" msgid="3687969138375092423">"Synkronisering"</string>
     <string name="accessibility_binding_label" msgid="4148120742096474641">"Tilgjengelighet"</string>
     <string name="wallpaper_binding_label" msgid="1240087844304687662">"Bakgrunnsbilde"</string>
-    <string name="chooser_wallpaper" msgid="7873476199295190279">"Endre bakgrunnsbilde"</string>
-    <string name="pptp_vpn_description" msgid="2688045385181439401">"PPTP·(point-to-point·tunneling·protocol)"</string>
-    <string name="l2tp_vpn_description" msgid="3750692169378923304">"Tunnelprotokoll for lag 2"</string>
-    <string name="l2tp_ipsec_psk_vpn_description" msgid="3945043564008303239">"Forhåndsdelt nøkkelbasert L2TP/IPSec VPN"</string>
-    <string name="l2tp_ipsec_crt_vpn_description" msgid="5382714073103653577">"Sertifikatbasert L2TP/IPSec VPN"</string>
+    <string name="chooser_wallpaper" msgid="7873476199295190279">"Velg bakgrunnsbilde"</string>
+    <string name="pptp_vpn_description" msgid="2688045385181439401">"Punkt-til-punkt-tunneleringsprotokoll"</string>
+    <string name="l2tp_vpn_description" msgid="3750692169378923304">"Lag 2-tunneleringsprotokoll"</string>
+    <string name="l2tp_ipsec_psk_vpn_description" msgid="3945043564008303239">"Passordbasert L2TP/IPSec-VPN"</string>
+    <string name="l2tp_ipsec_crt_vpn_description" msgid="5382714073103653577">"Sertifikatbasert L2TP/IPSec-VPN"</string>
 </resources>
diff --git a/core/res/res/values-nl/strings.xml b/core/res/res/values-nl/strings.xml
index f419284..c5f5a4b 100644
--- a/core/res/res/values-nl/strings.xml
+++ b/core/res/res/values-nl/strings.xml
@@ -444,7 +444,7 @@
     <string name="phoneTypeOther" msgid="1544425847868765990">"Overig"</string>
     <string name="phoneTypeCallback" msgid="2712175203065678206">"Terugbelnummer"</string>
     <string name="phoneTypeCar" msgid="8738360689616716982">"Auto"</string>
-    <string name="phoneTypeCompanyMain" msgid="540434356461478916">"Hoofdkantoor"</string>
+    <string name="phoneTypeCompanyMain" msgid="540434356461478916">"Bedrijf, algemeen"</string>
     <string name="phoneTypeIsdn" msgid="8022453193171370337">"ISDN"</string>
     <string name="phoneTypeMain" msgid="6766137010628326916">"Algemeen"</string>
     <string name="phoneTypeOtherFax" msgid="8587657145072446565">"Andere fax"</string>
diff --git a/docs/html/guide/appendix/api-levels.jd b/docs/html/guide/appendix/api-levels.jd
index b3b6371..0830032 100644
--- a/docs/html/guide/appendix/api-levels.jd
+++ b/docs/html/guide/appendix/api-levels.jd
@@ -324,22 +324,24 @@
 accessible to your application, based on the API Level that it specifies in 
 the <code>android:minSdkVersion</code> attribute of its manifest file. </p>
 
-<p>To use filtering, set the control to the same API Level as that specified
-by your application. Notice that APIs introduced in a later API Level are 
-then grayed out and their content is masked, since they would not be
-accessible to your application. </p>
+<p>To use filtering, select the checkbox to enable filtering, just below the
+page search box. Then set the "Filter by API Level" control to the same API
+Level as specified by your application. Notice that APIs introduced in a later
+API Level are then grayed out and their content is masked, since they would not
+be accessible to your application. </p>
 
 <p>Filtering by API Level in the documentation does not provide a view
 of what is new or introduced in each API Level &mdash; it simply provides a way
 to view the entire API associated with a given API Level, while excluding API
 elements introduced in later API Levels.</p>
 
-<p>By default, API Level filtering is enabled and set to show the latest API
-Level. If you do not want to use filtering reference documentation, 
-simply select the highest available API Level. </p>
+<p>If you decide that you don't want to filter the API documentation, just
+disable the feature using the checkbox. By default, API Level filtering is
+disabled, so that you can view the full framework API, regardless of API Level.
+</p>
 
 <p>Also note that the reference documentation for individual API elements
-specifies the API Level at which the elements were introduced. The API Level 
+specifies the API Level at which each element was introduced. The API Level 
 for packages and classes is specified as "Since &lt;api level&gt;" at the 
 top-right corner of the content area on each documentation page. The API Level 
 for class members is specified in their detailed description headers, 
diff --git a/docs/html/guide/practices/screens_support.jd b/docs/html/guide/practices/screens_support.jd
index 1d16d88..88975f8 100644
--- a/docs/html/guide/practices/screens_support.jd
+++ b/docs/html/guide/practices/screens_support.jd
@@ -1069,29 +1069,30 @@
 various screen sizes, you should make sure to add the corresponding size
 attribute(s) to your application's manifest. -->
 
+<div id="f9.5" style="float:right;margin:0;padding:0;">
+  <img src="{@docRoot}images/screens_support/avds-config.png" style="padding:0;margin:0;">
+  <p class="caption" style="margin:0 0 1.5em 1em;padding:0 0 0 1em;"><strong>Figure 3.</strong>
+  A typical set of AVDs for testing screens support.</p>
+</div>
+
 <p>As a test environment for your applications, set up a series of AVDs that
 emulate the screen sizes and densities you want to support. The Android SDK
-includes four emulator skins to get you started. You can use the Android AVD
+includes six emulator skins to get you started. You can use the Android AVD
 Manager or the <code>android</code> tool to create AVDs that use the various
 emulator skins and you can also set up custom AVDs to test densities other than
 the defaults. For general information about working with AVDs, see 
 <a href="{@docRoot}guide/developing/tools/avd.html">Android Virtual
 Devices</a>.</p>
 
-<p>The Android 1.6 and higher platforms in the SDK include these emulator skins,
-which represent the primary screen configurations that your should test:</p>
+<p>The Android SDK provides a set of default emulator skins that you can use for 
+testing. The skins are included as part of each Android platform that you can
+install in your SDK. The Android 1.6 platform offers these default skins:</p>
 
 <ul>
   <li>
     QVGA (240x320, low density, small screen)
   </li>
   <li>
-    WQVGA400 (240x400, low density, normal screen)
-  </li>
-  <li>
-    WQVGA432 (240x432, low density, normal screen)
-  </li>
-  <li>
     HVGA (320x480, medium density, normal screen)
   </li>
   <li>
@@ -1102,6 +1103,18 @@
   </li>
 </ul>
 
+<p>The Android 2.0 platform offers all of the Android 1.6 default skins, 
+above, plus:</p>
+
+<ul>
+  <li>
+    WQVGA400 (240x400, low density, normal screen)
+  </li>
+  <li>
+    WQVGA432 (240x432, low density, normal screen)
+  </li>
+</ul>
+
 <p>If you are using the <code>android</code> tool command line to create your
 AVDs, here's an example of how to specify the skin you want to use:</p>
 
@@ -1131,6 +1144,12 @@
     QVGA, low density: 3.3"
   </li>
   <li>
+    WQVGA, low density: 3.9"
+  </li>
+  <li>
+    WQVGA432, low density: 4.1"
+  </li>
+  <li>
     HVGA, medium density: 3.6"
   </li>
   <li>
@@ -1141,6 +1160,12 @@
   </li>
 </ul>
 
+<div style="float: right;background-color:#fff;margin: 0;padding: 20px 0 20px 20px;width:520px;">
+  <img src="{@docRoot}images/screens_support/avd-density.png" style="padding:0;margin:0;">
+  <p class="caption" style="margin:0 0 1.5em 1em;padding:0 0 0 1em; width:280px;"><strong>Figure 4.</strong>
+  Resolution and density options that you can use, when creating an AVD using the AVD Manager.</p>
+</div>
+
 <p>You should also make sure to test your application on different physical
 screen sizes within a single size-density configuration. For example, according
 to <a href="#range">Table 1</a>, the minimum supported diagonal of QVGA is 2.8".
@@ -1150,21 +1175,35 @@
 
 <pre>emulator -avd &lt;name&gt; -scale 0.6</pre>
 
-<p>If you would like to test your application on a screen not supported by the
-built-in skins, you can either adjust an existing skin, or create a custom
-resolution.</p>
+<p>If you would like to test your application on a screen that uses a resolution
+or density not supported by the built-in skins, you can either adjust an
+existing skin, or create an AVD
+that uses a custom resolution or density.</p>
 
-<p>For example, to test on a large WVGA800 screen with medium density:</p>
+<p>In the AVD Manager, you can specify a custom skin resolution or density in
+the Create New AVD dialog, as shown in Figure 4, at right.</p>
+
+<p>In the <code>android</code> tool, follow these steps to create an AVD with a
+custom resolution or density:</p>
 
 <ol>
-  <li>Create an AVD based on the WVGA800 skin (using the <code>android</code>
-tool's command line.)<br></li>
-  <li>Answer "yes" when asked about using custom hardware</li>
-  <li>enter "160" when asked about the value for <em>hw.lcd.density</em>
-(120-low, 160-medium, 240-high).</li>
+  <li>Use the <code>create avd</code> command to create a new AVD, specifying
+the <code>--skin</code> option with a value that references either a default
+skin name (such as "WVGA800") or a custom skin resolution (such as 240x432).
+Here's an example:
+     <pre>android create avd -n &lt;name&gt; -t &lt;targetID&gt; --skin WVGA800</pre>
+  </li>
+  <li>To specify a custom density for the skin, answer "yes" when asked whether
+you want to create a custom hardware profile for the new AVD.</li>
+  <li>Continue through the various profile settings until the tool asks you to
+specify "Abstracted LCD density" (<em>hw.lcd.density</em>). Consult <a
+href="#range">Table 1</a>, earlier in this document, and enter the appropriate
+value. For example, enter "160" to use medium density for the WVGA800 screen.</li>
+  <li>Set any other hardware options and complete the AVD creation.</li>
 </ol>
 
-<p>When running this AVD, the emulator will emulate a 5.8" WVGA screen.</p>
+<p>In the example above (WVGA medium density), the new AVD will emulate a 5.8" 
+WVGA screen.</p>
 
 <p>As an alternative to adjusting the emulator skin configuration, you can use
 the emulator skin's default density and add the <code>-dpi-device</code> option
@@ -1172,25 +1211,6 @@
 
 <pre>emulator -avd WVGA800 -scale 96dpi -dpi-device 160</pre>
 
-<p>If you would like to test your application with a resolution not supported by
-the provided skins, you can use the desired resolution in place of the skin
-name. For instance, for FWQVGA you would use:</p>
-
-<pre>android create avd ... --skin 240x432</pre>
-
-<p>Next, you would need to set the proper density for the screen. When asked by
-the tool whether you want to create a custom hardware profile for the new AVD,
-enter "yes". Continue through the various profile settings until the tools asks
-you to specify "Abstracted LCD density". Consult <a href="#range">Table 1</a>,
-earlier in this document, and enter the appropriate value. For the FWQVGA
-screen, the density should be "160", or medium.</p>
-
-<div id="f9.5" style="text-align:left;margin:0;padding:0;">
-  <img src="{@docRoot}images/screens_support/avds-config.png" style="padding:0;margin:0;">
-  <p class="caption" style="margin:0 0 1.5em 1em;padding:0 0 0 1em;"><strong>Figure 3.</strong>
-  A typical set of AVDs for testing screens support.</p>
-</div>
-
 
 <h2 id="compatibility-examples">Screen-Compatibility Examples</h2>
 
diff --git a/docs/html/images/screens_support/avd-density.png b/docs/html/images/screens_support/avd-density.png
new file mode 100644
index 0000000..e3fc36e
--- /dev/null
+++ b/docs/html/images/screens_support/avd-density.png
Binary files differ
diff --git a/docs/html/sdk/android-1.5.jd b/docs/html/sdk/android-1.5.jd
index 15d1938..4612682 100644
--- a/docs/html/sdk/android-1.5.jd
+++ b/docs/html/sdk/android-1.5.jd
@@ -16,7 +16,6 @@
 	<li><a href="#apps">Built-in Applications</a></li>
 	<li><a href="#locs">Locales</a></li>
 	<li><a href="#skins">Emulator Skins</a></li>
-	<li><a href="#notes">Other Notes</a></li>
 	<li><a href="#api">Framework API</a>
         <ol>
 	<li><a href="#api-level">API level</a></li>
diff --git a/docs/html/sdk/android-1.6.jd b/docs/html/sdk/android-1.6.jd
index 38112b5..4b659a1a 100644
--- a/docs/html/sdk/android-1.6.jd
+++ b/docs/html/sdk/android-1.6.jd
@@ -16,7 +16,6 @@
 	<li><a href="#apps">Built-in Applications</a></li>
 	<li><a href="#locs">Locales</a></li>
 	<li><a href="#skins">Emulator Skins</a></li>
-	<li><a href="#notes">Other Notes</a></li>
 	<li><a href="#api">Framework API</a>
         <ol>
 	<li><a href="#api-level">API level</a></li>
diff --git a/docs/html/sdk/api_diff/3/changes.html b/docs/html/sdk/api_diff/3/changes.html
index bc0f879..9bc67b9 100644
--- a/docs/html/sdk/api_diff/3/changes.html
+++ b/docs/html/sdk/api_diff/3/changes.html
@@ -26,12 +26,12 @@
 body{background-image:url();padding:12px;}
 </style>
 </head>
-<FRAMESET COLS="242,**" frameborder="1" border="7" bordercolor="#e9e9e9"> 
-<frameset rows="164,**" frameborder="1" border="7" resizable="yes">
-    <FRAME SRC="changes/jdiff_topleftframe.html" SCROLLING="no" NAME="topleftframe">
-    <FRAME SRC="changes/alldiffs_index_all.html" SCROLLING="auto" NAME="bottomleftframe">
+<FRAMESET COLS="242,**" framespacing="1" frameborder="yes" border="1" bordercolor="#e9e9e9">
+<frameset rows="174,**" framespacing="1" frameborder="yes"  border="1" bordercolor="#e9e9e9">
+    <FRAME SRC="changes/jdiff_topleftframe.html" SCROLLING="no" NAME="topleftframe" frameborder="1">
+    <FRAME SRC="changes/alldiffs_index_all.html" SCROLLING="auto" NAME="bottomleftframe" frameborder="1">
   </FRAMESET>
-  <FRAME SRC="changes/changes-summary.html" SCROLLING="auto" NAME="rightframe">
+  <FRAME SRC="changes/changes-summary.html" SCROLLING="auto" NAME="rightframe" frameborder="1">
 </FRAMESET>
 <NOFRAMES>
 <H2>
diff --git a/docs/html/sdk/api_diff/3/stylesheet-jdiff.css b/docs/html/sdk/api_diff/3/stylesheet-jdiff.css
index b3c1b9a..abc4dd5 100644
--- a/docs/html/sdk/api_diff/3/stylesheet-jdiff.css
+++ b/docs/html/sdk/api_diff/3/stylesheet-jdiff.css
@@ -3,6 +3,7 @@
 
 div.and-diff-id {border: 1px solid #eee;position:relative;float:right;clear:both;padding:0px;}
 table.diffspectable {border:1px;padding:0px;margin:0px;}
+table.jdiffIndex {margin-bottom:.5em;}
 .diffspechead {background-color:#eee;}
 .diffspectable tr {border:0px;padding:0px;}
 .diffspectable td  {background-color:eee;border:0px;font-size:90%;font-weight:normal;padding:0px;padding-left:1px;padding-right:1px;text-align:center;color:777;}
@@ -29,7 +30,7 @@
   }
 .hiddenlink {
   font-size:96%;
-  line-height:.8em;
+/*  line-height:.8em; */
   text-decoration:none;}
 a {
   text-decoration:none;}
diff --git a/docs/html/sdk/api_diff/4/changes.html b/docs/html/sdk/api_diff/4/changes.html
index c1b66a1..9cfdc24 100644
--- a/docs/html/sdk/api_diff/4/changes.html
+++ b/docs/html/sdk/api_diff/4/changes.html
@@ -25,12 +25,12 @@
 <style type="text/css">
 </style>
 </HEAD>
-<FRAMESET COLS="242,**" frameborder="1" border="7" xframespacing="20" bordercolor="#e9e9e9"> 
-<frameset rows="164,**" frameborder="1" border="7" xframespacing="20" resizable="yes">
-    <FRAME SRC="changes/jdiff_topleftframe.html" SCROLLING="no" NAME="topleftframe" xframeborder="1" xborder="6" xframespacing="0">
-    <FRAME SRC="changes/alldiffs_index_all.html" SCROLLING="auto" NAME="bottomleftframe" xframeborder="1" xborder="1" xframespacing="0">
+<FRAMESET COLS="242,**" framespacing="1" frameborder="yes" border="1" bordercolor="#e9e9e9">
+<frameset rows="174,**" framespacing="1" frameborder="yes"  border="1" bordercolor="#e9e9e9">
+    <FRAME SRC="changes/jdiff_topleftframe.html" SCROLLING="no" NAME="topleftframe" frameborder="1">
+    <FRAME SRC="changes/alldiffs_index_all.html" SCROLLING="auto" NAME="bottomleftframe" frameborder="1">
   </FRAMESET>
-  <FRAME SRC="changes/changes-summary.html" SCROLLING="auto" NAME="rightframe" xframeborder="1" xborder="1" xframespacing="0">
+  <FRAME SRC="changes/changes-summary.html" SCROLLING="auto" NAME="rightframe" frameborder="1">
 </FRAMESET>
 <NOFRAMES>
 <H2>
diff --git a/docs/html/sdk/api_diff/4/stylesheet-jdiff.css b/docs/html/sdk/api_diff/4/stylesheet-jdiff.css
index b3c1b9a..824b3df 100644
--- a/docs/html/sdk/api_diff/4/stylesheet-jdiff.css
+++ b/docs/html/sdk/api_diff/4/stylesheet-jdiff.css
@@ -3,6 +3,7 @@
 
 div.and-diff-id {border: 1px solid #eee;position:relative;float:right;clear:both;padding:0px;}
 table.diffspectable {border:1px;padding:0px;margin:0px;}
+table.jdiffIndex {margin-bottom:.5em;}
 .diffspechead {background-color:#eee;}
 .diffspectable tr {border:0px;padding:0px;}
 .diffspectable td  {background-color:eee;border:0px;font-size:90%;font-weight:normal;padding:0px;padding-left:1px;padding-right:1px;text-align:center;color:777;}
@@ -29,7 +30,7 @@
   }
 .hiddenlink {
   font-size:96%;
-  line-height:.8em;
+/* line-height:.8em; */
   text-decoration:none;}
 a {
   text-decoration:none;}
diff --git a/docs/html/sdk/api_diff/5/changes.html b/docs/html/sdk/api_diff/5/changes.html
index dc3f7cb..671e890 100644
--- a/docs/html/sdk/api_diff/5/changes.html
+++ b/docs/html/sdk/api_diff/5/changes.html
@@ -25,12 +25,12 @@
 <style type="text/css">
 </style>
 </HEAD>
-<FRAMESET COLS="242,**" frameborder="1" border="7" xframespacing="20" bordercolor="#e9e9e9"> 
-<frameset rows="164,**" frameborder="1" border="7" xframespacing="20" resizable="yes">
-    <FRAME SRC="changes/jdiff_topleftframe.html" SCROLLING="no" NAME="topleftframe" xframeborder="1" xborder="6" xframespacing="0">
-    <FRAME SRC="changes/alldiffs_index_all.html" SCROLLING="auto" NAME="bottomleftframe" xframeborder="1" xborder="1" xframespacing="0">
+<FRAMESET COLS="242,**" framespacing="1" frameborder="yes" border="1" bordercolor="#e9e9e9">
+<frameset rows="174,**" framespacing="1" frameborder="yes"  border="1" bordercolor="#e9e9e9">
+    <FRAME SRC="changes/jdiff_topleftframe.html" SCROLLING="no" NAME="topleftframe" frameborder="1">
+    <FRAME SRC="changes/alldiffs_index_all.html" SCROLLING="auto" NAME="bottomleftframe" frameborder="1">
   </FRAMESET>
-  <FRAME SRC="changes/changes-summary.html" SCROLLING="auto" NAME="rightframe" xframeborder="1" xborder="1" xframespacing="0">
+  <FRAME SRC="changes/changes-summary.html" SCROLLING="auto" NAME="rightframe" frameborder="1">
 </FRAMESET>
 <NOFRAMES>
 <H2>
diff --git a/docs/html/sdk/api_diff/5/stylesheet-jdiff.css b/docs/html/sdk/api_diff/5/stylesheet-jdiff.css
index b3c1b9a..abc4dd5 100644
--- a/docs/html/sdk/api_diff/5/stylesheet-jdiff.css
+++ b/docs/html/sdk/api_diff/5/stylesheet-jdiff.css
@@ -3,6 +3,7 @@
 
 div.and-diff-id {border: 1px solid #eee;position:relative;float:right;clear:both;padding:0px;}
 table.diffspectable {border:1px;padding:0px;margin:0px;}
+table.jdiffIndex {margin-bottom:.5em;}
 .diffspechead {background-color:#eee;}
 .diffspectable tr {border:0px;padding:0px;}
 .diffspectable td  {background-color:eee;border:0px;font-size:90%;font-weight:normal;padding:0px;padding-left:1px;padding-right:1px;text-align:center;color:777;}
@@ -29,7 +30,7 @@
   }
 .hiddenlink {
   font-size:96%;
-  line-height:.8em;
+/*  line-height:.8em; */
   text-decoration:none;}
 a {
   text-decoration:none;}
diff --git a/docs/html/search.jd b/docs/html/search.jd
index 8032b22..d0e7478 100644
--- a/docs/html/search.jd
+++ b/docs/html/search.jd
@@ -70,8 +70,8 @@
         searchControl.setSearchStartingCallback(this, function(control, searcher, query) {
             // save the tab index from the hash
             tabIndex = location.hash.split("&t=")[1];
-        
-            $("#searchTitle").html("search results for <em>" + query + "</em>");
+
+            $("#searchTitle").html("search results for <em>" + escapeHTML(query) + "</em>");
             $.history.add('q=' + query + '&t=' + tabIndex);
             openTab();
         });
@@ -96,7 +96,8 @@
       $(window).history(function(e, hash) {
         var query = decodeURI(getQuery(hash));
         searchControl.execute(query);
-        $("#searchTitle").html("search results for <em>" + query + "</em>");
+
+        $("#searchTitle").html("search results for <em>" + escapeHTML(query) + "</em>");
       });
 
       // forcefully regain key-up event control (previously jacked by search api)
@@ -131,6 +132,13 @@
         return queryParts[1];
       }
 
+      /* returns the given string with all HTML brackets converted to entities
+         TODO: move this to the site's JS library */
+      function escapeHTML(string) {
+        return string.replace(/</g,"&lt;")
+                     .replace(/>/g,"&gt;");
+      }
+
 </script>

 

   <div id="mainBodyFixed" style="width:auto; margin:20px">

diff --git a/docs/html/videos/index.jd b/docs/html/videos/index.jd
index ddb9f86..4e53aac 100644
--- a/docs/html/videos/index.jd
+++ b/docs/html/videos/index.jd
@@ -37,12 +37,10 @@
  * Each playlist ID is paired with a custom video description.
  */
 var featured = {
-// Android 1.6 Release
-  'MBRFkLKRwFw' : "The Android 1.6 release includes new features and improvements to the Android platform. Here's an introduction to what's new in Android 1.6.",
+// Android 2.0 Release
+  'opZ69P-0Jbc' : "The Android 2.0 platform adds exciting new user features and developer APIs. Here's an introduction to what's new.",
 // How to Make your Android UI Fast..
   'N6YdwzAvwOA' : "Make your user interface fast, with more efficient AdapterViews, better bitmap scaling, faster redrawing, ViewStub layouts, fewer Views, and more.", 
-// Coding for Life: Battery Life
-//  'OUemfrKe65c' : "Learn what kinds of operations consume the most battery and how you can reduce your usage, with tips for parsing and zipping data, using wakelocks, and running a Service.",
 // How Do I Code Thee?
   'GARMe7Km_gk' : "If you'd like to augment your Android applications with pieces written in JavaScript or native code, watch this video."
 };
diff --git a/include/ui/CameraHardwareInterface.h b/include/ui/CameraHardwareInterface.h
index af40f31..240c134 100644
--- a/include/ui/CameraHardwareInterface.h
+++ b/include/ui/CameraHardwareInterface.h
@@ -25,6 +25,15 @@
 #include <ui/Overlay.h>
 
 namespace android {
+/**
+ *  The size of image for display.
+ */
+typedef struct image_rect_struct
+{
+  uint32_t width;      /* Image width */
+  uint32_t height;     /* Image height */
+} image_rect_type;
+
 
 typedef void (*notify_callback)(int32_t msgType,
                                 int32_t ext1,
diff --git a/include/ui/GraphicBuffer.h b/include/ui/GraphicBuffer.h
index 8897f03..2172536 100644
--- a/include/ui/GraphicBuffer.h
+++ b/include/ui/GraphicBuffer.h
@@ -66,7 +66,11 @@
     GraphicBuffer();
 
     // creates w * h buffer
-    GraphicBuffer(uint32_t w, uint32_t h, PixelFormat format, uint32_t ssage);
+    GraphicBuffer(uint32_t w, uint32_t h, PixelFormat format, uint32_t usage);
+
+    // create a buffer from an existing handle
+    GraphicBuffer(uint32_t w, uint32_t h, PixelFormat format, uint32_t usage,
+            uint32_t stride, native_handle_t* handle, bool keepOwnership);
 
     // return status
     status_t initCheck() const;
@@ -94,9 +98,15 @@
     GraphicBuffer(const Parcel& reply);
     virtual ~GraphicBuffer();
 
+    enum {
+        ownNone   = 0,
+        ownHandle = 1,
+        ownData   = 2,
+    };
+
     inline const GraphicBufferMapper& getBufferMapper() const { return mBufferMapper; }
     inline GraphicBufferMapper& getBufferMapper() { return mBufferMapper; }
-    bool mOwner;
+    uint8_t mOwner;
 
 private:
     friend class Surface;
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp
index 8ac9c26..b7d1297 100644
--- a/libs/rs/rsAllocation.cpp
+++ b/libs/rs/rsAllocation.cpp
@@ -405,7 +405,7 @@
     const uint8_t * src = static_cast<const uint8_t *>(data);
     for (uint32_t y = 0; y < h; y++) {
         uint8_t * ydst = &tmp[(y + ((h2 - h) >> 1)) * w2 * bpp];
-        memcpy(&ydst[(w2 - w) >> 1], src, w * bpp);
+        memcpy(&ydst[((w2 - w) >> 1) * bpp], src, w * bpp);
         src += w * bpp;
     }
 
diff --git a/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp b/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp
index f84933e..1abfd68 100644
--- a/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp
+++ b/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp
@@ -256,12 +256,16 @@
     if (strstr(gl_extensions, "GL_OES_draw_texture")) {
         mFlags |= DRAW_TEXTURE_EXTENSION;
     }
+#ifdef EGL_ANDROID_image_native_buffer
     if (strstr( gl_extensions, "GL_OES_EGL_image") &&
         (strstr(egl_extensions, "EGL_KHR_image_base") || 
                 strstr(egl_extensions, "EGL_KHR_image")) &&
         strstr(egl_extensions, "EGL_ANDROID_image_native_buffer")) {
         mFlags |= DIRECT_TEXTURE;
     }
+#else
+#warning "EGL_ANDROID_image_native_buffer not supported"
+#endif
 
     // Unbind the context from this thread
     eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
diff --git a/libs/surfaceflinger/Layer.cpp b/libs/surfaceflinger/Layer.cpp
index 2bb1e12..f5a5a0b 100644
--- a/libs/surfaceflinger/Layer.cpp
+++ b/libs/surfaceflinger/Layer.cpp
@@ -130,62 +130,6 @@
     return NO_ERROR;
 }
 
-status_t Layer::initializeEglImageLocked(
-        const sp<GraphicBuffer>& buffer, Texture* texture)
-{
-    status_t err = NO_ERROR;
-
-    // we need to recreate the texture
-    EGLDisplay dpy(mFlinger->graphicPlane(0).getEGLDisplay());
-
-    // free the previous image
-    if (texture->image != EGL_NO_IMAGE_KHR) {
-        eglDestroyImageKHR(dpy, texture->image);
-        texture->image = EGL_NO_IMAGE_KHR;
-    }
-
-    // construct an EGL_NATIVE_BUFFER_ANDROID
-    android_native_buffer_t* clientBuf = buffer->getNativeBuffer();
-
-    // create the new EGLImageKHR
-    const EGLint attrs[] = {
-            EGL_IMAGE_PRESERVED_KHR,    EGL_TRUE,
-            EGL_NONE,                   EGL_NONE
-    };
-    texture->image = eglCreateImageKHR(
-            dpy, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID,
-            (EGLClientBuffer)clientBuf, attrs);
-
-    LOGE_IF(texture->image == EGL_NO_IMAGE_KHR,
-            "eglCreateImageKHR() failed. err=0x%4x",
-            eglGetError());
-
-    if (texture->image != EGL_NO_IMAGE_KHR) {
-        glBindTexture(GL_TEXTURE_2D, texture->name);
-        glEGLImageTargetTexture2DOES(GL_TEXTURE_2D,
-                (GLeglImageOES)texture->image);
-        GLint error = glGetError();
-        if (UNLIKELY(error != GL_NO_ERROR)) {
-            // this failed, for instance, because we don't support NPOT.
-            // FIXME: do something!
-            LOGE("layer=%p, glEGLImageTargetTexture2DOES(%p) "
-                 "failed err=0x%04x",
-                 this, texture->image, error);
-            mFlags &= ~DisplayHardware::DIRECT_TEXTURE;
-            err = INVALID_OPERATION;
-        } else {
-            // Everything went okay!
-            texture->NPOTAdjust = false;
-            texture->dirty  = false;
-            texture->width  = clientBuf->width;
-            texture->height = clientBuf->height;
-        }
-    } else {
-        err = INVALID_OPERATION;
-    }
-    return err;
-}
-
 void Layer::reloadTexture(const Region& dirty)
 {
     Mutex::Autolock _l(mLock);
@@ -199,10 +143,11 @@
         mTextures[index].height = 0;
     }
 
+#ifdef EGL_ANDROID_image_native_buffer
     if (mFlags & DisplayHardware::DIRECT_TEXTURE) {
         if (buffer->usage & GraphicBuffer::USAGE_HW_TEXTURE) {
             if (mTextures[index].dirty) {
-                initializeEglImageLocked(buffer, &mTextures[index]);
+                initializeEglImage(buffer, &mTextures[index]);
             }
         } else {
             if (mHybridBuffer==0 || (mHybridBuffer->width != buffer->width ||
@@ -212,7 +157,7 @@
                         buffer->width, buffer->height, buffer->format,
                         GraphicBuffer::USAGE_SW_WRITE_OFTEN |
                         GraphicBuffer::USAGE_HW_TEXTURE);
-                initializeEglImageLocked(
+                initializeEglImage(
                         mHybridBuffer, &mTextures[0]);
             }
 
@@ -279,7 +224,9 @@
                 buffer->unlock();
             }
         }
-    } else {
+    } else
+#endif
+    {
         for (size_t i=0 ; i<NUM_BUFFERS ; i++) {
             mTextures[i].image = EGL_NO_IMAGE_KHR;
         }
diff --git a/libs/surfaceflinger/Layer.h b/libs/surfaceflinger/Layer.h
index 57b3dfa..1310ecc 100644
--- a/libs/surfaceflinger/Layer.h
+++ b/libs/surfaceflinger/Layer.h
@@ -85,8 +85,6 @@
     }
  
     void reloadTexture(const Region& dirty);
-    status_t initializeEglImageLocked(
-            const sp<GraphicBuffer>& buffer, Texture* texture);
 
     uint32_t getEffectiveUsage(uint32_t usage) const;
 
diff --git a/libs/surfaceflinger/LayerBase.cpp b/libs/surfaceflinger/LayerBase.cpp
index ecc7894..8003d22 100644
--- a/libs/surfaceflinger/LayerBase.cpp
+++ b/libs/surfaceflinger/LayerBase.cpp
@@ -617,6 +617,63 @@
     }
 }
 
+status_t LayerBase::initializeEglImage(
+        const sp<GraphicBuffer>& buffer, Texture* texture)
+{
+    status_t err = NO_ERROR;
+
+    // we need to recreate the texture
+    EGLDisplay dpy(mFlinger->graphicPlane(0).getEGLDisplay());
+
+    // free the previous image
+    if (texture->image != EGL_NO_IMAGE_KHR) {
+        eglDestroyImageKHR(dpy, texture->image);
+        texture->image = EGL_NO_IMAGE_KHR;
+    }
+
+    // construct an EGL_NATIVE_BUFFER_ANDROID
+    android_native_buffer_t* clientBuf = buffer->getNativeBuffer();
+
+    // create the new EGLImageKHR
+    const EGLint attrs[] = {
+            EGL_IMAGE_PRESERVED_KHR,    EGL_TRUE,
+            EGL_NONE,                   EGL_NONE
+    };
+    texture->image = eglCreateImageKHR(
+            dpy, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID,
+            (EGLClientBuffer)clientBuf, attrs);
+
+    LOGE_IF(texture->image == EGL_NO_IMAGE_KHR,
+            "eglCreateImageKHR() failed. err=0x%4x",
+            eglGetError());
+
+    if (texture->image != EGL_NO_IMAGE_KHR) {
+        glBindTexture(GL_TEXTURE_2D, texture->name);
+        glEGLImageTargetTexture2DOES(GL_TEXTURE_2D,
+                (GLeglImageOES)texture->image);
+        GLint error = glGetError();
+        if (UNLIKELY(error != GL_NO_ERROR)) {
+            // this failed, for instance, because we don't support NPOT.
+            // FIXME: do something!
+            LOGE("layer=%p, glEGLImageTargetTexture2DOES(%p) "
+                 "failed err=0x%04x",
+                 this, texture->image, error);
+            mFlags &= ~DisplayHardware::DIRECT_TEXTURE;
+            err = INVALID_OPERATION;
+        } else {
+            // Everything went okay!
+            texture->NPOTAdjust = false;
+            texture->dirty  = false;
+            texture->width  = clientBuf->width;
+            texture->height = clientBuf->height;
+        }
+    } else {
+        err = INVALID_OPERATION;
+    }
+    return err;
+}
+
+
 // ---------------------------------------------------------------------------
 
 int32_t LayerBaseClient::sIdentity = 0;
diff --git a/libs/surfaceflinger/LayerBase.h b/libs/surfaceflinger/LayerBase.h
index efa4f8c..ed07b3f 100644
--- a/libs/surfaceflinger/LayerBase.h
+++ b/libs/surfaceflinger/LayerBase.h
@@ -261,6 +261,8 @@
           void drawWithOpenGL(const Region& clip, const Texture& texture) const;
           void loadTexture(Texture* texture, 
                   const Region& dirty, const GGLSurface& t) const;
+          status_t initializeEglImage(
+                  const sp<GraphicBuffer>& buffer, Texture* texture);
 
           
                 sp<SurfaceFlinger> mFlinger;
diff --git a/libs/surfaceflinger/LayerBuffer.cpp b/libs/surfaceflinger/LayerBuffer.cpp
index 7e27a02..6590503 100644
--- a/libs/surfaceflinger/LayerBuffer.cpp
+++ b/libs/surfaceflinger/LayerBuffer.cpp
@@ -339,12 +339,6 @@
     mLayer.setNeedsBlending((info.h_alpha - info.l_alpha) > 0);    
     mBufferSize = info.getScanlineSize(buffers.hor_stride)*buffers.ver_stride;
     mLayer.forceVisibilityTransaction();
-
-    hw_module_t const* module;
-    mBlitEngine = NULL;
-    if (hw_get_module(COPYBIT_HARDWARE_MODULE_ID, &module) == 0) {
-        copybit_open(module, &mBlitEngine);
-    }
 }
 
 LayerBuffer::BufferSource::~BufferSource()
@@ -352,8 +346,9 @@
     if (mTexture.name != -1U) {
         glDeleteTextures(1, &mTexture.name);
     }
-    if (mBlitEngine) {
-        copybit_close(mBlitEngine);
+    if (mTexture.image != EGL_NO_IMAGE_KHR) {
+        EGLDisplay dpy(mLayer.mFlinger->graphicPlane(0).getEGLDisplay());
+        eglDestroyImageKHR(dpy, mTexture.image);
     }
 }
 
@@ -421,122 +416,28 @@
     status_t err = NO_ERROR;
     NativeBuffer src(ourBuffer->getBuffer());
     const Rect transformedBounds(mLayer.getTransformedBounds());
-    copybit_device_t* copybit = mBlitEngine;
 
-    if (copybit)  {
-        const int src_width  = src.crop.r - src.crop.l;
-        const int src_height = src.crop.b - src.crop.t;
-        int W = transformedBounds.width();
-        int H = transformedBounds.height();
-        if (mLayer.getOrientation() & Transform::ROT_90) {
-            int t(W); W=H; H=t;
-        }
+    if (UNLIKELY(mTexture.name == -1LU)) {
+        mTexture.name = mLayer.createTexture();
+    }
 
-#ifdef EGL_ANDROID_get_render_buffer
-        EGLDisplay dpy = eglGetCurrentDisplay();
-        EGLSurface draw = eglGetCurrentSurface(EGL_DRAW); 
-        EGLClientBuffer clientBuf = eglGetRenderBufferANDROID(dpy, draw);
-        android_native_buffer_t* nb = (android_native_buffer_t*)clientBuf;
-        if (nb == 0) {
-            err = BAD_VALUE;
-        } else {
-            copybit_image_t dst;
-            dst.w       = nb->width;
-            dst.h       = nb->height;
-            dst.format  = nb->format;
-            dst.base    = NULL; // unused by copybit on msm7k
-            dst.handle  = (native_handle_t *)nb->handle;
+#if defined(EGL_ANDROID_image_native_buffer)
+    if (mLayer.mFlags & DisplayHardware::DIRECT_TEXTURE) {
+         // NOTE: Assume the buffer is  allocated with the proper USAGE flags
+        sp<GraphicBuffer> graphicBuffer = new GraphicBuffer(
+                src.crop.r, src.crop.b, src.img.format, 
+                GraphicBuffer::USAGE_HW_TEXTURE,
+                src.img.w, src.img.handle, false);
 
-            /* With LayerBuffer, it is likely that we'll have to rescale the
-             * surface, because this is often used for video playback or
-             * camera-preview. Since we want these operation as fast as possible
-             * we make sure we can use the 2D H/W even if it doesn't support
-             * the requested scale factor, in which case we perform the scaling
-             * in several passes. */
-
-            const float min = copybit->get(copybit, COPYBIT_MINIFICATION_LIMIT);
-            const float mag = copybit->get(copybit, COPYBIT_MAGNIFICATION_LIMIT);
-
-            float xscale = 1.0f;
-            if (src_width > W*min)          xscale = 1.0f / min;
-            else if (src_width*mag < W)     xscale = mag;
-
-            float yscale = 1.0f;
-            if (src_height > H*min)         yscale = 1.0f / min;
-            else if (src_height*mag < H)    yscale = mag;
-
-            if (UNLIKELY(xscale!=1.0f || yscale!=1.0f)) {
-                const int tmp_w = floorf(src_width  * xscale);
-                const int tmp_h = floorf(src_height * yscale);
-                
-                if (mTempBitmap==0 || 
-                        mTempBitmap->getWidth() < size_t(tmp_w) || 
-                        mTempBitmap->getHeight() < size_t(tmp_h)) {
-                    mTempBitmap.clear();
-                    mTempBitmap = new GraphicBuffer(
-                            tmp_w, tmp_h, src.img.format, 
-                            GraphicBuffer::USAGE_HW_2D);
-                    err = mTempBitmap->initCheck();
-                }
-
-                if (LIKELY(err == NO_ERROR)) {
-                    NativeBuffer tmp;
-                    tmp.img.w = tmp_w;
-                    tmp.img.h = tmp_h;
-                    tmp.img.format = src.img.format;
-                    tmp.img.handle = (native_handle_t*)mTempBitmap->getNativeBuffer()->handle;
-                    tmp.crop.l = 0;
-                    tmp.crop.t = 0;
-                    tmp.crop.r = tmp.img.w;
-                    tmp.crop.b = tmp.img.h;
-
-                    region_iterator tmp_it(Region(Rect(tmp.crop.r, tmp.crop.b)));
-                    copybit->set_parameter(copybit, COPYBIT_TRANSFORM, 0);
-                    copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, 0xFF);
-                    copybit->set_parameter(copybit, COPYBIT_DITHER, COPYBIT_DISABLE);
-                    err = copybit->stretch(copybit,
-                            &tmp.img, &src.img, &tmp.crop, &src.crop, &tmp_it);
-                    src = tmp;
-                }
-            }
-
-            const Rect transformedBounds(mLayer.getTransformedBounds());
-            const copybit_rect_t& drect =
-                reinterpret_cast<const copybit_rect_t&>(transformedBounds);
-            const State& s(mLayer.drawingState());
-            region_iterator it(clip);
-
-            // pick the right orientation for this buffer
-            int orientation = mLayer.getOrientation();
-            if (UNLIKELY(mBufferHeap.transform)) {
-                Transform rot90;
-                GraphicPlane::orientationToTransfrom(
-                        ISurfaceComposer::eOrientation90, 0, 0, &rot90);
-                const Transform& planeTransform(mLayer.graphicPlane(0).transform());
-                const Layer::State& s(mLayer.drawingState());
-                Transform tr(planeTransform * s.transform * rot90);
-                orientation = tr.getOrientation();
-            }
-
-            copybit->set_parameter(copybit, COPYBIT_TRANSFORM, orientation);
-            copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, s.alpha);
-            copybit->set_parameter(copybit, COPYBIT_DITHER, COPYBIT_ENABLE);
-
-            err = copybit->stretch(copybit,
-                    &dst, &src.img, &drect, &src.crop, &it);
-            if (err != NO_ERROR) {
-                LOGE("copybit failed (%s)", strerror(err));
-            }
-        }
+        err = mLayer.initializeEglImage(graphicBuffer, &mTexture);
     }
 #endif
-    
-    if (!copybit || err) 
-    {
+    else {
+        err = INVALID_OPERATION;
+    }
+
+    if (err != NO_ERROR) {
         // OpenGL fall-back
-        if (UNLIKELY(mTexture.name == -1LU)) {
-            mTexture.name = mLayer.createTexture();
-        }
         GLuint w = 0;
         GLuint h = 0;
         GGLSurface t;
@@ -549,11 +450,11 @@
         t.data = (GGLubyte*)src.img.base;
         const Region dirty(Rect(t.width, t.height));
         mLayer.loadTexture(&mTexture, dirty, t);
-        mTexture.transform = mBufferHeap.transform;
-        mLayer.drawWithOpenGL(clip, mTexture);
     }
-}
 
+    mTexture.transform = mBufferHeap.transform;
+    mLayer.drawWithOpenGL(clip, mTexture);
+}
 
 // ---------------------------------------------------------------------------
 
diff --git a/libs/surfaceflinger/LayerBuffer.h b/libs/surfaceflinger/LayerBuffer.h
index 5eb472c..438b711 100644
--- a/libs/surfaceflinger/LayerBuffer.h
+++ b/libs/surfaceflinger/LayerBuffer.h
@@ -132,7 +132,6 @@
         size_t                          mBufferSize;
         mutable sp<GraphicBuffer>       mTempBitmap;
         mutable LayerBase::Texture      mTexture;
-        copybit_device_t*               mBlitEngine;
     };
     
     class OverlaySource : public Source {
diff --git a/libs/surfaceflinger/LayerDim.cpp b/libs/surfaceflinger/LayerDim.cpp
index 538dc77..fd61e30 100644
--- a/libs/surfaceflinger/LayerDim.cpp
+++ b/libs/surfaceflinger/LayerDim.cpp
@@ -55,8 +55,8 @@
     sHeight = h;
     sUseTexture = false;
     
-#ifdef DIM_WITH_TEXTURE
-    
+#if defined(DIM_WITH_TEXTURE) && defined(EGL_ANDROID_image_native_buffer)
+
 #warning "using a texture to implement LayerDim"
     
     /* On some h/w like msm7K, it is faster to use a texture because the
@@ -69,7 +69,6 @@
     uint32_t flags = hw.getFlags();
 
     if (LIKELY(flags & DisplayHardware::DIRECT_TEXTURE)) {
-        // TODO: api to pass the usage flags
         sp<GraphicBuffer> buffer = new GraphicBuffer(w, h, PIXEL_FORMAT_RGB_565,
                  GraphicBuffer::USAGE_SW_WRITE_OFTEN |
                  GraphicBuffer::USAGE_HW_TEXTURE);
@@ -123,7 +122,7 @@
         glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
         glColor4x(0, 0, 0, alpha);
         
-#ifdef DIM_WITH_TEXTURE
+#if defined(DIM_WITH_TEXTURE) && defined(EGL_ANDROID_image_native_buffer)
         if (sUseTexture) {
             glBindTexture(GL_TEXTURE_2D, sTexId);
             glEnable(GL_TEXTURE_2D);
diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp
index 1cf20d7..efe2d78 100644
--- a/libs/ui/GraphicBuffer.cpp
+++ b/libs/ui/GraphicBuffer.cpp
@@ -37,7 +37,7 @@
 // ===========================================================================
 
 GraphicBuffer::GraphicBuffer()
-    : BASE(), mOwner(false), mBufferMapper(GraphicBufferMapper::get()),
+    : BASE(), mOwner(ownData), mBufferMapper(GraphicBufferMapper::get()),
       mInitCheck(NO_ERROR),  mVStride(0), mIndex(-1)
 {
     width  = 
@@ -50,7 +50,7 @@
 
 GraphicBuffer::GraphicBuffer(uint32_t w, uint32_t h, 
         PixelFormat reqFormat, uint32_t reqUsage)
-    : BASE(), mOwner(false), mBufferMapper(GraphicBufferMapper::get()),
+    : BASE(), mOwner(ownData), mBufferMapper(GraphicBufferMapper::get()),
       mInitCheck(NO_ERROR),  mVStride(0), mIndex(-1)
 {
     width  = 
@@ -62,8 +62,23 @@
     mInitCheck = initSize(w, h, reqFormat, reqUsage);
 }
 
+GraphicBuffer::GraphicBuffer(uint32_t w, uint32_t h,
+        PixelFormat inFormat, uint32_t inUsage,
+        uint32_t inStride, native_handle_t* inHandle, bool keepOwnership)
+    : BASE(), mOwner(keepOwnership ? ownHandle : ownNone),
+      mBufferMapper(GraphicBufferMapper::get()),
+      mInitCheck(NO_ERROR),  mVStride(0), mIndex(-1)
+{
+    width  = w;
+    height = h;
+    stride = inStride;
+    format = inFormat;
+    usage  = inUsage;
+    handle = inHandle;
+}
+
 GraphicBuffer::GraphicBuffer(const Parcel& data) 
-    : BASE(), mOwner(true), mBufferMapper(GraphicBufferMapper::get()),
+    : BASE(), mOwner(ownHandle), mBufferMapper(GraphicBufferMapper::get()),
       mInitCheck(NO_ERROR),  mVStride(0), mIndex(-1)
 {
     // we own the handle in this case
@@ -83,10 +98,10 @@
 GraphicBuffer::~GraphicBuffer()
 {
     if (handle) {
-        if (mOwner) {
+        if (mOwner == ownHandle) {
             native_handle_close(handle);
             native_handle_delete(const_cast<native_handle*>(handle));
-        } else {
+        } else if (mOwner == ownData) {
             GraphicBufferAllocator& allocator(GraphicBufferAllocator::get());
             allocator.free(handle);
         }
@@ -106,6 +121,9 @@
 status_t GraphicBuffer::reallocate(uint32_t w, uint32_t h, PixelFormat f,
         uint32_t reqUsage)
 {
+    if (mOwner != ownData)
+        return INVALID_OPERATION;
+
     if (handle) {
         GraphicBufferAllocator& allocator(GraphicBufferAllocator::get());
         allocator.free(handle);
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index d90871e..58a0bba 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -959,10 +959,10 @@
     ///////////////////////////////////////////////////////////////////////////
 
     public class VolumeStreamState {
-        private final String mVolumeIndexSettingName;
-        private final String mLastAudibleVolumeIndexSettingName;
         private final int mStreamType;
 
+        private String mVolumeIndexSettingName;
+        private String mLastAudibleVolumeIndexSettingName;
         private int mIndexMax;
         private int mIndex;
         private int mLastAudibleIndex;
@@ -970,8 +970,7 @@
 
         private VolumeStreamState(String settingName, int streamType) {
 
-            mVolumeIndexSettingName = settingName;
-            mLastAudibleVolumeIndexSettingName = settingName + System.APPEND_FOR_LAST_AUDIBLE;
+            setVolumeIndexSettingName(settingName);
 
             mStreamType = streamType;
 
@@ -991,6 +990,11 @@
             mDeathHandlers = new ArrayList<VolumeDeathHandler>();
         }
 
+        public void setVolumeIndexSettingName(String settingName) {
+            mVolumeIndexSettingName = settingName;
+            mLastAudibleVolumeIndexSettingName = settingName + System.APPEND_FOR_LAST_AUDIBLE;
+        }
+
         public boolean adjustIndex(int deltaIndex) {
             return setIndex(mIndex + deltaIndex * 10, true);
         }
@@ -1370,11 +1374,17 @@
                     mNotificationsUseRingVolume = notificationsUseRingVolume;
                     if (mNotificationsUseRingVolume == 1) {
                         STREAM_VOLUME_ALIAS[AudioSystem.STREAM_NOTIFICATION] = AudioSystem.STREAM_RING;
+                        mStreamStates[AudioSystem.STREAM_NOTIFICATION].setVolumeIndexSettingName(
+                                System.VOLUME_SETTINGS[AudioSystem.STREAM_RING]);
                     } else {
                         STREAM_VOLUME_ALIAS[AudioSystem.STREAM_NOTIFICATION] = AudioSystem.STREAM_NOTIFICATION;
+                        mStreamStates[AudioSystem.STREAM_NOTIFICATION].setVolumeIndexSettingName(
+                                System.VOLUME_SETTINGS[AudioSystem.STREAM_NOTIFICATION]);
                         // Persist notification volume volume as it was not persisted while aliased to ring volume
+                        //  and persist with no delay as there might be registered observers of the persisted
+                        //  notification volume.
                         sendMsg(mAudioHandler, MSG_PERSIST_VOLUME, AudioSystem.STREAM_NOTIFICATION,
-                                SENDMSG_REPLACE, 0, 0, mStreamStates[AudioSystem.STREAM_NOTIFICATION], PERSIST_DELAY);
+                                SENDMSG_REPLACE, 0, 0, mStreamStates[AudioSystem.STREAM_NOTIFICATION], 0);
                     }
                 }
             }
diff --git a/opengl/libagl/Android.mk b/opengl/libagl/Android.mk
index 2522656..9837845 100644
--- a/opengl/libagl/Android.mk
+++ b/opengl/libagl/Android.mk
@@ -25,6 +25,13 @@
 	primitives.cpp.arm	        \
 	vertex.cpp.arm
 
+LOCAL_CFLAGS += -DLOG_TAG=\"libagl\"
+LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
+LOCAL_CFLAGS += -fvisibility=hidden
+
+LOCAL_SHARED_LIBRARIES := libcutils libhardware libutils libpixelflinger
+LOCAL_LDLIBS := -lpthread -ldl
+
 ifeq ($(TARGET_ARCH),arm)
 	LOCAL_SRC_FILES += fixed_asm.S iterators.S
 	LOCAL_CFLAGS += -fstrict-aliasing
@@ -38,15 +45,9 @@
 ifeq ($(LIBAGL_USE_GRALLOC_COPYBITS),1)
     LOCAL_CFLAGS += -DLIBAGL_USE_GRALLOC_COPYBITS
     LOCAL_SRC_FILES += copybit.cpp
+    LOCAL_SHARED_LIBRARIES += libui
 endif
 
-LOCAL_CFLAGS += -DLOG_TAG=\"libagl\"
-LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
-
-LOCAL_SHARED_LIBRARIES := libcutils libhardware libutils libpixelflinger
-LOCAL_CFLAGS += -fvisibility=hidden
-
-LOCAL_LDLIBS := -lpthread -ldl
 
 LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/egl
 LOCAL_MODULE:= libGLES_android
diff --git a/opengl/libagl/copybit.cpp b/opengl/libagl/copybit.cpp
index 73b2355..4b9e59b 100644
--- a/opengl/libagl/copybit.cpp
+++ b/opengl/libagl/copybit.cpp
@@ -33,6 +33,10 @@
 #include <hardware/copybit.h>
 #include <private/ui/android_natives_priv.h>
 
+#include <ui/GraphicBuffer.h>
+#include <ui/Region.h>
+#include <ui/Rect.h>
+
 
 #define DEBUG_COPYBIT true
 
@@ -150,6 +154,8 @@
         int transform,
         ogles_context_t* c)
 {
+    status_t err = NO_ERROR;
+
     // We assume checkContext has already been called and has already
     // returned true.
 
@@ -175,16 +181,6 @@
         dtdy /= screen_h;
     }
     dtdy = -dtdy; // see equation of dtdy above
-    if (dsdx < c->copybits.minScale || dsdx > c->copybits.maxScale
-            || dtdy < c->copybits.minScale || dtdy > c->copybits.maxScale) {
-        // The requested scale is out of the range the hardware
-        // can support.
-        LOGD_IF(DEBUG_COPYBIT,
-                "scale out of range dsdx=%08x (Wcr=%d / w=%d), "
-                "dtdy=%08x (Hcr=%d / h=%d), Ucr=%d, Vcr=%d", 
-                dsdx, Wcr, w, dtdy, Hcr, h, Ucr, Vcr);
-        return false;
-    }
 
     // copybit doesn't say anything about filtering, so we can't
     // discriminate. On msm7k, copybit will always filter.
@@ -206,6 +202,7 @@
     
     const uint32_t enables = c->rasterizer.state.enables;
     int planeAlpha = 255;
+    bool alphaPlaneWorkaround = false;
     static const int tmu = 0;
     texture_t& tev(c->rasterizer.state.texture[tmu]);
     int32_t opFormat = textureObject->surface.format;
@@ -265,9 +262,10 @@
             if (c->currentColorClamped.r == c->currentColorClamped.a &&
                 c->currentColorClamped.g == c->currentColorClamped.a &&
                 c->currentColorClamped.b == c->currentColorClamped.a) {
-                // TODO: Need to emulate: RGBA source, color={a,a,a,a} / premult
-                // and RGBA source, color={1,1,1,a} / regular-blending
-                // (both are equivalent)
+                // TODO: RGBA source, color={1,1,1,a} / regular-blending
+                // is equivalent
+                alphaPlaneWorkaround = true;
+                break;
             }
         }
         LOGD_IF(DEBUG_COPYBIT, "GGL_MODULATE");
@@ -278,28 +276,153 @@
         return false;
     }
 
-
-    // LOGW("calling copybits");
-
     copybit_device_t* copybit = c->copybits.blitEngine;
+    copybit_image_t src;
+    buffer_handle_t source_hnd = textureObject->buffer->handle;
+    textureToCopyBitImage(&textureObject->surface, opFormat, source_hnd, &src);
+    copybit_rect_t srect = { Ucr, Vcr + Hcr, Ucr + Wcr, Vcr };
+
+    /*
+     *  Below we perform extra passes needed to emulate things the h/w
+     * cannot do.
+     */
+
+    const GLfixed minScaleInv = gglDivQ(0x10000, c->copybits.minScale, 16);
+    const GLfixed maxScaleInv = gglDivQ(0x10000, c->copybits.maxScale, 16);
+
+    sp<GraphicBuffer> tempBitmap;
+
+    if (dsdx < maxScaleInv || dsdx > minScaleInv ||
+        dtdy < maxScaleInv || dtdy > minScaleInv)
+    {
+        // The requested scale is out of the range the hardware
+        // can support.
+        LOGD_IF(DEBUG_COPYBIT,
+                "scale out of range dsdx=%08x (Wcr=%d / w=%d), "
+                "dtdy=%08x (Hcr=%d / h=%d), Ucr=%d, Vcr=%d",
+                dsdx, Wcr, w, dtdy, Hcr, h, Ucr, Vcr);
+
+        int32_t xscale=0x10000, yscale=0x10000;
+        if (dsdx > minScaleInv)         xscale = c->copybits.minScale;
+        else if (dsdx < maxScaleInv)    xscale = c->copybits.maxScale;
+        if (dtdy > minScaleInv)         yscale = c->copybits.minScale;
+        else if (dtdy < maxScaleInv)    yscale = c->copybits.maxScale;
+        dsdx = gglMulx(dsdx, xscale);
+        dtdy = gglMulx(dtdy, yscale);
+
+        /* we handle only one step of resizing below. Handling an arbitrary
+         * number is relatively easy (replace "if" above by "while"), but requires
+         * two intermediate buffers and so far we never had the need.
+         */
+
+        if (dsdx < maxScaleInv || dsdx > minScaleInv ||
+            dtdy < maxScaleInv || dtdy > minScaleInv) {
+            LOGD_IF(DEBUG_COPYBIT,
+                    "scale out of range dsdx=%08x (Wcr=%d / w=%d), "
+                    "dtdy=%08x (Hcr=%d / h=%d), Ucr=%d, Vcr=%d",
+                    dsdx, Wcr, w, dtdy, Hcr, h, Ucr, Vcr);
+            return false;
+        }
+
+        const int tmp_w = gglMulx(srect.r - srect.l, xscale, 16);
+        const int tmp_h = gglMulx(srect.b - srect.t, yscale, 16);
+
+        LOGD_IF(DEBUG_COPYBIT,
+                "xscale=%08x, yscale=%08x, dsdx=%08x, dtdy=%08x, tmp_w=%d, tmp_h=%d",
+                xscale, yscale, dsdx, dtdy, tmp_w, tmp_h);
+
+        tempBitmap = new GraphicBuffer(
+                    tmp_w, tmp_h, src.format,
+                    GraphicBuffer::USAGE_HW_2D);
+
+        err = tempBitmap->initCheck();
+        if (err == NO_ERROR) {
+            copybit_image_t tmp_dst;
+            copybit_rect_t tmp_rect;
+            tmp_dst.w = tmp_w;
+            tmp_dst.h = tmp_h;
+            tmp_dst.format = tempBitmap->format;
+            tmp_dst.handle = (native_handle_t*)tempBitmap->getNativeBuffer()->handle;
+            tmp_rect.l = 0;
+            tmp_rect.t = 0;
+            tmp_rect.r = tmp_dst.w;
+            tmp_rect.b = tmp_dst.h;
+            region_iterator tmp_it(Region(Rect(tmp_rect.r, tmp_rect.b)));
+            copybit->set_parameter(copybit, COPYBIT_TRANSFORM, 0);
+            copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, 0xFF);
+            copybit->set_parameter(copybit, COPYBIT_DITHER, COPYBIT_DISABLE);
+            err = copybit->stretch(copybit,
+                    &tmp_dst, &src, &tmp_rect, &srect, &tmp_it);
+            src = tmp_dst;
+            srect = tmp_rect;
+        }
+    }
 
     copybit_image_t dst;
     buffer_handle_t target_hnd = c->copybits.drawSurfaceBuffer;
     textureToCopyBitImage(&cbSurface, cbSurface.format, target_hnd, &dst);
     copybit_rect_t drect = {x, y, x+w, y+h};
 
-    copybit_image_t src;
-    buffer_handle_t source_hnd = textureObject->buffer->handle;
-    textureToCopyBitImage(&textureObject->surface, opFormat, source_hnd, &src);
-    copybit_rect_t srect = { Ucr, Vcr + Hcr, Ucr + Wcr, Vcr };
 
-    copybit->set_parameter(copybit, COPYBIT_TRANSFORM, transform);
-    copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, planeAlpha);
-    copybit->set_parameter(copybit, COPYBIT_DITHER,
-            (enables & GGL_ENABLE_DITHER) ? COPYBIT_ENABLE : COPYBIT_DISABLE);
+    /* and now the alpha-plane hack. This handles the "Fade" case of a
+     * texture with an alpha channel.
+     */
+    if (alphaPlaneWorkaround) {
+        sp<GraphicBuffer> tempCb = new GraphicBuffer(
+                    w, h, COPYBIT_FORMAT_RGB_565,
+                    GraphicBuffer::USAGE_HW_2D);
 
-    clipRectRegion it(c);
-    status_t err = copybit->stretch(copybit, &dst, &src, &drect, &srect, &it);
+        err = tempCb->initCheck();
+
+        copybit_image_t tmpCbImg;
+        copybit_rect_t tmpCbRect;
+        tmpCbImg.w = w;
+        tmpCbImg.h = h;
+        tmpCbImg.format = tempCb->format;
+        tmpCbImg.handle = (native_handle_t*)tempCb->getNativeBuffer()->handle;
+        tmpCbRect.l = 0;
+        tmpCbRect.t = 0;
+        tmpCbRect.r = w;
+        tmpCbRect.b = h;
+
+        if (!err) {
+            // first make a copy of the destination buffer
+            region_iterator tmp_it(Region(Rect(w, h)));
+            copybit->set_parameter(copybit, COPYBIT_TRANSFORM, 0);
+            copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, 0xFF);
+            copybit->set_parameter(copybit, COPYBIT_DITHER, COPYBIT_DISABLE);
+            err = copybit->stretch(copybit,
+                    &tmpCbImg, &dst, &tmpCbRect, &drect, &tmp_it);
+        }
+        if (!err) {
+            // then proceed as usual, but without the alpha plane
+            copybit->set_parameter(copybit, COPYBIT_TRANSFORM, transform);
+            copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, 0xFF);
+            copybit->set_parameter(copybit, COPYBIT_DITHER,
+                    (enables & GGL_ENABLE_DITHER) ?
+                            COPYBIT_ENABLE : COPYBIT_DISABLE);
+            clipRectRegion it(c);
+            err = copybit->stretch(copybit, &dst, &src, &drect, &srect, &it);
+        }
+        if (!err) {
+            // finally copy back the destination on top with 1-alphaplane
+            int invPlaneAlpha = 0xFF - fixedToByte(c->currentColorClamped.a);
+            clipRectRegion it(c);
+            copybit->set_parameter(copybit, COPYBIT_TRANSFORM, 0);
+            copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, invPlaneAlpha);
+            copybit->set_parameter(copybit, COPYBIT_DITHER, COPYBIT_ENABLE);
+            err = copybit->stretch(copybit,
+                    &dst, &tmpCbImg, &drect, &tmpCbRect, &it);
+        }
+    } else {
+        copybit->set_parameter(copybit, COPYBIT_TRANSFORM, transform);
+        copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, planeAlpha);
+        copybit->set_parameter(copybit, COPYBIT_DITHER,
+                (enables & GGL_ENABLE_DITHER) ?
+                        COPYBIT_ENABLE : COPYBIT_DISABLE);
+        clipRectRegion it(c);
+        err = copybit->stretch(copybit, &dst, &src, &drect, &srect, &it);
+    }
     if (err != NO_ERROR) {
         c->textures.tmu[0].texture->try_copybit = false;
     }
diff --git a/opengl/tests/linetex/Android.mk b/opengl/tests/linetex/Android.mk
new file mode 100644
index 0000000..6ff248d
--- /dev/null
+++ b/opengl/tests/linetex/Android.mk
@@ -0,0 +1,17 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+	linetex.cpp
+
+LOCAL_SHARED_LIBRARIES := \
+	libcutils \
+    libEGL \
+    libGLESv1_CM \
+    libui
+
+LOCAL_MODULE:= test-opengl-linetex
+
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_EXECUTABLE)
diff --git a/opengl/tests/linetex/linetex.cpp b/opengl/tests/linetex/linetex.cpp
new file mode 100644
index 0000000..e62fe03
--- /dev/null
+++ b/opengl/tests/linetex/linetex.cpp
@@ -0,0 +1,117 @@
+/*
+**
+** Copyright 2006, 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.
+*/
+
+#define LOG_TAG "fillrate"
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <EGL/egl.h>
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+
+#include <utils/StopWatch.h>
+#include <ui/FramebufferNativeWindow.h>
+#include <ui/EGLUtils.h>
+
+using namespace android;
+
+int main(int argc, char** argv)
+{
+    EGLint configAttribs[] = {
+         EGL_DEPTH_SIZE, 0,
+         EGL_NONE
+     };
+     
+     EGLint majorVersion;
+     EGLint minorVersion;
+     EGLContext context;
+     EGLConfig config;
+     EGLSurface surface;
+     EGLint w, h;
+     EGLDisplay dpy;
+
+     EGLNativeWindowType window = android_createDisplaySurface();
+     
+     dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+     eglInitialize(dpy, &majorVersion, &minorVersion);
+          
+     status_t err = EGLUtils::selectConfigForNativeWindow(
+             dpy, configAttribs, window, &config);
+     if (err) {
+         fprintf(stderr, "couldn't find an EGLConfig matching the screen format\n");
+         return 0;
+     }
+
+     surface = eglCreateWindowSurface(dpy, config, window, NULL);
+     context = eglCreateContext(dpy, config, NULL, NULL);
+     eglMakeCurrent(dpy, surface, surface, context);   
+     eglQuerySurface(dpy, surface, EGL_WIDTH, &w);
+     eglQuerySurface(dpy, surface, EGL_HEIGHT, &h);
+     
+     printf("w=%d, h=%d\n", w, h);
+     
+     glBindTexture(GL_TEXTURE_2D, 0);
+     glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+     glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+     glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+     glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+     glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+     glDisable(GL_DITHER);
+     glDisable(GL_BLEND);
+     glEnable(GL_TEXTURE_2D);
+     glColor4f(1,1,1,1);
+
+     const uint32_t t32[] = {
+             0xFFFFFFFF, 0xFF0000FF, 0xFF00FF00, 0xFFFF0000,
+             0xFFFFFF00, 0xFFFF00FF, 0xFF00FFFF, 0xFF000000
+     };
+
+     const GLfloat vertices[4][2] = {
+             { 0,  0 },
+             { w,  h }
+     };
+
+     const GLfloat texCoords[4][2] = {
+             { 0,  0 },
+             { 1,  0 }
+     };
+
+     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 8, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, t32);
+
+     glViewport(0, 0, w, h);
+     glMatrixMode(GL_PROJECTION);
+     glLoadIdentity();
+     glOrthof(0, w, 0, h, 0, 1);
+
+     glEnableClientState(GL_VERTEX_ARRAY);
+     glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+     glVertexPointer(2, GL_FLOAT, 0, vertices);
+     glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
+
+     glClearColor(0,0,0,0);
+     glClear(GL_COLOR_BUFFER_BIT);
+     glDrawArrays(GL_LINES, 0, 2);
+     eglSwapBuffers(dpy, surface);
+
+     usleep(5*1000000);
+
+     eglTerminate(dpy);
+     
+     return 0;
+}
diff --git a/packages/SubscribedFeedsProvider/res/values-nb/strings.xml b/packages/SubscribedFeedsProvider/res/values-nb/strings.xml
index 53bf3b57..30a2c5ea 100644
--- a/packages/SubscribedFeedsProvider/res/values-nb/strings.xml
+++ b/packages/SubscribedFeedsProvider/res/values-nb/strings.xml
@@ -15,6 +15,6 @@
 -->
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="app_label" msgid="5400580392303600842">"Synkroniser·innmatinger"</string>
+    <string name="app_label" msgid="5400580392303600842">"Strømsynkronisering"</string>
     <string name="provider_label" msgid="3669714991966737047">"Push-abonnementer"</string>
 </resources>
diff --git a/packages/VpnServices/res/values-nb/strings.xml b/packages/VpnServices/res/values-nb/strings.xml
index 506f999..9aac828 100644
--- a/packages/VpnServices/res/values-nb/strings.xml
+++ b/packages/VpnServices/res/values-nb/strings.xml
@@ -16,7 +16,7 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="app_label" msgid="4589592829302498102">"VPN-tjenester"</string>
-    <string name="vpn_notification_title_connected" msgid="8598654486956133580">"<xliff:g id="PROFILENAME">%s</xliff:g> er VPN-tilkoblet"</string>
-    <string name="vpn_notification_title_disconnected" msgid="6216572264382192027">"<xliff:g id="PROFILENAME">%s</xliff:g> er VPN-frakoblet"</string>
+    <string name="vpn_notification_title_connected" msgid="8598654486956133580">"Koblet til VPNet <xliff:g id="PROFILENAME">%s</xliff:g>"</string>
+    <string name="vpn_notification_title_disconnected" msgid="6216572264382192027">"Koblet fra VPNet <xliff:g id="PROFILENAME">%s</xliff:g>"</string>
     <string name="vpn_notification_hint_disconnected" msgid="1952209867082269429">"Trykk for å koble til et VPN på nytt"</string>
 </resources>
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java
index 5f30b3d..a83459e 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -6344,7 +6344,9 @@
                     continue;
                 }
                 for (PackageSetting pkg:sus.packages) {
-                    if (pkg.pkg.requestedPermissions.contains(eachPerm)) {
+                    if (pkg.pkg != null &&
+                            !pkg.pkg.packageName.equalsIgnoreCase(deletedPs.pkg.packageName) &&
+                            pkg.pkg.requestedPermissions.contains(eachPerm)) {
                         used = true;
                         break;
                     }
@@ -6359,7 +6361,9 @@
             int newGids[] = globalGids;
             for (String eachPerm : sus.grantedPermissions) {
                 BasePermission bp = mPermissions.get(eachPerm);
-                newGids = appendInts(newGids, bp.gids);
+                if (bp != null) {
+                    newGids = appendInts(newGids, bp.gids);
+                }
             }
             sus.gids = newGids;
         }
diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java
index 927c1b3..4bf606d 100644
--- a/services/java/com/android/server/PowerManagerService.java
+++ b/services/java/com/android/server/PowerManagerService.java
@@ -158,7 +158,6 @@
     private int mProximityCount = 0;
     private int mPowerState;
     private boolean mOffBecauseOfUser;
-    private boolean mAnimatingScreenOff;
     private int mUserState;
     private boolean mKeyboardVisible = false;
     private boolean mUserActivityAllowed = true;
@@ -1232,7 +1231,6 @@
                         Log.d(TAG,
                               "preventScreenOn: turning on after a prior preventScreenOn(true)!");
                     }
-                    mAnimatingScreenOff = false;
                     int err = setScreenStateLocked(true);
                     if (err != 0) {
                         Log.w(TAG, "preventScreenOn: error from setScreenStateLocked(): " + err);
@@ -1394,7 +1392,6 @@
                         reallyTurnScreenOn = false;
                     }
                     if (reallyTurnScreenOn) {
-                        mAnimatingScreenOff = false;
                         err = setScreenStateLocked(true);
                         long identity = Binder.clearCallingIdentity();
                         try {
@@ -1436,7 +1433,6 @@
                     if (!mScreenBrightness.animating) {
                         err = screenOffFinishedAnimatingLocked(becauseOfUser);
                     } else {
-                        mAnimatingScreenOff = true;
                         mOffBecauseOfUser = becauseOfUser;
                         err = 0;
                         mLastTouchDown = 0;
@@ -1454,7 +1450,6 @@
                 mTotalTouchDownTime, mTouchCycles);
         mLastTouchDown = 0;
         int err = setScreenStateLocked(false);
-        mAnimatingScreenOff = false;
         if (mScreenOnStartTime != 0) {
             mScreenOnTime += SystemClock.elapsedRealtime() - mScreenOnStartTime;
             mScreenOnStartTime = 0;
@@ -1827,9 +1822,6 @@
             return;
         }
 
-        if (mAnimatingScreenOff) {
-            return;
-        }
         if (false) {
             if (((mPokey & POKE_LOCK_IGNORE_CHEEK_EVENTS) != 0)) {
                 Log.d(TAG, "userActivity !!!");//, new RuntimeException());
@@ -1847,6 +1839,11 @@
                         + " mProximitySensorActive=" + mProximitySensorActive
                         + " force=" + force);
             }
+            // ignore user activity if we are in the process of turning off the screen
+            if (mScreenBrightness.animating && mScreenBrightness.targetValue == 0) {
+                Log.d(TAG, "ignoring user activity while turning off screen");
+                return;
+            }
             if (mLastEventTime <= time || force) {
                 mLastEventTime = time;
                 if ((mUserActivityAllowed && !mProximitySensorActive) || force) {
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index cd6a371..94667eb 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -9303,6 +9303,15 @@
                                     & WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER) != 0) {
                                 wallpaperMayChange = true;
                             }
+                            if (changed && !forceHiding
+                                    && (mCurrentFocus == null)
+                                    && (mFocusedApp != null)) {
+                                // It's possible that the last focus recalculation left no
+                                // current focused window even though the app has come to the
+                                // foreground already.  In this case, we make sure to recalculate
+                                // focus when we show a window.
+                                focusMayChange = true;
+                            }
                         }
                         
                         mPolicy.animatingWindowLw(w, attrs);
@@ -9644,7 +9653,8 @@
                             WindowState w = (WindowState)mWindows.get(i);
                             if (w.mSurface != null) {
                                 final WindowManager.LayoutParams attrs = w.mAttrs;
-                                if (mPolicy.doesForceHide(w, attrs)) {
+                                if (mPolicy.doesForceHide(w, attrs) && w.isVisibleLw()) {
+                                    if (DEBUG_FOCUS) Log.i(TAG, "win=" + w + " force hides other windows");
                                     forceHiding = true;
                                 } else if (mPolicy.canBeForceHidden(w, attrs)) {
                                     if (!w.mAnimating) {
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index ad1926e..56270f4 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -2705,13 +2705,31 @@
 
             // Have the window manager re-evaluate the orientation of
             // the screen based on the new activity order.
-            Configuration config = mWindowManager.updateOrientationFromAppTokens(
-                    mConfiguration,
-                    next.mayFreezeScreenLocked(next.app) ? next : null);
-            if (config != null) {
-                next.frozenBeforeDestroy = true;
+            boolean updated;
+            synchronized (this) {
+                Configuration config = mWindowManager.updateOrientationFromAppTokens(
+                        mConfiguration,
+                        next.mayFreezeScreenLocked(next.app) ? next : null);
+                if (config != null) {
+                    /*
+                     * Explicitly restore the locale to the one from the
+                     * old configuration, since the one that comes back from
+                     * the window manager has the default (boot) locale.
+                     *
+                     * It looks like previously the locale picker only worked
+                     * by coincidence: usually it would do its setting of
+                     * the locale after the activity transition, so it didn't
+                     * matter that this lost it.  With the synchronized
+                     * block now keeping them from happening at the same time,
+                     * this one always would happen second and undo what the
+                     * locale picker had just done.
+                     */
+                    config.locale = mConfiguration.locale;
+                    next.frozenBeforeDestroy = true;
+                }
+                updated = updateConfigurationLocked(config, next);
             }
-            if (!updateConfigurationLocked(config, next)) {
+            if (!updated) {
                 // The configuration update wasn't able to keep the existing
                 // instance of the activity, and instead started a new one.
                 // We should be all done, but let's just make sure our activity