Loading services/core/java/com/android/server/LocationManagerService.java +25 −0 Original line number Diff line number Diff line Loading @@ -307,6 +307,7 @@ public class LocationManagerService extends ILocationManager.Stub { intentFilter.addAction(Intent.ACTION_USER_SWITCHED); intentFilter.addAction(Intent.ACTION_MANAGED_PROFILE_ADDED); intentFilter.addAction(Intent.ACTION_MANAGED_PROFILE_REMOVED); intentFilter.addAction(Intent.ACTION_SHUTDOWN); mContext.registerReceiverAsUser(new BroadcastReceiver() { @Override Loading @@ -317,11 +318,35 @@ public class LocationManagerService extends ILocationManager.Stub { } else if (Intent.ACTION_MANAGED_PROFILE_ADDED.equals(action) || Intent.ACTION_MANAGED_PROFILE_REMOVED.equals(action)) { updateUserProfiles(mCurrentUserId); } else if (Intent.ACTION_SHUTDOWN.equals(action)) { shutdownComponents(); } } }, UserHandle.ALL, intentFilter, null, mLocationHandler); } /** * Provides a way for components held by the {@link LocationManagerService} to clean-up * gracefully on system's shutdown. * * NOTES: * 1) Only provides a chance to clean-up on an opt-in basis. This guarantees back-compat * support for components that do not wish to handle such event. */ private void shutdownComponents() { if(D) Log.d(TAG, "Shutting down components..."); LocationProviderInterface gpsProvider = mProvidersByName.get(LocationManager.GPS_PROVIDER); if (gpsProvider != null && gpsProvider.isEnabled()) { gpsProvider.disable(); } FlpHardwareProvider flpHardwareProvider = FlpHardwareProvider.getInstance(mContext); if (FlpHardwareProvider.isSupported() && flpHardwareProvider != null) { flpHardwareProvider.cleanup(); } } /** * Makes a list of userids that are related to the current user. This is * relevant when using managed profiles. Otherwise the list only contains Loading services/core/java/com/android/server/location/FlpHardwareProvider.java +7 −4 Original line number Diff line number Diff line Loading @@ -16,19 +16,18 @@ package com.android.server.location; import android.content.Context; import android.hardware.location.GeofenceHardware; import android.hardware.location.GeofenceHardwareImpl; import android.hardware.location.GeofenceHardwareRequestParcelable; import android.hardware.location.IFusedLocationHardware; import android.hardware.location.IFusedLocationHardwareSink; import android.location.IFusedGeofenceHardware; import android.location.FusedBatchOptions; import android.location.IFusedGeofenceHardware; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.location.LocationRequest; import android.content.Context; import android.os.Bundle; import android.os.Looper; import android.os.RemoteException; Loading Loading @@ -301,7 +300,6 @@ public class FlpHardwareProvider { private native void nativeRequestBatchedLocation(int lastNLocations); private native void nativeFlushBatchedLocations(); private native void nativeInjectLocation(Location location); // TODO [Fix] sort out the lifetime of the instance private native void nativeCleanup(); // FlpDiagnosticsInterface members Loading Loading @@ -341,6 +339,11 @@ public class FlpHardwareProvider { return mGeofenceHardwareService; } public void cleanup() { Log.i(TAG, "Calling nativeCleanup()"); nativeCleanup(); } private final IFusedLocationHardware mLocationHardware = new IFusedLocationHardware.Stub() { @Override public void registerSink(IFusedLocationHardwareSink eventSink) { Loading services/core/jni/com_android_server_location_FlpHardwareProvider.cpp +0 −10 Original line number Diff line number Diff line Loading @@ -840,16 +840,6 @@ static void Cleanup(JNIEnv* env, jobject /* object */) { env->DeleteGlobalRef(sCallbacksObj); sCallbacksObj = NULL; } sFlpInterface = NULL; sFlpDiagnosticInterface = NULL; sFlpDeviceContextInterface = NULL; sFlpGeofencingInterface = NULL; if(sHardwareDevice != NULL) { sHardwareDevice->close(sHardwareDevice); sHardwareDevice = NULL; } } static void GetBatchedLocation(JNIEnv* env, jobject /* object */, jint lastNLocations) { Loading Loading
services/core/java/com/android/server/LocationManagerService.java +25 −0 Original line number Diff line number Diff line Loading @@ -307,6 +307,7 @@ public class LocationManagerService extends ILocationManager.Stub { intentFilter.addAction(Intent.ACTION_USER_SWITCHED); intentFilter.addAction(Intent.ACTION_MANAGED_PROFILE_ADDED); intentFilter.addAction(Intent.ACTION_MANAGED_PROFILE_REMOVED); intentFilter.addAction(Intent.ACTION_SHUTDOWN); mContext.registerReceiverAsUser(new BroadcastReceiver() { @Override Loading @@ -317,11 +318,35 @@ public class LocationManagerService extends ILocationManager.Stub { } else if (Intent.ACTION_MANAGED_PROFILE_ADDED.equals(action) || Intent.ACTION_MANAGED_PROFILE_REMOVED.equals(action)) { updateUserProfiles(mCurrentUserId); } else if (Intent.ACTION_SHUTDOWN.equals(action)) { shutdownComponents(); } } }, UserHandle.ALL, intentFilter, null, mLocationHandler); } /** * Provides a way for components held by the {@link LocationManagerService} to clean-up * gracefully on system's shutdown. * * NOTES: * 1) Only provides a chance to clean-up on an opt-in basis. This guarantees back-compat * support for components that do not wish to handle such event. */ private void shutdownComponents() { if(D) Log.d(TAG, "Shutting down components..."); LocationProviderInterface gpsProvider = mProvidersByName.get(LocationManager.GPS_PROVIDER); if (gpsProvider != null && gpsProvider.isEnabled()) { gpsProvider.disable(); } FlpHardwareProvider flpHardwareProvider = FlpHardwareProvider.getInstance(mContext); if (FlpHardwareProvider.isSupported() && flpHardwareProvider != null) { flpHardwareProvider.cleanup(); } } /** * Makes a list of userids that are related to the current user. This is * relevant when using managed profiles. Otherwise the list only contains Loading
services/core/java/com/android/server/location/FlpHardwareProvider.java +7 −4 Original line number Diff line number Diff line Loading @@ -16,19 +16,18 @@ package com.android.server.location; import android.content.Context; import android.hardware.location.GeofenceHardware; import android.hardware.location.GeofenceHardwareImpl; import android.hardware.location.GeofenceHardwareRequestParcelable; import android.hardware.location.IFusedLocationHardware; import android.hardware.location.IFusedLocationHardwareSink; import android.location.IFusedGeofenceHardware; import android.location.FusedBatchOptions; import android.location.IFusedGeofenceHardware; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.location.LocationRequest; import android.content.Context; import android.os.Bundle; import android.os.Looper; import android.os.RemoteException; Loading Loading @@ -301,7 +300,6 @@ public class FlpHardwareProvider { private native void nativeRequestBatchedLocation(int lastNLocations); private native void nativeFlushBatchedLocations(); private native void nativeInjectLocation(Location location); // TODO [Fix] sort out the lifetime of the instance private native void nativeCleanup(); // FlpDiagnosticsInterface members Loading Loading @@ -341,6 +339,11 @@ public class FlpHardwareProvider { return mGeofenceHardwareService; } public void cleanup() { Log.i(TAG, "Calling nativeCleanup()"); nativeCleanup(); } private final IFusedLocationHardware mLocationHardware = new IFusedLocationHardware.Stub() { @Override public void registerSink(IFusedLocationHardwareSink eventSink) { Loading
services/core/jni/com_android_server_location_FlpHardwareProvider.cpp +0 −10 Original line number Diff line number Diff line Loading @@ -840,16 +840,6 @@ static void Cleanup(JNIEnv* env, jobject /* object */) { env->DeleteGlobalRef(sCallbacksObj); sCallbacksObj = NULL; } sFlpInterface = NULL; sFlpDiagnosticInterface = NULL; sFlpDeviceContextInterface = NULL; sFlpGeofencingInterface = NULL; if(sHardwareDevice != NULL) { sHardwareDevice->close(sHardwareDevice); sHardwareDevice = NULL; } } static void GetBatchedLocation(JNIEnv* env, jobject /* object */, jint lastNLocations) { Loading