summaryrefslogtreecommitdiff
path: root/src/com/android/phone/SmsCallbackModeService.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/phone/SmsCallbackModeService.java')
-rw-r--r--src/com/android/phone/SmsCallbackModeService.java120
1 files changed, 10 insertions, 110 deletions
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;
- }
}