Merge "Get the MCC/MNC using defaults." into lmp-sprout-dev
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index e3cbef5..2e24785 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -1970,9 +1970,9 @@
      * {@hide}
      */
     public void setProvisioningNotificationVisible(boolean visible, int networkType,
-            String extraInfo, String url) {
+            String action) {
         try {
-            mService.setProvisioningNotificationVisible(visible, networkType, extraInfo, url);
+            mService.setProvisioningNotificationVisible(visible, networkType, action);
         } catch (RemoteException e) {
         }
     }
diff --git a/core/java/android/net/IConnectivityManager.aidl b/core/java/android/net/IConnectivityManager.aidl
index 974c4cd..a983d88 100644
--- a/core/java/android/net/IConnectivityManager.aidl
+++ b/core/java/android/net/IConnectivityManager.aidl
@@ -139,8 +139,7 @@
 
     LinkQualityInfo[] getAllLinkQualityInfo();
 
-    void setProvisioningNotificationVisible(boolean visible, int networkType, in String extraInfo,
-            in String url);
+    void setProvisioningNotificationVisible(boolean visible, int networkType, in String action);
 
     void setAirplaneMode(boolean enable);
 
diff --git a/core/java/android/service/dreams/DreamService.java b/core/java/android/service/dreams/DreamService.java
index 92647f0..38b043971 100644
--- a/core/java/android/service/dreams/DreamService.java
+++ b/core/java/android/service/dreams/DreamService.java
@@ -967,6 +967,9 @@
                         | (mScreenBright ? WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON : 0)
                         );
             mWindow.setAttributes(lp);
+            // Workaround: Currently low-profile and in-window system bar backgrounds don't go
+            // along well. Dreams usually don't need such bars anyways, so disable them by default.
+            mWindow.clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
             mWindow.setWindowManager(null, windowToken, "dream", true);
 
             applySystemUiVisibilityFlags(
diff --git a/core/res/res/drawable/list_divider_material.xml b/core/res/res/drawable/list_divider_material.xml
index 7ff212a..babb646 100644
--- a/core/res/res/drawable/list_divider_material.xml
+++ b/core/res/res/drawable/list_divider_material.xml
@@ -17,4 +17,4 @@
 <nine-patch xmlns:android="http://schemas.android.com/apk/res/android"
     android:src="@drawable/list_divider_mtrl_alpha"
     android:tint="?attr/colorForeground"
-    android:alpha="0.16" />
+    android:alpha="0.12" />
diff --git a/core/res/res/drawable/list_section_divider_material.xml b/core/res/res/drawable/list_section_divider_material.xml
index 515634e..f44c3f2 100644
--- a/core/res/res/drawable/list_section_divider_material.xml
+++ b/core/res/res/drawable/list_section_divider_material.xml
@@ -16,4 +16,5 @@
 
 <nine-patch xmlns:android="http://schemas.android.com/apk/res/android"
     android:src="@drawable/list_section_divider_mtrl_alpha"
-    android:tint="?attr/colorControlNormal" />
+    android:tint="?attr/colorForeground"
+    android:alpha="0.12" />
diff --git a/core/res/res/layout/alert_dialog_material.xml b/core/res/res/layout/alert_dialog_material.xml
index 54a1061..545d95e 100644
--- a/core/res/res/layout/alert_dialog_material.xml
+++ b/core/res/res/layout/alert_dialog_material.xml
@@ -66,7 +66,7 @@
                 android:layout_height="wrap_content"
                 android:orientation="vertical">
                 <TextView android:id="@+id/message"
-                          style="?attr/textAppearanceMedium"
+                          style="@style/TextAppearance.Material.Subhead"
                           android:layout_width="match_parent"
                           android:layout_height="wrap_content"
                           android:paddingStart="@dimen/alert_dialog_padding_material"
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 9bdc1f8..a7d197b 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -3393,6 +3393,8 @@
     <string name="low_internal_storage_view_title">Storage space running out</string>
     <!-- If the device is getting low on internal storage, a notification is shown to the user.  This is the message of that notification. -->
     <string name="low_internal_storage_view_text">Some system functions may not work</string>
+    <!-- If the device does not have storage for the main system classes, a notification is shown to the user.  This is the message of that notification. -->
+    <string name="low_internal_storage_view_text_no_boot">Not enough storage for the system. Make sure you have 250MB of free space and restart.</string>
 
     <!-- [CHAR LIMIT=NONE] Stub notification title for an app running a service that has provided
          a bad bad notification for itself. -->
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index 13170ad..08bda1f 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -81,6 +81,13 @@
     <!-- Show camera affordance on Keyguard -->
     <bool name="config_keyguardShowCameraAffordance">true</bool>
 
+    <!-- Whether we should use SRC drawing mode when drawing the scrim behind. If this flag is set,
+         we change the canvas opacity so libhwui doesn't call glClear on our surface, and then we
+         draw the scrim with SRC to overwrite the whole buffer, which saves us a layer of overdraw.
+         However, SRC performs poorly on some devices, where it is more efficient to
+         glClear + SRC_OVER, in which case this flag should be disabled. -->
+    <bool name="config_status_bar_scrim_behind_use_src">true</bool>
+
     <!-- The length of the vibration when the notification pops open. -->
     <integer name="one_finger_pop_duration_ms">10</integer>
 
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java b/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java
index 3bf86a0..34bbc2e 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java
@@ -89,29 +89,7 @@
                 sScreenOnNotPulsingStats = new SummaryStats();
                 sEmergencyCallStats = new SummaryStats();
                 log("init");
-                KeyguardUpdateMonitor.getInstance(context)
-                        .registerCallback(new KeyguardUpdateMonitorCallback() {
-                    @Override
-                    public void onEmergencyCallAction() {
-                        traceEmergencyCall();
-                    }
-                    @Override
-                    public void onKeyguardBouncerChanged(boolean bouncer) {
-                        traceKeyguardBouncerChanged(bouncer);
-                    }
-                    @Override
-                    public void onScreenTurnedOn() {
-                        traceScreenOn();
-                    }
-                    @Override
-                    public void onScreenTurnedOff(int why) {
-                        traceScreenOff(why);
-                    }
-                    @Override
-                    public void onKeyguardVisibilityChanged(boolean showing) {
-                        traceKeyguard(showing);
-                    }
-                });
+                KeyguardUpdateMonitor.getInstance(context).registerCallback(sKeyguardCallback);
             }
         }
         log("dozing " + dozing);
@@ -126,6 +104,7 @@
     public static void traceEmergencyCall() {
         if (!ENABLED) return;
         log("emergencyCall");
+        sEmergencyCallStats.append();
     }
 
     public static void traceKeyguardBouncerChanged(boolean showing) {
@@ -208,4 +187,32 @@
             pw.println();
         }
     }
+
+    private static final KeyguardUpdateMonitorCallback sKeyguardCallback =
+            new KeyguardUpdateMonitorCallback() {
+        @Override
+        public void onEmergencyCallAction() {
+            traceEmergencyCall();
+        }
+
+        @Override
+        public void onKeyguardBouncerChanged(boolean bouncer) {
+            traceKeyguardBouncerChanged(bouncer);
+        }
+
+        @Override
+        public void onScreenTurnedOn() {
+            traceScreenOn();
+        }
+
+        @Override
+        public void onScreenTurnedOff(int why) {
+            traceScreenOff(why);
+        }
+
+        @Override
+        public void onKeyguardVisibilityChanged(boolean showing) {
+            traceKeyguard(showing);
+        }
+    };
 }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index aa75fd4..eef4a5a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -92,7 +92,6 @@
 import com.android.systemui.SystemUI;
 import com.android.systemui.statusbar.NotificationData.Entry;
 import com.android.systemui.statusbar.phone.KeyguardTouchDelegate;
-import com.android.systemui.statusbar.phone.PhoneStatusBar;
 import com.android.systemui.statusbar.phone.NavigationBarView;
 import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
 import com.android.systemui.statusbar.policy.HeadsUpNotificationView;
@@ -293,10 +292,6 @@
 
                         // close the shade if it was open
                         if (handled) {
-                            if (PhoneStatusBar.DEBUG_EMPTY_KEYGUARD) {
-                                Log.i(TAG, "Collapsing panel from mOnClickHandler after keyguard"
-                                        + "dismiss");
-                            }
                             animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */);
                             visibilityChanged(false);
                         }
@@ -343,9 +338,6 @@
                 Settings.Secure.putInt(mContext.getContentResolver(),
                         Settings.Secure.SHOW_NOTE_ABOUT_NOTIFICATION_HIDING, 0);
                 if (BANNER_ACTION_SETUP.equals(action)) {
-                    if (PhoneStatusBar.DEBUG_EMPTY_KEYGUARD) {
-                        Log.i(TAG, "Animating collapse because of BANNER_ACTION_SETUP");
-                    }
                     animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */);
                     mContext.startActivity(new Intent(Settings.ACTION_APP_NOTIFICATION_REDACTION)
                             .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
@@ -771,10 +763,6 @@
                         }
                     }
                 });
-                if (PhoneStatusBar.DEBUG_EMPTY_KEYGUARD) {
-                    Log.i(TAG, "Collapsing panel from startNotificationGutsIntent after keyguard"
-                            + "dismiss");
-                }
                 animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */);
                 return true;
             }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ScrimView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ScrimView.java
index 2353425..682676b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ScrimView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ScrimView.java
@@ -33,7 +33,7 @@
 public class ScrimView extends View
 {
     private int mScrimColor;
-    private boolean mIsEmpty;
+    private boolean mIsEmpty = true;
     private boolean mDrawAsSrc;
     private float mViewAlpha = 1.0f;
     private ValueAnimator mAlphaAnimator;
@@ -70,7 +70,7 @@
 
     @Override
     protected void onDraw(Canvas canvas) {
-        if (mDrawAsSrc || !mIsEmpty) {
+        if (mDrawAsSrc || (!mIsEmpty && mViewAlpha > 0f)) {
             PorterDuff.Mode mode = mDrawAsSrc ? PorterDuff.Mode.SRC : PorterDuff.Mode.SRC_OVER;
             int color = mScrimColor;
             color = Color.argb((int) (Color.alpha(color) * mViewAlpha), Color.red(color),
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
index fceed2f..dd5df12 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
@@ -132,9 +132,6 @@
         public boolean performAccessibilityAction(View host, int action, Bundle args) {
             if (action == ACTION_CLICK) {
                 if (host == mLockIcon) {
-                    if (PhoneStatusBar.DEBUG_EMPTY_KEYGUARD) {
-                        Log.i(TAG, "Collapsing panel from lock icon accessibility click");
-                    }
                     mPhoneStatusBar.animateCollapsePanels(
                             CommandQueue.FLAG_EXCLUDE_NONE, true /* force */);
                     return true;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ObservableScrollView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ObservableScrollView.java
index b842a6b..1186a33 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ObservableScrollView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ObservableScrollView.java
@@ -34,6 +34,7 @@
     private float mLastX;
     private float mLastY;
     private boolean mBlockFlinging;
+    private boolean mTouchCancelled;
 
     public ObservableScrollView(Context context, AttributeSet attrs) {
         super(context, attrs);
@@ -87,9 +88,20 @@
 
     @Override
     public boolean dispatchTouchEvent(MotionEvent ev) {
-        boolean isEndGuesture = (ev.getAction() == MotionEvent.ACTION_UP
-                || ev.getAction() == MotionEvent.ACTION_CANCEL);
-        if (!mTouchEnabled && !isEndGuesture) {
+        if (ev.getAction() == MotionEvent.ACTION_DOWN) {
+            if (!mTouchEnabled) {
+                mTouchCancelled = true;
+                return false;
+            }
+            mTouchCancelled = false;
+        } else if (mTouchCancelled) {
+            return false;
+        } else if (!mTouchEnabled) {
+            MotionEvent cancel = MotionEvent.obtain(ev);
+            cancel.setAction(MotionEvent.ACTION_CANCEL);
+            super.dispatchTouchEvent(ev);
+            cancel.recycle();
+            mTouchCancelled = true;
             return false;
         }
         return super.dispatchTouchEvent(ev);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java
index ccafbd1..f74d2f4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java
@@ -140,9 +140,6 @@
         mPanelHolder.setSelectedPanel(mTouchingPanel);
         for (PanelView pv : mPanels) {
             if (pv != panel) {
-                if (PhoneStatusBar.DEBUG_EMPTY_KEYGUARD) {
-                    Log.i(TAG, "Collapsing because opening another panel");
-                }
                 pv.collapse(false /* delayed */);
             }
         }
@@ -194,15 +191,9 @@
         boolean waiting = false;
         for (PanelView pv : mPanels) {
             if (animate && !pv.isFullyCollapsed()) {
-                if (PhoneStatusBar.DEBUG_EMPTY_KEYGUARD) {
-                    Log.i(TAG, "Animating collapse, delayed");
-                }
                 pv.collapse(true /* delayed */);
                 waiting = true;
             } else {
-                if (PhoneStatusBar.DEBUG_EMPTY_KEYGUARD) {
-                    Log.i(TAG, "Collapsing without animation");
-                }
                 pv.resetViews();
                 pv.setExpandedFraction(0); // just in case
                 pv.setVisibility(View.GONE);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index 95c5020..cacc2df7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -136,9 +136,6 @@
     }
 
     private void runPeekAnimation() {
-        if (PhoneStatusBar.DEBUG_EMPTY_KEYGUARD) {
-            Log.i(TAG, "Starting peek animation");
-        }
         mPeekHeight = getPeekHeight();
         if (DEBUG) logf("peek to height=%.1f", mPeekHeight);
         if (mHeightAnimator != null) {
@@ -159,15 +156,9 @@
             public void onAnimationEnd(Animator animation) {
                 mPeekAnimator = null;
                 if (mCollapseAfterPeek && !mCancelled) {
-                    if (PhoneStatusBar.DEBUG_EMPTY_KEYGUARD) {
-                        Log.i(TAG, "Peek animation finished, posting collapse");
-                    }
                     postOnAnimation(new Runnable() {
                         @Override
                         public void run() {
-                            if (PhoneStatusBar.DEBUG_EMPTY_KEYGUARD) {
-                                Log.i(TAG, "Peek animation finished, collapsing");
-                            }
                             collapse(false /* delayed */);
                         }
                     });
@@ -345,9 +336,6 @@
                     }
                     boolean expand = flingExpands(vel, vectorVel);
                     onTrackingStopped(expand);
-                    if (PhoneStatusBar.DEBUG_EMPTY_KEYGUARD) {
-                        Log.i(TAG, "Flinging: expand=" + expand);
-                    }
                     DozeLog.traceFling(expand, mTouchAboveFalsingThreshold,
                             mStatusBar.isFalsingThresholdNeeded());
                     fling(vel, expand);
@@ -535,9 +523,6 @@
             notifyExpandingFinished();
             return;
         }
-        if (PhoneStatusBar.DEBUG_EMPTY_KEYGUARD) {
-            Log.i(TAG, "Executing fling: expand=" + expand + " vel=" + vel);
-        }
         mOverExpandedBeforeFling = getOverExpansionAmount() > 0f;
         ValueAnimator animator = createHeightAnimator(target);
         if (expand) {
@@ -719,14 +704,8 @@
             mClosing = true;
             notifyExpandingStarted();
             if (delayed) {
-                if (PhoneStatusBar.DEBUG_EMPTY_KEYGUARD) {
-                    Log.i(TAG, "Posting collapse runnable, will be run in 120ms");
-                }
                 postDelayed(mFlingCollapseRunnable, 120);
             } else {
-                if (PhoneStatusBar.DEBUG_EMPTY_KEYGUARD) {
-                    Log.i(TAG, "Animating collapsing now");
-                }
                 fling(0, false /* expand */);
             }
         }
@@ -735,9 +714,6 @@
     private final Runnable mFlingCollapseRunnable = new Runnable() {
         @Override
         public void run() {
-            if (PhoneStatusBar.DEBUG_EMPTY_KEYGUARD) {
-                Log.i(TAG, "Executing collapse runnable, animating collapsing now");
-            }
             fling(0, false /* expand */);
         }
     };
@@ -766,11 +742,6 @@
     }
 
     public void instantExpand() {
-        if (PhoneStatusBar.DEBUG_EMPTY_KEYGUARD) {
-            Log.i(TAG, "Before instant expanding"
-                    + " mTracking=" + mTracking
-                    + " mExpanding=" + mExpanding);
-        }
         mInstantExpanding = true;
         mUpdateFlingOnLayout = false;
         abortAnimations();
@@ -791,11 +762,6 @@
                     public void onGlobalLayout() {
                         if (mStatusBar.getStatusBarWindow().getHeight()
                                 != mStatusBar.getStatusBarHeight()) {
-                            if (PhoneStatusBar.DEBUG_EMPTY_KEYGUARD) {
-                                Log.i(TAG, "Now instant expanding after layout"
-                                        + " mTracking=" + mTracking
-                                        + " mExpanding=" + mExpanding);
-                            }
                             getViewTreeObserver().removeOnGlobalLayoutListener(this);
                             setExpandedFraction(1f);
                             mInstantExpanding = false;
@@ -942,9 +908,6 @@
     private final Runnable mPostCollapseRunnable = new Runnable() {
         @Override
         public void run() {
-            if (PhoneStatusBar.DEBUG_EMPTY_KEYGUARD) {
-                Log.i(TAG, "Collapsing after middle clicked");
-            }
             collapse(false /* delayed */);
         }
     };
@@ -957,9 +920,6 @@
                 mStatusBar.goToKeyguard();
                 return true;
             case StatusBarState.SHADE:
-                if (PhoneStatusBar.DEBUG_EMPTY_KEYGUARD) {
-                    Log.i(TAG, "Middle clicked in shade state, posting collapsing runnable");
-                }
 
                 // This gets called in the middle of the touch handling, where the state is still
                 // that we are tracking the panel. Collapse the panel after this is done.
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 71fef65..2227408 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -183,7 +183,6 @@
     public static final boolean DEBUG_GESTURES = false;
     public static final boolean DEBUG_MEDIA = false;
     public static final boolean DEBUG_MEDIA_FAKE_ARTWORK = false;
-    public static final boolean DEBUG_EMPTY_KEYGUARD = true;
 
     public static final boolean DEBUG_WINDOW_STATE = false;
 
@@ -430,6 +429,7 @@
     private boolean mVisible;
     private boolean mWaitingForKeyguardExit;
     private boolean mDozing;
+    private boolean mScrimSrcModeEnabled;
 
     private Interpolator mLinearOutSlowIn;
     private Interpolator mLinearInterpolator = new LinearInterpolator();
@@ -569,6 +569,8 @@
         mDisplay = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE))
                 .getDefaultDisplay();
         updateDisplaySize();
+        mScrimSrcModeEnabled = mContext.getResources().getBoolean(
+                R.bool.config_status_bar_scrim_behind_use_src);
         super.start(); // calls createAndAddWindows()
 
         mMediaSessionManager
@@ -737,7 +739,7 @@
 
         ScrimView scrimBehind = (ScrimView) mStatusBarWindow.findViewById(R.id.scrim_behind);
         ScrimView scrimInFront = (ScrimView) mStatusBarWindow.findViewById(R.id.scrim_in_front);
-        mScrimController = new ScrimController(scrimBehind, scrimInFront);
+        mScrimController = new ScrimController(scrimBehind, scrimInFront, mScrimSrcModeEnabled);
         mScrimController.setBackDropView(mBackdrop);
         mStatusBarView.setScrimController(mScrimController);
 
@@ -1870,7 +1872,9 @@
                 if (mBackdropBack.getDrawable() != null) {
                     Drawable drawable = mBackdropBack.getDrawable();
                     mBackdropFront.setImageDrawable(drawable);
-                    mBackdropFront.getDrawable().mutate().setXfermode(mSrcOverXferMode);
+                    if (mScrimSrcModeEnabled) {
+                        mBackdropFront.getDrawable().mutate().setXfermode(mSrcOverXferMode);
+                    }
                     mBackdropFront.setAlpha(1f);
                     mBackdropFront.setVisibility(View.VISIBLE);
                 } else {
@@ -1885,7 +1889,9 @@
                 } else {
                     mBackdropBack.setImageBitmap(artworkBitmap);
                 }
-                mBackdropBack.getDrawable().mutate().setXfermode(mSrcXferMode);
+                if (mScrimSrcModeEnabled) {
+                    mBackdropBack.getDrawable().mutate().setXfermode(mSrcXferMode);
+                }
 
                 if (mBackdropFront.getVisibility() == View.VISIBLE) {
                     if (DEBUG_MEDIA) {
@@ -2134,6 +2140,10 @@
         return mMediaNotificationKey;
     }
 
+    public boolean isScrimSrcModeEnabled() {
+        return mScrimSrcModeEnabled;
+    }
+
     /**
      * All changes to the status bar and notifications funnel through here and are batched.
      */
@@ -2271,11 +2281,6 @@
             mStatusBarWindowManager.setStatusBarFocusable(false);
 
             mStatusBarWindow.cancelExpandHelper();
-            if (DEBUG_EMPTY_KEYGUARD) {
-                Log.i(TAG, "Collapsing panel from animateCollapsePanels:"
-                        + " force=" + force
-                        + " mState=" + mState);
-            }
             mStatusBarView.collapseAllPanels(true);
         }
     }
@@ -2363,9 +2368,6 @@
     }
 
     public void animateCollapseQuickSettings() {
-        if (DEBUG_EMPTY_KEYGUARD) {
-            Log.i(TAG, "Collapsing panel from animateCollapseQuickSettings");
-        }
         mStatusBarView.collapseAllPanels(true);
     }
 
@@ -2378,9 +2380,6 @@
         }
 
         // Ensure the panel is fully collapsed (just in case; bug 6765842, 7260868)
-        if (DEBUG_EMPTY_KEYGUARD) {
-            Log.i(TAG, "Collapsing panel from makeExpandedInvisible");
-        }
         mStatusBarView.collapseAllPanels(/*animate=*/ false);
 
         // reset things to their proper state
@@ -2472,9 +2471,6 @@
             mStatusBarWindowState = state;
             if (DEBUG_WINDOW_STATE) Log.d(TAG, "Status bar " + windowStateToString(state));
             if (!showing) {
-                if (DEBUG_EMPTY_KEYGUARD) {
-                    Log.i(TAG, "Collapsing panel from setWindowState");
-                }
                 mStatusBarView.collapseAllPanels(false);
             }
         }
@@ -3034,10 +3030,6 @@
                     }
                 });
                 if (dismissShade) {
-                    if (PhoneStatusBar.DEBUG_EMPTY_KEYGUARD) {
-                        Log.i(TAG, "Collapsing panel startActivityDismissKeyguard after keyguard"
-                                + "dismiss");
-                    }
                     animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */);
                 }
                 return true;
@@ -3716,9 +3708,6 @@
     public boolean onSpacePressed() {
         if (mScreenOn != null && mScreenOn
                 && (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED)) {
-            if (PhoneStatusBar.DEBUG_EMPTY_KEYGUARD) {
-                Log.i(TAG, "Collapsing panel from onSpacePressed");
-            }
             animateCollapsePanels(0 /* flags */, true /* force */);
             return true;
         }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
index 5353f25..6793f69 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
@@ -74,8 +74,9 @@
     private final Interpolator mInterpolator = new DecelerateInterpolator();
     private final Interpolator mLinearOutSlowInInterpolator;
     private BackDropView mBackDropView;
+    private boolean mScrimSrcEnabled;
 
-    public ScrimController(ScrimView scrimBehind, ScrimView scrimInFront) {
+    public ScrimController(ScrimView scrimBehind, ScrimView scrimInFront, boolean scrimSrcEnabled) {
         mScrimBehind = scrimBehind;
         mScrimInFront = scrimInFront;
         final Context context = scrimBehind.getContext();
@@ -83,6 +84,7 @@
         mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context,
                 android.R.interpolator.linear_out_slow_in);
         mDozeParameters = new DozeParameters(context);
+        mScrimSrcEnabled = scrimSrcEnabled;
     }
 
     public void setKeyguardShowing(boolean showing) {
@@ -384,7 +386,7 @@
     }
 
     private void updateScrimBehindDrawingMode() {
-        boolean asSrc = mBackDropView.getVisibility() != View.VISIBLE;
+        boolean asSrc = mBackDropView.getVisibility() != View.VISIBLE && mScrimSrcEnabled;
         mScrimBehind.setDrawAsSrc(asSrc);
     }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
index 4c86990..242f1b7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
@@ -55,7 +55,6 @@
     public StatusBarWindowView(Context context, AttributeSet attrs) {
         super(context, attrs);
         setMotionEventSplittingEnabled(false);
-        setWillNotDraw(false);
         mTransparentSrcPaint.setColor(0);
         mTransparentSrcPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
     }
@@ -105,11 +104,16 @@
         // We need to ensure that our window doesn't suffer from overdraw which would normally
         // occur if our window is translucent. Since we are drawing the whole window anyway with
         // the scrim, we don't need the window to be cleared in the beginning.
-        IBinder windowToken = getWindowToken();
-        WindowManager.LayoutParams lp = (WindowManager.LayoutParams) getLayoutParams();
-        lp.token = windowToken;
-        setLayoutParams(lp);
-        WindowManagerGlobal.getInstance().changeCanvasOpacity(windowToken, true);
+        if (mService.isScrimSrcModeEnabled()) {
+            IBinder windowToken = getWindowToken();
+            WindowManager.LayoutParams lp = (WindowManager.LayoutParams) getLayoutParams();
+            lp.token = windowToken;
+            setLayoutParams(lp);
+            WindowManagerGlobal.getInstance().changeCanvasOpacity(windowToken, true);
+            setWillNotDraw(false);
+        } else {
+            setWillNotDraw(!DEBUG);
+        }
     }
 
     @Override
@@ -199,23 +203,25 @@
     @Override
     public void onDraw(Canvas canvas) {
         super.onDraw(canvas);
-        // We need to ensure that our window is always drawn fully even when we have paddings,
-        // since we simulate it to be opaque.
-        int paddedBottom = getHeight() - getPaddingBottom();
-        int paddedRight = getWidth() - getPaddingRight();
-        if (getPaddingTop() != 0) {
-            canvas.drawRect(0, 0, getWidth(), getPaddingTop(), mTransparentSrcPaint);
-        }
-        if (getPaddingBottom() != 0) {
-            canvas.drawRect(0, paddedBottom, getWidth(), getHeight(), mTransparentSrcPaint);
-        }
-        if (getPaddingLeft() != 0) {
-            canvas.drawRect(0, getPaddingTop(), getPaddingLeft(), paddedBottom,
-                    mTransparentSrcPaint);
-        }
-        if (getPaddingRight() != 0) {
-            canvas.drawRect(paddedRight, getPaddingTop(), getWidth(), paddedBottom,
-                    mTransparentSrcPaint);
+        if (mService.isScrimSrcModeEnabled()) {
+            // We need to ensure that our window is always drawn fully even when we have paddings,
+            // since we simulate it to be opaque.
+            int paddedBottom = getHeight() - getPaddingBottom();
+            int paddedRight = getWidth() - getPaddingRight();
+            if (getPaddingTop() != 0) {
+                canvas.drawRect(0, 0, getWidth(), getPaddingTop(), mTransparentSrcPaint);
+            }
+            if (getPaddingBottom() != 0) {
+                canvas.drawRect(0, paddedBottom, getWidth(), getHeight(), mTransparentSrcPaint);
+            }
+            if (getPaddingLeft() != 0) {
+                canvas.drawRect(0, getPaddingTop(), getPaddingLeft(), paddedBottom,
+                        mTransparentSrcPaint);
+            }
+            if (getPaddingRight() != 0) {
+                canvas.drawRect(paddedRight, getPaddingTop(), getWidth(), paddedBottom,
+                        mTransparentSrcPaint);
+            }
         }
         if (DEBUG) {
             Paint pt = new Paint();
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index a3c64d0..0b1a627 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -745,10 +745,6 @@
 
         mPacManager = new PacManager(mContext, mHandler, EVENT_PROXY_HAS_CHANGED);
 
-        filter = new IntentFilter();
-        filter.addAction(CONNECTED_TO_PROVISIONING_NETWORK_ACTION);
-        mContext.registerReceiver(mProvisioningReceiver, filter);
-
         mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
     }
 
@@ -1947,23 +1943,6 @@
                             state + "/" + info.getDetailedState());
                     }
 
-                    // Since mobile has the notion of a network/apn that can be used for
-                    // provisioning we need to check every time we're connected as
-                    // CaptiveProtalTracker won't detected it because DCT doesn't report it
-                    // as connected as ACTION_ANY_DATA_CONNECTION_STATE_CHANGED instead its
-                    // reported as ACTION_DATA_CONNECTION_CONNECTED_TO_PROVISIONING_APN. Which
-                    // is received by MDST and sent here as EVENT_STATE_CHANGED.
-                    if (ConnectivityManager.isNetworkTypeMobile(info.getType())
-                            && (0 != Settings.Global.getInt(mContext.getContentResolver(),
-                                        Settings.Global.DEVICE_PROVISIONED, 0))
-                            && (((state == NetworkInfo.State.CONNECTED)
-                                    && (info.getType() == ConnectivityManager.TYPE_MOBILE))
-                                || info.isConnectedToProvisioningNetwork())) {
-                        log("ConnectivityChange checkMobileProvisioning for"
-                                + " TYPE_MOBILE or ProvisioningNetwork");
-                        checkMobileProvisioning(CheckMp.MAX_TIMEOUT_MS);
-                    }
-
                     EventLogTags.writeConnectivityStateChanged(
                             info.getType(), info.getSubtype(), info.getDetailedState().ordinal());
 
@@ -2931,733 +2910,25 @@
                          enabled));
     }
 
-    private boolean isMobileDataStateTrackerReady() {
-        MobileDataStateTracker mdst =
-                (MobileDataStateTracker) mNetTrackers[ConnectivityManager.TYPE_MOBILE_HIPRI];
-        return (mdst != null) && (mdst.isReady());
-    }
-
-    /**
-     * The ResultReceiver resultCode for checkMobileProvisioning (CMP_RESULT_CODE)
-     */
-
-    /**
-     * No connection was possible to the network.
-     * This is NOT a warm sim.
-     */
-    private static final int CMP_RESULT_CODE_NO_CONNECTION = 0;
-
-    /**
-     * A connection was made to the internet, all is well.
-     * This is NOT a warm sim.
-     */
-    private static final int CMP_RESULT_CODE_CONNECTABLE = 1;
-
-    /**
-     * A connection was made but no dns server was available to resolve a name to address.
-     * This is NOT a warm sim since provisioning network is supported.
-     */
-    private static final int CMP_RESULT_CODE_NO_DNS = 2;
-
-    /**
-     * A connection was made but could not open a TCP connection.
-     * This is NOT a warm sim since provisioning network is supported.
-     */
-    private static final int CMP_RESULT_CODE_NO_TCP_CONNECTION = 3;
-
-    /**
-     * A connection was made but there was a redirection, we appear to be in walled garden.
-     * This is an indication of a warm sim on a mobile network such as T-Mobile.
-     */
-    private static final int CMP_RESULT_CODE_REDIRECTED = 4;
-
-    /**
-     * The mobile network is a provisioning network.
-     * This is an indication of a warm sim on a mobile network such as AT&T.
-     */
-    private static final int CMP_RESULT_CODE_PROVISIONING_NETWORK = 5;
-
-    /**
-     * The mobile network is provisioning
-     */
-    private static final int CMP_RESULT_CODE_IS_PROVISIONING = 6;
-
-    private AtomicBoolean mIsProvisioningNetwork = new AtomicBoolean(false);
-    private AtomicBoolean mIsStartingProvisioning = new AtomicBoolean(false);
-
-    private AtomicBoolean mIsCheckingMobileProvisioning = new AtomicBoolean(false);
-
     @Override
     public int checkMobileProvisioning(int suggestedTimeOutMs) {
-        int timeOutMs = -1;
-        if (DBG) log("checkMobileProvisioning: E suggestedTimeOutMs=" + suggestedTimeOutMs);
-        enforceConnectivityInternalPermission();
-
-        final long token = Binder.clearCallingIdentity();
-        try {
-            timeOutMs = suggestedTimeOutMs;
-            if (suggestedTimeOutMs > CheckMp.MAX_TIMEOUT_MS) {
-                timeOutMs = CheckMp.MAX_TIMEOUT_MS;
-            }
-
-            // Check that mobile networks are supported
-            if (!isNetworkSupported(ConnectivityManager.TYPE_MOBILE)
-                    || !isNetworkSupported(ConnectivityManager.TYPE_MOBILE_HIPRI)) {
-                if (DBG) log("checkMobileProvisioning: X no mobile network");
-                return timeOutMs;
-            }
-
-            // If we're already checking don't do it again
-            // TODO: Add a queue of results...
-            if (mIsCheckingMobileProvisioning.getAndSet(true)) {
-                if (DBG) log("checkMobileProvisioning: X already checking ignore for the moment");
-                return timeOutMs;
-            }
-
-            // Start off with mobile notification off
-            setProvNotificationVisible(false, ConnectivityManager.TYPE_MOBILE_HIPRI, null, null);
-
-            CheckMp checkMp = new CheckMp(mContext, this);
-            CheckMp.CallBack cb = new CheckMp.CallBack() {
-                @Override
-                void onComplete(Integer result) {
-                    if (DBG) log("CheckMp.onComplete: result=" + result);
-                    NetworkInfo ni =
-                            mNetTrackers[ConnectivityManager.TYPE_MOBILE_HIPRI].getNetworkInfo();
-                    switch(result) {
-                        case CMP_RESULT_CODE_CONNECTABLE:
-                        case CMP_RESULT_CODE_NO_CONNECTION:
-                        case CMP_RESULT_CODE_NO_DNS:
-                        case CMP_RESULT_CODE_NO_TCP_CONNECTION: {
-                            if (DBG) log("CheckMp.onComplete: ignore, connected or no connection");
-                            break;
-                        }
-                        case CMP_RESULT_CODE_REDIRECTED: {
-                            if (DBG) log("CheckMp.onComplete: warm sim");
-                            String url = getMobileProvisioningUrl();
-                            if (TextUtils.isEmpty(url)) {
-                                url = getMobileRedirectedProvisioningUrl();
-                            }
-                            if (TextUtils.isEmpty(url) == false) {
-                                if (DBG) log("CheckMp.onComplete: warm (redirected), url=" + url);
-                                setProvNotificationVisible(true,
-                                        ConnectivityManager.TYPE_MOBILE_HIPRI, ni.getExtraInfo(),
-                                        url);
-                            } else {
-                                if (DBG) log("CheckMp.onComplete: warm (redirected), no url");
-                            }
-                            break;
-                        }
-                        case CMP_RESULT_CODE_PROVISIONING_NETWORK: {
-                            String url = getMobileProvisioningUrl();
-                            if (TextUtils.isEmpty(url) == false) {
-                                if (DBG) log("CheckMp.onComplete: warm (no dns/tcp), url=" + url);
-                                setProvNotificationVisible(true,
-                                        ConnectivityManager.TYPE_MOBILE_HIPRI, ni.getExtraInfo(),
-                                        url);
-                                // Mark that we've got a provisioning network and
-                                // Disable Mobile Data until user actually starts provisioning.
-                                mIsProvisioningNetwork.set(true);
-                                MobileDataStateTracker mdst = (MobileDataStateTracker)
-                                        mNetTrackers[ConnectivityManager.TYPE_MOBILE];
-
-                                // Disable radio until user starts provisioning
-                                mdst.setRadio(false);
-                            } else {
-                                if (DBG) log("CheckMp.onComplete: warm (no dns/tcp), no url");
-                            }
-                            break;
-                        }
-                        case CMP_RESULT_CODE_IS_PROVISIONING: {
-                            // FIXME: Need to know when provisioning is done. Probably we can
-                            // check the completion status if successful we're done if we
-                            // "timedout" or still connected to provisioning APN turn off data?
-                            if (DBG) log("CheckMp.onComplete: provisioning started");
-                            mIsStartingProvisioning.set(false);
-                            break;
-                        }
-                        default: {
-                            loge("CheckMp.onComplete: ignore unexpected result=" + result);
-                            break;
-                        }
-                    }
-                    mIsCheckingMobileProvisioning.set(false);
-                }
-            };
-            CheckMp.Params params =
-                    new CheckMp.Params(checkMp.getDefaultUrl(), timeOutMs, cb);
-            if (DBG) log("checkMobileProvisioning: params=" + params);
-            // TODO: Reenable when calls to the now defunct
-            //       MobileDataStateTracker.isProvisioningNetwork() are removed.
-            //       This code should be moved to the Telephony code.
-            // checkMp.execute(params);
-        } finally {
-            Binder.restoreCallingIdentity(token);
-            if (DBG) log("checkMobileProvisioning: X");
-        }
-        return timeOutMs;
-    }
-
-    static class CheckMp extends
-            AsyncTask<CheckMp.Params, Void, Integer> {
-        private static final String CHECKMP_TAG = "CheckMp";
-
-        // adb shell setprop persist.checkmp.testfailures 1 to enable testing failures
-        private static boolean mTestingFailures;
-
-        // Choosing 4 loops as half of them will use HTTPS and the other half HTTP
-        private static final int MAX_LOOPS = 4;
-
-        // Number of milli-seconds to complete all of the retires
-        public static final int MAX_TIMEOUT_MS =  60000;
-
-        // The socket should retry only 5 seconds, the default is longer
-        private static final int SOCKET_TIMEOUT_MS = 5000;
-
-        // Sleep time for network errors
-        private static final int NET_ERROR_SLEEP_SEC = 3;
-
-        // Sleep time for network route establishment
-        private static final int NET_ROUTE_ESTABLISHMENT_SLEEP_SEC = 3;
-
-        // Short sleep time for polling :(
-        private static final int POLLING_SLEEP_SEC = 1;
-
-        private Context mContext;
-        private ConnectivityService mCs;
-        private TelephonyManager mTm;
-        private Params mParams;
-
-        /**
-         * Parameters for AsyncTask.execute
-         */
-        static class Params {
-            private String mUrl;
-            private long mTimeOutMs;
-            private CallBack mCb;
-
-            Params(String url, long timeOutMs, CallBack cb) {
-                mUrl = url;
-                mTimeOutMs = timeOutMs;
-                mCb = cb;
-            }
-
-            @Override
-            public String toString() {
-                return "{" + " url=" + mUrl + " mTimeOutMs=" + mTimeOutMs + " mCb=" + mCb + "}";
-            }
-        }
-
-        // As explained to me by Brian Carlstrom and Kenny Root, Certificates can be
-        // issued by name or ip address, for Google its by name so when we construct
-        // this HostnameVerifier we'll pass the original Uri and use it to verify
-        // the host. If the host name in the original uril fails we'll test the
-        // hostname parameter just incase things change.
-        static class CheckMpHostnameVerifier implements HostnameVerifier {
-            Uri mOrgUri;
-
-            CheckMpHostnameVerifier(Uri orgUri) {
-                mOrgUri = orgUri;
-            }
-
-            @Override
-            public boolean verify(String hostname, SSLSession session) {
-                HostnameVerifier hv = HttpsURLConnection.getDefaultHostnameVerifier();
-                String orgUriHost = mOrgUri.getHost();
-                boolean retVal = hv.verify(orgUriHost, session) || hv.verify(hostname, session);
-                if (DBG) {
-                    log("isMobileOk: hostnameVerify retVal=" + retVal + " hostname=" + hostname
-                        + " orgUriHost=" + orgUriHost);
-                }
-                return retVal;
-            }
-        }
-
-        /**
-         * The call back object passed in Params. onComplete will be called
-         * on the main thread.
-         */
-        abstract static class CallBack {
-            // Called on the main thread.
-            abstract void onComplete(Integer result);
-        }
-
-        public CheckMp(Context context, ConnectivityService cs) {
-            if (Build.IS_DEBUGGABLE) {
-                mTestingFailures =
-                        SystemProperties.getInt("persist.checkmp.testfailures", 0) == 1;
-            } else {
-                mTestingFailures = false;
-            }
-
-            mContext = context;
-            mCs = cs;
-
-            // Setup access to TelephonyService we'll be using.
-            mTm = (TelephonyManager) mContext.getSystemService(
-                    Context.TELEPHONY_SERVICE);
-        }
-
-        /**
-         * Get the default url to use for the test.
-         */
-        public String getDefaultUrl() {
-            // See http://go/clientsdns for usage approval
-            String server = Settings.Global.getString(mContext.getContentResolver(),
-                    Settings.Global.CAPTIVE_PORTAL_SERVER);
-            if (server == null) {
-                server = "clients3.google.com";
-            }
-            return "http://" + server + "/generate_204";
-        }
-
-        /**
-         * Detect if its possible to connect to the http url. DNS based detection techniques
-         * do not work at all hotspots. The best way to check is to perform a request to
-         * a known address that fetches the data we expect.
-         */
-        private synchronized Integer isMobileOk(Params params) {
-            Integer result = CMP_RESULT_CODE_NO_CONNECTION;
-            Uri orgUri = Uri.parse(params.mUrl);
-            Random rand = new Random();
-            mParams = params;
-
-            if (mCs.isNetworkSupported(ConnectivityManager.TYPE_MOBILE) == false) {
-                result = CMP_RESULT_CODE_NO_CONNECTION;
-                log("isMobileOk: X not mobile capable result=" + result);
-                return result;
-            }
-
-            if (mCs.mIsStartingProvisioning.get()) {
-                result = CMP_RESULT_CODE_IS_PROVISIONING;
-                log("isMobileOk: X is provisioning result=" + result);
-                return result;
-            }
-
-            // See if we've already determined we've got a provisioning connection,
-            // if so we don't need to do anything active.
-            MobileDataStateTracker mdstDefault = (MobileDataStateTracker)
-                    mCs.mNetTrackers[ConnectivityManager.TYPE_MOBILE];
-            boolean isDefaultProvisioning = mdstDefault.isProvisioningNetwork();
-            log("isMobileOk: isDefaultProvisioning=" + isDefaultProvisioning);
-
-            MobileDataStateTracker mdstHipri = (MobileDataStateTracker)
-                    mCs.mNetTrackers[ConnectivityManager.TYPE_MOBILE_HIPRI];
-            boolean isHipriProvisioning = mdstHipri.isProvisioningNetwork();
-            log("isMobileOk: isHipriProvisioning=" + isHipriProvisioning);
-
-            if (isDefaultProvisioning || isHipriProvisioning) {
-                result = CMP_RESULT_CODE_PROVISIONING_NETWORK;
-                log("isMobileOk: X default || hipri is provisioning result=" + result);
-                return result;
-            }
-
-            try {
-                // Continue trying to connect until time has run out
-                long endTime = SystemClock.elapsedRealtime() + params.mTimeOutMs;
-
-                if (!mCs.isMobileDataStateTrackerReady()) {
-                    // Wait for MobileDataStateTracker to be ready.
-                    if (DBG) log("isMobileOk: mdst is not ready");
-                    while(SystemClock.elapsedRealtime() < endTime) {
-                        if (mCs.isMobileDataStateTrackerReady()) {
-                            // Enable fail fast as we'll do retries here and use a
-                            // hipri connection so the default connection stays active.
-                            if (DBG) log("isMobileOk: mdst ready, enable fail fast of mobile data");
-                            mCs.setEnableFailFastMobileData(DctConstants.ENABLED);
-                            break;
-                        }
-                        sleep(POLLING_SLEEP_SEC);
-                    }
-                }
-
-                log("isMobileOk: start hipri url=" + params.mUrl);
-
-                // First wait until we can start using hipri
-                Binder binder = new Binder();
-/*
-                while(SystemClock.elapsedRealtime() < endTime) {
-                    int ret = mCs.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
-                            Phone.FEATURE_ENABLE_HIPRI, binder);
-                    if ((ret == PhoneConstants.APN_ALREADY_ACTIVE)
-                        || (ret == PhoneConstants.APN_REQUEST_STARTED)) {
-                            log("isMobileOk: hipri started");
-                            break;
-                    }
-                    if (VDBG) log("isMobileOk: hipri not started yet");
-                    result = CMP_RESULT_CODE_NO_CONNECTION;
-                    sleep(POLLING_SLEEP_SEC);
-                }
-*/
-                // Continue trying to connect until time has run out
-                while(SystemClock.elapsedRealtime() < endTime) {
-                    try {
-                        // Wait for hipri to connect.
-                        // TODO: Don't poll and handle situation where hipri fails
-                        // because default is retrying. See b/9569540
-                        NetworkInfo.State state = mCs
-                                .getNetworkInfo(ConnectivityManager.TYPE_MOBILE_HIPRI).getState();
-                        if (state != NetworkInfo.State.CONNECTED) {
-                            if (true/*VDBG*/) {
-                                log("isMobileOk: not connected ni=" +
-                                    mCs.getNetworkInfo(ConnectivityManager.TYPE_MOBILE_HIPRI));
-                            }
-                            sleep(POLLING_SLEEP_SEC);
-                            result = CMP_RESULT_CODE_NO_CONNECTION;
-                            continue;
-                        }
-
-                        // Hipri has started check if this is a provisioning url
-                        MobileDataStateTracker mdst = (MobileDataStateTracker)
-                                mCs.mNetTrackers[ConnectivityManager.TYPE_MOBILE_HIPRI];
-                        if (mdst.isProvisioningNetwork()) {
-                            result = CMP_RESULT_CODE_PROVISIONING_NETWORK;
-                            if (DBG) log("isMobileOk: X isProvisioningNetwork result=" + result);
-                            return result;
-                        } else {
-                            if (DBG) log("isMobileOk: isProvisioningNetwork is false, continue");
-                        }
-
-                        // Get of the addresses associated with the url host. We need to use the
-                        // address otherwise HttpURLConnection object will use the name to get
-                        // the addresses and will try every address but that will bypass the
-                        // route to host we setup and the connection could succeed as the default
-                        // interface might be connected to the internet via wifi or other interface.
-                        InetAddress[] addresses;
-                        try {
-                            addresses = InetAddress.getAllByName(orgUri.getHost());
-                        } catch (UnknownHostException e) {
-                            result = CMP_RESULT_CODE_NO_DNS;
-                            log("isMobileOk: X UnknownHostException result=" + result);
-                            return result;
-                        }
-                        log("isMobileOk: addresses=" + inetAddressesToString(addresses));
-
-                        // Get the type of addresses supported by this link
-                        LinkProperties lp = mCs.getLinkPropertiesForTypeInternal(
-                                ConnectivityManager.TYPE_MOBILE_HIPRI);
-                        boolean linkHasIpv4 = lp.hasIPv4Address();
-                        boolean linkHasIpv6 = lp.hasGlobalIPv6Address();
-                        log("isMobileOk: linkHasIpv4=" + linkHasIpv4
-                                + " linkHasIpv6=" + linkHasIpv6);
-
-                        final ArrayList<InetAddress> validAddresses =
-                                new ArrayList<InetAddress>(addresses.length);
-
-                        for (InetAddress addr : addresses) {
-                            if (((addr instanceof Inet4Address) && linkHasIpv4) ||
-                                    ((addr instanceof Inet6Address) && linkHasIpv6)) {
-                                validAddresses.add(addr);
-                            }
-                        }
-
-                        if (validAddresses.size() == 0) {
-                            return CMP_RESULT_CODE_NO_CONNECTION;
-                        }
-
-                        int addrTried = 0;
-                        while (true) {
-                            // Loop through at most MAX_LOOPS valid addresses or until
-                            // we run out of time
-                            if (addrTried++ >= MAX_LOOPS) {
-                                log("isMobileOk: too many loops tried - giving up");
-                                break;
-                            }
-                            if (SystemClock.elapsedRealtime() >= endTime) {
-                                log("isMobileOk: spend too much time - giving up");
-                                break;
-                            }
-
-                            InetAddress hostAddr = validAddresses.get(rand.nextInt(
-                                    validAddresses.size()));
-
-                            // Make a route to host so we check the specific interface.
-                            if (mCs.requestRouteToHostAddress(ConnectivityManager.TYPE_MOBILE_HIPRI,
-                                    hostAddr.getAddress())) {
-                                // Wait a short time to be sure the route is established ??
-                                log("isMobileOk:"
-                                        + " wait to establish route to hostAddr=" + hostAddr);
-                                sleep(NET_ROUTE_ESTABLISHMENT_SLEEP_SEC);
-                            } else {
-                                log("isMobileOk:"
-                                        + " could not establish route to hostAddr=" + hostAddr);
-                                // Wait a short time before the next attempt
-                                sleep(NET_ERROR_SLEEP_SEC);
-                                continue;
-                            }
-
-                            // Rewrite the url to have numeric address to use the specific route
-                            // using http for half the attempts and https for the other half.
-                            // Doing https first and http second as on a redirected walled garden
-                            // such as t-mobile uses we get a SocketTimeoutException: "SSL
-                            // handshake timed out" which we declare as
-                            // CMP_RESULT_CODE_NO_TCP_CONNECTION. We could change this, but by
-                            // having http second we will be using logic used for some time.
-                            URL newUrl;
-                            String scheme = (addrTried <= (MAX_LOOPS/2)) ? "https" : "http";
-                            newUrl = new URL(scheme, hostAddr.getHostAddress(),
-                                        orgUri.getPath());
-                            log("isMobileOk: newUrl=" + newUrl);
-
-                            HttpURLConnection urlConn = null;
-                            try {
-                                // Open the connection set the request headers and get the response
-                                urlConn = (HttpURLConnection)newUrl.openConnection(
-                                        java.net.Proxy.NO_PROXY);
-                                if (scheme.equals("https")) {
-                                    ((HttpsURLConnection)urlConn).setHostnameVerifier(
-                                            new CheckMpHostnameVerifier(orgUri));
-                                }
-                                urlConn.setInstanceFollowRedirects(false);
-                                urlConn.setConnectTimeout(SOCKET_TIMEOUT_MS);
-                                urlConn.setReadTimeout(SOCKET_TIMEOUT_MS);
-                                urlConn.setUseCaches(false);
-                                urlConn.setAllowUserInteraction(false);
-                                // Set the "Connection" to "Close" as by default "Keep-Alive"
-                                // is used which is useless in this case.
-                                urlConn.setRequestProperty("Connection", "close");
-                                int responseCode = urlConn.getResponseCode();
-
-                                // For debug display the headers
-                                Map<String, List<String>> headers = urlConn.getHeaderFields();
-                                log("isMobileOk: headers=" + headers);
-
-                                // Close the connection
-                                urlConn.disconnect();
-                                urlConn = null;
-
-                                if (mTestingFailures) {
-                                    // Pretend no connection, this tests using http and https
-                                    result = CMP_RESULT_CODE_NO_CONNECTION;
-                                    log("isMobileOk: TESTING_FAILURES, pretend no connction");
-                                    continue;
-                                }
-
-                                if (responseCode == 204) {
-                                    // Return
-                                    result = CMP_RESULT_CODE_CONNECTABLE;
-                                    log("isMobileOk: X got expected responseCode=" + responseCode
-                                            + " result=" + result);
-                                    return result;
-                                } else {
-                                    // Retry to be sure this was redirected, we've gotten
-                                    // occasions where a server returned 200 even though
-                                    // the device didn't have a "warm" sim.
-                                    log("isMobileOk: not expected responseCode=" + responseCode);
-                                    // TODO - it would be nice in the single-address case to do
-                                    // another DNS resolve here, but flushing the cache is a bit
-                                    // heavy-handed.
-                                    result = CMP_RESULT_CODE_REDIRECTED;
-                                }
-                            } catch (Exception e) {
-                                log("isMobileOk: HttpURLConnection Exception" + e);
-                                result = CMP_RESULT_CODE_NO_TCP_CONNECTION;
-                                if (urlConn != null) {
-                                    urlConn.disconnect();
-                                    urlConn = null;
-                                }
-                                sleep(NET_ERROR_SLEEP_SEC);
-                                continue;
-                            }
-                        }
-                        log("isMobileOk: X loops|timed out result=" + result);
-                        return result;
-                    } catch (Exception e) {
-                        log("isMobileOk: Exception e=" + e);
-                        continue;
-                    }
-                }
-                log("isMobileOk: timed out");
-            } finally {
-                log("isMobileOk: F stop hipri");
-                mCs.setEnableFailFastMobileData(DctConstants.DISABLED);
-//                mCs.stopUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
-//                        Phone.FEATURE_ENABLE_HIPRI);
-
-                // Wait for hipri to disconnect.
-                long endTime = SystemClock.elapsedRealtime() + 5000;
-
-                while(SystemClock.elapsedRealtime() < endTime) {
-                    NetworkInfo.State state = mCs
-                            .getNetworkInfo(ConnectivityManager.TYPE_MOBILE_HIPRI).getState();
-                    if (state != NetworkInfo.State.DISCONNECTED) {
-                        if (VDBG) {
-                            log("isMobileOk: connected ni=" +
-                                mCs.getNetworkInfo(ConnectivityManager.TYPE_MOBILE_HIPRI));
-                        }
-                        sleep(POLLING_SLEEP_SEC);
-                        continue;
-                    }
-                }
-
-                log("isMobileOk: X result=" + result);
-            }
-            return result;
-        }
-
-        @Override
-        protected Integer doInBackground(Params... params) {
-            return isMobileOk(params[0]);
-        }
-
-        @Override
-        protected void onPostExecute(Integer result) {
-            log("onPostExecute: result=" + result);
-            if ((mParams != null) && (mParams.mCb != null)) {
-                mParams.mCb.onComplete(result);
-            }
-        }
-
-        private String inetAddressesToString(InetAddress[] addresses) {
-            StringBuffer sb = new StringBuffer();
-            boolean firstTime = true;
-            for(InetAddress addr : addresses) {
-                if (firstTime) {
-                    firstTime = false;
-                } else {
-                    sb.append(",");
-                }
-                sb.append(addr);
-            }
-            return sb.toString();
-        }
-
-        private void printNetworkInfo() {
-            boolean hasIccCard = mTm.hasIccCard();
-            int simState = mTm.getSimState();
-            log("hasIccCard=" + hasIccCard
-                    + " simState=" + simState);
-            NetworkInfo[] ni = mCs.getAllNetworkInfo();
-            if (ni != null) {
-                log("ni.length=" + ni.length);
-                for (NetworkInfo netInfo: ni) {
-                    log("netInfo=" + netInfo.toString());
-                }
-            } else {
-                log("no network info ni=null");
-            }
-        }
-
-        /**
-         * Sleep for a few seconds then return.
-         * @param seconds
-         */
-        private static void sleep(int seconds) {
-            long stopTime = System.nanoTime() + (seconds * 1000000000);
-            long sleepTime;
-            while ((sleepTime = stopTime - System.nanoTime()) > 0) {
-                try {
-                    Thread.sleep(sleepTime / 1000000);
-                } catch (InterruptedException ignored) {
-                }
-            }
-        }
-
-        private static void log(String s) {
-            Slog.d(ConnectivityService.TAG, "[" + CHECKMP_TAG + "] " + s);
-        }
-    }
-
-    // TODO: Move to ConnectivityManager and make public?
-    private static final String CONNECTED_TO_PROVISIONING_NETWORK_ACTION =
-            "com.android.server.connectivityservice.CONNECTED_TO_PROVISIONING_NETWORK_ACTION";
-
-    private BroadcastReceiver mProvisioningReceiver = new BroadcastReceiver() {
-        @Override
-        public void onReceive(Context context, Intent intent) {
-            if (intent.getAction().equals(CONNECTED_TO_PROVISIONING_NETWORK_ACTION)) {
-                handleMobileProvisioningAction(intent.getStringExtra("EXTRA_URL"));
-            }
-        }
-    };
-
-    private void handleMobileProvisioningAction(String url) {
-        // Mark notification as not visible
-        setProvNotificationVisible(false, ConnectivityManager.TYPE_MOBILE_HIPRI, null, null);
-
-        // Check airplane mode
-        boolean isAirplaneModeOn = Settings.System.getInt(mContext.getContentResolver(),
-                Settings.Global.AIRPLANE_MODE_ON, 0) == 1;
-        // If provisioning network and not in airplane mode handle as a special case,
-        // otherwise launch browser with the intent directly.
-        if (mIsProvisioningNetwork.get() && !isAirplaneModeOn) {
-            if (DBG) log("handleMobileProvisioningAction: on prov network enable then launch");
-            mIsProvisioningNetwork.set(false);
-//            mIsStartingProvisioning.set(true);
-//            MobileDataStateTracker mdst = (MobileDataStateTracker)
-//                    mNetTrackers[ConnectivityManager.TYPE_MOBILE];
-            // Radio was disabled on CMP_RESULT_CODE_PROVISIONING_NETWORK, enable it here
-//            mdst.setRadio(true);
-//            mdst.setEnableFailFastMobileData(DctConstants.ENABLED);
-//            mdst.enableMobileProvisioning(url);
-        } else {
-            if (DBG) log("handleMobileProvisioningAction: not prov network");
-            mIsProvisioningNetwork.set(false);
-            // Check for  apps that can handle provisioning first
-            Intent provisioningIntent = new Intent(TelephonyIntents.ACTION_CARRIER_SETUP);
-            List<String> carrierPackages =
-                    mTelephonyManager.getCarrierPackageNamesForIntent(provisioningIntent);
-            if (carrierPackages != null && !carrierPackages.isEmpty()) {
-                if (carrierPackages.size() != 1) {
-                    if (DBG) log("Multiple matching carrier apps found, launching the first.");
-                }
-                provisioningIntent.setPackage(carrierPackages.get(0));
-                provisioningIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT |
-                        Intent.FLAG_ACTIVITY_NEW_TASK);
-                mContext.startActivity(provisioningIntent);
-            } else {
-                // If no apps exist, use standard URL ACTION_VIEW method
-                Intent newIntent = Intent.makeMainSelectorActivity(Intent.ACTION_MAIN,
-                        Intent.CATEGORY_APP_BROWSER);
-                newIntent.setData(Uri.parse(url));
-                newIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT |
-                        Intent.FLAG_ACTIVITY_NEW_TASK);
-                try {
-                    mContext.startActivity(newIntent);
-                } catch (ActivityNotFoundException e) {
-                    loge("handleMobileProvisioningAction: startActivity failed" + e);
-                }
-            }
-        }
+        // TODO: Remove?  Any reason to trigger a provisioning check?
+        return -1;
     }
 
     private static final String NOTIFICATION_ID = "CaptivePortal.Notification";
     private volatile boolean mIsNotificationVisible = false;
 
-    private void setProvNotificationVisible(boolean visible, int networkType, String extraInfo,
-            String url) {
+    private void setProvNotificationVisible(boolean visible, int networkType, String action) {
         if (DBG) {
             log("setProvNotificationVisible: E visible=" + visible + " networkType=" + networkType
-                + " extraInfo=" + extraInfo + " url=" + url);
+                + " action=" + action);
         }
-        Intent intent = null;
-        PendingIntent pendingIntent = null;
-        if (visible) {
-            switch (networkType) {
-                case ConnectivityManager.TYPE_WIFI:
-                    intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
-                    intent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT |
-                            Intent.FLAG_ACTIVITY_NEW_TASK);
-                    pendingIntent = PendingIntent.getActivity(mContext, 0, intent, 0);
-                    break;
-                case ConnectivityManager.TYPE_MOBILE:
-                case ConnectivityManager.TYPE_MOBILE_HIPRI:
-                    intent = new Intent(CONNECTED_TO_PROVISIONING_NETWORK_ACTION);
-                    intent.putExtra("EXTRA_URL", url);
-                    intent.setFlags(0);
-                    pendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
-                    break;
-                default:
-                    intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
-                    intent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT |
-                            Intent.FLAG_ACTIVITY_NEW_TASK);
-                    pendingIntent = PendingIntent.getActivity(mContext, 0, intent, 0);
-                    break;
-            }
-        }
+        Intent intent = new Intent(action);
+        PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
         // Concatenate the range of types onto the range of NetIDs.
         int id = MAX_NET_ID + 1 + (networkType - ConnectivityManager.TYPE_NONE);
-        setProvNotificationVisibleIntent(visible, id, networkType, extraInfo, pendingIntent);
+        setProvNotificationVisibleIntent(visible, id, networkType, null, pendingIntent);
     }
 
     /**
@@ -3860,9 +3131,14 @@
 
     @Override
     public void setProvisioningNotificationVisible(boolean visible, int networkType,
-            String extraInfo, String url) {
+            String action) {
         enforceConnectivityInternalPermission();
-        setProvNotificationVisible(visible, networkType, extraInfo, url);
+        final long ident = Binder.clearCallingIdentity();
+        try {
+            setProvNotificationVisible(visible, networkType, action);
+        } finally {
+            Binder.restoreCallingIdentity(ident);
+        }
     }
 
     @Override
diff --git a/services/core/java/com/android/server/notification/DowntimeConditionProvider.java b/services/core/java/com/android/server/notification/DowntimeConditionProvider.java
index b71bad8..efe47c3 100644
--- a/services/core/java/com/android/server/notification/DowntimeConditionProvider.java
+++ b/services/core/java/com/android/server/notification/DowntimeConditionProvider.java
@@ -193,7 +193,8 @@
     }
 
     private boolean isInDowntime(int daysOffset, long time, long start, long end) {
-        final int day = ((getDayOfWeek(time) + daysOffset - 1) % Calendar.SATURDAY) + 1;
+        final int n = Calendar.SATURDAY;
+        final int day = ((getDayOfWeek(time) - 1) + (daysOffset % n) + n) % n + 1;
         start = addDays(start, daysOffset);
         end = addDays(end, daysOffset);
         return mDays.contains(day) && time >= start && time < end;
diff --git a/services/core/java/com/android/server/notification/ValidateNotificationPeople.java b/services/core/java/com/android/server/notification/ValidateNotificationPeople.java
index 6e2a8ad..11d00cf 100644
--- a/services/core/java/com/android/server/notification/ValidateNotificationPeople.java
+++ b/services/core/java/com/android/server/notification/ValidateNotificationPeople.java
@@ -231,7 +231,7 @@
                 if (lookupResult == null || lookupResult.isExpired()) {
                     pendingLookups.add(handle);
                 } else {
-                    if (DEBUG) Slog.d(TAG, "using cached lookupResult: " + lookupResult.mId);
+                    if (DEBUG) Slog.d(TAG, "using cached lookupResult");
                 }
                 if (lookupResult != null) {
                     affinity = Math.max(affinity, lookupResult.getAffinity());
@@ -336,11 +336,14 @@
         Cursor c = null;
         try {
             c = context.getContentResolver().query(lookupUri, LOOKUP_PROJECTION, null, null, null);
-            if (c != null && c.getCount() > 0) {
-                c.moveToFirst();
-                lookupResult.readContact(c);
+            if (c == null) {
+                Slog.w(TAG, "Null cursor from contacts query.");
+                return lookupResult;
             }
-        } catch(Throwable t) {
+            while (c.moveToNext()) {
+                lookupResult.mergeContact(c);
+            }
+        } catch (Throwable t) {
             Slog.w(TAG, "Problem getting content resolver or performing contacts query.", t);
         } finally {
             if (c != null) {
@@ -352,61 +355,54 @@
 
     private static class LookupResult {
         private static final long CONTACT_REFRESH_MILLIS = 60 * 60 * 1000;  // 1hr
-        public static final int INVALID_ID = -1;
 
         private final long mExpireMillis;
-        private int mId;
-        private boolean mStarred;
+        private float mAffinity = NONE;
 
         public LookupResult() {
-            mId = INVALID_ID;
-            mStarred = false;
             mExpireMillis = System.currentTimeMillis() + CONTACT_REFRESH_MILLIS;
         }
 
-        public void readContact(Cursor cursor) {
+        public void mergeContact(Cursor cursor) {
+            mAffinity = Math.max(mAffinity, VALID_CONTACT);
+
+            // Contact ID
+            int id;
             final int idIdx = cursor.getColumnIndex(Contacts._ID);
             if (idIdx >= 0) {
-                mId = cursor.getInt(idIdx);
-                if (DEBUG) Slog.d(TAG, "contact _ID is: " + mId);
+                id = cursor.getInt(idIdx);
+                if (DEBUG) Slog.d(TAG, "contact _ID is: " + id);
             } else {
-                if (DEBUG) Slog.d(TAG, "invalid cursor: no _ID");
+                id = -1;
+                Slog.i(TAG, "invalid cursor: no _ID");
             }
+
+            // Starred
             final int starIdx = cursor.getColumnIndex(Contacts.STARRED);
             if (starIdx >= 0) {
-                mStarred = cursor.getInt(starIdx) != 0;
-                if (DEBUG) Slog.d(TAG, "contact STARRED is: " + mStarred);
+                boolean isStarred = cursor.getInt(starIdx) != 0;
+                if (isStarred) {
+                    mAffinity = Math.max(mAffinity, STARRED_CONTACT);
+                }
+                if (DEBUG) Slog.d(TAG, "contact STARRED is: " + isStarred);
             } else {
                 if (DEBUG) Slog.d(TAG, "invalid cursor: no STARRED");
             }
         }
 
-        public boolean isExpired() {
+        private boolean isExpired() {
             return mExpireMillis < System.currentTimeMillis();
         }
 
-        public boolean isInvalid() {
-            return mId == INVALID_ID || isExpired();
+        private boolean isInvalid() {
+            return mAffinity == NONE || isExpired();
         }
 
         public float getAffinity() {
             if (isInvalid()) {
                 return NONE;
-            } else if (mStarred) {
-                return STARRED_CONTACT;
-            } else {
-                return VALID_CONTACT;
             }
-        }
-
-        public LookupResult setStarred(boolean starred) {
-            mStarred = starred;
-            return this;
-        }
-
-        public LookupResult setId(int id) {
-            mId = id;
-            return this;
+            return mAffinity;
         }
     }
 
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/Config.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/Config.java
index 16b54f1..82a5130 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/Config.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/Config.java
@@ -73,8 +73,7 @@
 
     public static String getTime(int platformVersion) {
         if (platformVersion == 0) {
-            // TODO: revisit when the version is selected.
-            return "4:57";
+            return "5:00";
         }
         if (platformVersion < GINGERBREAD) {
             return "2:20";