Stop 1 sec updates of ECBM Notification
Previously, the ECBM notification would call update
1/sec to update the time before we get out of ECBM
in the notification. In the new system, this causes
a sound to occur every time the notification updates.
This fixes the issue by utilizing the notification
when() method instead.
Test: ECBM mode on Vzw SIM
Bug: 38175843
Change-Id: I1cdef9c1b17a0d2ccbb2c8b51928c05b0095f839
diff --git a/src/com/android/phone/EmergencyCallbackModeService.java b/src/com/android/phone/EmergencyCallbackModeService.java
index 3219c69..a07f7aa 100644
--- a/src/com/android/phone/EmergencyCallbackModeService.java
+++ b/src/com/android/phone/EmergencyCallbackModeService.java
@@ -39,6 +39,8 @@
import com.android.internal.telephony.TelephonyProperties;
import com.android.internal.telephony.util.NotificationChannelController;
+import java.text.SimpleDateFormat;
+
/**
* Application service that inserts/removes Emergency Callback Mode notification and
* updates Emergency Callback Mode countdown clock in the notification
@@ -152,7 +154,6 @@
@Override
public void onTick(long millisUntilFinished) {
mTimeLeft = millisUntilFinished;
- EmergencyCallbackModeService.this.showNotification(millisUntilFinished);
}
@Override
@@ -197,10 +198,17 @@
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);
+ // 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(R.string.phone_in_ecm_notification_complete_time,
+ completeTime);
}
builder.setContentText(text);
builder.setChannelId(NotificationChannelController.CHANNEL_ID_ALERT);