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
This commit is contained in:
@ -139,6 +139,7 @@ class ServerThread extends Thread {
|
||||
DockObserver dock = null;
|
||||
UsbService usb = null;
|
||||
SerialService serial = null;
|
||||
TwilightService twilight = null;
|
||||
UiModeManagerService uiMode = null;
|
||||
RecognitionManagerService recognition = null;
|
||||
ThrottleService throttle = null;
|
||||
@ -585,10 +586,17 @@ class ServerThread extends Thread {
|
||||
Slog.e(TAG, "Failure starting SerialService", e);
|
||||
}
|
||||
|
||||
try {
|
||||
Slog.i(TAG, "Twilight Service");
|
||||
twilight = new TwilightService(context);
|
||||
} catch (Throwable e) {
|
||||
reportWtf("starting TwilightService", e);
|
||||
}
|
||||
|
||||
try {
|
||||
Slog.i(TAG, "UI Mode Manager Service");
|
||||
// Listen for UI mode changes
|
||||
uiMode = new UiModeManagerService(context);
|
||||
uiMode = new UiModeManagerService(context, twilight);
|
||||
} catch (Throwable e) {
|
||||
reportWtf("starting UiModeManagerService", e);
|
||||
}
|
||||
@ -750,6 +758,7 @@ class ServerThread extends Thread {
|
||||
final DockObserver dockF = dock;
|
||||
final UsbService usbF = usb;
|
||||
final ThrottleService throttleF = throttle;
|
||||
final TwilightService twilightF = twilight;
|
||||
final UiModeManagerService uiModeF = uiMode;
|
||||
final AppWidgetService appWidgetF = appWidget;
|
||||
final WallpaperManagerService wallpaperF = wallpaper;
|
||||
@ -809,6 +818,11 @@ class ServerThread extends Thread {
|
||||
} catch (Throwable e) {
|
||||
reportWtf("making USB Service ready", e);
|
||||
}
|
||||
try {
|
||||
if (twilightF != null) twilightF.systemReady();
|
||||
} catch (Throwable e) {
|
||||
reportWtf("makin Twilight Service ready", e);
|
||||
}
|
||||
try {
|
||||
if (uiModeF != null) uiModeF.systemReady();
|
||||
} catch (Throwable e) {
|
||||
|
Reference in New Issue
Block a user