Pending Location information added to Dark Theme

Resolved an issue in Settings where sunset/sunrise dark mode failed silently when a location was unavailable. Now, an error dialog is shown, even if location services are enabled, but a specific location is missing.

A footer stating the same issue is now present while the location is pending.

Existing banner that appears when Location is disabled is now being removed once Location is turned on. Previously the UI would refresh only after exiting and returning to the preference view.

Bug: 324548844
Bug: 402025928
Test: atest UiModeManagerServiceTest
Flag: EXEMPT bugfix
Change-Id: I914937185f11a686b453f929728b6329ebd05389
This commit is contained in:
Marcelo Arteiro
2025-03-11 14:48:38 +00:00
parent cf5646c92b
commit 157030dcef
9 changed files with 118 additions and 10 deletions

View File

@@ -16,7 +16,7 @@
package com.android.settings.display;
import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
import static com.android.settings.core.BasePreferenceController.DISABLED_DEPENDENT_SETTING;
import static com.google.common.truth.Truth.assertThat;
@@ -53,10 +53,10 @@ public class TwilightLocationPreferenceControllerTest {
}
@Test
public void getAvailabilityStatus_locationEnabled_shouldBeCONDITIONALLY_UNAVAILABLE() {
public void getAvailabilityStatus_locationEnabled_shouldBeDISABLED_DEPENDENT_SETTING() {
when(mLocationManager.isLocationEnabled()).thenReturn(true);
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_DEPENDENT_SETTING);
}
@Test

View File

@@ -31,6 +31,7 @@ import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.location.Location;
import android.location.LocationManager;
import android.os.PowerManager;
@@ -98,6 +99,7 @@ public class DarkModeScheduleSelectorControllerTest {
mPreference.setEntryValues(new CharSequence[]{"never", "auto", "custom"});
doNothing().when(mPreference).setValueIndex(anyInt());
when(mLocationManager.isLocationEnabled()).thenReturn(true);
when(mLocationManager.getLastLocation()).thenReturn(new Location("mock"));
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
when(mUiService.setNightModeActivated(anyBoolean())).thenReturn(true);
mController = new DarkModeScheduleSelectorController(mContext, mPreferenceKey);