Loading core/java/android/hardware/location/GeofenceHardwareImpl.java +26 −1 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ public final class GeofenceHardwareImpl { private IFusedGeofenceHardware mFusedService; private IGpsGeofenceHardware mGpsService; private int mCapabilities; private int[] mSupportedMonitorTypes = new int[GeofenceHardware.NUM_MONITORS]; Loading Loading @@ -89,6 +90,9 @@ public final class GeofenceHardwareImpl { private static final int RESOLUTION_LEVEL_COARSE = 2; private static final int RESOLUTION_LEVEL_FINE = 3; // Capability constant corresponding to fused_location.h entry when geofencing supports GNNS. private static final int CAPABILITY_GNSS = 1; public synchronized static GeofenceHardwareImpl getInstance(Context context) { if (sInstance == null) { sInstance = new GeofenceHardwareImpl(context); Loading Loading @@ -141,7 +145,9 @@ public final class GeofenceHardwareImpl { private void updateFusedHardwareAvailability() { boolean fusedSupported; try { fusedSupported = (mFusedService != null ? mFusedService.isSupported() : false); fusedSupported = (mFusedService != null ? mFusedService.isSupported() && (mCapabilities & CAPABILITY_GNSS) != 0 : false); } catch (RemoteException e) { Log.e(TAG, "RemoteException calling LocationManagerService"); fusedSupported = false; Loading @@ -166,6 +172,11 @@ public final class GeofenceHardwareImpl { } } public void onCapabilities(int capabilities) { mCapabilities = capabilities; updateFusedHardwareAvailability(); } public void setFusedGeofenceHardware(IFusedGeofenceHardware service) { if(mFusedService == null) { mFusedService = service; Loading Loading @@ -212,6 +223,20 @@ public final class GeofenceHardwareImpl { } } public int getCapabilitiesForMonitoringType(int monitoringType) { switch (mSupportedMonitorTypes[monitoringType]) { case GeofenceHardware.MONITOR_CURRENTLY_AVAILABLE: switch (monitoringType) { case GeofenceHardware.MONITORING_TYPE_GPS_HARDWARE: return CAPABILITY_GNSS; case GeofenceHardware.MONITORING_TYPE_FUSED_HARDWARE: return mCapabilities; } break; } return 0; } public boolean addCircularFence( int monitoringType, GeofenceHardwareRequestParcelable request, Loading core/java/android/hardware/location/GeofenceHardwareService.java +11 −0 Original line number Diff line number Diff line Loading @@ -65,14 +65,17 @@ public class GeofenceHardwareService extends Service { } private IBinder mBinder = new IGeofenceHardware.Stub() { @Override public void setGpsGeofenceHardware(IGpsGeofenceHardware service) { mGeofenceHardwareImpl.setGpsHardwareGeofence(service); } @Override public void setFusedGeofenceHardware(IFusedGeofenceHardware service) { mGeofenceHardwareImpl.setFusedGeofenceHardware(service); } @Override public int[] getMonitoringTypes() { mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE, "Location Hardware permission not granted to access hardware geofence"); Loading @@ -80,12 +83,15 @@ public class GeofenceHardwareService extends Service { return mGeofenceHardwareImpl.getMonitoringTypes(); } @Override public int getStatusOfMonitoringType(int monitoringType) { mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE, "Location Hardware permission not granted to access hardware geofence"); return mGeofenceHardwareImpl.getStatusOfMonitoringType(monitoringType); } @Override public boolean addCircularFence( int monitoringType, GeofenceHardwareRequestParcelable request, Loading @@ -96,6 +102,7 @@ public class GeofenceHardwareService extends Service { return mGeofenceHardwareImpl.addCircularFence(monitoringType, request, callback); } @Override public boolean removeGeofence(int id, int monitoringType) { mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE, "Location Hardware permission not granted to access hardware geofence"); Loading @@ -104,6 +111,7 @@ public class GeofenceHardwareService extends Service { return mGeofenceHardwareImpl.removeGeofence(id, monitoringType); } @Override public boolean pauseGeofence(int id, int monitoringType) { mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE, "Location Hardware permission not granted to access hardware geofence"); Loading @@ -112,6 +120,7 @@ public class GeofenceHardwareService extends Service { return mGeofenceHardwareImpl.pauseGeofence(id, monitoringType); } @Override public boolean resumeGeofence(int id, int monitoringType, int monitorTransitions) { mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE, "Location Hardware permission not granted to access hardware geofence"); Loading @@ -120,6 +129,7 @@ public class GeofenceHardwareService extends Service { return mGeofenceHardwareImpl.resumeGeofence(id, monitoringType, monitorTransitions); } @Override public boolean registerForMonitorStateChangeCallback(int monitoringType, IGeofenceHardwareMonitorCallback callback) { mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE, Loading @@ -130,6 +140,7 @@ public class GeofenceHardwareService extends Service { callback); } @Override public boolean unregisterForMonitorStateChangeCallback(int monitoringType, IGeofenceHardwareMonitorCallback callback) { mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE, Loading core/java/android/hardware/location/IFusedLocationHardwareSink.aidl +8 −2 Original line number Diff line number Diff line Loading @@ -30,12 +30,18 @@ interface IFusedLocationHardwareSink { * * @param locations The batch of location information available. */ void onLocationAvailable(in Location[] locations); void onLocationAvailable(in Location[] locations) = 0; /** * Event generated from FLP HAL to provide diagnostic data to the platform. * * @param data The diagnostic data provided by FLP HAL. */ void onDiagnosticDataAvailable(in String data); void onDiagnosticDataAvailable(in String data) = 1; /** * Event generated from FLP HAL to provide a mask of supported * capabilities. Should be called immediatly after init. */ void onCapabilities(int capabilities) = 2; } No newline at end of file location/lib/java/com/android/location/provider/FusedLocationHardware.java +36 −4 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ import java.util.Map; * Class that exposes IFusedLocationHardware functionality to unbundled services. */ public final class FusedLocationHardware { private final String TAG = "FusedLocationHardware"; private static final String TAG = "FusedLocationHardware"; private IFusedLocationHardware mLocationHardware; Loading @@ -52,6 +52,11 @@ public final class FusedLocationHardware { public void onDiagnosticDataAvailable(String data) { dispatchDiagnosticData(data); } @Override public void onCapabilities(int capabilities) { dispatchCapabilities(capabilities); } }; /** Loading Loading @@ -204,6 +209,7 @@ public final class FusedLocationHardware { private class DispatcherHandler extends Handler { public static final int DISPATCH_LOCATION = 1; public static final int DISPATCH_DIAGNOSTIC_DATA = 2; public static final int DISPATCH_CAPABILITIES = 3; public DispatcherHandler(Looper looper) { super(looper, null /*callback*/ , true /*async*/); Loading @@ -218,6 +224,10 @@ public final class FusedLocationHardware { break; case DISPATCH_DIAGNOSTIC_DATA: command.dispatchDiagnosticData(); break; case DISPATCH_CAPABILITIES: command.dispatchCapabilities(); break; default: Log.e(TAG, "Invalid dispatch message"); break; Loading @@ -229,14 +239,17 @@ public final class FusedLocationHardware { private final FusedLocationHardwareSink mSink; private final Location[] mLocations; private final String mData; private final int mCapabilities; public MessageCommand( FusedLocationHardwareSink sink, Location[] locations, String data) { String data, int capabilities) { mSink = sink; mLocations = locations; mData = data; mCapabilities = capabilities; } public void dispatchLocation() { Loading @@ -246,6 +259,10 @@ public final class FusedLocationHardware { public void dispatchDiagnosticData() { mSink.onDiagnosticDataAvailable(mData); } public void dispatchCapabilities() { mSink.onCapabilities(mCapabilities); } } private void dispatchLocations(Location[] locations) { Loading @@ -258,7 +275,7 @@ public final class FusedLocationHardware { Message message = Message.obtain( entry.getValue(), DispatcherHandler.DISPATCH_LOCATION, new MessageCommand(entry.getKey(), locations, null /*data*/)); new MessageCommand(entry.getKey(), locations, null /*data*/, 0)); message.sendToTarget(); } } Loading @@ -273,7 +290,22 @@ public final class FusedLocationHardware { Message message = Message.obtain( entry.getValue(), DispatcherHandler.DISPATCH_DIAGNOSTIC_DATA, new MessageCommand(entry.getKey(), null /*locations*/, data)); new MessageCommand(entry.getKey(), null /*locations*/, data, 0)); message.sendToTarget(); } } private void dispatchCapabilities(int capabilities) { HashMap<FusedLocationHardwareSink, DispatcherHandler> sinks; synchronized(mSinkList) { sinks = mSinkList; } for(Map.Entry<FusedLocationHardwareSink, DispatcherHandler> entry : sinks.entrySet()) { Message message = Message.obtain( entry.getValue(), DispatcherHandler.DISPATCH_CAPABILITIES, new MessageCommand(entry.getKey(), null /*locations*/, null, capabilities)); message.sendToTarget(); } } Loading location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java +28 −5 Original line number Diff line number Diff line Loading @@ -20,11 +20,34 @@ import android.location.Location; /** * Base class for sinks to interact with FusedLocationHardware. * * <p>Default implementations allow new methods to be added without crashing * clients compiled against an old library version. */ public abstract class FusedLocationHardwareSink { /* * Methods to provide a facade for IFusedLocationHardware public class FusedLocationHardwareSink { /** * Called when one or more locations are available from the FLP * HAL. */ public void onLocationAvailable(Location[] locations) { // default do nothing } /** * Called when diagnostic data is available from the FLP HAL. */ public abstract void onLocationAvailable(Location[] locations); public abstract void onDiagnosticDataAvailable(String data); public void onDiagnosticDataAvailable(String data) { // default do nothing } /** * Called when capabilities are available from the FLP HAL. * Should be called once right after initialization. * * @param capabilities A bitmask of capabilities defined in * fused_location.h. */ public void onCapabilities(int capabilities) { // default do nothing } } No newline at end of file Loading
core/java/android/hardware/location/GeofenceHardwareImpl.java +26 −1 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ public final class GeofenceHardwareImpl { private IFusedGeofenceHardware mFusedService; private IGpsGeofenceHardware mGpsService; private int mCapabilities; private int[] mSupportedMonitorTypes = new int[GeofenceHardware.NUM_MONITORS]; Loading Loading @@ -89,6 +90,9 @@ public final class GeofenceHardwareImpl { private static final int RESOLUTION_LEVEL_COARSE = 2; private static final int RESOLUTION_LEVEL_FINE = 3; // Capability constant corresponding to fused_location.h entry when geofencing supports GNNS. private static final int CAPABILITY_GNSS = 1; public synchronized static GeofenceHardwareImpl getInstance(Context context) { if (sInstance == null) { sInstance = new GeofenceHardwareImpl(context); Loading Loading @@ -141,7 +145,9 @@ public final class GeofenceHardwareImpl { private void updateFusedHardwareAvailability() { boolean fusedSupported; try { fusedSupported = (mFusedService != null ? mFusedService.isSupported() : false); fusedSupported = (mFusedService != null ? mFusedService.isSupported() && (mCapabilities & CAPABILITY_GNSS) != 0 : false); } catch (RemoteException e) { Log.e(TAG, "RemoteException calling LocationManagerService"); fusedSupported = false; Loading @@ -166,6 +172,11 @@ public final class GeofenceHardwareImpl { } } public void onCapabilities(int capabilities) { mCapabilities = capabilities; updateFusedHardwareAvailability(); } public void setFusedGeofenceHardware(IFusedGeofenceHardware service) { if(mFusedService == null) { mFusedService = service; Loading Loading @@ -212,6 +223,20 @@ public final class GeofenceHardwareImpl { } } public int getCapabilitiesForMonitoringType(int monitoringType) { switch (mSupportedMonitorTypes[monitoringType]) { case GeofenceHardware.MONITOR_CURRENTLY_AVAILABLE: switch (monitoringType) { case GeofenceHardware.MONITORING_TYPE_GPS_HARDWARE: return CAPABILITY_GNSS; case GeofenceHardware.MONITORING_TYPE_FUSED_HARDWARE: return mCapabilities; } break; } return 0; } public boolean addCircularFence( int monitoringType, GeofenceHardwareRequestParcelable request, Loading
core/java/android/hardware/location/GeofenceHardwareService.java +11 −0 Original line number Diff line number Diff line Loading @@ -65,14 +65,17 @@ public class GeofenceHardwareService extends Service { } private IBinder mBinder = new IGeofenceHardware.Stub() { @Override public void setGpsGeofenceHardware(IGpsGeofenceHardware service) { mGeofenceHardwareImpl.setGpsHardwareGeofence(service); } @Override public void setFusedGeofenceHardware(IFusedGeofenceHardware service) { mGeofenceHardwareImpl.setFusedGeofenceHardware(service); } @Override public int[] getMonitoringTypes() { mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE, "Location Hardware permission not granted to access hardware geofence"); Loading @@ -80,12 +83,15 @@ public class GeofenceHardwareService extends Service { return mGeofenceHardwareImpl.getMonitoringTypes(); } @Override public int getStatusOfMonitoringType(int monitoringType) { mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE, "Location Hardware permission not granted to access hardware geofence"); return mGeofenceHardwareImpl.getStatusOfMonitoringType(monitoringType); } @Override public boolean addCircularFence( int monitoringType, GeofenceHardwareRequestParcelable request, Loading @@ -96,6 +102,7 @@ public class GeofenceHardwareService extends Service { return mGeofenceHardwareImpl.addCircularFence(monitoringType, request, callback); } @Override public boolean removeGeofence(int id, int monitoringType) { mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE, "Location Hardware permission not granted to access hardware geofence"); Loading @@ -104,6 +111,7 @@ public class GeofenceHardwareService extends Service { return mGeofenceHardwareImpl.removeGeofence(id, monitoringType); } @Override public boolean pauseGeofence(int id, int monitoringType) { mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE, "Location Hardware permission not granted to access hardware geofence"); Loading @@ -112,6 +120,7 @@ public class GeofenceHardwareService extends Service { return mGeofenceHardwareImpl.pauseGeofence(id, monitoringType); } @Override public boolean resumeGeofence(int id, int monitoringType, int monitorTransitions) { mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE, "Location Hardware permission not granted to access hardware geofence"); Loading @@ -120,6 +129,7 @@ public class GeofenceHardwareService extends Service { return mGeofenceHardwareImpl.resumeGeofence(id, monitoringType, monitorTransitions); } @Override public boolean registerForMonitorStateChangeCallback(int monitoringType, IGeofenceHardwareMonitorCallback callback) { mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE, Loading @@ -130,6 +140,7 @@ public class GeofenceHardwareService extends Service { callback); } @Override public boolean unregisterForMonitorStateChangeCallback(int monitoringType, IGeofenceHardwareMonitorCallback callback) { mContext.enforceCallingPermission(Manifest.permission.LOCATION_HARDWARE, Loading
core/java/android/hardware/location/IFusedLocationHardwareSink.aidl +8 −2 Original line number Diff line number Diff line Loading @@ -30,12 +30,18 @@ interface IFusedLocationHardwareSink { * * @param locations The batch of location information available. */ void onLocationAvailable(in Location[] locations); void onLocationAvailable(in Location[] locations) = 0; /** * Event generated from FLP HAL to provide diagnostic data to the platform. * * @param data The diagnostic data provided by FLP HAL. */ void onDiagnosticDataAvailable(in String data); void onDiagnosticDataAvailable(in String data) = 1; /** * Event generated from FLP HAL to provide a mask of supported * capabilities. Should be called immediatly after init. */ void onCapabilities(int capabilities) = 2; } No newline at end of file
location/lib/java/com/android/location/provider/FusedLocationHardware.java +36 −4 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ import java.util.Map; * Class that exposes IFusedLocationHardware functionality to unbundled services. */ public final class FusedLocationHardware { private final String TAG = "FusedLocationHardware"; private static final String TAG = "FusedLocationHardware"; private IFusedLocationHardware mLocationHardware; Loading @@ -52,6 +52,11 @@ public final class FusedLocationHardware { public void onDiagnosticDataAvailable(String data) { dispatchDiagnosticData(data); } @Override public void onCapabilities(int capabilities) { dispatchCapabilities(capabilities); } }; /** Loading Loading @@ -204,6 +209,7 @@ public final class FusedLocationHardware { private class DispatcherHandler extends Handler { public static final int DISPATCH_LOCATION = 1; public static final int DISPATCH_DIAGNOSTIC_DATA = 2; public static final int DISPATCH_CAPABILITIES = 3; public DispatcherHandler(Looper looper) { super(looper, null /*callback*/ , true /*async*/); Loading @@ -218,6 +224,10 @@ public final class FusedLocationHardware { break; case DISPATCH_DIAGNOSTIC_DATA: command.dispatchDiagnosticData(); break; case DISPATCH_CAPABILITIES: command.dispatchCapabilities(); break; default: Log.e(TAG, "Invalid dispatch message"); break; Loading @@ -229,14 +239,17 @@ public final class FusedLocationHardware { private final FusedLocationHardwareSink mSink; private final Location[] mLocations; private final String mData; private final int mCapabilities; public MessageCommand( FusedLocationHardwareSink sink, Location[] locations, String data) { String data, int capabilities) { mSink = sink; mLocations = locations; mData = data; mCapabilities = capabilities; } public void dispatchLocation() { Loading @@ -246,6 +259,10 @@ public final class FusedLocationHardware { public void dispatchDiagnosticData() { mSink.onDiagnosticDataAvailable(mData); } public void dispatchCapabilities() { mSink.onCapabilities(mCapabilities); } } private void dispatchLocations(Location[] locations) { Loading @@ -258,7 +275,7 @@ public final class FusedLocationHardware { Message message = Message.obtain( entry.getValue(), DispatcherHandler.DISPATCH_LOCATION, new MessageCommand(entry.getKey(), locations, null /*data*/)); new MessageCommand(entry.getKey(), locations, null /*data*/, 0)); message.sendToTarget(); } } Loading @@ -273,7 +290,22 @@ public final class FusedLocationHardware { Message message = Message.obtain( entry.getValue(), DispatcherHandler.DISPATCH_DIAGNOSTIC_DATA, new MessageCommand(entry.getKey(), null /*locations*/, data)); new MessageCommand(entry.getKey(), null /*locations*/, data, 0)); message.sendToTarget(); } } private void dispatchCapabilities(int capabilities) { HashMap<FusedLocationHardwareSink, DispatcherHandler> sinks; synchronized(mSinkList) { sinks = mSinkList; } for(Map.Entry<FusedLocationHardwareSink, DispatcherHandler> entry : sinks.entrySet()) { Message message = Message.obtain( entry.getValue(), DispatcherHandler.DISPATCH_CAPABILITIES, new MessageCommand(entry.getKey(), null /*locations*/, null, capabilities)); message.sendToTarget(); } } Loading
location/lib/java/com/android/location/provider/FusedLocationHardwareSink.java +28 −5 Original line number Diff line number Diff line Loading @@ -20,11 +20,34 @@ import android.location.Location; /** * Base class for sinks to interact with FusedLocationHardware. * * <p>Default implementations allow new methods to be added without crashing * clients compiled against an old library version. */ public abstract class FusedLocationHardwareSink { /* * Methods to provide a facade for IFusedLocationHardware public class FusedLocationHardwareSink { /** * Called when one or more locations are available from the FLP * HAL. */ public void onLocationAvailable(Location[] locations) { // default do nothing } /** * Called when diagnostic data is available from the FLP HAL. */ public abstract void onLocationAvailable(Location[] locations); public abstract void onDiagnosticDataAvailable(String data); public void onDiagnosticDataAvailable(String data) { // default do nothing } /** * Called when capabilities are available from the FLP HAL. * Should be called once right after initialization. * * @param capabilities A bitmask of capabilities defined in * fused_location.h. */ public void onCapabilities(int capabilities) { // default do nothing } } No newline at end of file