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

Commit 69f7e876 authored by Nate Myren's avatar Nate Myren
Browse files

Delay location updates for 1000ms

Since the Location Extra Package reacts to the same broadcast as the
permissionController, we must wait for it to complete its state update
before updating the PermissionController UI

Fixes: 158159226
Test: Go to PermissionController location page, enable/disable location,
verify the location extra package is enabled/disabled with location (if
location history is on)

Change-Id: Ifc581d7cfd7df77a0544e2d3a693a5383e984b10
parent 26f2ff20
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);
        }
    };