Store whether the Dialog was previously dismissed

The dialog can be dismissed by either the framework automatically (i.e.
when the screen is rotated) or when the subscriptions change.

If both of these things happen while the class is not deleted, then
dismiss() will be called twice and there will be a crash

Bug: 184899699
Test: atest -c SettingsUnitTests
Change-Id: Ibaef59696feb566664a424f65f806396f02497e8
This commit is contained in:
Jeremy Goldman
2021-05-13 11:09:44 +08:00
parent 3a77c9c9e4
commit 09a185dbca
3 changed files with 19 additions and 1 deletions

View File

@@ -23,6 +23,7 @@ import android.content.DialogInterface;
import android.os.Bundle;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -81,7 +82,12 @@ public class PreferredSimDialogFragment extends SimDialogFragment implements
}
private void updateDialog(AlertDialog dialog) {
Log.d(TAG, "Dialog updated, dismiss status: " + mWasDismissed);
final SubscriptionInfo info = getPreferredSubscription();
if (mWasDismissed) {
return;
}
if (info == null) {
dismiss();
return;