Check if the bedtime settings intent is null before launch

Test: make RunSettingsRoboTests -j56 ROBOTEST_FILTER=com.android.settings.display.darkmode.*
Bug: 306060498
Change-Id: Iddaec94c3a4cba74841d83305e581605c030bf33
This commit is contained in:
Steven Ng
2023-11-03 19:25:03 +00:00
parent 9718ae0aa9
commit 9ad7284d3f

View File

@@ -20,6 +20,7 @@ import static android.app.UiModeManager.MODE_NIGHT_CUSTOM_TYPE_BEDTIME;
import android.app.UiModeManager; import android.app.UiModeManager;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import androidx.preference.Preference; import androidx.preference.Preference;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
@@ -52,7 +53,12 @@ public class DarkModeCustomBedtimePreferenceController extends BasePreferenceCon
super.displayPreference(screen); super.displayPreference(screen);
mFooterPreference = screen.findPreference(getPreferenceKey()); mFooterPreference = screen.findPreference(getPreferenceKey());
mFooterPreference.setLearnMoreAction( mFooterPreference.setLearnMoreAction(
v -> v.getContext().startActivity(mBedtimeSettings.getBedtimeSettingsIntent())); v -> {
Intent bedtimeSettingsIntent = mBedtimeSettings.getBedtimeSettingsIntent();
if (bedtimeSettingsIntent != null) {
v.getContext().startActivity(bedtimeSettingsIntent);
}
});
mFooterPreference.setLearnMoreText( mFooterPreference.setLearnMoreText(
mContext.getString(R.string.dark_ui_bedtime_footer_action)); mContext.getString(R.string.dark_ui_bedtime_footer_action));
} }