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

Commit 34773092 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov Committed by Android (Google) Code Review
Browse files

Merge "[SB][Location] Synchronize on location callbacks when adding/removing." into main

parents d40cca12 c9c0e6cb
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import android.os.UserManager;
import android.provider.DeviceConfig;
import android.provider.Settings;

import androidx.annotation.GuardedBy;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;

@@ -361,6 +362,7 @@ public class LocationControllerImpl extends BroadcastReceiver implements Locatio
        private static final int MSG_ADD_CALLBACK = 3;
        private static final int MSG_REMOVE_CALLBACK = 4;

        @GuardedBy("mSettingsChangeCallbacks")
        private final ArrayList<LocationChangeCallback> mSettingsChangeCallbacks =
                new ArrayList<>();

@@ -378,10 +380,14 @@ public class LocationControllerImpl extends BroadcastReceiver implements Locatio
                    locationActiveChanged();
                    break;
                case MSG_ADD_CALLBACK:
                    synchronized (mSettingsChangeCallbacks) {
                        mSettingsChangeCallbacks.add((LocationChangeCallback) msg.obj);
                    }
                    break;
                case MSG_REMOVE_CALLBACK:
                    synchronized (mSettingsChangeCallbacks) {
                        mSettingsChangeCallbacks.remove((LocationChangeCallback) msg.obj);
                    }
                    break;

            }