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

Commit 9c94dd9d authored by Nate Myren's avatar Nate Myren Committed by Android (Google) Code Review
Browse files

Merge "Delay location updates for 1000ms" into rvc-dev

parents 72caa638 69f7e876
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.IntentFilter;
import android.location.LocationManager;
import android.os.Handler;
import android.os.Looper;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.Log;
@@ -43,6 +45,8 @@ public class LocationUtils {
    public static final String LOCATION_PERMISSION = Manifest.permission_group.LOCATION;

    private static final String TAG = LocationUtils.class.getSimpleName();
    private static final long LOCATION_UPDATE_DELAY_MS = 1000;
    private static final Handler sMainHandler = new Handler(Looper.getMainLooper());

    public static void showLocationDialog(final Context context, CharSequence label) {
        new AlertDialog.Builder(context)
@@ -121,11 +125,13 @@ public class LocationUtils {
        @Override
        public void onReceive(Context context, Intent intent) {
            boolean isEnabled = intent.getBooleanExtra(EXTRA_LOCATION_ENABLED, true);
            sMainHandler.postDelayed(() -> {
                synchronized (sLocationListeners) {
                    for (LocationListener l : sLocationListeners) {
                        l.onLocationStateChange(isEnabled);
                    }
                }
            }, LOCATION_UPDATE_DELAY_MS);
        }
    };