Update showCallScreen to use Telecomm (2/6)
Implement showCallScreen in TelecommServiceImpl and route through new
InCallService#bringToForeground.
Bug: 15008165
Change-Id: Ib674e2e48efaa1cc97d1513dc2c2b27fdb343657
diff --git a/src/com/android/telecomm/CallsManager.java b/src/com/android/telecomm/CallsManager.java
index 7aeaed5..888f076 100644
--- a/src/com/android/telecomm/CallsManager.java
+++ b/src/com/android/telecomm/CallsManager.java
@@ -28,8 +28,9 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Sets;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.Set;
/**
@@ -67,13 +68,20 @@
* The main call repository. Keeps an instance of all live calls. New incoming and outgoing
* calls are added to the map and removed when the calls move to the disconnected state.
*/
- private final Set<Call> mCalls = Sets.newLinkedHashSet();
+ private final Set<Call> mCalls = new LinkedHashSet<>();
/**
* Set of new calls created to perform a handoff. The calls are added when handoff is initiated
* and removed when hadnoff is complete.
*/
- private final Set<Call> mPendingHandoffCalls = Sets.newLinkedHashSet();
+ private final Set<Call> mPendingHandoffCalls = new LinkedHashSet<>();
+
+
+ private final DtmfLocalTonePlayer mDtmfLocalTonePlayer = new DtmfLocalTonePlayer();
+ private final InCallController mInCallController = new InCallController();
+ private final CallAudioManager mCallAudioManager;
+ private final Ringer mRinger;
+ private final Set<CallsManagerListener> mListeners = new HashSet<>();
/**
* The call the user is currently interacting with. This is the call that should have audio
@@ -81,14 +89,6 @@
*/
private Call mForegroundCall;
- private final DtmfLocalTonePlayer mDtmfLocalTonePlayer = new DtmfLocalTonePlayer();
-
- private final CallAudioManager mCallAudioManager;
-
- private final Ringer mRinger;
-
- private final Set<CallsManagerListener> mListeners = Sets.newHashSet();
-
/** Singleton accessor. */
static CallsManager getInstance() {
return INSTANCE;
@@ -106,7 +106,7 @@
mListeners.add(new CallLogManager(app));
mListeners.add(new PhoneStateBroadcaster());
- mListeners.add(new InCallController());
+ mListeners.add(mInCallController);
mListeners.add(mRinger);
mListeners.add(new RingbackPlayer(this, playerFactory));
mListeners.add(new InCallToneMonitor(playerFactory, this));
@@ -170,6 +170,10 @@
return mRinger;
}
+ InCallController getInCallController() {
+ return mInCallController;
+ }
+
boolean hasEmergencyCall() {
for (Call call : mCalls) {
if (call.isEmergencyCall()) {
diff --git a/src/com/android/telecomm/InCallController.java b/src/com/android/telecomm/InCallController.java
index 395e92e..4bba241 100644
--- a/src/com/android/telecomm/InCallController.java
+++ b/src/com/android/telecomm/InCallController.java
@@ -90,7 +90,7 @@
mCallIdMapper.addCall(call);
try {
mInCallService.addCall(toInCallCall(call));
- } catch (RemoteException e) {
+ } catch (RemoteException ignored) {
}
}
}
@@ -137,11 +137,22 @@
newAudioState);
try {
mInCallService.onAudioStateChanged(newAudioState);
- } catch (RemoteException e) {
+ } catch (RemoteException ignored) {
}
}
}
+ void bringToForeground(boolean showDialpad) {
+ if (mInCallService != null) {
+ try {
+ mInCallService.bringToForeground(showDialpad);
+ } catch (RemoteException ignored) {
+ }
+ } else {
+ Log.w(this, "Asking to bring unbound in-call UI to foreground.");
+ }
+ }
+
/**
* Unbinds an existing bound connection to the in-call app.
*/
@@ -221,7 +232,7 @@
if (mInCallService != null) {
try {
mInCallService.updateCall(toInCallCall(call));
- } catch (RemoteException e) {
+ } catch (RemoteException ignored) {
}
}
}
diff --git a/src/com/android/telecomm/TelecommServiceImpl.java b/src/com/android/telecomm/TelecommServiceImpl.java
index beb046b..1b377b8 100644
--- a/src/com/android/telecomm/TelecommServiceImpl.java
+++ b/src/com/android/telecomm/TelecommServiceImpl.java
@@ -31,6 +31,7 @@
private static final String SERVICE_NAME = "telecomm";
private static final int MSG_SILENCE_RINGER = 1;
+ private static final int MSG_SHOW_CALL_SCREEN = 2;
/** The singleton instance. */
private static TelecommServiceImpl sInstance;
@@ -47,6 +48,9 @@
case MSG_SILENCE_RINGER:
silenceRingerInternal();
break;
+ case MSG_SHOW_CALL_SCREEN:
+ showCallScreenInternal(msg.arg1 == 1);
+ break;
}
}
};
@@ -106,4 +110,13 @@
TelecommApp.getInstance().enforceCallingOrSelfPermission(
android.Manifest.permission.MODIFY_PHONE_STATE, null);
}
+
+ @Override
+ public void showCallScreen(boolean showDialpad) {
+ mHandler.obtainMessage(MSG_SHOW_CALL_SCREEN, showDialpad ? 1 : 0, 0).sendToTarget();
+ }
+
+ private void showCallScreenInternal(boolean showDialpad) {
+ CallsManager.getInstance().getInCallController().bringToForeground(showDialpad);
+ }
}