From e7a567eea1613627e177c7445549abae0c89a6ee Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Tue, 20 Aug 2013 15:07:51 -0700 Subject: Adding proximity sensor code to in-call UI. Many of these changes are verbatim code copies from what used to exist in services/Telephony. The rest of them are straight logic copies that should do the exact same things. New class ProximitySensor manages the proximity behavior. It receives device state from InCallPresenter, AudioModeProvider, CallButtonPresenter, and AcceleromterListener, the last of which is a transplanted class from services/Telephony. ProximitySensor listens for the following events: 1. Change in the call state 2. Change in the audio mode 3. Change in the device orientation (from AccelerometerListener) 4. Change in the dialpad visibility 5. Change in hard keyboard open/close events. 6. Change in foreground position of InCall UI app. It uses these to figure out when to enable/disable proximity sensor. CL that removes code from TeleService: I77e0d15ad1a8f5a090c1368db98edaa246dbcd72 bug: 10366512 Change-Id: I5c2ea6daa9443e7ad77c67f272bc0bafdb060e5e --- InCallUI/AndroidManifest.xml | 1 + .../android/incallui/AccelerometerListener.java | 161 ++++++++++++++ .../com/android/incallui/CallButtonPresenter.java | 6 + .../src/com/android/incallui/InCallActivity.java | 11 + .../src/com/android/incallui/InCallPresenter.java | 13 ++ .../src/com/android/incallui/ProximitySensor.java | 232 +++++++++++++++++++++ 6 files changed, 424 insertions(+) create mode 100644 InCallUI/src/com/android/incallui/AccelerometerListener.java create mode 100644 InCallUI/src/com/android/incallui/ProximitySensor.java diff --git a/InCallUI/AndroidManifest.xml b/InCallUI/AndroidManifest.xml index 3196dba60..42d8e3173 100644 --- a/InCallUI/AndroidManifest.xml +++ b/InCallUI/AndroidManifest.xml @@ -23,6 +23,7 @@ + VERTICAL_ANGLE ? ORIENTATION_VERTICAL : ORIENTATION_HORIZONTAL); + if (VDEBUG) Log.d(TAG, "angle: " + angle + " orientation: " + orientation); + setOrientation(orientation); + } + + SensorEventListener mSensorListener = new SensorEventListener() { + public void onSensorChanged(SensorEvent event) { + onSensorEvent(event.values[0], event.values[1], event.values[2]); + } + + public void onAccuracyChanged(Sensor sensor, int accuracy) { + // ignore + } + }; + + Handler mHandler = new Handler() { + public void handleMessage(Message msg) { + switch (msg.what) { + case ORIENTATION_CHANGED: + synchronized (this) { + mOrientation = mPendingOrientation; + if (DEBUG) { + Log.d(TAG, "orientation: " + + (mOrientation == ORIENTATION_HORIZONTAL ? "horizontal" + : (mOrientation == ORIENTATION_VERTICAL ? "vertical" + : "unknown"))); + } + mListener.orientationChanged(mOrientation); + } + break; + } + } + }; +} diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java index 12cc65663..233231754 100644 --- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java +++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java @@ -33,6 +33,7 @@ public class CallButtonPresenter extends Presenter