summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFan Zhang <zhfan@google.com>2020-12-14 12:30:35 -0800
committerFan Zhang <zhfan@google.com>2020-12-14 12:35:40 -0800
commitd9d3c5a8ef9fb6a0d042bb6b8a91952e35847230 (patch)
tree0ac99e1338fd90277495a42fa323f35f154f4cab /src
parent050ac792e5b0c1a951dbcd4cadd07af523477541 (diff)
downloadEmergencyInfo-d9d3c5a8ef9fb6a0d042bb6b8a91952e35847230.tar.gz
Add flags to support background counting down
A few flags are added in preparation to support counting down in background. - STATE_MILLIS_LEFT can also be set in activity intent. When we have a fg service for countdown, the fg service's notification can launch this UI, so we need to know remaining time from that intent. - mCountdownCancelled and mCountdownFinished flags: they are needed to start a foreground service right before UI is dismissed. Bug: 172075832 Test: manually inspected logs Change-Id: I97de40b5df790f2f366d5273e792c2327fd4c557
Diffstat (limited to 'src')
-rw-r--r--src/com/android/emergency/action/EmergencyActionFragment.java26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/com/android/emergency/action/EmergencyActionFragment.java b/src/com/android/emergency/action/EmergencyActionFragment.java
index 43598b6d..f0b36d4e 100644
--- a/src/com/android/emergency/action/EmergencyActionFragment.java
+++ b/src/com/android/emergency/action/EmergencyActionFragment.java
@@ -18,7 +18,9 @@ package com.android.emergency.action;
import static android.telecom.TelecomManager.EXTRA_CALL_SOURCE;
+import android.app.Activity;
import android.content.Context;
+import android.content.Intent;
import android.media.AudioAttributes;
import android.media.AudioManager;
import android.media.MediaPlayer;
@@ -60,6 +62,8 @@ public class EmergencyActionFragment extends Fragment implements OnSlideComplete
private long mCountDownMillisLeft;
private int mUserSetAlarmVolume;
private boolean mResetAlarmVolumeNeeded;
+ private boolean mCountdownCancelled;
+ private boolean mCountdownFinished;
@Override
public void onAttach(Context context) {
@@ -84,8 +88,18 @@ public class EmergencyActionFragment extends Fragment implements OnSlideComplete
if (savedInstanceState != null) {
mCountDownMillisLeft = savedInstanceState.getLong(STATE_MILLIS_LEFT);
} else {
- mCountDownMillisLeft =
- getResources().getInteger(R.integer.emergency_action_count_down_millis);
+ Activity activity = getActivity();
+ Intent intent = null;
+ if (activity != null) {
+ intent = activity.getIntent();
+ }
+ if (intent != null) {
+ mCountDownMillisLeft = intent.getLongExtra(STATE_MILLIS_LEFT,
+ getResources().getInteger(R.integer.emergency_action_count_down_millis));
+ } else {
+ mCountDownMillisLeft =
+ getResources().getInteger(R.integer.emergency_action_count_down_millis);
+ }
}
return view;
@@ -116,10 +130,17 @@ public class EmergencyActionFragment extends Fragment implements OnSlideComplete
}
stopWarningSound();
+ if (!mCountdownCancelled && !mCountdownFinished) {
+ Log.d(TAG,
+ "Emergency countdown UI dismissed without being cancelled/finished, "
+ + "continuing countdown in background");
+ // TODO(b/172075832): Continue countdown in a foreground service.
+ }
}
@Override
public void onSlideComplete() {
+ mCountdownCancelled = true;
getActivity().finish();
}
@@ -150,6 +171,7 @@ public class EmergencyActionFragment extends Fragment implements OnSlideComplete
@Override
public void onFinish() {
+ mCountdownFinished = true;
startEmergencyCall();
getActivity().finish();
}