Fix NPE in date time settings

- the callback is null when slice call setChecked() of PreferenceController

Bug: 343109816
Bug: 334924107
Test: robotest & manual
Flag: EXEMPT bug fix
Change-Id: Ia4d60455b6f14a46d00ae285017bc96ad4855679
This commit is contained in:
Edgar Wang
2024-05-29 11:46:46 +00:00
parent 3c822399ae
commit 82bd2c75f7
3 changed files with 15 additions and 0 deletions

View File

@@ -40,6 +40,11 @@ public class AutoTimeZonePreferenceController extends TogglePreferenceController
public AutoTimeZonePreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
mTimeManager = context.getSystemService(TimeManager.class);
// This is a no-op implementation of UpdateTimeAndDateCallback to avoid a NPE when
// setTimeAndDateCallback() isn't called, e.g. for slices and other cases where the
// controller is instantiated outside of the context of the real Date & Time settings
// screen.
mCallback = (c) -> {};
}
/**