Clean up user activity handling

- Only call userActivity in down touch event
- Use normal timeout when QS is open
- Clean up old code regarding user activity in Keyguard

Change-Id: I968eeed33fef44def37b68eb1ddc63f1a531ab35
diff --git a/packages/Keyguard/src/com/android/keyguard/FaceUnlock.java b/packages/Keyguard/src/com/android/keyguard/FaceUnlock.java
index 2f14003..8d13ac2 100644
--- a/packages/Keyguard/src/com/android/keyguard/FaceUnlock.java
+++ b/packages/Keyguard/src/com/android/keyguard/FaceUnlock.java
@@ -66,10 +66,6 @@
     // mRunning and mServiceRunning.  I'd just rather wait to change that logic.
     private volatile boolean mIsRunning = false;
 
-    // So the user has a consistent amount of time when brought to the backup method from Face
-    // Unlock
-    private final int BACKUP_LOCK_TIMEOUT = 5000;
-
     KeyguardSecurityCallback mKeyguardScreenCallback;
 
     /**
@@ -268,7 +264,7 @@
                 // When switching between portrait and landscape view while Face Unlock is running,
                 // the screen will eventually go dark unless we poke the wakelock when Face Unlock
                 // is restarted.
-                mKeyguardScreenCallback.userActivity(0);
+                mKeyguardScreenCallback.userActivity();
 
                 int[] position;
                 position = new int[2];
@@ -325,7 +321,7 @@
 
         mKeyguardScreenCallback.showBackupSecurity();
         stop();
-        mKeyguardScreenCallback.userActivity(BACKUP_LOCK_TIMEOUT);
+        mKeyguardScreenCallback.userActivity();
     }
 
     /**
@@ -347,7 +343,7 @@
     void handlePokeWakelock(int millis) {
       PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
       if (powerManager.isScreenOn()) {
-        mKeyguardScreenCallback.userActivity(millis);
+        mKeyguardScreenCallback.userActivity();
       }
     }
 
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java
index c49c318..2c9247a 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java
@@ -152,7 +152,7 @@
 
     @Override
     public boolean onKeyDown(int keyCode, KeyEvent event) {
-        mCallback.userActivity(0);
+        mCallback.userActivity();
         return false;
     }
 
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardAccountView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardAccountView.java
index 69abc7a..2432509 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardAccountView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardAccountView.java
@@ -50,7 +50,6 @@
  */
 public class KeyguardAccountView extends LinearLayout implements KeyguardSecurityView,
         View.OnClickListener, TextWatcher {
-    private static final int AWAKE_POKE_MILLIS = 30000;
     private static final String LOCK_PATTERN_PACKAGE = "com.android.settings";
     private static final String LOCK_PATTERN_CLASS = LOCK_PATTERN_PACKAGE + ".ChooseLockGeneric";
 
@@ -119,7 +118,7 @@
 
     public void onTextChanged(CharSequence s, int start, int before, int count) {
         if (mCallback != null) {
-            mCallback.userActivity(AWAKE_POKE_MILLIS);
+            mCallback.userActivity();
         }
     }
 
@@ -154,7 +153,7 @@
     }
 
     public void onClick(View v) {
-        mCallback.userActivity(0);
+        mCallback.userActivity();
         if (v == mOk) {
             asyncCheckPassword();
         }
@@ -258,7 +257,7 @@
     }
 
     private void asyncCheckPassword() {
-        mCallback.userActivity(AWAKE_POKE_MILLIS);
+        mCallback.userActivity();
         final String login = mLogin.getText().toString();
         final String password = mPassword.getText().toString();
         Account account = findIntendedAccount(login);
@@ -273,7 +272,7 @@
                 new AccountManagerCallback<Bundle>() {
             public void run(AccountManagerFuture<Bundle> future) {
                 try {
-                    mCallback.userActivity(AWAKE_POKE_MILLIS);
+                    mCallback.userActivity();
                     final Bundle result = future.getResult();
                     final boolean verified = result.getBoolean(AccountManager.KEY_BOOLEAN_RESULT);
                     postOnCheckPasswordResult(verified);
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardConstants.java b/packages/Keyguard/src/com/android/keyguard/KeyguardConstants.java
index bfa95f38..77643bd 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardConstants.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardConstants.java
@@ -26,7 +26,4 @@
      * be used temporarily for debugging.
      */
     public static final boolean DEBUG = false;
-
-    /** Timeout used for key presses. */
-    public static final int DIGIT_PRESS_WAKE_MILLIS = 5000;
 }
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardPasswordView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardPasswordView.java
index 9f820f8..99ff6a7 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardPasswordView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardPasswordView.java
@@ -111,7 +111,7 @@
         // Poke the wakelock any time the text is selected or modified
         mPasswordEntry.setOnClickListener(new OnClickListener() {
             public void onClick(View v) {
-                mCallback.userActivity(0); // TODO: customize timeout for text?
+                mCallback.userActivity();
             }
         });
 
@@ -127,7 +127,7 @@
 
             public void afterTextChanged(Editable s) {
                 if (mCallback != null) {
-                    mCallback.userActivity(0);
+                    mCallback.userActivity();
                 }
             }
         });
@@ -141,7 +141,7 @@
             imeOrDeleteButtonVisible = true;
             switchImeButton.setOnClickListener(new OnClickListener() {
                 public void onClick(View v) {
-                    mCallback.userActivity(0); // Leave the screen on a bit longer
+                    mCallback.userActivity(); // Leave the screen on a bit longer
                     mImm.showInputMethodPicker();
                 }
             });
@@ -247,7 +247,7 @@
     @Override
     public void beforeTextChanged(CharSequence s, int start, int count, int after) {
         if (mCallback != null) {
-            mCallback.userActivity(KeyguardConstants.DIGIT_PRESS_WAKE_MILLIS);
+            mCallback.userActivity();
         }
     }
 
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java
index a0b5536..d5dcd71 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java
@@ -59,9 +59,6 @@
     // how long we stay awake after each key beyond MIN_PATTERN_BEFORE_POKE_WAKELOCK
     private static final int UNLOCK_PATTERN_WAKE_INTERVAL_MS = 7000;
 
-    // how long we stay awake after the user hits the first dot.
-    private static final int UNLOCK_PATTERN_WAKE_INTERVAL_FIRST_DOTS_MS = 2000;
-
     // how many cells the user has to cross before we poke the wakelock
     private static final int MIN_PATTERN_BEFORE_POKE_WAKELOCK = 2;
 
@@ -256,14 +253,7 @@
         }
 
         public void onPatternCellAdded(List<LockPatternView.Cell> pattern) {
-            // To guard against accidental poking of the wakelock, look for
-            // the user actually trying to draw a pattern of some minimal length.
-            if (pattern.size() > MIN_PATTERN_BEFORE_POKE_WAKELOCK) {
-                mCallback.userActivity(UNLOCK_PATTERN_WAKE_INTERVAL_MS);
-            } else {
-                // Give just a little extra time if they hit one of the first few dots
-                mCallback.userActivity(UNLOCK_PATTERN_WAKE_INTERVAL_FIRST_DOTS_MS);
-            }
+            mCallback.userActivity();
         }
 
         public void onPatternDetected(List<LockPatternView.Cell> pattern) {
@@ -273,7 +263,7 @@
                 mCallback.dismiss(true);
             } else {
                 if (pattern.size() > MIN_PATTERN_BEFORE_POKE_WAKELOCK) {
-                    mCallback.userActivity(UNLOCK_PATTERN_WAKE_INTERVAL_MS);
+                    mCallback.userActivity();
                 }
                 mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Wrong);
                 boolean registeredAttempt =
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardPinBasedInputView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardPinBasedInputView.java
index b6f6fd6..bca0305 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardPinBasedInputView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardPinBasedInputView.java
@@ -148,7 +148,7 @@
         // Poke the wakelock any time the text is selected or modified
         mPasswordEntry.setOnClickListener(new OnClickListener() {
             public void onClick(View v) {
-                mCallback.userActivity(0); // TODO: customize timeout for text?
+                mCallback.userActivity();
             }
         });
 
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityCallback.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityCallback.java
index 975ad6c..f361b5c 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityCallback.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityCallback.java
@@ -24,11 +24,9 @@
     void dismiss(boolean securityVerified);
 
     /**
-     * Manually report user activity to keep the device awake. If timeout is 0,
-     * uses user-defined timeout.
-     * @param timeout
+     * Manually report user activity to keep the device awake.
      */
-    void userActivity(long timeout);
+    void userActivity();
 
     /**
      * Checks if keyguard is in "verify credentials" mode.
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java
index 382cbec..7727e4a 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java
@@ -47,7 +47,7 @@
     // Used to notify the container when something interesting happens.
     public interface SecurityCallback {
         public boolean dismiss(boolean authenticated);
-        public void userActivity(long timeout);
+        public void userActivity();
         public void onSecurityModeChanged(SecurityMode securityMode, boolean needsInput);
         public void finish();
     }
@@ -419,9 +419,9 @@
 
     private KeyguardSecurityCallback mCallback = new KeyguardSecurityCallback() {
 
-        public void userActivity(long timeout) {
+        public void userActivity() {
             if (mSecurityCallback != null) {
-                mSecurityCallback.userActivity(timeout);
+                mSecurityCallback.userActivity();
             }
         }
 
@@ -459,7 +459,7 @@
     // state for the current security method.
     private KeyguardSecurityCallback mNullCallback = new KeyguardSecurityCallback() {
         @Override
-        public void userActivity(long timeout) { }
+        public void userActivity() { }
         @Override
         public void showBackupSecurity() { }
         @Override
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSelectorView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSelectorView.java
index 98baa04..85bd87d 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardSelectorView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSelectorView.java
@@ -58,7 +58,7 @@
 
             if (resId == R.drawable.ic_lockscreen_unlock_phantom
                     || resId == R.drawable.ic_lockscreen_unlock) {
-                mCallback.userActivity(0);
+                mCallback.userActivity();
                 mCallback.dismiss(false);
             }
         }
@@ -70,7 +70,7 @@
         }
 
         public void onGrabbed(View v, int handle) {
-            mCallback.userActivity(0);
+            mCallback.userActivity();
             doTransition(mFadeView, 0.0f);
         }
 
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSimPinView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSimPinView.java
index cc90bcb..e8e3b19 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardSimPinView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSimPinView.java
@@ -185,7 +185,7 @@
             // otherwise, display a message to the user, and don't submit.
             mSecurityMessageDisplay.setMessage(R.string.kg_invalid_sim_pin_hint, true);
             resetPasswordText(true);
-            mCallback.userActivity(0);
+            mCallback.userActivity();
             return;
         }
 
@@ -223,7 +223,7 @@
                                         + " attemptsRemaining=" + attemptsRemaining);
                                 resetPasswordText(true /* animate */);
                             }
-                            mCallback.userActivity(0);
+                            mCallback.userActivity();
                             mCheckSimPinThread = null;
                         }
                     });
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java b/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java
index 8945b15..737e49b 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java
@@ -155,17 +155,6 @@
         return mSecurityContainer;
     }
 
-    /**
-     * Extend display timeout
-     * @param timeout duration to delay timeout, in ms.
-     */
-    @Override
-    public void userActivity(long timeout) {
-        if (mViewMediatorCallback != null) {
-            mViewMediatorCallback.userActivity(timeout);
-        }
-    }
-
     @Override
     public boolean dismiss(boolean authenticated) {
         return mSecurityContainer.showNextSecurityScreenOrFinish(authenticated);
diff --git a/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java b/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java
index 1f23785..f74843e 100644
--- a/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java
+++ b/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java
@@ -27,13 +27,6 @@
     void userActivity();
 
     /**
-     * Reports user activity and requests that the screen stay on for at least
-     * the specified amount of time.
-     * @param millis The amount of time in millis.  This value is currently ignored.
-     */
-    void userActivity(long millis);
-
-    /**
      * Report that the keyguard is done.
      * @param authenticated Whether the user securely got past the keyguard.
      *   the only reason for this to be false is if the keyguard was instructed
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index 85f58881..0681ff4 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -29,7 +29,6 @@
 import android.content.IntentFilter;
 import android.media.AudioManager;
 import android.media.SoundPool;
-import android.os.Build;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Looper;
@@ -45,8 +44,8 @@
 import android.util.EventLog;
 import android.util.Log;
 import android.util.Slog;
-import android.view.ViewGroup;
 import android.view.IWindowManager;
+import android.view.ViewGroup;
 import android.view.WindowManagerGlobal;
 import android.view.WindowManagerPolicy;
 
@@ -65,8 +64,6 @@
 import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
 import com.android.systemui.statusbar.phone.StatusBarWindowManager;
 
-import java.io.File;
-
 import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
 
 
@@ -406,10 +403,6 @@
             KeyguardViewMediator.this.userActivity();
         }
 
-        public void userActivity(long holdMs) {
-            KeyguardViewMediator.this.userActivity(holdMs);
-        }
-
         public void keyguardDone(boolean authenticated) {
             KeyguardViewMediator.this.keyguardDone(authenticated, true);
         }
@@ -439,13 +432,7 @@
         }
     };
 
-    private void userActivity() {
-        userActivity(AWAKE_INTERVAL_DEFAULT_MS);
-    }
-
-    public void userActivity(long holdMs) {
-        // We ignore the hold time.  Eventually we should remove it.
-        // Instead, the keyguard window has an explicit user activity timeout set on it.
+    public void userActivity() {
         mPM.userActivity(SystemClock.uptimeMillis(), false);
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardPageSwipeHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardPageSwipeHelper.java
index e312d58..d5f9619 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardPageSwipeHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardPageSwipeHelper.java
@@ -59,7 +59,6 @@
     private int mMinTranslationAmount;
     private int mMinFlingVelocity;
     private int mHintDistance;
-    private PowerManager mPowerManager;
     private final View mLeftIcon;
     private final View mCenterIcon;
     private final View mRightIcon;
@@ -77,7 +76,6 @@
         updateIcon(mLeftIcon, 1.0f, SWIPE_RESTING_ALPHA_AMOUNT, false);
         updateIcon(mCenterIcon, 1.0f, SWIPE_RESTING_ALPHA_AMOUNT, false);
         updateIcon(mRightIcon, 1.0f, SWIPE_RESTING_ALPHA_AMOUNT, false);
-        mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
         initDimens();
     }
 
@@ -145,7 +143,6 @@
                 }
                 if (mSwipingInProgress) {
                     setTranslation(mTranslationOnDown + x - mInitialTouchX, false);
-                    onUserActivity(event.getEventTime());
                 }
                 break;
 
@@ -254,10 +251,6 @@
         }
     }
 
-    private void onUserActivity(long when) {
-        mPowerManager.userActivity(when, false);
-    }
-
     private void cancelAnimations() {
         ArrayList<View> targetViews = mCallback.getTranslationViews();
         for (View target : targetViews) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index 0c6ea50..82e082b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -618,6 +618,7 @@
             updateQsState();
             requestPanelHeightUpdate();
             mNotificationStackScroller.setInterceptDelegateEnabled(expanded);
+            mStatusBar.setQsExpanded(expanded);
         }
     }
 
@@ -657,7 +658,6 @@
         setQsTranslation(height);
         requestScrollerTopPaddingUpdate(false /* animate */);
         updateNotificationScrim(height);
-        mStatusBar.userActivity();
     }
 
     private void updateNotificationScrim(float height) {
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 2c5ece6..c962dde 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -368,6 +368,7 @@
 
         switch (event.getActionMasked()) {
             case MotionEvent.ACTION_DOWN:
+                mStatusBar.userActivity();
                 if (mHeightAnimator != null && !mHintAnimationRunning ||
                         mPeekPending || mPeekAnimator != null) {
                     if (mHeightAnimator != null) {
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 62e2734..4c34eb1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -61,6 +61,7 @@
 import android.os.PowerManager;
 import android.os.RemoteException;
 import android.os.SystemClock;
+import android.os.Trace;
 import android.os.UserHandle;
 import android.provider.Settings;
 import android.provider.Settings.SettingNotFoundException;
@@ -377,14 +378,6 @@
     private Interpolator mAlphaIn = new PathInterpolator(0f, 0.2f, 1f, 1f);
     private Interpolator mAlphaOut = new PathInterpolator(0f, 0f, 0.8f, 1f);
 
-    private final OnChildLocationsChangedListener mOnChildLocationsChangedListener =
-            new OnChildLocationsChangedListener() {
-        @Override
-        public void onChildLocationsChanged(NotificationStackScrollLayout stackScrollLayout) {
-            userActivity();
-        }
-    };
-
     private int mDisabledUnmodified;
 
     /** Keys of notifications currently visible to the user. */
@@ -608,7 +601,6 @@
         mStackScroller = (NotificationStackScrollLayout) mStatusBarWindow.findViewById(
                 R.id.notification_stack_scroller);
         mStackScroller.setLongPressListener(getNotificationLongClicker());
-        mStackScroller.setChildLocationsChangedListener(mOnChildLocationsChangedListener);
 
         mKeyguardIconOverflowContainer =
                 (NotificationOverflowContainer) LayoutInflater.from(mContext).inflate(
@@ -1553,6 +1545,10 @@
         return mScrimController;
     }
 
+    public void setQsExpanded(boolean expanded) {
+        mStatusBarWindowManager.setQsExpanded(expanded);
+    }
+
     /**
      * All changes to the status bar and notifications funnel through here and are batched.
      */
@@ -2886,8 +2882,9 @@
     }
 
     public void userActivity() {
-        mHandler.removeCallbacks(mUserActivity);
-        mHandler.post(mUserActivity);
+        if (mState == StatusBarState.KEYGUARD) {
+            mKeyguardViewMediatorCallback.userActivity();
+        }
     }
 
     public boolean interceptMediaKey(KeyEvent event) {
@@ -2928,7 +2925,6 @@
 
     @Override
     public void onActivated(ActivatableNotificationView view) {
-        userActivity();
         mKeyguardIndicationController.showTransientIndication(R.string.notification_tap_again);
         ActivatableNotificationView previousView = mStackScroller.getActivatedChild();
         if (previousView != null) {
@@ -3094,15 +3090,6 @@
         }
     }
 
-    private final Runnable mUserActivity = new Runnable() {
-        @Override
-        public void run() {
-            if (mState == StatusBarState.KEYGUARD) {
-                mKeyguardViewMediatorCallback.userActivity();
-            }
-        }
-    };
-
     // Recents
 
     @Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
index 103a582..6411fb8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
@@ -173,6 +173,5 @@
         super.panelExpansionChanged(panel, frac, expanded);
         mScrimController.setPanelExpansion(frac);
         mBar.updateCarrierLabelVisibility(false);
-        mBar.userActivity();
     }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
index fe57cef..6cb0f95 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
@@ -139,7 +139,8 @@
 
     private void applyUserActivityTimeout(State state) {
         if (state.isKeyguardShowingAndNotOccluded()
-                && state.statusBarState == StatusBarState.KEYGUARD) {
+                && state.statusBarState == StatusBarState.KEYGUARD
+                && !state.qsExpanded) {
             mLp.userActivityTimeout = state.keyguardUserActivityTimeout;
         } else {
             mLp.userActivityTimeout = -1;
@@ -148,7 +149,8 @@
 
     private void applyInputFeatures(State state) {
         if (state.isKeyguardShowingAndNotOccluded()
-                && state.statusBarState == StatusBarState.KEYGUARD) {
+                && state.statusBarState == StatusBarState.KEYGUARD
+                && !state.qsExpanded) {
             mLp.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_DISABLE_USER_ACTIVITY;
         } else {
             mLp.inputFeatures &= ~WindowManager.LayoutParams.INPUT_FEATURE_DISABLE_USER_ACTIVITY;
@@ -207,6 +209,11 @@
         apply(mCurrentState);
     }
 
+    public void setQsExpanded(boolean expanded) {
+        mCurrentState.qsExpanded = expanded;
+        apply(mCurrentState);
+    }
+
     /**
      * @param state The {@link StatusBarState} of the status bar.
      */
@@ -224,6 +231,7 @@
         long keyguardUserActivityTimeout;
         boolean bouncerShowing;
         boolean keyguardFadingAway;
+        boolean qsExpanded;
 
         /**
          * The {@link BaseStatusBar} state from the status bar.