Loading services/core/java/com/android/server/twilight/TwilightService.java +11 −14 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.twilight; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.AlarmManager; import android.content.BroadcastReceiver; import android.content.Context; Loading Loading @@ -160,8 +161,13 @@ public final class TwilightService extends SystemService // Request the device's location immediately if a previous location isn't available. if (mLocationManager.getLastLocation() == null) { if (mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) { mLocationManager.requestSingleUpdate( LocationManager.NETWORK_PROVIDER, this, Looper.getMainLooper()); mLocationManager.getCurrentLocation( LocationManager.NETWORK_PROVIDER, null, getContext().getMainExecutor(), this::onLocationChanged); } else if (mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { mLocationManager.getCurrentLocation( LocationManager.GPS_PROVIDER, null, getContext().getMainExecutor(), this::onLocationChanged); } } Loading Loading @@ -218,12 +224,7 @@ public final class TwilightService extends SystemService for (int i = mListeners.size() - 1; i >= 0; --i) { final TwilightListener listener = mListeners.keyAt(i); final Handler handler = mListeners.valueAt(i); handler.post(new Runnable() { @Override public void run() { listener.onTwilightStateChanged(state); } }); handler.post(() -> listener.onTwilightStateChanged(state)); } } } Loading @@ -243,12 +244,8 @@ public final class TwilightService extends SystemService } @Override public void onLocationChanged(Location location) { // Location providers may erroneously return (0.0, 0.0) when they fail to determine the // device's location. These location updates can be safely ignored since the chance of a // user actually being at these coordinates is quite low. if (location != null && !(location.getLongitude() == 0.0 && location.getLatitude() == 0.0)) { public void onLocationChanged(@Nullable Location location) { if (location != null) { Slog.d(TAG, "onLocationChanged:" + " provider=" + location.getProvider() + " accuracy=" + location.getAccuracy() Loading Loading
services/core/java/com/android/server/twilight/TwilightService.java +11 −14 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.twilight; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.AlarmManager; import android.content.BroadcastReceiver; import android.content.Context; Loading Loading @@ -160,8 +161,13 @@ public final class TwilightService extends SystemService // Request the device's location immediately if a previous location isn't available. if (mLocationManager.getLastLocation() == null) { if (mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) { mLocationManager.requestSingleUpdate( LocationManager.NETWORK_PROVIDER, this, Looper.getMainLooper()); mLocationManager.getCurrentLocation( LocationManager.NETWORK_PROVIDER, null, getContext().getMainExecutor(), this::onLocationChanged); } else if (mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { mLocationManager.getCurrentLocation( LocationManager.GPS_PROVIDER, null, getContext().getMainExecutor(), this::onLocationChanged); } } Loading Loading @@ -218,12 +224,7 @@ public final class TwilightService extends SystemService for (int i = mListeners.size() - 1; i >= 0; --i) { final TwilightListener listener = mListeners.keyAt(i); final Handler handler = mListeners.valueAt(i); handler.post(new Runnable() { @Override public void run() { listener.onTwilightStateChanged(state); } }); handler.post(() -> listener.onTwilightStateChanged(state)); } } } Loading @@ -243,12 +244,8 @@ public final class TwilightService extends SystemService } @Override public void onLocationChanged(Location location) { // Location providers may erroneously return (0.0, 0.0) when they fail to determine the // device's location. These location updates can be safely ignored since the chance of a // user actually being at these coordinates is quite low. if (location != null && !(location.getLongitude() == 0.0 && location.getLatitude() == 0.0)) { public void onLocationChanged(@Nullable Location location) { if (location != null) { Slog.d(TAG, "onLocationChanged:" + " provider=" + location.getProvider() + " accuracy=" + location.getAccuracy() Loading