From fac708c060b16ca49da2586c561b9059d237481e Mon Sep 17 00:00:00 2001 From: Yoshiaki Naka Date: Wed, 22 Jan 2020 19:49:27 +0900 Subject: Close Tone Dialog if the requested tone has already been stopped It is theoretically possible that the tone requested by PLAY TONE command has already been stopped before Tone Dialog is created if the specified duration is too short. To avoid keep displaying Tone Dialog in that scenario, Tone Dialog must finish itself if the tone has already been stopped. Bug: 148244769 Test: Manual Change-Id: I105b2a16ace6a554d475c653ac982d2c339a7fec --- src/com/android/stk/StkAppService.java | 4 ++++ src/com/android/stk/ToneDialog.java | 6 ++++++ 2 files changed, 10 insertions(+) (limited to 'src/com') diff --git a/src/com/android/stk/StkAppService.java b/src/com/android/stk/StkAppService.java index 4140d15..e03487c 100644 --- a/src/com/android/stk/StkAppService.java +++ b/src/com/android/stk/StkAppService.java @@ -2343,6 +2343,10 @@ public class StkAppService extends Service implements Runnable { } } + boolean isNoTonePlaying() { + return mTonePlayer == null ? true : false; + } + private void launchOpenChannelDialog(final int slotId) { TextMessage msg = mStkContext[slotId].mCurrentCmd.geTextMessage(); if (msg == null) { diff --git a/src/com/android/stk/ToneDialog.java b/src/com/android/stk/ToneDialog.java index 2efeecd..639a216 100644 --- a/src/com/android/stk/ToneDialog.java +++ b/src/com/android/stk/ToneDialog.java @@ -92,6 +92,12 @@ public class ToneDialog extends Activity { mAlertDialog = alertDialogBuilder.create(); mAlertDialog.show(); + + StkAppService appService = StkAppService.getInstance(); + // Finish the activity if the specified duration is too short and timed-out already. + if (appService != null && (appService.isNoTonePlaying())) { + finish(); + } } @Override -- cgit v1.2.3