InCallUI: Add a controller for proximity sensor

Add the setting for enable proximity sensor or not when calling

Change-Id: I292e254ab8090d9fcb739109d29d96078779467e
CRs-Fixed: 914710
diff --git a/InCallUI/src/com/android/incallui/ProximitySensor.java b/InCallUI/src/com/android/incallui/ProximitySensor.java
index 3c9fd93..fbd24e5 100644
--- a/InCallUI/src/com/android/incallui/ProximitySensor.java
+++ b/InCallUI/src/com/android/incallui/ProximitySensor.java
@@ -25,6 +25,7 @@
 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 @@
 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 @@
     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 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 @@
                     || 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