diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/activedisplay/ActiveDisplayView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/activedisplay/ActiveDisplayView.java index 28a82199a40..c4ad76aeb52 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/activedisplay/ActiveDisplayView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/activedisplay/ActiveDisplayView.java @@ -131,6 +131,7 @@ public class ActiveDisplayView extends FrameLayout { private Sensor mProximitySensor; private boolean mProximityIsFar = true; private boolean mIsInBrightLight = false; + private boolean mWakedByPocketMode = false; private LinearLayout mOverflowNotifications; private LayoutParams mRemoteViewLayoutParams; private int mIconSize; @@ -186,6 +187,7 @@ public void onNotificationRemoved(final StatusBarNotification sbn) { public void onTrigger(final View v, final int target) { if (target == UNLOCK_TARGET) { + mWakedByPocketMode = false; mNotification = null; hideNotificationView(); if (!mKeyguardManager.isKeyguardSecure()) { @@ -200,6 +202,7 @@ public void onTrigger(final View v, final int target) { } } } else if (target == OPEN_APP_TARGET) { + mWakedByPocketMode = false; hideNotificationView(); if (!mKeyguardManager.isKeyguardSecure()) { try { @@ -668,6 +671,7 @@ private void onScreenTurnedOff() { } private void turnScreenOff() { + mWakedByPocketMode = false; try { mPM.goToSleep(SystemClock.uptimeMillis(), 0); } catch (RemoteException e) { @@ -820,6 +824,7 @@ public void run() { } } catch (RemoteException re) { } catch (NameNotFoundException nnfe) { + } catch (Resources.NotFoundException e) { } } }); @@ -933,6 +938,7 @@ public void run() { } }); } catch (NameNotFoundException e) { + } catch (Resources.NotFoundException e) { } } @@ -997,11 +1003,20 @@ public void onSensorChanged(SensorEvent event) { if (value >= mProximitySensor.getMaximumRange()) { mProximityIsFar = true; if (!isScreenOn() && mPocketModeEnabled && !isOnCall()) { + mWakedByPocketMode = true; + mNotification = getNextAvailableNotification(); if (mNotification != null) showNotification(mNotification, true); } } else { mProximityIsFar = false; + if (isScreenOn() && mPocketModeEnabled && !isOnCall() && mWakedByPocketMode) { + mWakedByPocketMode = false; + + restoreBrightness(); + cancelTimeoutTimer(); + turnScreenOff(); + } } } else if (event.sensor.equals(mLightSensor)) { boolean isBright = mIsInBrightLight; @@ -1108,4 +1123,4 @@ private void cancelTimeoutTimer() { } catch (Exception e) { } } -} \ No newline at end of file +}