Call into the notification manager when the panel is revealed.

This lets it turn off the LED.  However, it seems like somebody broke
the notification LEDs.  GRRR.

Change-Id: I3f7066c2b2e1673dc0144a34cf59946351a647be
diff --git a/core/java/com/android/internal/statusbar/IStatusBarService.aidl b/core/java/com/android/internal/statusbar/IStatusBarService.aidl
index e3862ff..045c24f 100644
--- a/core/java/com/android/internal/statusbar/IStatusBarService.aidl
+++ b/core/java/com/android/internal/statusbar/IStatusBarService.aidl
@@ -35,7 +35,7 @@
     // You need the STATUS_BAR_SERVICE permission
     void registerStatusBar(IStatusBar callbacks, out StatusBarIconList iconList,
             out List<IBinder> notificationKeys, out List<StatusBarNotification> notifications);
-    void visibilityChanged(boolean visible);
+    void onPanelRevealed();
     void onNotificationClick(String pkg, String tag, int id);
     void onNotificationError(String pkg, String tag, int id, String message);
     void onClearAllNotifications();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/PhoneStatusBarService.java b/packages/SystemUI/src/com/android/systemui/statusbar/PhoneStatusBarService.java
index ae97400..d93a6c90 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/PhoneStatusBarService.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/PhoneStatusBarService.java
@@ -153,6 +153,7 @@
     TrackingView mTrackingView;
     WindowManager.LayoutParams mTrackingParams;
     int mTrackingPosition; // the position of the top of the tracking view.
+    private boolean mPanelSlightlyVisible;
 
     // ticker
     private Ticker mTicker;
@@ -1297,8 +1298,15 @@
                 // because the window itself extends below the content view.
                 mExpandedParams.y = -disph;
             }
-            visibilityChanged(visible);
             mExpandedDialog.getWindow().setAttributes(mExpandedParams);
+
+            // As long as this isn't just a repositioning that's not supposed to affect
+            // the user's perception of what's showing, call to say that the visibility
+            // has changed. (Otherwise, someone else will call to do that).
+            if (expandedPosition != EXPANDED_LEAVE_ALONE) {
+                Slog.d(TAG, "updateExpandedViewPos visibilityChanged(" + visible + ")");
+                visibilityChanged(visible);
+            }
         }
 
         if (SPEW) {
@@ -1328,12 +1336,11 @@
      * turned off.  If any other notifications happen, the lights will turn back on.  Steve says
      * this is what he wants. (see bug 1131461)
      */
-    private boolean mPanelSlightlyVisible;
     void visibilityChanged(boolean visible) {
         if (mPanelSlightlyVisible != visible) {
             mPanelSlightlyVisible = visible;
             try {
-                mBarService.visibilityChanged(visible);
+                mBarService.onPanelRevealed();
             } catch (RemoteException ex) {
                 // Won't fail unless the world has ended.
             }
diff --git a/services/java/com/android/server/StatusBarManagerService.java b/services/java/com/android/server/StatusBarManagerService.java
index 72d113a..176417a 100644
--- a/services/java/com/android/server/StatusBarManagerService.java
+++ b/services/java/com/android/server/StatusBarManagerService.java
@@ -277,13 +277,14 @@
     }
 
     /**
-     * The status bar service should call this when the user changes whether
-     * the status bar is visible or not.
+     * The status bar service should call this each time the user brings the panel from
+     * invisible to visible in order to clear the notification light.
      */
-    public void visibilityChanged(boolean visible) {
+    public void onPanelRevealed() {
         enforceStatusBarService();
 
-        //Slog.d(TAG, "visibilityChanged visible=" + visible);
+        // tell the notification manager to turn off the lights.
+        mNotificationCallbacks.onPanelRevealed();
     }
 
     public void onNotificationClick(String pkg, String tag, int id) {
@@ -445,24 +446,6 @@
         }
     }
 
-    /**
-     * The LEDs are turned o)ff when the notification panel is shown, even just a little bit.
-     * This was added last-minute and is inconsistent with the way the rest of the notifications
-     * are handled, because the notification isn't really cancelled.  The lights are just
-     * turned off.  If any other notifications happen, the lights will turn back on.  Steve says
-     * this is what he wants. (see bug 1131461)
-     */
-    private boolean mPanelSlightlyVisible;
-    void panelSlightlyVisible(boolean visible) {
-        if (mPanelSlightlyVisible != visible) {
-            mPanelSlightlyVisible = visible;
-            if (visible) {
-                // tell the notification manager to turn off the lights.
-                mNotificationCallbacks.onPanelRevealed();
-            }
-        }
-    }
-
     private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
         public void onReceive(Context context, Intent intent) {
             String action = intent.getAction();