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

Commit 97eaae72 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "InCallUI: Add a controller for proximity sensor" into atel.lnx.2.0-dev

parents 49f407be 841ef18b
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.hardware.display.DisplayManager.DisplayListener;
import android.os.PowerManager;
import android.telecom.CallAudioState;
import android.view.Display;
import android.provider.Settings;

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

    private final PowerManager mPowerManager;
    private final PowerManager.WakeLock mProximityWakeLock;
@@ -52,6 +54,7 @@ public class ProximitySensor implements AccelerometerListener.OrientationListene
    private boolean mUiShowing = 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(
@@ -232,6 +236,8 @@ public class ProximitySensor implements AccelerometerListener.OrientationListene
                    || CallAudioState.ROUTE_SPEAKER == audioMode
                    || CallAudioState.ROUTE_BLUETOOTH == audioMode
                    || 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
            // horizontal, but we do not force it on when we become horizontal until the