FileDocCategorySizeDatePackage
FusedLocationHardware.javaAPI DocAndroid 5.1 API9205Thu Mar 12 22:22:30 GMT 2015com.android.location.provider

FusedLocationHardware

public final class FusedLocationHardware extends Object
Class that exposes IFusedLocationHardware functionality to unbundled services.

Fields Summary
private final String
TAG
private android.hardware.location.IFusedLocationHardware
mLocationHardware
HashMap
mSinkList
private android.hardware.location.IFusedLocationHardwareSink
mInternalSink
Constructors Summary
public FusedLocationHardware(android.hardware.location.IFusedLocationHardware locationHardware)

hide


          
       
        mLocationHardware = locationHardware;
    
Methods Summary
private voiddispatchDiagnosticData(java.lang.String data)

        HashMap<FusedLocationHardwareSink, DispatcherHandler> sinks;
        synchronized(mSinkList) {
            sinks = mSinkList;
        }

        for(Map.Entry<FusedLocationHardwareSink, DispatcherHandler> entry : sinks.entrySet()) {
            Message message = Message.obtain(
                    entry.getValue(),
                    DispatcherHandler.DISPATCH_DIAGNOSTIC_DATA,
                    new MessageCommand(entry.getKey(), null /*locations*/, data));
            message.sendToTarget();
        }
    
private voiddispatchLocations(android.location.Location[] locations)

        HashMap<FusedLocationHardwareSink, DispatcherHandler> sinks;
        synchronized (mSinkList) {
            sinks = mSinkList;
        }

        for(Map.Entry<FusedLocationHardwareSink, DispatcherHandler> entry : sinks.entrySet()) {
            Message message = Message.obtain(
                    entry.getValue(),
                    DispatcherHandler.DISPATCH_LOCATION,
                    new MessageCommand(entry.getKey(), locations, null /*data*/));
            message.sendToTarget();
        }
    
public intgetSupportedBatchSize()

        try {
            return mLocationHardware.getSupportedBatchSize();
        } catch(RemoteException e) {
            Log.e(TAG, "RemoteException at getSupportedBatchSize");
            return 0;
        }
    
public voidinjectDeviceContext(int deviceEnabledContext)

        try {
            mLocationHardware.injectDeviceContext(deviceEnabledContext);
        } catch(RemoteException e) {
            Log.e(TAG, "RemoteException at injectDeviceContext");
        }
    
public voidinjectDiagnosticData(java.lang.String data)

        try {
            mLocationHardware.injectDiagnosticData(data);
        } catch(RemoteException e) {
            Log.e(TAG, "RemoteException at injectDiagnosticData");
        }
    
public voidregisterSink(FusedLocationHardwareSink sink, android.os.Looper looper)

        if(sink == null || looper == null) {
            throw new IllegalArgumentException("Parameter sink and looper cannot be null.");
        }

        boolean registerSink;
        synchronized (mSinkList) {
            // register only on first insertion
            registerSink = mSinkList.size() == 0;
            // guarantee uniqueness
            if(mSinkList.containsKey(sink)) {
                return;
            }

            HashMap<FusedLocationHardwareSink, DispatcherHandler> newSinkList =
                    new HashMap<FusedLocationHardwareSink, DispatcherHandler>(mSinkList);
            newSinkList.put(sink, new DispatcherHandler(looper));
            mSinkList = newSinkList;
        }

        if(registerSink) {
            try {
                mLocationHardware.registerSink(mInternalSink);
            } catch(RemoteException e) {
                Log.e(TAG, "RemoteException at registerSink");
            }
        }
    
public voidrequestBatchOfLocations(int batchSizeRequest)

        try {
            mLocationHardware.requestBatchOfLocations(batchSizeRequest);
        } catch(RemoteException e) {
            Log.e(TAG, "RemoteException at requestBatchOfLocations");
        }
    
public voidstartBatching(int id, GmsFusedBatchOptions batchOptions)

        try {
            mLocationHardware.startBatching(id, batchOptions.getParcelableOptions());
        } catch(RemoteException e) {
            Log.e(TAG, "RemoteException at startBatching");
        }
    
public voidstopBatching(int id)

        try {
            mLocationHardware.stopBatching(id);
        } catch(RemoteException e) {
            Log.e(TAG, "RemoteException at stopBatching");
        }
    
public booleansupportsDeviceContextInjection()

        try {
            return mLocationHardware.supportsDeviceContextInjection();
        } catch(RemoteException e) {
            Log.e(TAG, "RemoteException at supportsDeviceContextInjection");
            return false;
        }
    
public booleansupportsDiagnosticDataInjection()

        try {
            return mLocationHardware.supportsDiagnosticDataInjection();
        } catch(RemoteException e) {
            Log.e(TAG, "RemoteException at supportsDiagnisticDataInjection");
            return false;
        }
    
public voidunregisterSink(FusedLocationHardwareSink sink)

        if(sink == null) {
            throw new IllegalArgumentException("Parameter sink cannot be null.");
        }

        boolean unregisterSink;
        synchronized(mSinkList) {
            if(!mSinkList.containsKey(sink)) {
                //done
                return;
            }

            HashMap<FusedLocationHardwareSink, DispatcherHandler> newSinkList =
                    new HashMap<FusedLocationHardwareSink, DispatcherHandler>(mSinkList);
            newSinkList.remove(sink);
            //unregister after the last sink
            unregisterSink = newSinkList.size() == 0;

            mSinkList = newSinkList;
        }

        if(unregisterSink) {
            try {
                mLocationHardware.unregisterSink(mInternalSink);
            } catch(RemoteException e) {
                Log.e(TAG, "RemoteException at unregisterSink");
            }
        }
    
public voidupdateBatchingOptions(int id, GmsFusedBatchOptions batchOptions)

        try {
            mLocationHardware.updateBatchingOptions(id, batchOptions.getParcelableOptions());
        } catch(RemoteException e) {
            Log.e(TAG, "RemoteException at updateBatchingOptions");
        }