Adding implementation for bringToForeground.
Add implementation for CallHandlerService's new method, bring to
foreground. When called, the incallui determines if we have an active
call and the activity is not currently in the foreground. If both those
are true, then we bring up the existing InCallUI.
bug:10313347
Change-Id: Ic70cd7f1c5701992580626458c8d459a8ece7d9c
diff --git a/InCallUI/src/com/android/incallui/CallHandlerService.java b/InCallUI/src/com/android/incallui/CallHandlerService.java
index 76237e1..ca749aa 100644
--- a/InCallUI/src/com/android/incallui/CallHandlerService.java
+++ b/InCallUI/src/com/android/incallui/CallHandlerService.java
@@ -44,8 +44,9 @@
private static final int ON_AUDIO_MODE = 4;
private static final int ON_SUPPORTED_AUDIO_MODE = 5;
private static final int ON_DISCONNECT_CALL = 6;
+ private static final int ON_BRING_TO_FOREGROUND = 7;
- private static final int LARGEST_MSG_ID = ON_DISCONNECT_CALL;
+ private static final int LARGEST_MSG_ID = ON_BRING_TO_FOREGROUND;
private CallList mCallList;
@@ -175,6 +176,11 @@
Log.e(TAG, "Error processing onSupportedAudioModeChange() call.", e);
}
}
+
+ @Override
+ public void bringToForeground() {
+ mMainHandler.sendMessage(mMainHandler.obtainMessage(ON_BRING_TO_FOREGROUND));
+ }
};
/**
@@ -222,6 +228,11 @@
case ON_SUPPORTED_AUDIO_MODE:
mAudioModeProvider.onSupportedAudioModeChange(msg.arg1);
break;
+ case ON_BRING_TO_FOREGROUND:
+ if (mInCallPresenter != null) {
+ mInCallPresenter.bringToForeground();
+ }
+ break;
default:
break;
}
diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java
index 11f9308..cc3dcb2 100644
--- a/InCallUI/src/com/android/incallui/InCallPresenter.java
+++ b/InCallUI/src/com/android/incallui/InCallPresenter.java
@@ -239,6 +239,21 @@
}
/**
+ * Brings the app into the foreground if possible.
+ */
+ public void bringToForeground() {
+ // Before we bring the incall UI to the foreground, we check to see if:
+ // 1. there is an activity
+ // 2. the activity is not already in the foreground
+ // 3. We are in a state where we want to show the incall ui
+ if (mInCallActivity != null &&
+ !mInCallActivity.isForegroundActivity() &&
+ mInCallState != InCallState.HIDDEN) {
+ showInCall();
+ }
+ }
+
+ /**
* When the state of in-call changes, this is the first method to get called. It determines if
* the UI needs to be started or finished depending on the new state and does it.
*/