Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()) {
Expand All @@ -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 {
Expand Down Expand Up @@ -668,6 +671,7 @@ private void onScreenTurnedOff() {
}

private void turnScreenOff() {
mWakedByPocketMode = false;
try {
mPM.goToSleep(SystemClock.uptimeMillis(), 0);
} catch (RemoteException e) {
Expand Down Expand Up @@ -820,6 +824,7 @@ public void run() {
}
} catch (RemoteException re) {
} catch (NameNotFoundException nnfe) {
} catch (Resources.NotFoundException e) {
}
}
});
Expand Down Expand Up @@ -933,6 +938,7 @@ public void run() {
}
});
} catch (NameNotFoundException e) {
} catch (Resources.NotFoundException e) {
}
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1108,4 +1123,4 @@ private void cancelTimeoutTimer() {
} catch (Exception e) {
}
}
}
}