Fix a crash due to absence of no-arg fragment init

Fix a crash due to absence of no-arg fragment constructor.

e.g. if the dialog were shown and the device were rotated, the dialog
could not be restored.

Bug: 272439218
Test: Manual with repro steps before and after
Change-Id: Idca052acff709af132fa72f7919aa71fe8060595
This commit is contained in:
Neil Fuller
2023-03-10 13:44:47 +00:00
parent ae2c14a039
commit 7ddbef73f0
2 changed files with 3 additions and 8 deletions

View File

@@ -77,7 +77,7 @@ public class LocationTimeZoneDetectionPreferenceController
boolean isLocationEnabled =
timeZoneCapabilitiesAndConfig.getCapabilities().isUseLocationEnabled();
if (isChecked && !isLocationEnabled) {
new LocationToggleDisabledDialogFragment(mContext)
new LocationToggleDisabledDialogFragment()
.show(mFragment.getFragmentManager(), TAG);
// Toggle status is not updated.
return false;

View File

@@ -19,7 +19,6 @@ package com.android.settings.datetime;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
@@ -32,11 +31,7 @@ import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
*/
public class LocationToggleDisabledDialogFragment extends InstrumentedDialogFragment {
private final Context mContext;
public LocationToggleDisabledDialogFragment(Context context) {
mContext = context;
}
public LocationToggleDisabledDialogFragment() {}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
@@ -48,7 +43,7 @@ public class LocationToggleDisabledDialogFragment extends InstrumentedDialogFrag
R.string.location_time_zone_detection_location_is_off_dialog_ok_button,
(dialog, which) -> {
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
mContext.startActivity(intent);
getContext().startActivity(intent);
})
.setNegativeButton(
R.string.location_time_zone_detection_location_is_off_dialog_cancel_button,