summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHikari-no-Tenshi <kyryljan.serhij@gmail.com>2016-10-23 12:50:27 +0300
committerHikari-no-Tenshi <kyryljan.serhij@gmail.com>2016-10-23 12:50:27 +0300
commit571bf69cfd40db6f2a2ca6b65a73fb65cdf34acc (patch)
tree623ec853a917ae2bcb6455782178ad8b81e7e55c
parent26159fb3723102eb962f641915d8f52a1ed992ba (diff)
downloadandroid_packages_apps_Dialer-cm-14.0.tar.gz
android_packages_apps_Dialer-cm-14.0.tar.bz2
android_packages_apps_Dialer-cm-14.0.zip
Let InCallUI handle proximity sensor for incoming calls [2/2]cm-14.0
Change-Id: I939a70ac09a8868e128a7ecc982a570993cb86c7
-rw-r--r--InCallUI/src/com/android/incallui/ProximitySensor.java17
1 files changed, 14 insertions, 3 deletions
diff --git a/InCallUI/src/com/android/incallui/ProximitySensor.java b/InCallUI/src/com/android/incallui/ProximitySensor.java
index 3c9fd9370..b9c0d8e40 100644
--- a/InCallUI/src/com/android/incallui/ProximitySensor.java
+++ b/InCallUI/src/com/android/incallui/ProximitySensor.java
@@ -23,6 +23,7 @@ import android.content.res.Configuration;
import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManager.DisplayListener;
import android.os.PowerManager;
+import cyanogenmod.providers.CMSettings;
import android.telecom.CallAudioState;
import android.view.Display;
@@ -50,8 +51,10 @@ public class ProximitySensor implements AccelerometerListener.OrientationListene
private final ProximityDisplayListener mDisplayListener;
private int mOrientation = AccelerometerListener.ORIENTATION_UNKNOWN;
private boolean mUiShowing = false;
+ private boolean mHasIncomingCall = false;
private boolean mIsPhoneOffhook = false;
private boolean mDialpadVisible;
+ private Context mContext;
// True if the keyboard is currently *not* hidden
// Gets updated whenever there is a Configuration change
@@ -59,6 +62,7 @@ public class ProximitySensor implements AccelerometerListener.OrientationListene
public ProximitySensor(Context context, AudioModeProvider audioModeProvider,
AccelerometerListener accelerometerListener) {
+ mContext = context;
mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
if (mPowerManager.isWakeLockLevelSupported(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK)) {
mProximityWakeLock = mPowerManager.newWakeLock(
@@ -106,6 +110,7 @@ public class ProximitySensor implements AccelerometerListener.OrientationListene
// can also put the in-call screen in the INCALL state.
boolean hasOngoingCall = InCallState.INCALL == newState && callList.hasLiveCall();
boolean isOffhook = (InCallState.OUTGOING == newState) || hasOngoingCall;
+ mHasIncomingCall = (InCallState.INCOMING == newState);
if (isOffhook != mIsPhoneOffhook) {
mIsPhoneOffhook = isOffhook;
@@ -115,6 +120,10 @@ public class ProximitySensor implements AccelerometerListener.OrientationListene
updateProximitySensorMode();
}
+
+ if (mHasIncomingCall) {
+ updateProximitySensorMode();
+ }
}
@Override
@@ -232,6 +241,8 @@ public class ProximitySensor implements AccelerometerListener.OrientationListene
|| CallAudioState.ROUTE_SPEAKER == audioMode
|| CallAudioState.ROUTE_BLUETOOTH == audioMode
|| mIsHardKeyboardOpen);
+ screenOnImmediately |= CMSettings.System.getInt(mContext.getContentResolver(),
+ CMSettings.System.PROXIMITY_ON_WAKE, 1) == 0;
// We do not keep the screen off when the user is outside in-call screen and we are
// horizontal, but we do not force it on when we become horizontal until the
@@ -257,10 +268,10 @@ public class ProximitySensor implements AccelerometerListener.OrientationListene
.add("aud", CallAudioState.audioRouteToString(audioMode))
.toString());
- if (mIsPhoneOffhook && !screenOnImmediately) {
+ if ((mIsPhoneOffhook || mHasIncomingCall) && !screenOnImmediately) {
Log.d(this, "Turning on proximity sensor");
- // Phone is in use! Arrange for the screen to turn off
- // automatically when the sensor detects a close object.
+ // Phone is idle. We don't want any special proximity sensor
+ // behavior in this case.
turnOnProximitySensor();
} else {
Log.d(this, "Turning off proximity sensor");