summaryrefslogtreecommitdiff
path: root/InCallUI/src/com/android/incallui/InCallActivity.java
diff options
context:
space:
mode:
authorSantos Cordon <santoscordon@google.com>2013-09-20 17:06:18 -0700
committerSantos Cordon <santoscordon@google.com>2013-09-23 19:33:43 -0700
commit9ccf74a1e34b0a08b8d74cbb5a494eea879fd15e (patch)
tree22ecd3d50053702e84483a8f45234007e858ec2b /InCallUI/src/com/android/incallui/InCallActivity.java
parentcd72227f331b862d70c1271b1c9a5f3a1ab30bee (diff)
Add generic error code dialogs for failed calls.
This change listens for disconnected calls and if the disconnection cause matches a set of predefined causes, we show a dialog to the user. New dialog messages: - You can\'t make outgoing calls while call barring is on. - All calls are restricted by access control. - Emergency calls are restricted by access control. - Normal calls are restricted by access control. - Outgoing calls are restricted by FDN. Several changes were necessary to support this: 1) Dialog code (InCallActivity.java) 2) Notifications for a new disconnect (CallList.java) - previously we sent a large update for ondisconnect, now we just send the notice for that particular call. InCallPresenter was written so that the same thing that used to happen still happens. 3) Check if we need to show a disconnect dialog when the UI comes up. - I found that FDN disconnection happens so quickly that the disconnect came before the UI was up, so this was necessary. (InCallPresenter.setActivity()) 4) CallCard should be initialized with disconnecting/disconnecting calls. - Call Card presenter intializes itself when it starts up using live calls, but as with the FDN case above, a disconnected call should be used if no live calls exist. (CallList.getFirstCall()) 5) If a dialog is up while an incoming call comes up, dismiss it automatically so that users can see incoming UI. - (InCallPresenter.startOrFinishUi()) 6) Keep the UI up as long as there is a dialog for the incoming call. - Previously, UI would come down once all calls were shut down but in the case of present dialogs, we want it to stay up. (InCallActivity.finish()) - When the dialog is dismissed, check if we want to tear down UI. (InCallActivity.onDialogDismissed()) 7) Only tear down UI once we are in the NO_CALL state. - We used to tear down when the activity was null (closed) and the service was disconnected. This is problematic because a call that immediately disconnects (like FDN errors) would shut down the service before the UI had a chance to come up. We added a check to the conditional for the state NO_CALL before shutting down. (InCallPresenter.attemptCleanup()). bug: 10680210 Change-Id: I1fd33dd53dc0eec5a02b7a940cfd018cec3d20c0
Diffstat (limited to 'InCallUI/src/com/android/incallui/InCallActivity.java')
-rw-r--r--InCallUI/src/com/android/incallui/InCallActivity.java83
1 files changed, 81 insertions, 2 deletions
diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java
index c3793ad2e..761691f4d 100644
--- a/InCallUI/src/com/android/incallui/InCallActivity.java
+++ b/InCallUI/src/com/android/incallui/InCallActivity.java
@@ -20,6 +20,10 @@ import com.android.services.telephony.common.Call;
import com.android.services.telephony.common.Call.State;
import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnClickListener;
+import android.content.DialogInterface.OnCancelListener;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
@@ -37,12 +41,15 @@ public class InCallActivity extends Activity {
public static final String SHOW_DIALPAD_EXTRA = "InCallActivity.show_dialpad";
+ private static final int INVALID_RES_ID = -1;
+
private CallButtonFragment mCallButtonFragment;
private CallCardFragment mCallCardFragment;
private AnswerFragment mAnswerFragment;
private DialpadFragment mDialpadFragment;
private ConferenceManagerFragment mConferenceManagerFragment;
private boolean mIsForegroundActivity;
+ private AlertDialog mDialog;
/** Use to pass 'showDialpad' from {@link #onNewIntent} to {@link #onResume} */
private boolean mShowDialpadRequested;
@@ -145,8 +152,12 @@ public class InCallActivity extends Activity {
*/
@Override
public void finish() {
- Log.d(this, "finish()...");
- super.finish();
+ Log.i(this, "finish(). Dialog showing: " + (mDialog != null));
+
+ // skip finish if we are still showing a dialog.
+ if (mDialog == null) {
+ super.finish();
+ }
}
@Override
@@ -352,4 +363,72 @@ public class InCallActivity extends Activity {
}
return super.dispatchPopulateAccessibilityEvent(event);
}
+
+ public void maybeShowErrorDialogOnDisconnect(Call.DisconnectCause cause) {
+ Log.d(this, "maybeShowErrorDialogOnDisconnect");
+
+ if (!isFinishing()) {
+ final int resId = getResIdForDisconnectCause(cause);
+ if (resId != INVALID_RES_ID) {
+ showErrorDialog(resId);
+ }
+ }
+ }
+
+ public void dismissPendingDialogs() {
+ if (mDialog != null) {
+ mDialog.dismiss();
+ mDialog = null;
+ }
+ }
+
+ /**
+ * Utility function to bring up a generic "error" dialog.
+ */
+ private void showErrorDialog(int resId) {
+ final CharSequence msg = getResources().getText(resId);
+ Log.i(this, "Show Dialog: " + msg);
+
+ dismissPendingDialogs();
+
+ mDialog = new AlertDialog.Builder(this)
+ .setMessage(msg)
+ .setPositiveButton(R.string.ok, new OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ onDialogDismissed();
+ }})
+ .setOnCancelListener(new OnCancelListener() {
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ onDialogDismissed();
+ }})
+ .create();
+
+ mDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
+ mDialog.show();
+ }
+
+ private int getResIdForDisconnectCause(Call.DisconnectCause cause) {
+ int resId = INVALID_RES_ID;
+
+ if (cause == Call.DisconnectCause.CALL_BARRED) {
+ resId = R.string.callFailed_cb_enabled;
+ } else if (cause == Call.DisconnectCause.FDN_BLOCKED) {
+ resId = R.string.callFailed_fdn_only;
+ } else if (cause == Call.DisconnectCause.CS_RESTRICTED) {
+ resId = R.string.callFailed_dsac_restricted;
+ } else if (cause == Call.DisconnectCause.CS_RESTRICTED_EMERGENCY) {
+ resId = R.string.callFailed_dsac_restricted_emergency;
+ } else if (cause == Call.DisconnectCause.CS_RESTRICTED_NORMAL) {
+ resId = R.string.callFailed_dsac_restricted_normal;
+ }
+
+ return resId;
+ }
+
+ private void onDialogDismissed() {
+ mDialog = null;
+ InCallPresenter.getInstance().onDismissDialog();
+ }
}