Turn screen on for call-waiting calls
Normal incoming calls get the screen powered on through the window
flag FLAG_TURN_SCREEN_ON. However, this only works when the window
is being created or sent to foreground. But for call-waiting cases where
the screen is off and in-call is in foreground, the screen remains off
since the flag is not triggered.
Solution is to look for the case where the screen is off and the new
incoming call is a call-waiting call...and in that case finish() the
activity and create it again. Since the screen is off, there is no
concern over jank from bouncing the activity.
bug:11031245
Change-Id: Ic0c206d57c9d1ce5beebff49a07c7877f6d1a423
diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java
index 4b38939..1b9f60c 100644
--- a/InCallUI/src/com/android/incallui/InCallPresenter.java
+++ b/InCallUI/src/com/android/incallui/InCallPresenter.java
@@ -568,7 +568,7 @@
if (isActivityStarted()) {
mInCallActivity.dismissPendingDialogs();
}
- mStatusBarNotifier.updateNotificationAndLaunchIncomingCallUi(newState, mCallList);
+ startUi(newState);
} else if (newState == InCallState.NO_CALLS) {
// The new state is the no calls state. Tear everything down.
attemptFinishActivity();
@@ -577,6 +577,27 @@
return newState;
}
+ private void startUi(InCallState inCallState) {
+ final Call incomingCall = mCallList.getIncomingCall();
+ final boolean isCallWaiting = (incomingCall != null &&
+ incomingCall.getState() == Call.State.CALL_WAITING);
+
+ // If the screen is off, we need to make sure it gets turned on for incoming calls.
+ // This normally works just fine thanks to FLAG_TURN_SCREEN_ON but that only works
+ // when the activity is first created. Therefore, to ensure the screen is turned on
+ // for the call waiting case, we finish() the current activity and start a new one.
+ // There should be no jank from this since the screen is already off and will remain so
+ // until our new activity is up.
+ if (mProximitySensor.isScreenReallyOff() && isCallWaiting) {
+ if (isActivityStarted()) {
+ mInCallActivity.finish();
+ }
+ mInCallActivity = null;
+ }
+
+ mStatusBarNotifier.updateNotificationAndLaunchIncomingCallUi(inCallState, mCallList);
+ }
+
/**
* Checks to see if both the UI is gone and the service is disconnected. If so, tear it all
* down.
diff --git a/InCallUI/src/com/android/incallui/ProximitySensor.java b/InCallUI/src/com/android/incallui/ProximitySensor.java
index 2210a38..727b923 100644
--- a/InCallUI/src/com/android/incallui/ProximitySensor.java
+++ b/InCallUI/src/com/android/incallui/ProximitySensor.java
@@ -154,6 +154,15 @@
}
/**
+ * TODO: There is no way to determine if a screen is off due to proximity or if it is
+ * legitimately off, but if ever we can do that in the future, it would be useful here.
+ * Until then, this function will simply return true of the screen is off.
+ */
+ public boolean isScreenReallyOff() {
+ return !mPowerManager.isScreenOn();
+ }
+
+ /**
* @return true if this device supports the "proximity sensor
* auto-lock" feature while in-call (see updateProximitySensorMode()).
*/