diff options
author | 2022-07-15 03:22:27 +0000 | |
---|---|---|
committer | 2022-07-15 04:09:23 +0000 | |
commit | 1a716842e8cd95b4fc5ada2b284c576a3fb27d1d (patch) | |
tree | 5b112cc1c3655ab4d4bd8cfbe012c5d5845da871 /WifiDialog/src | |
parent | 25ab770d79b9cb83da1de6d77d4da8d68464431e (diff) |
Do not kill WifiDialog process if there are activities remaining
There may be edge cases where WifiDialogActivity finishes and a new
dialog is requested immediately. In this case, the new dialog request
starts a new WifiDialogActivity since the first one is finishing.
However, once the first activity calls onDestroy(), we end up killing
the entire Process which kills the second activity. Instead, we should
check if there are any other activity instances before calling killing
the process.
Bug: 236803960
Test: Enable iface conflict dialog, turn on STA + AP, go to P2P settings
and reject the dialog. Verify the second dialog pops up immediately and
the process is not killed. Verify accepting the second dialog kills the
process.
Change-Id: I19ffebdc1b7285b67dd0b4ca825dd27fac945e2b
Diffstat (limited to 'WifiDialog/src')
-rw-r--r-- | WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java b/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java index 49824da5fa..734fbd9522 100644 --- a/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java +++ b/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java @@ -65,6 +65,8 @@ import java.util.Set; * Main Activity of the WifiDialog application. All dialogs should be created and managed from here. */ public class WifiDialogActivity extends Activity { + private static int sNumActiveInstances = 0; + private static final String TAG = "WifiDialog"; private static final String KEY_DIALOG_INTENTS = "KEY_DIALOG_INTENTS"; @@ -194,6 +196,10 @@ public class WifiDialogActivity extends Activity { @Override protected void onStart() { super.onStart(); + sNumActiveInstances++; + if (mIsVerboseLoggingEnabled) { + Log.v(TAG, "onStart() incrementing sActiveInstances to " + sNumActiveInstances); + } registerReceiver( mCloseSystemDialogsReceiver, new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); ArraySet<Integer> invalidDialogIds = new ArraySet<>(); @@ -237,6 +243,10 @@ public class WifiDialogActivity extends Activity { @Override protected void onStop() { super.onStop(); + sNumActiveInstances--; + if (mIsVerboseLoggingEnabled) { + Log.v(TAG, "onStop() decrementing sActiveInstances to " + sNumActiveInstances); + } unregisterReceiver(mCloseSystemDialogsReceiver); if (isChangingConfigurations()) { @@ -296,7 +306,15 @@ public class WifiDialogActivity extends Activity { protected void onDestroy() { super.onDestroy(); if (isFinishing()) { - // Kill the process now instead of waiting indefinitely for ActivityManager to kill it. + if (sNumActiveInstances > 0) { + if (mIsVerboseLoggingEnabled) { + Log.v(TAG, "Finished with sNumActiveInstances: " + sNumActiveInstances); + } + return; + } + if (mIsVerboseLoggingEnabled) { + Log.v(TAG, "Finished with no active instances left. Killing process."); + } Process.killProcess(android.os.Process.myPid()); } } |