summaryrefslogtreecommitdiff
path: root/InCallUI
diff options
context:
space:
mode:
authorSailesh Nepal <sail@google.com>2014-05-14 18:45:34 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-05-14 18:45:34 +0000
commit4a5724583326a6dbbad8ca8453b17791b72e5b15 (patch)
tree7b8133c07827e2ef5d8ebc85128a202bb436b4f7 /InCallUI
parentbfe59973cb676f6ab06da60869af5f1e817c264d (diff)
parentb58fa55baf6e1838311028bd93983fb61b6249e1 (diff)
am 26c837ec: Merge "Update InCallUI to use new Telecomm wrappers" into master-nova
* commit '26c837ec32777efcbe437b1743e7a295a27273e3': Update InCallUI to use new Telecomm wrappers
Diffstat (limited to 'InCallUI')
-rw-r--r--InCallUI/AndroidManifest.xml4
-rw-r--r--InCallUI/src/com/android/incallui/AnswerPresenter.java25
-rw-r--r--InCallUI/src/com/android/incallui/CallButtonPresenter.java12
-rw-r--r--InCallUI/src/com/android/incallui/InCallPresenter.java10
-rw-r--r--InCallUI/src/com/android/incallui/InCallService.java123
-rw-r--r--InCallUI/src/com/android/incallui/InCallServiceImpl.java88
6 files changed, 106 insertions, 156 deletions
diff --git a/InCallUI/AndroidManifest.xml b/InCallUI/AndroidManifest.xml
index 0716eb082..cca718fae 100644
--- a/InCallUI/AndroidManifest.xml
+++ b/InCallUI/AndroidManifest.xml
@@ -50,9 +50,9 @@
</intent-filter>
</service>
- <service android:name="InCallService">
+ <service android:name="InCallServiceImpl">
<intent-filter>
- <action android:name="android.telecomm.IInCallService" />
+ <action android:name="android.telecomm.InCallService" />
</intent-filter>
</service>
diff --git a/InCallUI/src/com/android/incallui/AnswerPresenter.java b/InCallUI/src/com/android/incallui/AnswerPresenter.java
index 664692347..315270784 100644
--- a/InCallUI/src/com/android/incallui/AnswerPresenter.java
+++ b/InCallUI/src/com/android/incallui/AnswerPresenter.java
@@ -16,8 +16,7 @@
package com.android.incallui;
-import android.os.RemoteException;
-import android.telecomm.IInCallAdapter;
+import android.telecomm.InCallAdapter;
import com.android.services.telephony.common.Call;
@@ -132,20 +131,14 @@ public class AnswerPresenter extends Presenter<AnswerPresenter.AnswerUi>
// TODO(santoscordon): Need a TelecommAdapter wrapper object so that we dont have to check
// for null like this everywhere.
- IInCallAdapter telecommAdapter = InCallPresenter.getInstance().getTelecommAdapter();
+ InCallAdapter telecommAdapter = InCallPresenter.getInstance().getTelecommAdapter();
if (telecommAdapter != null) {
// TODO(santoscordon): Remove translator by using only String-based IDs in all of the
// in-call app.
String callId = CallInfoTranslator.getTelecommCallId(mCall);
if (callId != null) {
- // TODO(santoscordon): TelecommAdapter wrapper would also eliminate much of this
- // try-catch code.
- try {
- Log.i(this, "Answering the call: " + callId);
- telecommAdapter.answerCall(callId);
- } catch (RemoteException e) {
- Log.e(this, "Failed to send answer command.", e);
- }
+ Log.i(this, "Answering the call: " + callId);
+ telecommAdapter.answerCall(callId);
}
}
}
@@ -159,16 +152,12 @@ public class AnswerPresenter extends Presenter<AnswerPresenter.AnswerUi>
CallCommandClient.getInstance().rejectCall(mCall, false, null);
- IInCallAdapter telecommAdapter = InCallPresenter.getInstance().getTelecommAdapter();
+ InCallAdapter telecommAdapter = InCallPresenter.getInstance().getTelecommAdapter();
if (telecommAdapter != null) {
String callId = CallInfoTranslator.getTelecommCallId(mCall);
if (callId != null) {
- try {
- Log.i(this, "Rejecting the call: " + callId);
- telecommAdapter.rejectCall(callId);
- } catch (RemoteException e) {
- Log.e(this, "Failed to send reject command.", e);
- }
+ Log.i(this, "Rejecting the call: " + callId);
+ telecommAdapter.rejectCall(callId);
}
}
}
diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java
index 0b5b0f4ca..1cb2df274 100644
--- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java
@@ -33,7 +33,7 @@ import com.android.services.telephony.common.Call.Capabilities;
import android.app.Fragment;
import android.os.RemoteException;
-import android.telecomm.IInCallAdapter;
+import android.telecomm.InCallAdapter;
/**
* Logic for call buttons.
@@ -199,16 +199,12 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
CallCommandClient.getInstance().disconnectCall(mCall.getCallId());
// Notify Telecomm that the user hit end-call.
- IInCallAdapter telecommAdapter = InCallPresenter.getInstance().getTelecommAdapter();
+ InCallAdapter telecommAdapter = InCallPresenter.getInstance().getTelecommAdapter();
if (telecommAdapter != null) {
String callId = CallInfoTranslator.getTelecommCallId(mCall);
if (callId != null) {
- try {
- Log.i(this, "Disconnecting the call: " + callId);
- telecommAdapter.disconnectCall(callId);
- } catch (RemoteException e) {
- Log.e(this, "Failed to send disconnect command.", e);
- }
+ Log.i(this, "Disconnecting the call: " + callId);
+ telecommAdapter.disconnectCall(callId);
}
}
}
diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java
index bc7c41a2c..271ba4012 100644
--- a/InCallUI/src/com/android/incallui/InCallPresenter.java
+++ b/InCallUI/src/com/android/incallui/InCallPresenter.java
@@ -21,7 +21,7 @@ import com.google.common.base.Preconditions;
import android.content.Context;
import android.content.Intent;
-import android.telecomm.IInCallAdapter;
+import android.telecomm.InCallAdapter;
import com.android.services.telephony.common.Call;
import com.android.services.telephony.common.Call.Capabilities;
@@ -57,7 +57,7 @@ public class InCallPresenter implements CallList.Listener {
private boolean mServiceConnected = false;
/** Used to send call-related commands and updates back to Telecomm. */
- private IInCallAdapter mTelecommAdapter;
+ private InCallAdapter mTelecommAdapter;
/**
* Is true when the activity has been previously started. Some code needs to know not just if
@@ -558,15 +558,15 @@ public class InCallPresenter implements CallList.Listener {
}
/**
- * Persists the current instance of IInCallAdapter.
+ * Persists the current instance of InCallAdapter.
*
* @param telecommAdapter The adapter to the Telecomm system used to send call-related commands.
*/
- void setTelecommAdapter(IInCallAdapter telecommAdapter) {
+ void setTelecommAdapter(InCallAdapter telecommAdapter) {
mTelecommAdapter = telecommAdapter;
}
- IInCallAdapter getTelecommAdapter() {
+ InCallAdapter getTelecommAdapter() {
return mTelecommAdapter;
}
diff --git a/InCallUI/src/com/android/incallui/InCallService.java b/InCallUI/src/com/android/incallui/InCallService.java
deleted file mode 100644
index 2be1736de..000000000
--- a/InCallUI/src/com/android/incallui/InCallService.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.incallui;
-
-import android.app.Service;
-import android.content.Intent;
-import android.os.Handler;
-import android.os.IBinder;
-import android.os.Looper;
-import android.telecomm.CallInfo;
-import android.telecomm.IInCallAdapter;
-import android.telecomm.IInCallService;
-
-import com.android.services.telephony.common.Call;
-
-/**
- * Used to receive updates about calls from the Telecomm component. This service is bound to
- * Telecomm while there exist calls which potentially require UI. This includes ringing (incoming),
- * dialing (outgoing), and active calls. When the last call is disconnected, Telecomm will unbind to
- * the service triggering InCallActivity (via CallList) to finish soon after.
- */
-public class InCallService extends Service {
-
- /**
- * The actual service implementation that is passed to Telecomm as a binder. Implements all the
- * methods of {@link IInCallService}. Most methods ultimately update one or more calls in
- * {@link CallList} which in turn will trigger UI activity.
- */
- private class InCallServiceBinder extends IInCallService.Stub {
- /**
- * TODO(santoscordon): Rename this to setTelecommAdapter.
- * {@inheritDoc}
- */
- @Override public void setInCallAdapter(final IInCallAdapter inCallAdapter) {
- mHandler.post(new Runnable() {
- @Override public void run() {
- InCallPresenter.getInstance().setTelecommAdapter(inCallAdapter);
- }
- });
- }
-
- /** {@inheritDoc} */
- @Override public void addCall(final CallInfo callInfo) {
- mHandler.post(new Runnable() {
- @Override public void run() {
- Call call = CallInfoTranslator.getCall(callInfo);
- CallList.getInstance().onUpdate(call);
- }
- });
- }
-
- /** {@inheritDoc} */
- @Override public void setActive(final String callId) {
- mHandler.post(new Runnable() {
- @Override public void run() {
- Call call = CallInfoTranslator.getCall(callId);
- if (null != call) {
- call.setState(Call.State.ACTIVE);
- if (call.getConnectTime() == 0) {
- call.setConnectTime(System.currentTimeMillis());
- }
- CallList.getInstance().onUpdate(call);
- }
- }
- });
- }
-
- /** {@inheritDoc} */
- @Override public void setDisconnected(final String callId) {
- mHandler.post(new Runnable() {
- @Override public void run() {
- Call call = CallInfoTranslator.getCall(callId);
- if (null != call) {
- call.setState(Call.State.DISCONNECTED);
- CallList.getInstance().onDisconnect(call);
-
- // Remove it from the mapping since we no longer need to interact
- // with the Call.
- CallInfoTranslator.removeCall(callId);
- }
- }
- });
- }
- }
-
- private final Handler mHandler = new Handler(Looper.getMainLooper());
-
- /** Instance of IInCallService which is sent to Telecomm. */
- private final InCallServiceBinder mBinder = new InCallServiceBinder();
-
- /** {@inheritDoc} */
- @Override public IBinder onBind(Intent intent) {
- return mBinder;
- }
-
- /** {@inheritDoc} */
- @Override public void onCreate() {
- InCallPresenter inCallPresenter = InCallPresenter.getInstance();
- inCallPresenter.setUp(
- getApplicationContext(), CallList.getInstance(), AudioModeProvider.getInstance());
- }
-
- /** {@inheritDoc} */
- @Override public void onDestroy() {
- // Tear down the InCall system
- CallList.getInstance().clearOnDisconnect();
- InCallPresenter.getInstance().tearDown();
- }
-}
diff --git a/InCallUI/src/com/android/incallui/InCallServiceImpl.java b/InCallUI/src/com/android/incallui/InCallServiceImpl.java
new file mode 100644
index 000000000..09991d7b6
--- /dev/null
+++ b/InCallUI/src/com/android/incallui/InCallServiceImpl.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.incallui;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.Looper;
+import android.telecomm.CallInfo;
+import android.telecomm.InCallAdapter;
+
+import com.android.services.telephony.common.Call;
+
+/**
+ * Used to receive updates about calls from the Telecomm component. This service is bound to
+ * Telecomm while there exist calls which potentially require UI. This includes ringing (incoming),
+ * dialing (outgoing), and active calls. When the last call is disconnected, Telecomm will unbind to
+ * the service triggering InCallActivity (via CallList) to finish soon after.
+ */
+public class InCallServiceImpl extends android.telecomm.InCallService {
+ /** {@inheritDoc} */
+ @Override public void onCreate() {
+ InCallPresenter inCallPresenter = InCallPresenter.getInstance();
+ inCallPresenter.setUp(
+ getApplicationContext(), CallList.getInstance(), AudioModeProvider.getInstance());
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onDestroy() {
+ // Tear down the InCall system
+ CallList.getInstance().clearOnDisconnect();
+ InCallPresenter.getInstance().tearDown();
+ }
+
+ /**
+ * TODO(santoscordon): Rename this to setTelecommAdapter.
+ * {@inheritDoc}
+ */
+ @Override protected void setInCallAdapter(InCallAdapter inCallAdapter) {
+ InCallPresenter.getInstance().setTelecommAdapter(inCallAdapter);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void addCall(CallInfo callInfo) {
+ Call call = CallInfoTranslator.getCall(callInfo);
+ CallList.getInstance().onUpdate(call);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void setActive(String callId) {
+ Call call = CallInfoTranslator.getCall(callId);
+ if (null != call) {
+ call.setState(Call.State.ACTIVE);
+ if (call.getConnectTime() == 0) {
+ call.setConnectTime(System.currentTimeMillis());
+ }
+ CallList.getInstance().onUpdate(call);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void setDisconnected(String callId) {
+ Call call = CallInfoTranslator.getCall(callId);
+ if (null != call) {
+ call.setState(Call.State.DISCONNECTED);
+ CallList.getInstance().onDisconnect(call);
+
+ // Remove it from the mapping since we no longer need to interact
+ // with the Call.
+ CallInfoTranslator.removeCall(callId);
+ }
+ }
+}