Merge "Clean up and bug fixes in the TouchExplorer."
diff --git a/core/java/android/preference/DialogPreference.java b/core/java/android/preference/DialogPreference.java
index 73427d2..c59ed18 100644
--- a/core/java/android/preference/DialogPreference.java
+++ b/core/java/android/preference/DialogPreference.java
@@ -321,8 +321,7 @@
      */
     private void requestInputMethod(Dialog dialog) {
         Window window = dialog.getWindow();
-        window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE |
-                WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
+        window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
     }
 
     /**
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index 86f061a..80cbbfb 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -1574,8 +1574,17 @@
 
         ss.inActionMode = mChoiceMode == CHOICE_MODE_MULTIPLE_MODAL && mChoiceActionMode != null;
 
-        ss.checkState = mCheckStates;
-        ss.checkIdState = mCheckedIdStates;
+        if (mCheckStates != null) {
+            ss.checkState = mCheckStates.clone();
+        }
+        if (mCheckedIdStates != null) {
+            final LongSparseArray<Boolean> idState = new LongSparseArray<Boolean>();
+            final int count = mCheckedIdStates.size();
+            for (int i = 0; i < count; i++) {
+                idState.put(mCheckedIdStates.keyAt(i), mCheckedIdStates.valueAt(i));
+            }
+            ss.checkIdState = idState;
+        }
         ss.checkedItemCount = mCheckedItemCount;
 
         return ss;
diff --git a/core/java/com/android/internal/widget/AbsActionBarView.java b/core/java/com/android/internal/widget/AbsActionBarView.java
index ccbce3e..df2f717 100644
--- a/core/java/com/android/internal/widget/AbsActionBarView.java
+++ b/core/java/com/android/internal/widget/AbsActionBarView.java
@@ -56,6 +56,16 @@
         mSplitView = splitView;
     }
 
+    /**
+     * @return Current visibility or if animating, the visibility being animated to.
+     */
+    public int getAnimatedVisibility() {
+        if (mVisibilityAnim != null) {
+            return mVisAnimListener.mFinalVisibility;
+        }
+        return getVisibility();
+    }
+
     public void animateToVisibility(int visibility) {
         if (mVisibilityAnim != null) {
             mVisibilityAnim.cancel();
@@ -179,7 +189,7 @@
 
     protected class VisibilityAnimListener implements Animator.AnimatorListener {
         private boolean mCanceled = false;
-        private int mFinalVisibility;
+        int mFinalVisibility;
 
         public VisibilityAnimListener withFinalVisibility(int visibility) {
             mFinalVisibility = visibility;
@@ -199,6 +209,9 @@
 
             mVisibilityAnim = null;
             setVisibility(mFinalVisibility);
+            if (mSplitView != null && mMenuView != null) {
+                mMenuView.setVisibility(mFinalVisibility);
+            }
         }
 
         @Override
diff --git a/core/java/com/android/internal/widget/ActionBarContextView.java b/core/java/com/android/internal/widget/ActionBarContextView.java
index 45d38ae..4fccc32 100644
--- a/core/java/com/android/internal/widget/ActionBarContextView.java
+++ b/core/java/com/android/internal/widget/ActionBarContextView.java
@@ -33,6 +33,7 @@
 import android.view.ActionMode;
 import android.view.LayoutInflater;
 import android.view.View;
+import android.view.ViewGroup;
 import android.view.animation.DecelerateInterpolator;
 import android.widget.LinearLayout;
 import android.widget.TextView;
@@ -270,14 +271,14 @@
     }
 
     @Override
-    protected LayoutParams generateDefaultLayoutParams() {
+    protected ViewGroup.LayoutParams generateDefaultLayoutParams() {
         // Used by custom views if they don't supply layout params. Everything else
         // added to an ActionBarContextView should have them already.
         return new MarginLayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
     }
 
     @Override
-    public LayoutParams generateLayoutParams(AttributeSet attrs) {
+    public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) {
         return new MarginLayoutParams(getContext(), attrs);
     }
 
@@ -321,7 +322,7 @@
         }
 
         if (mCustomView != null) {
-            LayoutParams lp = mCustomView.getLayoutParams();
+            ViewGroup.LayoutParams lp = mCustomView.getLayoutParams();
             final int customWidthMode = lp.width != LayoutParams.WRAP_CONTENT ?
                     MeasureSpec.EXACTLY : MeasureSpec.AT_MOST;
             final int customWidth = lp.width >= 0 ?
diff --git a/core/java/com/android/internal/widget/ActionBarView.java b/core/java/com/android/internal/widget/ActionBarView.java
index a0f6259..ff26d50 100644
--- a/core/java/com/android/internal/widget/ActionBarView.java
+++ b/core/java/com/android/internal/widget/ActionBarView.java
@@ -401,6 +401,7 @@
                 if (oldParent != null && oldParent != mSplitView) {
                     oldParent.removeView(menuView);
                 }
+                menuView.setVisibility(getAnimatedVisibility());
                 mSplitView.addView(menuView, layoutParams);
             } else {
                 // We'll add this later if we missed it this time.
@@ -683,7 +684,7 @@
     }
 
     @Override
-    protected LayoutParams generateDefaultLayoutParams() {
+    protected ViewGroup.LayoutParams generateDefaultLayoutParams() {
         // Used by custom nav views if they don't supply layout params. Everything else
         // added to an ActionBarView should have them already.
         return new ActionBar.LayoutParams(DEFAULT_CUSTOM_GRAVITY);
@@ -810,7 +811,7 @@
         HomeView homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout;
 
         if (homeLayout.getVisibility() != GONE) {
-            final LayoutParams lp = homeLayout.getLayoutParams();
+            final ViewGroup.LayoutParams lp = homeLayout.getLayoutParams();
             int homeWidthSpec;
             if (lp.width < 0) {
                 homeWidthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST);
@@ -881,7 +882,7 @@
         }
 
         if (customView != null) {
-            final LayoutParams lp = generateLayoutParams(customView.getLayoutParams());
+            final ViewGroup.LayoutParams lp = generateLayoutParams(customView.getLayoutParams());
             final ActionBar.LayoutParams ablp = lp instanceof ActionBar.LayoutParams ?
                     (ActionBar.LayoutParams) lp : null;
 
@@ -1017,7 +1018,7 @@
             customView = mCustomNavView;
         }
         if (customView != null) {
-            LayoutParams lp = customView.getLayoutParams();
+            ViewGroup.LayoutParams lp = customView.getLayoutParams();
             final ActionBar.LayoutParams ablp = lp instanceof ActionBar.LayoutParams ?
                     (ActionBar.LayoutParams) lp : null;
 
@@ -1095,12 +1096,12 @@
     }
 
     @Override
-    public LayoutParams generateLayoutParams(AttributeSet attrs) {
+    public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) {
         return new ActionBar.LayoutParams(getContext(), attrs);
     }
 
     @Override
-    public LayoutParams generateLayoutParams(LayoutParams lp) {
+    public ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) {
         if (lp == null) {
             lp = generateDefaultLayoutParams();
         }
diff --git a/core/res/res/drawable-hdpi/menu_hardkey_panel_holo_dark.9.png b/core/res/res/drawable-hdpi/menu_hardkey_panel_holo_dark.9.png
new file mode 100644
index 0000000..53871a05
--- /dev/null
+++ b/core/res/res/drawable-hdpi/menu_hardkey_panel_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/menu_hardkey_panel_holo_light.9.png b/core/res/res/drawable-hdpi/menu_hardkey_panel_holo_light.9.png
new file mode 100644
index 0000000..e3a0313
--- /dev/null
+++ b/core/res/res/drawable-hdpi/menu_hardkey_panel_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/text_select_handle_left.png b/core/res/res/drawable-hdpi/text_select_handle_left.png
index 82cb640..e980857 100644
--- a/core/res/res/drawable-hdpi/text_select_handle_left.png
+++ b/core/res/res/drawable-hdpi/text_select_handle_left.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/text_select_handle_middle.png b/core/res/res/drawable-hdpi/text_select_handle_middle.png
index a2a909a..603f497 100644
--- a/core/res/res/drawable-hdpi/text_select_handle_middle.png
+++ b/core/res/res/drawable-hdpi/text_select_handle_middle.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/text_select_handle_right.png b/core/res/res/drawable-hdpi/text_select_handle_right.png
index 31f1c03..a5efe30 100644
--- a/core/res/res/drawable-hdpi/text_select_handle_right.png
+++ b/core/res/res/drawable-hdpi/text_select_handle_right.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/menu_hardkey_panel_holo_dark.9.png b/core/res/res/drawable-mdpi/menu_hardkey_panel_holo_dark.9.png
new file mode 100644
index 0000000..9d80b77
--- /dev/null
+++ b/core/res/res/drawable-mdpi/menu_hardkey_panel_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/menu_hardkey_panel_holo_light.9.png b/core/res/res/drawable-mdpi/menu_hardkey_panel_holo_light.9.png
new file mode 100644
index 0000000..efa4325
--- /dev/null
+++ b/core/res/res/drawable-mdpi/menu_hardkey_panel_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/text_select_handle_left.png b/core/res/res/drawable-mdpi/text_select_handle_left.png
index d2cb710..0c3a0cc 100644
--- a/core/res/res/drawable-mdpi/text_select_handle_left.png
+++ b/core/res/res/drawable-mdpi/text_select_handle_left.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/text_select_handle_middle.png b/core/res/res/drawable-mdpi/text_select_handle_middle.png
index db70e5a..f488bdd 100644
--- a/core/res/res/drawable-mdpi/text_select_handle_middle.png
+++ b/core/res/res/drawable-mdpi/text_select_handle_middle.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/text_select_handle_right.png b/core/res/res/drawable-mdpi/text_select_handle_right.png
index be3d6ea..d3880c6 100644
--- a/core/res/res/drawable-mdpi/text_select_handle_right.png
+++ b/core/res/res/drawable-mdpi/text_select_handle_right.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/menu_hardkey_panel_holo_dark.9.png b/core/res/res/drawable-xhdpi/menu_hardkey_panel_holo_dark.9.png
new file mode 100644
index 0000000..521e2d9
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/menu_hardkey_panel_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/menu_hardkey_panel_holo_light.9.png b/core/res/res/drawable-xhdpi/menu_hardkey_panel_holo_light.9.png
new file mode 100644
index 0000000..92e117d
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/menu_hardkey_panel_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/text_select_handle_left.png b/core/res/res/drawable-xhdpi/text_select_handle_left.png
index 6a10560..5fcbc52 100644
--- a/core/res/res/drawable-xhdpi/text_select_handle_left.png
+++ b/core/res/res/drawable-xhdpi/text_select_handle_left.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/text_select_handle_middle.png b/core/res/res/drawable-xhdpi/text_select_handle_middle.png
index 71aaa85..05c2ca7 100644
--- a/core/res/res/drawable-xhdpi/text_select_handle_middle.png
+++ b/core/res/res/drawable-xhdpi/text_select_handle_middle.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/text_select_handle_right.png b/core/res/res/drawable-xhdpi/text_select_handle_right.png
index 5339adc..ebf97c4 100644
--- a/core/res/res/drawable-xhdpi/text_select_handle_right.png
+++ b/core/res/res/drawable-xhdpi/text_select_handle_right.png
Binary files differ
diff --git a/core/res/res/values/arrays.xml b/core/res/res/values/arrays.xml
index 04e510b..57e9bbf 100644
--- a/core/res/res/values/arrays.xml
+++ b/core/res/res/values/arrays.xml
@@ -163,6 +163,8 @@
        <item>@drawable/list_selector_holo_light</item>
        <item>@drawable/menu_background</item>
        <item>@drawable/menu_background_fill_parent_width</item>
+       <item>@drawable/menu_hardkey_panel_holo_dark</item>
+       <item>@drawable/menu_hardkey_panel_holo_light</item>
        <item>@drawable/menu_submenu_background</item>
        <item>@drawable/menu_selector</item>
        <item>@drawable/overscroll_edge</item>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index a3e460e..8e0f300 100755
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -1789,7 +1789,7 @@
 
     <!-- When the lock screen is showing and the phone plugged in, and the battery
          is not fully charged, show the current charge %.  -->
-    <string name="lockscreen_plugged_in">Charging (<xliff:g id="number">%d</xliff:g><xliff:g id="percent">%%</xliff:g>)</string>
+    <string name="lockscreen_plugged_in">Charging, <xliff:g id="number">%d</xliff:g><xliff:g id="percent">%%</xliff:g></string>
     <!-- When the lock screen is showing, the phone is plugged in and the battery is fully
          charged, say that it is charged. -->
     <string name="lockscreen_charged">Charged.</string>
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index 903fc04..f8866f2 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -980,7 +980,7 @@
         <item name="toastFrameBackground">@android:drawable/toast_frame_holo</item>
         
         <!-- Panel attributes -->
-        <item name="panelBackground">@android:drawable/menu_dropdown_panel_holo_dark</item>
+        <item name="panelBackground">@android:drawable/menu_hardkey_panel_holo_dark</item>
         <item name="panelFullBackground">@android:drawable/menu_background_fill_parent_width</item>
         <!-- These three attributes do not seems to be used by the framework. Declared public though -->
         <item name="panelColorBackground">#000</item>
@@ -1283,7 +1283,7 @@
         <item name="toastFrameBackground">@android:drawable/toast_frame_holo</item>
         
         <!-- Panel attributes -->
-        <item name="panelBackground">@android:drawable/menu_dropdown_panel_holo_light</item>
+        <item name="panelBackground">@android:drawable/menu_hardkey_panel_holo_light</item>
         <item name="panelFullBackground">@android:drawable/menu_background_fill_parent_width</item>
         <!-- These three attributes do not seems to be used by the framework. Declared public though -->
         <item name="panelColorBackground">#000</item>
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index a5c9053..dbe4115 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -3084,7 +3084,7 @@
                 mRcDisplay.setCurrentClientId(
                         newClientGeneration, newClientEventReceiver, clearing);
             } catch (RemoteException e) {
-                Log.e(TAG, "Dead display in onRcDisplayUpdate() "+e);
+                Log.e(TAG, "Dead display in setNewRcClientOnDisplays_syncRcsCurrc() "+e);
                 // if we had a display before, stop monitoring its death
                 rcDisplay_stopDeathMonitor_syncRcStack();
                 mRcDisplay = null;
@@ -3103,7 +3103,7 @@
                 try {
                     se.mRcClient.setCurrentClientGenerationId(newClientGeneration);
                 } catch (RemoteException e) {
-                    Log.w(TAG, "Dead client in onRcDisplayUpdate()"+e);
+                    Log.w(TAG, "Dead client in setNewRcClientGenerationOnClients_syncRcsCurrc()"+e);
                     stackIterator.remove();
                     se.unlinkToRcClientDeath();
                 }
@@ -3160,7 +3160,7 @@
                             rcse.mReceiverComponent /*event receiver*/,
                             false /*clearing*/);
 
-                    // ask the current client that it needs to send info
+                    // tell the current client that it needs to send info
                     try {
                         mCurrentRcClient.onInformationRequested(mCurrentRcClientGen,
                                 flags, mArtworkExpectedWidth, mArtworkExpectedHeight);
@@ -3457,6 +3457,21 @@
                     }
                 }
             }
+
+            // we have a new display, tell the current client that it needs to send info
+            // (following lock order: mRCStack then mCurrentRcLock)
+            synchronized(mCurrentRcLock) {
+                if (mCurrentRcClient != null) {
+                    // tell the current client that it needs to send info
+                    try {
+                        mCurrentRcClient.onInformationRequested(mCurrentRcClientGen,
+                                RC_INFO_ALL, mArtworkExpectedWidth, mArtworkExpectedHeight);
+                    } catch (RemoteException e) {
+                        Log.e(TAG, "Current valid remote client is dead: "+e);
+                        mCurrentRcClient = null;
+                    }
+                }
+            }
         }
     }
 
diff --git a/media/java/android/media/RemoteControlClient.java b/media/java/android/media/RemoteControlClient.java
index 2bdd3c9..d59bc2b 100644
--- a/media/java/android/media/RemoteControlClient.java
+++ b/media/java/android/media/RemoteControlClient.java
@@ -703,7 +703,7 @@
 
     private void onUnplugDisplay(IRemoteControlDisplay rcd) {
         synchronized(mCacheLock) {
-            if ((mRcDisplay != null) && (mRcDisplay.equals(rcd))) {
+            if ((mRcDisplay != null) && (mRcDisplay.asBinder().equals(rcd.asBinder()))) {
                 mRcDisplay = null;
                 mArtworkExpectedWidth = ARTWORK_DEFAULT_SIZE;
                 mArtworkExpectedHeight = ARTWORK_DEFAULT_SIZE;
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
index 7fb141a..1f08a91 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
@@ -316,9 +316,11 @@
                                 &cropLeft, &cropTop, &cropRight, &cropBottom));
 
                     LOGV("Video output format changed to %d x %d "
-                         "(crop: %d, %d, %d, %d)",
+                         "(crop: %d x %d @ (%d, %d))",
                          width, height,
-                         cropLeft, cropTop, cropRight, cropBottom);
+                         (cropRight - cropLeft + 1),
+                         (cropBottom - cropTop + 1),
+                         cropLeft, cropTop);
 
                     notifyListener(
                             MEDIA_SET_VIDEO_SIZE,
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
index 35ed43f..8f213da 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
@@ -395,29 +395,40 @@
         postDrainVideoQueue();
     }
 
-    if (mSyncQueues && !mAudioQueue.empty() && !mVideoQueue.empty()) {
-        int64_t firstAudioTimeUs;
-        int64_t firstVideoTimeUs;
-        CHECK((*mAudioQueue.begin()).mBuffer->meta()
-                ->findInt64("timeUs", &firstAudioTimeUs));
-        CHECK((*mVideoQueue.begin()).mBuffer->meta()
-                ->findInt64("timeUs", &firstVideoTimeUs));
-
-        int64_t diff = firstVideoTimeUs - firstAudioTimeUs;
-
-        LOGV("queueDiff = %.2f secs", diff / 1E6);
-
-        if (diff > 100000ll) {
-            // Audio data starts More than 0.1 secs before video.
-            // Drop some audio.
-
-            (*mAudioQueue.begin()).mNotifyConsumed->post();
-            mAudioQueue.erase(mAudioQueue.begin());
-            return;
-        }
-
-        syncQueuesDone();
+    if (!mSyncQueues || mAudioQueue.empty() || mVideoQueue.empty()) {
+        return;
     }
+
+    sp<ABuffer> firstAudioBuffer = (*mAudioQueue.begin()).mBuffer;
+    sp<ABuffer> firstVideoBuffer = (*mVideoQueue.begin()).mBuffer;
+
+    if (firstAudioBuffer == NULL || firstVideoBuffer == NULL) {
+        // EOS signalled on either queue.
+        syncQueuesDone();
+        return;
+    }
+
+    int64_t firstAudioTimeUs;
+    int64_t firstVideoTimeUs;
+    CHECK(firstAudioBuffer->meta()
+            ->findInt64("timeUs", &firstAudioTimeUs));
+    CHECK(firstVideoBuffer->meta()
+            ->findInt64("timeUs", &firstVideoTimeUs));
+
+    int64_t diff = firstVideoTimeUs - firstAudioTimeUs;
+
+    LOGV("queueDiff = %.2f secs", diff / 1E6);
+
+    if (diff > 100000ll) {
+        // Audio data starts More than 0.1 secs before video.
+        // Drop some audio.
+
+        (*mAudioQueue.begin()).mNotifyConsumed->post();
+        mAudioQueue.erase(mAudioQueue.begin());
+        return;
+    }
+
+    syncQueuesDone();
 }
 
 void NuPlayer::Renderer::syncQueuesDone() {
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index 5d91f6a..e9dc61c 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -1738,7 +1738,17 @@
 void ACodec::LoadedToIdleState::stateEntered() {
     LOGV("[%s] Now Loaded->Idle", mCodec->mComponentName.c_str());
 
-    CHECK_EQ(allocateBuffers(), (status_t)OK);
+    status_t err;
+    if ((err = allocateBuffers()) != OK) {
+        LOGE("Failed to allocate buffers after transitioning to IDLE state "
+             "(error 0x%08x)",
+             err);
+
+        sp<AMessage> notify = mCodec->mNotify->dup();
+        notify->setInt32("what", ACodec::kWhatError);
+        notify->setInt32("omx-error", OMX_ErrorUndefined);
+        notify->post();
+    }
 }
 
 status_t ACodec::LoadedToIdleState::allocateBuffers() {
@@ -2046,8 +2056,18 @@
                             mCodec->mNode, OMX_CommandPortEnable, kPortIndexOutput),
                          (status_t)OK);
 
-                CHECK_EQ(mCodec->allocateBuffersOnPort(kPortIndexOutput),
-                         (status_t)OK);
+                status_t err;
+                if ((err = mCodec->allocateBuffersOnPort(
+                                kPortIndexOutput)) != OK) {
+                    LOGE("Failed to allocate output port buffers after "
+                         "port reconfiguration (error 0x%08x)",
+                         err);
+
+                    sp<AMessage> notify = mCodec->mNotify->dup();
+                    notify->setInt32("what", ACodec::kWhatError);
+                    notify->setInt32("omx-error", OMX_ErrorUndefined);
+                    notify->post();
+                }
 
                 return true;
             } else if (data1 == (OMX_U32)OMX_CommandPortEnable) {
diff --git a/media/libstagefright/SurfaceMediaSource.cpp b/media/libstagefright/SurfaceMediaSource.cpp
index c2e6707..91b81c2 100644
--- a/media/libstagefright/SurfaceMediaSource.cpp
+++ b/media/libstagefright/SurfaceMediaSource.cpp
@@ -179,9 +179,11 @@
     // TODO: Currently just uses mDefaultWidth/Height. In the future
     // we might declare mHeight and mWidth and check against those here.
     if ((w != 0) || (h != 0)) {
-        LOGE("dequeuebuffer: invalid buffer size! Req: %dx%d, Found: %dx%d",
-                mDefaultWidth, mDefaultHeight, w, h);
-        return BAD_VALUE;
+        if ((w != mDefaultWidth) || (h != mDefaultHeight)) {
+            LOGE("dequeuebuffer: invalid buffer size! Req: %dx%d, Found: %dx%d",
+                    mDefaultWidth, mDefaultHeight, w, h);
+            return BAD_VALUE;
+        }
     }
 
     status_t returnFlags(OK);
diff --git a/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java b/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java
index ee0a6e9..ce3bc74 100644
--- a/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java
@@ -165,7 +165,7 @@
         View switchImeButton = findViewById(R.id.switch_ime_button);
         final InputMethodManager imm = (InputMethodManager) getContext().getSystemService(
                 Context.INPUT_METHOD_SERVICE);
-        if (switchImeButton != null && hasMultipleEnabledIMEsOrSubtypes(imm, false)) {
+        if (mIsAlpha && switchImeButton != null && hasMultipleEnabledIMEsOrSubtypes(imm, false)) {
             switchImeButton.setVisibility(View.VISIBLE);
             switchImeButton.setOnClickListener(new OnClickListener() {
                 public void onClick(View v) {
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index e258b1a..192d32b 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -5291,24 +5291,24 @@
                     case Surface.ROTATION_0:
                         return Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
                     case Surface.ROTATION_90:
-                        return Gravity.RIGHT | Gravity.CENTER_VERTICAL;
+                        return Gravity.RIGHT | Gravity.BOTTOM;
                     case Surface.ROTATION_180:
-                        return Gravity.CENTER_HORIZONTAL | Gravity.TOP;
+                        return Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
                     case Surface.ROTATION_270:
-                        return Gravity.LEFT | Gravity.CENTER_VERTICAL;
+                        return Gravity.LEFT | Gravity.BOTTOM;
                 }
             } else {
                 // On devices with a natural orientation of landscape
                 switch (rotation) {
                     default:
                     case Surface.ROTATION_0:
-                        return Gravity.RIGHT | Gravity.CENTER_VERTICAL;
+                        return Gravity.RIGHT | Gravity.BOTTOM;
                     case Surface.ROTATION_90:
                         return Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
                     case Surface.ROTATION_180:
-                        return Gravity.LEFT | Gravity.CENTER_VERTICAL;
+                        return Gravity.LEFT | Gravity.BOTTOM;
                     case Surface.ROTATION_270:
-                        return Gravity.CENTER_HORIZONTAL | Gravity.TOP;
+                        return Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
                 }
             }
         }