Merge "Import translations. DO NOT MERGE" into jb-dev
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index 2782dca..e8f87bb 100644
--- a/core/java/android/provider/ContactsContract.java
+++ b/core/java/android/provider/ContactsContract.java
@@ -24,6 +24,7 @@
 import android.content.ContentUris;
 import android.content.ContentValues;
 import android.content.Context;
+import android.content.ContextWrapper;
 import android.content.CursorEntityIterator;
 import android.content.Entity;
 import android.content.EntityIterator;
@@ -7711,9 +7712,19 @@
          */
         public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode,
                 String[] excludeMimes) {
+            // When launching from an Activiy, we don't want to start a new task, but otherwise
+            // we *must* start a new task.  (Otherwise startActivity() would crash.)
+            Context actualContext = context;
+            while ((actualContext instanceof ContextWrapper)
+                    && !(actualContext instanceof Activity)) {
+                actualContext = ((ContextWrapper) actualContext).getBaseContext();
+            }
+            final int intentFlags = (actualContext instanceof Activity)
+                    ? Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
+                    : Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK;
+
             // Launch pivot dialog through intent for now
-            final Intent intent = new Intent(ACTION_QUICK_CONTACT)
-                    .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
+            final Intent intent = new Intent(ACTION_QUICK_CONTACT).addFlags(intentFlags);
 
             intent.setData(lookupUri);
             intent.setSourceBounds(target);
diff --git a/core/java/android/view/VolumePanel.java b/core/java/android/view/VolumePanel.java
index 78984e0..5ffc2c3 100644
--- a/core/java/android/view/VolumePanel.java
+++ b/core/java/android/view/VolumePanel.java
@@ -437,8 +437,10 @@
 
     public void postVolumeChanged(int streamType, int flags) {
         if (hasMessages(MSG_VOLUME_CHANGED)) return;
-        if (mStreamControls == null) {
-            createSliders();
+        synchronized (this) {
+            if (mStreamControls == null) {
+                createSliders();
+            }
         }
         removeMessages(MSG_FREE_RESOURCES);
         obtainMessage(MSG_VOLUME_CHANGED, streamType, flags).sendToTarget();
@@ -450,8 +452,10 @@
 
     public void postMuteChanged(int streamType, int flags) {
         if (hasMessages(MSG_VOLUME_CHANGED)) return;
-        if (mStreamControls == null) {
-            createSliders();
+        synchronized (this) {
+            if (mStreamControls == null) {
+                createSliders();
+            }
         }
         removeMessages(MSG_FREE_RESOURCES);
         obtainMessage(MSG_MUTE_CHANGED, streamType, flags).sendToTarget();
@@ -471,10 +475,12 @@
         if (LOGD) Log.d(TAG, "onVolumeChanged(streamType: " + streamType + ", flags: " + flags + ")");
 
         if ((flags & AudioManager.FLAG_SHOW_UI) != 0) {
-            if (mActiveStreamType != streamType) {
-                reorderSliders(streamType);
+            synchronized (this) {
+                if (mActiveStreamType != streamType) {
+                    reorderSliders(streamType);
+                }
+                onShowVolumeChanged(streamType, flags);
             }
-            onShowVolumeChanged(streamType, flags);
         }
 
         if ((flags & AudioManager.FLAG_PLAY_SOUND) != 0 && ! mRingIsSilent) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 3a50560..ecdaa39 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -484,14 +484,7 @@
 
     @Override
     public void showSearchPanel() {
-        // XXX This is a bit of a hack.  Since navbar is no longer slippery, we use the
-        // gesture to dismiss the expanded statusbar.
-        if (mExpanded) {
-            animateCollapse();
-            return;
-        } else {
-            super.showSearchPanel();
-        }
+        super.showSearchPanel();
         WindowManager.LayoutParams lp =
             (android.view.WindowManager.LayoutParams) mNavigationBarView.getLayoutParams();
         lp.flags &= ~WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
@@ -1044,6 +1037,7 @@
 
         mExpandedVisible = true;
         mNotificationPanel.setVisibility(View.VISIBLE);
+        makeSlippery(mNavigationBarView, true);
 
         updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
 
@@ -1059,6 +1053,16 @@
         visibilityChanged(true);
     }
 
+    private static void makeSlippery(View view, boolean slippery) {
+        WindowManager.LayoutParams lp = (WindowManager.LayoutParams) view.getLayoutParams();
+        if (slippery) {
+            lp.flags |= WindowManager.LayoutParams.FLAG_SLIPPERY;
+        } else {
+            lp.flags &= ~WindowManager.LayoutParams.FLAG_SLIPPERY;
+        }
+        WindowManagerImpl.getDefault().updateViewLayout(view, lp);
+    }
+
     public void animateExpand() {
         if (SPEW) Slog.d(TAG, "Animate expand: expanded=" + mExpanded);
         if ((mDisabled & StatusBarManager.DISABLE_EXPAND) != 0) {
@@ -1144,6 +1148,7 @@
         mExpandedVisible = false;
         visibilityChanged(false);
         mNotificationPanel.setVisibility(View.INVISIBLE);
+        makeSlippery(mNavigationBarView, false);
 
         // Shrink the window to the size of the status bar only
         WindowManager.LayoutParams lp = (WindowManager.LayoutParams) mStatusBarWindow.getLayoutParams();
diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java
index 38e08ae..469b4f1 100644
--- a/services/java/com/android/server/PowerManagerService.java
+++ b/services/java/com/android/server/PowerManagerService.java
@@ -2242,7 +2242,9 @@
                     } else {
                         newValue = endValue;
                         mHighestLightSensorValue = endSensorValue;
-                        mInitialAnimation = false;
+                        if (endValue > 0) {
+                            mInitialAnimation = false;
+                        }
                     }
 
                     if (mDebugLightAnimation) {
@@ -2290,7 +2292,7 @@
                 currentMask = mask;
                 duration = (int) (mWindowScaleAnimation * animationDuration);
                 startTimeMillis = SystemClock.elapsedRealtime();
-                mInitialAnimation = currentValue == 0 && target > 0;
+                mInitialAnimation = mInitialAnimation && target > 0;
 
                 if (mDebugLightAnimation) {
                     Slog.v(TAG, "animateTo(target=" + target
@@ -2608,7 +2610,8 @@
         }
     };
 
-    private boolean mInitialAnimation; // used to prevent lightsensor changes while turning on
+    /** used to prevent lightsensor changes while turning on. */
+    private boolean mInitialAnimation = true;
 
     private void dockStateChanged(int state) {
         synchronized (mLocks) {
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index 10919f2..efbf0d4 100755
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -5437,8 +5437,8 @@
                 // window.
                 including = !ws.mIsImWindow && !ws.isFullscreen(dw, dh);
 
-                if (maxLayer < ws.mWinAnimator.mAnimLayer) {
-                    maxLayer = ws.mWinAnimator.mAnimLayer;
+                if (maxLayer < ws.mWinAnimator.mSurfaceLayer) {
+                    maxLayer = ws.mWinAnimator.mSurfaceLayer;
                 }
                 
                 // Don't include wallpaper in bounds calculation
diff --git a/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java b/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java
index 5220d04..1a42f93 100644
--- a/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java
@@ -263,12 +263,19 @@
                 Context.CONNECTIVITY_SERVICE);
         sWifiOnly = (cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE) == false);
 
-        // Disable for wifi only devices.
-        if (Settings.Secure.getString(contentResolver, Settings.Secure.WIFI_WATCHDOG_ON) == null
-                && sWifiOnly) {
-            log("Disabling watchog for wi-fi only device");
-            putSettingsBoolean(contentResolver, Settings.Secure.WIFI_WATCHDOG_ON, false);
+        // Watchdog is always enabled. Poor network detection & walled garden detection
+        // can individually be turned on/off
+        // TODO: Remove this setting & clean up state machine since we always have
+        // watchdog in an enabled state
+        putSettingsBoolean(contentResolver, Settings.Secure.WIFI_WATCHDOG_ON, true);
+
+        // Disable poor network avoidance, but keep watchdog active for walled garden detection
+        if (sWifiOnly) {
+            log("Disabling poor network avoidance for wi-fi only device");
+            putSettingsBoolean(contentResolver,
+                    Settings.Secure.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED, false);
         }
+
         WifiWatchdogStateMachine wwsm = new WifiWatchdogStateMachine(context);
         wwsm.start();
         return wwsm;