diff options
-rw-r--r-- | res/values/strings.xml | 24 | ||||
-rw-r--r-- | src/com/android/phone/PhoneGlobals.java | 22 | ||||
-rw-r--r-- | src/com/android/phone/SmsCallbackModeExitDialog.java | 142 | ||||
-rw-r--r-- | src/com/android/phone/SmsCallbackModeService.java | 120 | ||||
-rw-r--r-- | src/com/android/services/telephony/TelecomAccountRegistry.java | 19 | ||||
-rw-r--r-- | src/com/android/services/telephony/TelephonyConnectionService.java | 2 |
6 files changed, 60 insertions, 269 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index 9f8f94ad73..22ec68a488 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1524,31 +1524,21 @@ <!-- Sms Callback Mode (SCM) --> <string name="scm_exit_dialog">ScmExitDialog</string> <!-- SCM: Status bar notification message --> - <string name="phone_entered_scm_text">Entered Sms Callback Mode</string> + <string name="phone_entered_scm_text">Entered SMS Callback Mode</string> <!-- SCM: Notification title --> - <string name="phone_in_scm_notification_title">Sms Callback Mode</string> + <string name="phone_in_scm_notification_title">SMS Callback Mode</string> <!-- SCM: Displays the time when SCM will end, Example: "No Data Connection until 10:45 AM" --> - <string name="phone_in_scm_notification_complete_time">until <xliff:g id="completeTime">%s</xliff:g></string> + <string name="phone_in_scm_notification_complete_time">Since <xliff:g id="completeTime">%s</xliff:g></string> <!-- SCM: Dialog box message for exiting from the notifications screen --> - <plurals name="alert_dialog_exit_scm"> - <!-- number of minutes is one --> - <item quantity="one">The phone will be in Sms Callback mode for <xliff:g id="count">%s</xliff:g> minute. While in this mode, no apps using a data connection can be used. Do you want to exit now?</item> - <!-- number of minutes is not equal to one --> - <item quantity="other">The phone will be in Sms Callback mode for <xliff:g id="count">%s</xliff:g> minutes. While in this mode, no applications using a data connection can be used. Do you want to exit now?</item> - </plurals> + <string name="alert_dialog_exit_scm">The phone is in SMS Callback mode. While in this mode, no apps using a data connection can be used. Do you want to exit now?</string> <!-- SCM: Dialog box message for exiting from any other app --> - <plurals name="alert_dialog_not_avaialble_in_scm"> - <!-- number of minutes is one --> - <item quantity="one">The selected action isn\'t available while in the Sms Callback mode. The phone will be in this mode for <xliff:g id="count">%s</xliff:g> minute. Do you want to exit now?</item> - <!-- number of minutes is not equal to one --> - <item quantity="other">The selected action isn\'t available while in the Sms Callback mode. The phone will be in this mode for <xliff:g id="count">%s</xliff:g> minutes. Do you want to exit now?</item> - </plurals> + <string name="alert_dialog_not_avaialble_in_scm">The selected action isn\'t available while in the SMS Callback mode.Do you want to exit now?</string> <!-- SCM: Dialog box message while in emergency call --> <string name="alert_dialog_in_scm_call">The selected action isn\'t available while in an emergency call.</string> <!-- SCM: Progress text --> - <string name="progress_dialog_exiting_scm">Exiting Sms Callback mode</string> + <string name="progress_dialog_exiting_scm">Exiting SMS Callback mode</string> <!-- SCM: Notification body wihout data restriction hint --> - <string name="phone_in_scm_call_notification_text_without_data_restriction_hint">The phone is in sms callback mode</string> + <string name="phone_in_scm_call_notification_text_without_data_restriction_hint">The phone is in SMS callback mode</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-array name="absent_num" translatable="false"> diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java index 46a3c3df0e..cee8cf54d1 100644 --- a/src/com/android/phone/PhoneGlobals.java +++ b/src/com/android/phone/PhoneGlobals.java @@ -165,6 +165,7 @@ public class PhoneGlobals extends ContextWrapper { CarrierConfigLoader configLoader; private Phone phoneInEcm; + private Phone phoneInScbm; static boolean sVoiceCapable = true; @@ -818,10 +819,19 @@ public class PhoneGlobals extends ContextWrapper { Log.w(LOG_TAG, "phoneInEcm is null."); } } else if (action.equals(SmsCallbackModeService.ACTION_SMS_CALLBACK_MODE_CHANGED)) { - if (intent.getBooleanExtra( - SmsCallbackModeService.EXTRA_PHONE_IN_SCM_STATE, false)) { - // Start Sms Callback Mode service - context.startService(new Intent(context, SmsCallbackModeService.class)); + int phoneId = intent.getIntExtra(PhoneConstants.PHONE_KEY, 0); + Log.d(LOG_TAG, "SMS Callback Mode. phoneId:" + phoneId); + phoneInScbm = PhoneFactory.getPhone(phoneId); + if (phoneInScbm != null) { + if (intent.getBooleanExtra( + SmsCallbackModeService.EXTRA_PHONE_IN_SCM_STATE, false)) { + // Start Sms Callback Mode service + context.startService(new Intent(context, SmsCallbackModeService.class)); + } else { + phoneInScbm = null; + } + } else { + Log.w(LOG_TAG, "phoneInScbm is null."); } } else if (action.equals(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED)) { // Roaming status could be overridden by carrier config, so we need to update it. @@ -1007,6 +1017,10 @@ public class PhoneGlobals extends ContextWrapper { return phoneInEcm; } + public Phone getPhoneInEmergencyMode() { + return phoneInEcm != null ? phoneInEcm: phoneInScbm; + } + /** * Triggers a refresh of the message waiting (voicemail) indicator. * diff --git a/src/com/android/phone/SmsCallbackModeExitDialog.java b/src/com/android/phone/SmsCallbackModeExitDialog.java index c994e858dc..a37a73f52b 100644 --- a/src/com/android/phone/SmsCallbackModeExitDialog.java +++ b/src/com/android/phone/SmsCallbackModeExitDialog.java @@ -44,7 +44,6 @@ import android.os.Message; import android.telephony.TelephonyManager; import android.util.Log; -import com.android.internal.telephony.EcbmHandler; import com.android.internal.telephony.Phone; import com.android.internal.telephony.PhoneFactory; import com.android.internal.telephony.TelephonyIntents; @@ -70,16 +69,11 @@ public class SmsCallbackModeExitDialog extends Activity implements OnCancelListe AlertDialog mAlertDialog = null; ProgressDialog mProgressDialog = null; - CountDownTimer mTimer = null; SmsCallbackModeService mService = null; Handler mHandler = null; int mDialogType = 0; - long mScmTimeout = 0; - private boolean mInEmergencySms = false; - private static final int SCM_TIMER_RESET = 1; private Phone mPhone = null; private boolean mIsResumed = false; - //private EcbmHandler mEcbmHandler; @Override public void onCreate(Bundle savedInstanceState) { @@ -105,9 +99,6 @@ public class SmsCallbackModeExitDialog extends Activity implements OnCancelListe "ScmExitDialogWaitThread"); waitForConnectionCompleteThread.start(); - // Register SCM timer reset notfication - mPhone.registerForScbmTimerReset(mTimerResetHandler, SCM_TIMER_RESET, null); - // Register receiver for intent closing the dialog IntentFilter filter = new IntentFilter(); filter.addAction(SmsCallbackModeService.ACTION_SMS_CALLBACK_MODE_CHANGED); @@ -134,10 +125,6 @@ public class SmsCallbackModeExitDialog extends Activity implements OnCancelListe } catch (IllegalArgumentException e) { // Receiver was never registered - silently ignore. } - // Unregister ECM timer reset notification - if (mPhone != null) { - mPhone.unregisterForScbmTimerReset(mHandler); - } } @Override @@ -159,36 +146,6 @@ public class SmsCallbackModeExitDialog extends Activity implements OnCancelListe public void run() { Looper.prepare(); - // Bind to the remote service - bindService(new Intent(SmsCallbackModeExitDialog.this, - SmsCallbackModeService.class), mConnection, Context.BIND_AUTO_CREATE); - - // Wait for bind to finish - synchronized (SmsCallbackModeExitDialog.this) { - try { - if (mService == null) { - SmsCallbackModeExitDialog.this.wait(); - } - } catch (InterruptedException e) { - Log.d("ECM", "SmsCallbackModeExitDialog InterruptedException: " - + e.getMessage()); - e.printStackTrace(); - } - } - - // Get timeout value and call state from the service - if (mService != null) { - mScmTimeout = mService.getSmsCallbackModeTimeout(); - mInEmergencySms = mService.getSmsCallbackModeSmsState(); - try { - // Unbind from remote service - unbindService(mConnection); - } catch (IllegalArgumentException e) { - // Failed to unbind from service. - Log.w(TAG, "Failed to unbind from SmsCallbackModeService"); - } - } - // Show dialog mHandler.post(new Runnable() { public void run() { @@ -206,31 +163,13 @@ public class SmsCallbackModeExitDialog extends Activity implements OnCancelListe Log.w(TAG, "Tried to show dialog, but activity was already finished"); return; } - if (mInEmergencySms) { - mDialogType = EXIT_SCM_IN_EMERGENCY_SMS_DIALOG; - showDialog(EXIT_SCM_IN_EMERGENCY_SMS_DIALOG); - } else { - if (getIntent().getAction().equals( - SmsCallbackModeService.ACTION_SHOW_NOTICE_SCM_BLOCK_OTHERS)) { - mDialogType = EXIT_SCM_BLOCK_OTHERS; - showDialog(EXIT_SCM_BLOCK_OTHERS); - } else if (getIntent().getAction().equals(ACTION_SHOW_SCM_EXIT_DIALOG)) { - mDialogType = EXIT_SCM_DIALOG; - showDialog(EXIT_SCM_DIALOG); - } - - mTimer = new CountDownTimer(mScmTimeout, 1000) { - @Override - public void onTick(long millisUntilFinished) { - CharSequence text = getDialogText(millisUntilFinished); - mAlertDialog.setMessage(text); - } - - @Override - public void onFinish() { - //Do nothing - } - }.start(); + if (getIntent().getAction().equals( + SmsCallbackModeService.ACTION_SHOW_NOTICE_SCM_BLOCK_OTHERS)) { + mDialogType = EXIT_SCM_BLOCK_OTHERS; + showDialog(EXIT_SCM_BLOCK_OTHERS); + } else if (getIntent().getAction().equals(ACTION_SHOW_SCM_EXIT_DIALOG)) { + mDialogType = EXIT_SCM_DIALOG; + showDialog(EXIT_SCM_DIALOG); } } @@ -242,7 +181,7 @@ public class SmsCallbackModeExitDialog extends Activity implements OnCancelListe switch (id) { case EXIT_SCM_BLOCK_OTHERS: case EXIT_SCM_DIALOG: - CharSequence text = getDialogText(mScmTimeout); + CharSequence text = getDialogText(); mAlertDialog = new AlertDialog.Builder(SmsCallbackModeExitDialog.this, android.R.style.Theme_DeviceDefault_Dialog_Alert) .setIcon(R.drawable.ic_emergency_callback_mode) @@ -260,7 +199,6 @@ public class SmsCallbackModeExitDialog extends Activity implements OnCancelListe // Show progress dialog showDialog(EXIT_SCM_PROGRESS_DIALOG); - mTimer.cancel(); } }) .setNegativeButton(R.string.alert_dialog_no, @@ -274,23 +212,6 @@ public class SmsCallbackModeExitDialog extends Activity implements OnCancelListe mAlertDialog.setOnCancelListener(this); return mAlertDialog; - case EXIT_SCM_IN_EMERGENCY_SMS_DIALOG: - mAlertDialog = new AlertDialog.Builder(SmsCallbackModeExitDialog.this, - android.R.style.Theme_DeviceDefault_Dialog_Alert) - .setIcon(R.drawable.ic_emergency_callback_mode) - .setTitle(R.string.phone_in_scm_notification_title) - .setMessage(R.string.alert_dialog_in_scm_call) - .setNeutralButton(R.string.alert_dialog_dismiss, - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int whichButton) { - // User clicked Dismiss - setResult(RESULT_CANCELED); - finish(); - } - }).create(); - mAlertDialog.setOnCancelListener(this); - return mAlertDialog; - case EXIT_SCM_PROGRESS_DIALOG: mProgressDialog = new ProgressDialog(SmsCallbackModeExitDialog.this); mProgressDialog.setMessage(getText(R.string.progress_dialog_exiting_scm)); @@ -306,19 +227,14 @@ public class SmsCallbackModeExitDialog extends Activity implements OnCancelListe /** * Returns dialog box text with updated timeout value */ - private CharSequence getDialogText(long millisUntilFinished) { - // Format time - int minutes = (int)(millisUntilFinished / 60000); - String time = String.format("%d:%02d", minutes, - (millisUntilFinished % 60000) / 1000); - + private CharSequence getDialogText() { switch (mDialogType) { case EXIT_SCM_BLOCK_OTHERS: - return String.format(getResources().getQuantityText( - R.plurals.alert_dialog_not_avaialble_in_scm, minutes).toString(), time); + return getResources().getString( + R.string.alert_dialog_not_avaialble_in_scm); case EXIT_SCM_DIALOG: - return String.format(getResources().getQuantityText( - R.plurals.alert_dialog_exit_scm, minutes).toString(), time); + return getResources().getString( + R.string.alert_dialog_exit_scm); } return null; } @@ -354,36 +270,4 @@ public class SmsCallbackModeExitDialog extends Activity implements OnCancelListe } }; - /** - * Class for interacting with the interface of the service - */ - private ServiceConnection mConnection = new ServiceConnection() { - public void onServiceConnected(ComponentName className, IBinder service) { - mService = ((SmsCallbackModeService.LocalBinder)service).getService(); - // Notify thread that connection is ready - synchronized (SmsCallbackModeExitDialog.this) { - SmsCallbackModeExitDialog.this.notify(); - } - } - - 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 SCM_TIMER_RESET: - if(!((Boolean)((AsyncResult) msg.obj).result).booleanValue()) { - SmsCallbackModeExitDialog.this.setResult(RESULT_CANCELED); - finish(); - } - break; - } - } - }; } diff --git a/src/com/android/phone/SmsCallbackModeService.java b/src/com/android/phone/SmsCallbackModeService.java index 226f92387d..30e9da37cf 100644 --- a/src/com/android/phone/SmsCallbackModeService.java +++ b/src/com/android/phone/SmsCallbackModeService.java @@ -53,17 +53,11 @@ import java.text.SimpleDateFormat; */ public class SmsCallbackModeService extends Service { - // Default Emergency Callback Mode timeout value - private static final long DEFAULT_SCM_EXIT_TIMER_VALUE = 300000L; private static final String LOG_TAG = "SmsCallbackModeService"; private NotificationManager mNotificationManager = null; - private CountDownTimer mTimer = null; - private long mTimeLeft = 0; + private long mTime = 0; private Phone mPhone = null; - private boolean mInEmergencySms = false; - - private static final int SCM_TIMER_RESET = 1; /** * Intent action broadcasted when Sms Callback Mode changed. @@ -84,16 +78,6 @@ public class SmsCallbackModeService extends Service { public static final String ACTION_SHOW_NOTICE_SCM_BLOCK_OTHERS = "org.codeaurora.intent.action.SHOW_NOTICE_SCM_BLOCK_OTHERS"; - private Handler mHandler = new Handler() { - public void handleMessage(Message msg) { - switch (msg.what) { - case SCM_TIMER_RESET: - resetScmTimer((AsyncResult) msg.obj); - break; - } - } - }; - @Override public void onCreate() { mPhone = PhoneFactory.getDefaultPhone(); @@ -104,10 +88,7 @@ public class SmsCallbackModeService extends Service { registerReceiver(mScmReceiver, filter); mNotificationManager = getSystemService(NotificationManager.class); - - mPhone.registerForScbmTimerReset(mHandler, SCM_TIMER_RESET, null); - - startTimerNotification(); + showNotification(); } @Override @@ -115,13 +96,9 @@ public class SmsCallbackModeService extends Service { if (mPhone != null) { // Unregister receiver unregisterReceiver(mScmReceiver); - // Unregister SCM timer reset notification - mPhone.unregisterForScbmTimerReset(mHandler); - // Cancel the notification and timer mNotificationManager.cancelAsUser(null, R.string.phone_in_scm_notification_title, UserHandle.ALL); - mTimer.cancel(); } } @@ -141,47 +118,12 @@ public class SmsCallbackModeService extends Service { }; /** - * Start timer notification for Sms Callback Mode - */ - private void startTimerNotification() { - // Get Sms Callback Mode timeout value - long scmTimeout = TelephonyProperties.ecm_exit_timer(). - orElse(DEFAULT_SCM_EXIT_TIMER_VALUE); - - // Show the notification - showNotification(scmTimeout); - - // Start countdown timer for the notification updates - if (mTimer != null) { - mTimer.cancel(); - } else { - mTimer = new CountDownTimer(scmTimeout, 1000) { - - @Override - public void onTick(long millisUntilFinished) { - mTimeLeft = millisUntilFinished; - } - - @Override - public void onFinish() { - //Do nothing - } - - }; - } - mTimer.start(); - } - - /** * Shows notification for Sms Callback Mode */ - private void showNotification(long millisUntilFinished) { + private void showNotification() { boolean isInScm = mPhone.isInScbm(); if (!isInScm) { Log.i(LOG_TAG, "Asked to show notification but not in SCM mode"); - if (mTimer != null) { - mTimer.cancel(); - } return; } final Notification.Builder builder = new Notification.Builder(getApplicationContext()); @@ -202,25 +144,13 @@ public class SmsCallbackModeService extends Service { // Format notification string String text = null; - if(mInEmergencySms) { - text = getText( - R.string.phone_in_scm_call_notification_text_without_data_restriction_hint) - .toString(); - } else { - // Calculate the time in ms when the notification will be finished. - long finishedCountMs = millisUntilFinished + System.currentTimeMillis(); - builder.setShowWhen(true); - builder.setChronometerCountDown(true); - builder.setUsesChronometer(true); - builder.setWhen(finishedCountMs); - - String completeTime = SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT).format( - finishedCountMs); - text = getResources().getString( - // During IMS SCM, data restriction hint should be removed. - R.string.phone_in_scm_notification_complete_time, - completeTime); - } + // Calculate the time in ms when the notification will be finished. + mTime = System.currentTimeMillis(); + String completeTime = SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT).format( + mTime); + text = getResources().getString( + R.string.phone_in_scm_notification_complete_time, + completeTime); builder.setContentText(text); builder.setChannelId(NotificationChannelController.CHANNEL_ID_ALERT); @@ -229,23 +159,6 @@ public class SmsCallbackModeService extends Service { builder.build(), UserHandle.ALL); } - /** - * Handle SCM_TIMER_RESET notification - */ - private void resetScmTimer(AsyncResult r) { - boolean isTimerCanceled = ((Boolean)r.result).booleanValue(); - Log.i(LOG_TAG, "resetScmTimer: " + isTimerCanceled); - - if (isTimerCanceled) { - mInEmergencySms = true; - mTimer.cancel(); - showNotification(0); - } else { - mInEmergencySms = false; - startTimerNotification(); - } - } - @Override public IBinder onBind(Intent intent) { return mBinder; @@ -263,17 +176,4 @@ public class SmsCallbackModeService extends Service { } } - /** - * Returns Sms Callback Mode timeout value - */ - public long getSmsCallbackModeTimeout() { - return mTimeLeft; - } - - /** - * Returns Sms Callback Mode Sms state - */ - public boolean getSmsCallbackModeSmsState() { - return mInEmergencySms; - } } diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java index cdf122645c..477ff9be07 100644 --- a/src/com/android/services/telephony/TelecomAccountRegistry.java +++ b/src/com/android/services/telephony/TelecomAccountRegistry.java @@ -66,6 +66,7 @@ import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.PhoneFactory; import com.android.internal.telephony.RIL; import com.android.internal.telephony.SubscriptionController; +import com.android.internal.telephony.util.QtiImsUtils; import com.android.phone.PhoneGlobals; import com.android.phone.PhoneUtils; import com.android.phone.R; @@ -924,8 +925,9 @@ public class TelecomAccountRegistry { String[] supportedCountries = mContext.getResources().getStringArray( R.array.config_simless_emergency_rtt_supported_countries); - if (supportedCountries == null || Arrays.stream(supportedCountries).noneMatch( - Predicate.isEqual(country))) { + if ((supportedCountries == null || Arrays.stream(supportedCountries).noneMatch( + Predicate.isEqual(country))) && !QtiImsUtils.isSimLessRttSupported( + mPhone.getPhoneId(), mPhone.getContext())) { Log.i(this, "isRttCurrentlySupported -- emergency acct and" + " not supported in this country: " + country); return false; @@ -1609,13 +1611,14 @@ public class TelecomAccountRegistry { || phone.getFullIccSerialNumber() == null) { Log.d(this, "setupAccounts: skipping invalid subid %d", subscriptionId); // If device configured in dsds mode, a SIM removed and if corresponding - // phone is in ECM then add emergency account to that sub so that - // incoming emergency call can be processed. - Phone phoneInEcm = PhoneGlobals.getInstance().getPhoneInEcm(); + // phone is in ECM or SCBM then add emergency account to that sub so + // that incoming emergency call can be processed. + Phone emergencyPhone = + PhoneGlobals.getInstance().getPhoneInEmergencyMode(); if ((mTelephonyManager.getPhoneCount() > 1) - && (phoneInEcm != null) - && phoneInEcm.getPhoneId() == phone.getPhoneId()) { - mAccounts.add(new AccountEntry(phoneInEcm, true /* emergency */, + && (emergencyPhone != null) + && emergencyPhone.getPhoneId() == phone.getPhoneId()) { + mAccounts.add(new AccountEntry(emergencyPhone, true /* emergency */, false /* isTest */)); isAccountAdded = true; } diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java index 6feb706ab3..116e13b9c0 100644 --- a/src/com/android/services/telephony/TelephonyConnectionService.java +++ b/src/com/android/services/telephony/TelephonyConnectionService.java @@ -1415,7 +1415,7 @@ public class TelephonyConnectionService extends ConnectionService { Phone phone; if (isEmergency) { - phone = PhoneGlobals.getInstance().getPhoneInEcm(); + phone = PhoneGlobals.getInstance().getPhoneInEmergencyMode(); } else { phone = getPhoneForAccount(accountHandle, isEmergency, /* Note: when not an emergency, handle can be null for unknown callers */ |