From abbeb67a123055af1d140bb8aff259dc210ccfd0 Mon Sep 17 00:00:00 2001 From: Christine Chen Date: Mon, 7 Oct 2013 16:30:57 -0700 Subject: Adds support for texting after phone disconnects. Bug: 11111553 Change-Id: I8abcae4439e7b9697d7b4a4335e093d7ad13a1b3 --- .../src/com/android/incallui/AnswerFragment.java | 69 +++++++++++++++++++--- .../src/com/android/incallui/AnswerPresenter.java | 20 +++++-- .../com/android/incallui/CallCommandClient.java | 9 ++- .../src/com/android/incallui/InCallActivity.java | 6 +- 4 files changed, 85 insertions(+), 19 deletions(-) (limited to 'InCallUI/src/com/android') diff --git a/InCallUI/src/com/android/incallui/AnswerFragment.java b/InCallUI/src/com/android/incallui/AnswerFragment.java index 29a458656..1b249f29f 100644 --- a/InCallUI/src/com/android/incallui/AnswerFragment.java +++ b/InCallUI/src/com/android/incallui/AnswerFragment.java @@ -51,6 +51,11 @@ public class AnswerFragment extends BaseFragment mTextResponsesAdapter = null; private GlowPadWrapper mGlowpad; @@ -125,19 +130,57 @@ public class AnswerFragment extends BaseFragment private static final String TAG = AnswerPresenter.class.getSimpleName(); private int mCallId = Call.INVALID_CALL_ID; + private Call mCall = null; @Override public void onUiReady(AnswerUi ui) { @@ -82,6 +83,7 @@ public class AnswerPresenter extends Presenter private void processIncomingCall(Call call) { mCallId = call.getCallId(); + mCall = call; // Listen for call updates for the current call. CallList.getInstance().addCallUpdateListener(mCallId, this); @@ -108,6 +110,9 @@ public class AnswerPresenter extends Presenter CallList.getInstance().removeCallUpdateListener(mCallId, this); getUi().showAnswerUi(false); + + // mCallId will hold the state of the call. We don't clear the mCall variable here as + // it may be useful for sending text messages after phone disconnects. mCallId = Call.INVALID_CALL_ID; } } @@ -123,13 +128,9 @@ public class AnswerPresenter extends Presenter } public void onDecline() { - if (mCallId == Call.INVALID_CALL_ID) { - return; - } - Log.d(this, "onDecline " + mCallId); - CallCommandClient.getInstance().rejectCall(mCallId, false, null); + CallCommandClient.getInstance().rejectCall(mCall, false, null); } public void onText() { @@ -140,7 +141,14 @@ public class AnswerPresenter extends Presenter public void rejectCallWithMessage(String message) { Log.d(this, "sendTextToDefaultActivity()..."); - CallCommandClient.getInstance().rejectCall(mCallId, true, message); + + CallCommandClient.getInstance().rejectCall(mCall, true, message); + + onDismissDialog(); + } + + public void onDismissDialog() { + InCallPresenter.getInstance().onDismissDialog(); } interface AnswerUi extends Ui { diff --git a/InCallUI/src/com/android/incallui/CallCommandClient.java b/InCallUI/src/com/android/incallui/CallCommandClient.java index 3f4ee7781..52d2100c8 100644 --- a/InCallUI/src/com/android/incallui/CallCommandClient.java +++ b/InCallUI/src/com/android/incallui/CallCommandClient.java @@ -18,8 +18,10 @@ package com.android.incallui; import android.os.RemoteException; + import com.android.services.telephony.common.AudioMode; import com.android.services.telephony.common.ICallCommandService; +import com.android.services.telephony.common.Call; /** * Main interface for phone related commands. @@ -57,14 +59,15 @@ public class CallCommandClient { } } - public void rejectCall(int callId, boolean rejectWithMessage, String message) { - Log.i(this, "rejectCall: " + callId + ", with rejectMessage? " + rejectWithMessage); + public void rejectCall(Call call, boolean rejectWithMessage, String message) { + Log.i(this, "rejectCall: " + call.getCallId() + + ", with rejectMessage? " + rejectWithMessage); if (mCommandService == null) { Log.e(this, "Cannot reject call; CallCommandService == null"); return; } try { - mCommandService.rejectCall(callId, rejectWithMessage, message); + mCommandService.rejectCall(call, rejectWithMessage, message); } catch (RemoteException e) { Log.e(this, "Error rejecting call.", e); } diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java index 32d1f5538..ac21d52a2 100644 --- a/InCallUI/src/com/android/incallui/InCallActivity.java +++ b/InCallUI/src/com/android/incallui/InCallActivity.java @@ -138,6 +138,9 @@ public class InCallActivity extends Activity { return mIsForegroundActivity; } + private boolean hasPendingErrorDialog() { + return mDialog != null; + } /** * Dismisses the in-call screen. * @@ -158,7 +161,7 @@ public class InCallActivity extends Activity { Log.i(this, "finish(). Dialog showing: " + (mDialog != null)); // skip finish if we are still showing a dialog. - if (mDialog == null) { + if (!hasPendingErrorDialog() && !mAnswerFragment.hasPendingDialogs()) { super.finish(); } } @@ -427,6 +430,7 @@ public class InCallActivity extends Activity { mDialog.dismiss(); mDialog = null; } + mAnswerFragment.dismissPendingDialogues(); } /** -- cgit v1.2.3