Fix leaked windows exception in WifiDialogActivity
WifiDialog was created by WifiDialogActivity. If activity was destroyed suddenly, WifiDialog can't dismiss itself. So, we need to dismiss dialog, when activity was destroyed. Test: robo and manual test Bug: 111841375 Change-Id: I8aaf1c78e72144bf7c9cbc2392bce30e715d86e9
This commit is contained in:
@@ -52,6 +52,8 @@ public class WifiDialogActivity extends Activity implements WifiDialog.WifiDialo
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final String KEY_CONNECT_FOR_CALLER = "connect_for_caller";
|
static final String KEY_CONNECT_FOR_CALLER = "connect_for_caller";
|
||||||
|
|
||||||
|
private WifiDialog mDialog;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
final Intent intent = getIntent();
|
final Intent intent = getIntent();
|
||||||
@@ -67,10 +69,10 @@ public class WifiDialogActivity extends Activity implements WifiDialog.WifiDialo
|
|||||||
accessPoint = new AccessPoint(this, accessPointState);
|
accessPoint = new AccessPoint(this, accessPointState);
|
||||||
}
|
}
|
||||||
|
|
||||||
WifiDialog dialog = WifiDialog.createModal(
|
mDialog = WifiDialog.createModal(
|
||||||
this, this, accessPoint, WifiConfigUiBase.MODE_CONNECT);
|
this, this, accessPoint, WifiConfigUiBase.MODE_CONNECT);
|
||||||
dialog.show();
|
mDialog.show();
|
||||||
dialog.setOnDismissListener(this);
|
mDialog.setOnDismissListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -79,6 +81,15 @@ public class WifiDialogActivity extends Activity implements WifiDialog.WifiDialo
|
|||||||
overridePendingTransition(0, 0);
|
overridePendingTransition(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
if (mDialog != null && mDialog.isShowing()) {
|
||||||
|
mDialog.dismiss();
|
||||||
|
mDialog = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onForget(WifiDialog dialog) {
|
public void onForget(WifiDialog dialog) {
|
||||||
final WifiManager wifiManager = getSystemService(WifiManager.class);
|
final WifiManager wifiManager = getSystemService(WifiManager.class);
|
||||||
@@ -147,6 +158,7 @@ public class WifiDialogActivity extends Activity implements WifiDialog.WifiDialo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDismiss(DialogInterface dialogInterface) {
|
public void onDismiss(DialogInterface dialogInterface) {
|
||||||
|
mDialog = null;
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user