Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8e554f88 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Replace deprecated APIs"

parents baf9c299 423afd56
Loading
Loading
Loading
Loading
+11 −14
Original line number Diff line number Diff line
@@ -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;
@@ -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);
            }
        }

@@ -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));
                }
            }
        }
@@ -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()