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

Commit 1b24fb17 authored by Wyatt Riley's avatar Wyatt Riley
Browse files

LocationManager - Handle Shutdown for right User

Only process a shutdown when it is for all users (whole system),
not a single user

Change-Id: Id51b7fb4606460462c2f6749e5ac3984bdd8319f
Bug: 30646142
parent 41e185e7
Loading
Loading
Loading
Loading
+9 −4
Original line number Original line Diff line number Diff line
@@ -150,7 +150,7 @@ public class LocationManagerService extends ILocationManager.Stub {
    // used internally for synchronization
    // used internally for synchronization
    private final Object mLock = new Object();
    private final Object mLock = new Object();


    // --- fields below are final after systemReady() ---
    // --- fields below are final after systemRunning() ---
    private LocationFudger mLocationFudger;
    private LocationFudger mLocationFudger;
    private GeofenceManager mGeofenceManager;
    private GeofenceManager mGeofenceManager;
    private PackageManager mPackageManager;
    private PackageManager mPackageManager;
@@ -168,6 +168,7 @@ public class LocationManagerService extends ILocationManager.Stub {


    // --- fields below are protected by mLock ---
    // --- fields below are protected by mLock ---
    // Set of providers that are explicitly enabled
    // Set of providers that are explicitly enabled
    // Only used by passive, fused & test.  Network & GPS are controlled separately, and not listed.
    private final Set<String> mEnabledProviders = new HashSet<String>();
    private final Set<String> mEnabledProviders = new HashSet<String>();


    // Set of providers that are explicitly disabled
    // Set of providers that are explicitly disabled
@@ -236,12 +237,12 @@ public class LocationManagerService extends ILocationManager.Stub {


        if (D) Log.d(TAG, "Constructed");
        if (D) Log.d(TAG, "Constructed");


        // most startup is deferred until systemReady()
        // most startup is deferred until systemRunning()
    }
    }


    public void systemRunning() {
    public void systemRunning() {
        synchronized (mLock) {
        synchronized (mLock) {
            if (D) Log.d(TAG, "systemReady()");
            if (D) Log.d(TAG, "systemRunning()");


            // fetch package manager
            // fetch package manager
            mPackageManager = mContext.getPackageManager();
            mPackageManager = mContext.getPackageManager();
@@ -321,9 +322,13 @@ public class LocationManagerService extends ILocationManager.Stub {
                        || Intent.ACTION_MANAGED_PROFILE_REMOVED.equals(action)) {
                        || Intent.ACTION_MANAGED_PROFILE_REMOVED.equals(action)) {
                    updateUserProfiles(mCurrentUserId);
                    updateUserProfiles(mCurrentUserId);
                } else if (Intent.ACTION_SHUTDOWN.equals(action)) {
                } else if (Intent.ACTION_SHUTDOWN.equals(action)) {
                    // shutdown only if UserId indicates whole system, not just one user
                    if(D) Log.d(TAG, "Shutdown received with UserId: " + getSendingUserId());
                    if (getSendingUserId() == UserHandle.USER_ALL) {
                        shutdownComponents();
                        shutdownComponents();
                    }
                    }
                }
                }
            }
        }, UserHandle.ALL, intentFilter, null, mLocationHandler);
        }, UserHandle.ALL, intentFilter, null, mLocationHandler);
    }
    }