Loading services/core/java/com/android/server/LocationManagerService.java +143 −135 Original line number Diff line number Diff line Loading @@ -146,8 +146,13 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public void onBootPhase(int phase) { if (phase == SystemService.PHASE_THIRD_PARTY_APPS_CAN_START) { mService.systemRunning(); if (phase == PHASE_SYSTEM_SERVICES_READY) { // the location service must be functioning after this boot phase mService.onSystemReady(); } else if (phase == SystemService.PHASE_THIRD_PARTY_APPS_CAN_START) { // some providers rely on third party code, so we wait to initialize // providers until third party code is allowed to run mService.onSystemThirdPartyAppsCanStart(); } } } Loading Loading @@ -264,17 +269,11 @@ public class LocationManagerService extends ILocationManager.Stub { userId -> mContext.getResources().getStringArray( com.android.internal.R.array.config_locationExtraPackageNames)); // most startup is deferred until systemRunning() // most startup is deferred until systemReady() } private void systemRunning() { private void onSystemReady() { synchronized (mLock) { initializeLocked(); } } @GuardedBy("mLock") private void initializeLocked() { mPackageManager = mContext.getPackageManager(); mAppOps = mContext.getSystemService(AppOpsManager.class); mPowerManager = mContext.getSystemService(PowerManager.class); Loading @@ -282,16 +281,12 @@ public class LocationManagerService extends ILocationManager.Stub { mUserManager = mContext.getSystemService(UserManager.class); mSettingsStore = new LocationSettingsStore(mContext, mHandler); mLocationFudger = new LocationFudger(mContext, mHandler); mGeofenceManager = new GeofenceManager(mContext, mSettingsStore); PowerManagerInternal localPowerManager = LocalServices.getService(PowerManagerInternal.class); // prepare providers initializeProvidersLocked(); // add listeners mAppOps.startWatchingMode( AppOpsManager.OP_COARSE_LOCATION, Loading @@ -299,7 +294,8 @@ public class LocationManagerService extends ILocationManager.Stub { AppOpsManager.WATCH_FOREGROUND_CHANGES, new AppOpsManager.OnOpChangedInternalListener() { public void onOpChanged(int op, String packageName) { // onOpChanged invoked on ui thread, move to our thread to reduce risk of // onOpChanged invoked on ui thread, move to our thread to reduce // risk of // blocking ui thread mHandler.post(() -> { synchronized (mLock) { Loading @@ -310,7 +306,8 @@ public class LocationManagerService extends ILocationManager.Stub { }); mPackageManager.addOnPermissionsChangeListener( uid -> { // listener invoked on ui thread, move to our thread to reduce risk of blocking // listener invoked on ui thread, move to our thread to reduce risk of // blocking // ui thread mHandler.post(() -> { synchronized (mLock) { Loading @@ -320,7 +317,8 @@ public class LocationManagerService extends ILocationManager.Stub { }); mActivityManager.addOnUidImportanceListener( (uid, importance) -> { // listener invoked on ui thread, move to our thread to reduce risk of blocking // listener invoked on ui thread, move to our thread to reduce risk of // blocking // ui thread mHandler.post(() -> { synchronized (mLock) { Loading @@ -332,7 +330,8 @@ public class LocationManagerService extends ILocationManager.Stub { localPowerManager.registerLowPowerModeObserver(ServiceType.LOCATION, state -> { // listener invoked on ui thread, move to our thread to reduce risk of blocking // listener invoked on ui thread, move to our thread to reduce risk of // blocking // ui thread mHandler.post(() -> { synchronized (mLock) { Loading Loading @@ -394,7 +393,8 @@ public class LocationManagerService extends ILocationManager.Stub { synchronized (mLock) { switch (action) { case Intent.ACTION_USER_SWITCHED: onUserChangedLocked(intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0)); onUserChangedLocked( intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0)); break; case Intent.ACTION_MANAGED_PROFILE_ADDED: case Intent.ACTION_MANAGED_PROFILE_REMOVED: Loading @@ -409,12 +409,20 @@ public class LocationManagerService extends ILocationManager.Stub { } }, UserHandle.ALL, intentFilter, null, mHandler); // switching the user from null to system here performs the bulk of the initialization work. // the user being changed will cause a reload of all user specific settings, which causes // provider initialization, and propagates changes until a steady state is reached // switching the user from null to system here performs the bulk of the initialization // work. the user being changed will cause a reload of all user specific settings, which // causes initialization, and propagates changes until a steady state is reached mCurrentUserId = UserHandle.USER_NULL; onUserChangedLocked(ActivityManager.getCurrentUser()); } } private void onSystemThirdPartyAppsCanStart() { synchronized (mLock) { // prepare providers initializeProvidersLocked(); } } @GuardedBy("mLock") private void onAppOpChangedLocked() { Loading Loading
services/core/java/com/android/server/LocationManagerService.java +143 −135 Original line number Diff line number Diff line Loading @@ -146,8 +146,13 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public void onBootPhase(int phase) { if (phase == SystemService.PHASE_THIRD_PARTY_APPS_CAN_START) { mService.systemRunning(); if (phase == PHASE_SYSTEM_SERVICES_READY) { // the location service must be functioning after this boot phase mService.onSystemReady(); } else if (phase == SystemService.PHASE_THIRD_PARTY_APPS_CAN_START) { // some providers rely on third party code, so we wait to initialize // providers until third party code is allowed to run mService.onSystemThirdPartyAppsCanStart(); } } } Loading Loading @@ -264,17 +269,11 @@ public class LocationManagerService extends ILocationManager.Stub { userId -> mContext.getResources().getStringArray( com.android.internal.R.array.config_locationExtraPackageNames)); // most startup is deferred until systemRunning() // most startup is deferred until systemReady() } private void systemRunning() { private void onSystemReady() { synchronized (mLock) { initializeLocked(); } } @GuardedBy("mLock") private void initializeLocked() { mPackageManager = mContext.getPackageManager(); mAppOps = mContext.getSystemService(AppOpsManager.class); mPowerManager = mContext.getSystemService(PowerManager.class); Loading @@ -282,16 +281,12 @@ public class LocationManagerService extends ILocationManager.Stub { mUserManager = mContext.getSystemService(UserManager.class); mSettingsStore = new LocationSettingsStore(mContext, mHandler); mLocationFudger = new LocationFudger(mContext, mHandler); mGeofenceManager = new GeofenceManager(mContext, mSettingsStore); PowerManagerInternal localPowerManager = LocalServices.getService(PowerManagerInternal.class); // prepare providers initializeProvidersLocked(); // add listeners mAppOps.startWatchingMode( AppOpsManager.OP_COARSE_LOCATION, Loading @@ -299,7 +294,8 @@ public class LocationManagerService extends ILocationManager.Stub { AppOpsManager.WATCH_FOREGROUND_CHANGES, new AppOpsManager.OnOpChangedInternalListener() { public void onOpChanged(int op, String packageName) { // onOpChanged invoked on ui thread, move to our thread to reduce risk of // onOpChanged invoked on ui thread, move to our thread to reduce // risk of // blocking ui thread mHandler.post(() -> { synchronized (mLock) { Loading @@ -310,7 +306,8 @@ public class LocationManagerService extends ILocationManager.Stub { }); mPackageManager.addOnPermissionsChangeListener( uid -> { // listener invoked on ui thread, move to our thread to reduce risk of blocking // listener invoked on ui thread, move to our thread to reduce risk of // blocking // ui thread mHandler.post(() -> { synchronized (mLock) { Loading @@ -320,7 +317,8 @@ public class LocationManagerService extends ILocationManager.Stub { }); mActivityManager.addOnUidImportanceListener( (uid, importance) -> { // listener invoked on ui thread, move to our thread to reduce risk of blocking // listener invoked on ui thread, move to our thread to reduce risk of // blocking // ui thread mHandler.post(() -> { synchronized (mLock) { Loading @@ -332,7 +330,8 @@ public class LocationManagerService extends ILocationManager.Stub { localPowerManager.registerLowPowerModeObserver(ServiceType.LOCATION, state -> { // listener invoked on ui thread, move to our thread to reduce risk of blocking // listener invoked on ui thread, move to our thread to reduce risk of // blocking // ui thread mHandler.post(() -> { synchronized (mLock) { Loading Loading @@ -394,7 +393,8 @@ public class LocationManagerService extends ILocationManager.Stub { synchronized (mLock) { switch (action) { case Intent.ACTION_USER_SWITCHED: onUserChangedLocked(intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0)); onUserChangedLocked( intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0)); break; case Intent.ACTION_MANAGED_PROFILE_ADDED: case Intent.ACTION_MANAGED_PROFILE_REMOVED: Loading @@ -409,12 +409,20 @@ public class LocationManagerService extends ILocationManager.Stub { } }, UserHandle.ALL, intentFilter, null, mHandler); // switching the user from null to system here performs the bulk of the initialization work. // the user being changed will cause a reload of all user specific settings, which causes // provider initialization, and propagates changes until a steady state is reached // switching the user from null to system here performs the bulk of the initialization // work. the user being changed will cause a reload of all user specific settings, which // causes initialization, and propagates changes until a steady state is reached mCurrentUserId = UserHandle.USER_NULL; onUserChangedLocked(ActivityManager.getCurrentUser()); } } private void onSystemThirdPartyAppsCanStart() { synchronized (mLock) { // prepare providers initializeProvidersLocked(); } } @GuardedBy("mLock") private void onAppOpChangedLocked() { Loading