Skip to content

Commit 2416e09

Browse files
author
Jeff Brown
committed
Extract the twilight detection into its own service.
Moving the detection out of UiModeManagerService will make it easy for other services to register for the information. Fixed a bugs related to updating twilight state when the time is updated. We're using the same algorithm as before for passively tracking the location. Ideally we should update it to use the new location manager features for low-power location requests. Change-Id: I520c53b9946ab6f8d994587d357fd6542c300c07
1 parent ae25108 commit 2416e09

File tree

3 files changed

+607
-321
lines changed

3 files changed

+607
-321
lines changed

services/java/com/android/server/SystemServer.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ public void run() {
139139
DockObserver dock = null;
140140
UsbService usb = null;
141141
SerialService serial = null;
142+
TwilightService twilight = null;
142143
UiModeManagerService uiMode = null;
143144
RecognitionManagerService recognition = null;
144145
ThrottleService throttle = null;
@@ -585,10 +586,17 @@ public void run() {
585586
Slog.e(TAG, "Failure starting SerialService", e);
586587
}
587588

589+
try {
590+
Slog.i(TAG, "Twilight Service");
591+
twilight = new TwilightService(context);
592+
} catch (Throwable e) {
593+
reportWtf("starting TwilightService", e);
594+
}
595+
588596
try {
589597
Slog.i(TAG, "UI Mode Manager Service");
590598
// Listen for UI mode changes
591-
uiMode = new UiModeManagerService(context);
599+
uiMode = new UiModeManagerService(context, twilight);
592600
} catch (Throwable e) {
593601
reportWtf("starting UiModeManagerService", e);
594602
}
@@ -750,6 +758,7 @@ public void run() {
750758
final DockObserver dockF = dock;
751759
final UsbService usbF = usb;
752760
final ThrottleService throttleF = throttle;
761+
final TwilightService twilightF = twilight;
753762
final UiModeManagerService uiModeF = uiMode;
754763
final AppWidgetService appWidgetF = appWidget;
755764
final WallpaperManagerService wallpaperF = wallpaper;
@@ -809,6 +818,11 @@ public void run() {
809818
} catch (Throwable e) {
810819
reportWtf("making USB Service ready", e);
811820
}
821+
try {
822+
if (twilightF != null) twilightF.systemReady();
823+
} catch (Throwable e) {
824+
reportWtf("makin Twilight Service ready", e);
825+
}
812826
try {
813827
if (uiModeF != null) uiModeF.systemReady();
814828
} catch (Throwable e) {

0 commit comments

Comments
 (0)