From d7fa29fbc6d201b56c9a4481e87041183260cd90 Mon Sep 17 00:00:00 2001 From: Quang Luong Date: Wed, 9 Nov 2022 21:55:48 +0000 Subject: Kill WifiDialog process from Wifi service Have Wifi service send signal to kill the WifiDialog process instead of handling it implicitly from WifiDialogActivity. This allows for future synchronization to avoid launching a dialog at the same time the process is being killed, which causes undefined race-condition behavior. Bug: 257398441 Test: adb shell cmd wifi launch-dialog-simple -t Title -m Message, verify process is killed in logcat when dialog is replied/cancelled/home button pressed. Change-Id: Ia08a8226867d0171fd3b72f35e0c11802a920851 --- .../android/wifi/dialog/WifiDialogActivity.java | 28 ---------------------- 1 file changed, 28 deletions(-) (limited to 'WifiDialog/src') diff --git a/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java b/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java index b73bee04be..e5b2ac6b59 100644 --- a/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java +++ b/WifiDialog/src/com/android/wifi/dialog/WifiDialogActivity.java @@ -37,7 +37,6 @@ import android.os.CountDownTimer; import android.os.Handler; import android.os.Looper; import android.os.PowerManager; -import android.os.Process; import android.os.SystemClock; import android.os.Vibrator; import android.text.Editable; @@ -72,8 +71,6 @@ 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"; private static final String EXTRA_DIALOG_EXPIRATION_TIME_MS = @@ -213,10 +210,6 @@ 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 invalidDialogIds = new ArraySet<>(); @@ -260,10 +253,6 @@ 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()) { @@ -328,23 +317,6 @@ public class WifiDialogActivity extends Activity { } } - @Override - protected void onDestroy() { - super.onDestroy(); - if (isFinishing()) { - 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()); - } - } - /** * Creates and shows a dialog for the given dialogId and Intent. * Returns {@code true} if the dialog was successfully created, {@code false} otherwise. -- cgit v1.2.3-59-g8ed1b