Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Removed capability to exit ECM while on an emergency call
Browse files Browse the repository at this point in the history
Issue:
1. Enter Emergency Callback Mode (ECM) by making and ending an emergency call
2. Start another emergency call and press Home
3. Open notifications and select ECM notice
4. Exit ECM

The user shouldn't be allowed to exit ECM while in an emergency call.

Change-Id: I454dacdbb7c82853fa22fc2b9d79225e03672e4f
  • Loading branch information
Robert Kowalski authored and Wink Saville committed Sep 8, 2009
1 parent ba3f95e commit e627de5
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 33 deletions.
3 changes: 2 additions & 1 deletion AndroidManifest.xml
Expand Up @@ -363,8 +363,9 @@
</service>

<activity android:name="EmergencyCallbackModeExitDialog"
android:label="@string/ecm_exit_dialog"
android:excludeFromRecents="true"
android:label="@string/ecm_exit_dialog"
android:launchMode="singleTop"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<action android:name="com.android.phone.action.ACTION_SHOW_ECM_EXIT_DIALOG" />
Expand Down
5 changes: 5 additions & 0 deletions res/values/strings.xml
Expand Up @@ -1038,6 +1038,7 @@
<!-- ECM: Notification title -->
<string name="phone_in_ecm_notification_title">Emergency Callback Mode</string>
<!-- ECM: Notification body -->
<string name="phone_in_ecm_call_notification_text">Data connection disabled</string>
<plurals name="phone_in_ecm_notification_time">
<!-- number of minutes is one -->
<item quantity="one">No data connection for <xliff:g id="count">%s</xliff:g> minute</item>
Expand All @@ -1058,12 +1059,16 @@
<!-- number of minutes is not equal to one -->
<item quantity="other">The selected action is not available while in the emergency callback mode. The phone will be in this mode for <xliff:g id="count">%s</xliff:g> minutes. Would you like to exit now?</item>
</plurals>
<!-- ECM: Dialog box message while in emergency call -->
<string name="alert_dialog_in_ecm_call">The selected action is not available while in an emergency call</string>
<!-- ECM: Progress text -->
<string name="progress_dialog_exiting_ecm">Exiting Emergency Callback Mode</string>
<!-- ECM: ECM exit dialog choice -->
<string name="alert_dialog_yes">Yes</string>
<!-- ECM: ECM exit dialog choice -->
<string name="alert_dialog_no">No</string>
<!-- ECM: ECM exit dialog choice -->
<string name="alert_dialog_dismiss">Dismiss</string>
<!-- For incoming calls, this is a string we can get from a CDMA network instead of
the actual phone number, to indicate there's no number present. DO NOT TRANSLATE. -->
<string name="absent_num">ABSENT NUMBER</string>
Expand Down
98 changes: 75 additions & 23 deletions src/com/android/phone/EmergencyCallbackModeExitDialog.java
Expand Up @@ -28,11 +28,13 @@
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.res.Resources;
import android.os.AsyncResult;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.SystemProperties;
import android.util.Log;

Expand All @@ -57,6 +59,7 @@ public class EmergencyCallbackModeExitDialog extends Activity {
public static final int EXIT_ECM_BLOCK_OTHERS = 1;
public static final int EXIT_ECM_DIALOG = 2;
public static final int EXIT_ECM_PROGRESS_DIALOG = 3;
public static final int EXIT_ECM_IN_EMERGENCY_CALL_DIALOG = 4;

AlertDialog mAlertDialog = null;
ProgressDialog mProgressDialog = null;
Expand All @@ -65,6 +68,9 @@ public class EmergencyCallbackModeExitDialog extends Activity {
Handler mHandler = null;
int mDialogType = 0;
long mEcmTimeout = 0;
private boolean mInEmergencyCall = false;
private static final int ECM_TIMER_RESET = 1;
private Phone mPhone = null;

@Override
public void onCreate(Bundle savedInstanceState) {
Expand All @@ -84,6 +90,10 @@ public void onCreate(Bundle savedInstanceState) {
"EcmExitDialogWaitThread");
waitForConnectionCompleteThread.start();

// Register ECM timer reset notfication
mPhone = PhoneFactory.getDefaultPhone();
mPhone.registerForEcmTimerReset(mTimerResetHandler, ECM_TIMER_RESET, null);

// Register receiver for intent closing the dialog
IntentFilter filter = new IntentFilter();
filter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
Expand All @@ -94,6 +104,8 @@ public void onCreate(Bundle savedInstanceState) {
public void onDestroy() {
super.onDestroy();
unregisterReceiver(mEcmExitReceiver);
// Unregister ECM timer reset notification
mPhone.unregisterForEcmTimerReset(mHandler);
}

@Override
Expand Down Expand Up @@ -130,9 +142,10 @@ public void run() {
}
}

// Get timeout value from the service
// Get timeout value and call state from the service
if (mService != null) {
mEcmTimeout = mService.getEmergencyCallbackModeTimeout();
mInEmergencyCall = mService.getEmergencyCallbackModeCallState();
}

// Unbind from remote service
Expand All @@ -151,27 +164,33 @@ public void run() {
* Shows Emergency Callback Mode dialog and starts countdown timer
*/
private void showEmergencyCallbackModeExitDialog() {
if (getIntent().getAction().equals(
TelephonyIntents.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS)) {
mDialogType = EXIT_ECM_BLOCK_OTHERS;
showDialog(EXIT_ECM_BLOCK_OTHERS);
} else if (getIntent().getAction().equals(ACTION_SHOW_ECM_EXIT_DIALOG)) {
mDialogType = EXIT_ECM_DIALOG;
showDialog(EXIT_ECM_DIALOG);
}

mTimer = new CountDownTimer(mEcmTimeout, 1000) {
@Override
public void onTick(long millisUntilFinished) {
CharSequence text = getDialogText(millisUntilFinished);
mAlertDialog.setMessage(text);
if(mInEmergencyCall) {
mDialogType = EXIT_ECM_IN_EMERGENCY_CALL_DIALOG;
showDialog(EXIT_ECM_IN_EMERGENCY_CALL_DIALOG);
} else {
if (getIntent().getAction().equals(
TelephonyIntents.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS)) {
mDialogType = EXIT_ECM_BLOCK_OTHERS;
showDialog(EXIT_ECM_BLOCK_OTHERS);
} else if (getIntent().getAction().equals(ACTION_SHOW_ECM_EXIT_DIALOG)) {
mDialogType = EXIT_ECM_DIALOG;
showDialog(EXIT_ECM_DIALOG);
}

@Override
public void onFinish() {
//Do nothing
}
}.start();
mTimer = new CountDownTimer(mEcmTimeout, 1000) {
@Override
public void onTick(long millisUntilFinished) {
CharSequence text = getDialogText(millisUntilFinished);
mAlertDialog.setMessage(text);
}

@Override
public void onFinish() {
//Do nothing
}
}.start();
}
}

/**
Expand All @@ -184,14 +203,14 @@ protected Dialog onCreateDialog(int id) {
case EXIT_ECM_DIALOG:
CharSequence text = getDialogText(mEcmTimeout);
mAlertDialog = new AlertDialog.Builder(EmergencyCallbackModeExitDialog.this)
.setIcon(R.drawable.picture_emergency32x32).setTitle(
R.string.phone_in_ecm_notification_title).setMessage(text)
.setIcon(R.drawable.picture_emergency32x32)
.setTitle(R.string.phone_in_ecm_notification_title)
.setMessage(text)
.setPositiveButton(R.string.alert_dialog_yes,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int whichButton) {
// User clicked Yes. Exit Emergency Callback Mode.
Phone phone = PhoneFactory.getDefaultPhone();
phone.exitEmergencyCallbackMode();
mPhone.exitEmergencyCallbackMode();

// Show progress dialog
showDialog(EXIT_ECM_PROGRESS_DIALOG);
Expand All @@ -209,6 +228,22 @@ public void onClick(DialogInterface dialog, int whichButton) {
}).create();
return mAlertDialog;

case EXIT_ECM_IN_EMERGENCY_CALL_DIALOG:
mAlertDialog = new AlertDialog.Builder(EmergencyCallbackModeExitDialog.this)
.setIcon(R.drawable.picture_emergency32x32)
.setTitle(R.string.phone_in_ecm_notification_title)
.setMessage(R.string.alert_dialog_in_ecm_call)
.setNeutralButton(R.string.alert_dialog_dismiss,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// User clicked Dismiss
setResult(RESULT_OK, (new Intent()).putExtra(
EXTRA_EXIT_ECM_RESULT, false));
finish();
}
}).create();
return mAlertDialog;

case EXIT_ECM_PROGRESS_DIALOG:
mProgressDialog = new ProgressDialog(EmergencyCallbackModeExitDialog.this);
mProgressDialog.setMessage(getText(R.string.progress_dialog_exiting_ecm));
Expand Down Expand Up @@ -279,4 +314,21 @@ public void onServiceDisconnected(ComponentName className) {
mService = null;
}
};

/**
* Class for receiving framework timer reset notifications
*/
private Handler mTimerResetHandler = new Handler () {
public void handleMessage(Message msg) {
switch (msg.what) {
case ECM_TIMER_RESET:
if(!((Boolean)((AsyncResult) msg.obj).result).booleanValue()) {
EmergencyCallbackModeExitDialog.this.setResult(RESULT_OK, (new Intent())
.putExtra(EXTRA_EXIT_ECM_RESULT, false));
finish();
}
break;
}
}
};
}
31 changes: 22 additions & 9 deletions src/com/android/phone/EmergencyCallbackModeService.java
Expand Up @@ -55,8 +55,8 @@ public class EmergencyCallbackModeService extends Service {
private NotificationManager mNotificationManager = null;
private CountDownTimer mTimer = null;
private long mTimeLeft = 0;
private PhoneApp mApp;
private Phone mPhone;
private Phone mPhone = null;
private boolean mInEmergencyCall = false;

private static final int ECM_TIMER_RESET = 1;

Expand Down Expand Up @@ -88,8 +88,7 @@ public void onCreate() {
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

// Register ECM timer reset notfication
mApp = PhoneApp.getInstance();
mPhone = mApp.phone;
mPhone = PhoneFactory.getDefaultPhone();
mPhone.registerForEcmTimerReset(mHandler, ECM_TIMER_RESET, null);

startTimerNotification();
Expand Down Expand Up @@ -174,11 +173,15 @@ private void showNotification(long millisUntilFinished) {
new Intent(EmergencyCallbackModeExitDialog.ACTION_SHOW_ECM_EXIT_DIALOG), 0);

// Format notification string
int minutes = (int)(millisUntilFinished / 60000);
String time = String.format("%d:%02d", minutes, (millisUntilFinished % 60000) / 1000);
String text = String.format(getResources().getQuantityText(
R.plurals.phone_in_ecm_notification_time, minutes).toString(), time);

String text = null;
if(mInEmergencyCall) {
text = getText(R.string.phone_in_ecm_call_notification_text).toString();
} else {
int minutes = (int)(millisUntilFinished / 60000);
String time = String.format("%d:%02d", minutes, (millisUntilFinished % 60000) / 1000);
text = String.format(getResources().getQuantityText(
R.plurals.phone_in_ecm_notification_time, minutes).toString(), time);
}
// Set the info in the notification
notification.setLatestEventInfo(this, getText(R.string.phone_in_ecm_notification_title),
text, contentIntent);
Expand All @@ -196,8 +199,11 @@ private void resetEcmTimer(AsyncResult r) {
boolean isTimerCanceled = ((Boolean)r.result).booleanValue();

if (isTimerCanceled) {
mInEmergencyCall = true;
mTimer.cancel();
showNotification(0);
} else {
mInEmergencyCall = false;
startTimerNotification();
}
}
Expand Down Expand Up @@ -225,4 +231,11 @@ EmergencyCallbackModeService getService() {
public long getEmergencyCallbackModeTimeout() {
return mTimeLeft;
}

/**
* Returns Emergency Callback Mode call state
*/
public boolean getEmergencyCallbackModeCallState() {
return mInEmergencyCall;
}
}

0 comments on commit e627de5

Please sign in to comment.