Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 841ef18b authored by Mengjun Leng's avatar Mengjun Leng Committed by Gerrit - the friendly Code Review server
Browse files

InCallUI: Add a controller for proximity sensor

Add the setting for enable proximity sensor or not when calling

Change-Id: I292e254ab8090d9fcb739109d29d96078779467e
CRs-Fixed: 914710
parent 5a8c5bfa
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@ import android.hardware.display.DisplayManager.DisplayListener;
import android.os.PowerManager;
import android.os.PowerManager;
import android.telecom.CallAudioState;
import android.telecom.CallAudioState;
import android.view.Display;
import android.view.Display;
import android.provider.Settings;


import com.android.incallui.AudioModeProvider.AudioModeListener;
import com.android.incallui.AudioModeProvider.AudioModeListener;
import com.android.incallui.InCallPresenter.InCallState;
import com.android.incallui.InCallPresenter.InCallState;
@@ -42,6 +43,7 @@ import com.android.incallui.InCallPresenter.InCallStateListener;
public class ProximitySensor implements AccelerometerListener.OrientationListener,
public class ProximitySensor implements AccelerometerListener.OrientationListener,
        InCallStateListener, AudioModeListener {
        InCallStateListener, AudioModeListener {
    private static final String TAG = ProximitySensor.class.getSimpleName();
    private static final String TAG = ProximitySensor.class.getSimpleName();
    private static final String PROXIMITY_SENSOR = "proximity_sensor";


    private final PowerManager mPowerManager;
    private final PowerManager mPowerManager;
    private final PowerManager.WakeLock mProximityWakeLock;
    private final PowerManager.WakeLock mProximityWakeLock;
@@ -52,6 +54,7 @@ public class ProximitySensor implements AccelerometerListener.OrientationListene
    private boolean mUiShowing = false;
    private boolean mUiShowing = false;
    private boolean mIsPhoneOffhook = false;
    private boolean mIsPhoneOffhook = false;
    private boolean mDialpadVisible;
    private boolean mDialpadVisible;
    private Context mContext;


    // True if the keyboard is currently *not* hidden
    // True if the keyboard is currently *not* hidden
    // Gets updated whenever there is a Configuration change
    // Gets updated whenever there is a Configuration change
@@ -59,6 +62,7 @@ public class ProximitySensor implements AccelerometerListener.OrientationListene


    public ProximitySensor(Context context, AudioModeProvider audioModeProvider,
    public ProximitySensor(Context context, AudioModeProvider audioModeProvider,
            AccelerometerListener accelerometerListener) {
            AccelerometerListener accelerometerListener) {
        mContext = context;
        mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        if (mPowerManager.isWakeLockLevelSupported(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK)) {
        if (mPowerManager.isWakeLockLevelSupported(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK)) {
            mProximityWakeLock = mPowerManager.newWakeLock(
            mProximityWakeLock = mPowerManager.newWakeLock(
@@ -232,6 +236,8 @@ public class ProximitySensor implements AccelerometerListener.OrientationListene
                    || CallAudioState.ROUTE_SPEAKER == audioMode
                    || CallAudioState.ROUTE_SPEAKER == audioMode
                    || CallAudioState.ROUTE_BLUETOOTH == audioMode
                    || CallAudioState.ROUTE_BLUETOOTH == audioMode
                    || mIsHardKeyboardOpen);
                    || mIsHardKeyboardOpen);
            screenOnImmediately |= Settings.System.getInt(mContext.getContentResolver(),
                    PROXIMITY_SENSOR, 1) == 0;


            // We do not keep the screen off when the user is outside in-call screen and we are
            // 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
            // horizontal, but we do not force it on when we become horizontal until the