summaryrefslogtreecommitdiff
path: root/WifiDialog/src
diff options
context:
space:
mode:
author Quang Luong <qal@google.com> 2022-11-21 21:41:12 +0000
committer Quang Luong <qal@google.com> 2022-12-05 21:33:06 +0000
commit4a97623c486d3023fd715654ac26c42f0de8ad9e (patch)
tree53685bf242e41c0d1745c8552fdadd8337968a97 /WifiDialog/src
parentd7fa29fbc6d201b56c9a4481e87041183260cd90 (diff)
Clean up WifiDialogActivity's home button logic
WifiDialogActivity cancels all dialogs when ACTION_CLOSE_SYSTEM_DIALOGS is received. However, this happens before the device transitions to the home screen, allowing apps to immediately request a new dialog right before they're put into the background. This results in a dialog popping over the home screen. Instead, we should cancel the dialogs in onStop() (if not a configuration change or screen off), which happens after the user navigates to the home screen and the rest of the activities are put to the background. Bug: 257398441 Test: enable ICM dialogs and use test app to constantly request an iface dialog, verify home button press closes the dialog and does not pop a dialog over the home screen. Change-Id: I25ff807307d2d1c4d609df9d316f91e3f1407dbc
Diffstat (limited to 'WifiDialog/src')
-rw-r--r--WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java33
1 files changed, 3 insertions, 30 deletions
diff --git a/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java b/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java
index e5b2ac6b59..7db2c83c81 100644
--- a/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java
+++ b/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java
@@ -19,10 +19,7 @@ package com.android.wifi.dialog;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
-import android.content.BroadcastReceiver;
-import android.content.Context;
import android.content.Intent;
-import android.content.IntentFilter;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.icu.text.MessageFormat;
@@ -89,26 +86,6 @@ public class WifiDialogActivity extends Activity {
private @NonNull SparseArray<Dialog> mActiveDialogsPerId = new SparseArray<>();
private @NonNull SparseArray<CountDownTimer> mActiveCountDownTimersPerId = new SparseArray<>();
- // Broadcast receiver for listening to ACTION_CLOSE_SYSTEM_DIALOGS
- private BroadcastReceiver mCloseSystemDialogsReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- if (intent.getBooleanExtra(
- WifiManager.EXTRA_CLOSE_SYSTEM_DIALOGS_EXCEPT_WIFI, false)) {
- return;
- }
- if (mIsVerboseLoggingEnabled) {
- Log.v(TAG, "ACTION_CLOSE_SYSTEM_DIALOGS received, cancelling all dialogs.");
- }
- for (int i = 0; i < mActiveDialogsPerId.size(); i++) {
- Dialog dialog = mActiveDialogsPerId.valueAt(i);
- if (dialog.isShowing()) {
- dialog.cancel();
- }
- }
- }
- };
-
private WifiContext getWifiContext() {
if (mWifiContext == null) {
mWifiContext = new WifiContext(this);
@@ -210,8 +187,6 @@ public class WifiDialogActivity extends Activity {
@Override
protected void onStart() {
super.onStart();
- registerReceiver(
- mCloseSystemDialogsReceiver, new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
ArraySet<Integer> invalidDialogIds = new ArraySet<>();
for (int i = 0; i < mLaunchIntentsPerId.size(); i++) {
int dialogId = mLaunchIntentsPerId.keyAt(i);
@@ -253,7 +228,6 @@ public class WifiDialogActivity extends Activity {
@Override
protected void onStop() {
super.onStop();
- unregisterReceiver(mCloseSystemDialogsReceiver);
if (isChangingConfigurations()) {
// If we're stopping due to a configuration change, dismiss all the dialogs without
@@ -272,10 +246,9 @@ public class WifiDialogActivity extends Activity {
}
mActiveCountDownTimersPerId.clear();
} else if (getSystemService(PowerManager.class).isInteractive()) {
- // If we're stopping because we're switching to a new Activity, remove and cancel all
- // the dialogs.
- while (mActiveDialogsPerId.size() > 0) {
- removeIntentAndPossiblyFinish(mActiveDialogsPerId.keyAt(0));
+ // If we're stopping because we're switching to a new Activity, cancel all the dialogs.
+ for (int i = 0; i < mActiveDialogsPerId.size(); i++) {
+ mActiveDialogsPerId.get(i).cancel();
}
}
}