FileDocCategorySizeDatePackage
FusedProxy.javaAPI DocAndroid 5.1 API4493Thu Mar 12 22:22:42 GMT 2015com.android.server.location

FusedProxy

public final class FusedProxy extends Object
Proxy that helps bind GCore FusedProvider implementations to the Fused Hardware instances.
hide

Fields Summary
private final String
TAG
private final com.android.server.ServiceWatcher
mServiceWatcher
private final FusedLocationHardwareSecure
mLocationHardware
Constructors Summary
private FusedProxy(android.content.Context context, android.os.Handler handler, android.hardware.location.IFusedLocationHardware locationHardware, int overlaySwitchResId, int defaultServicePackageNameResId, int initialPackageNameResId)
Constructor of the class. This is private as the class follows a factory pattern for construction.

param
context The context needed for construction.
param
handler The handler needed for construction.
param
locationHardware The instance of the Fused location hardware assigned to the proxy.


                                                                         
     
             
             
             
             
             
              
        mLocationHardware = new FusedLocationHardwareSecure(
                locationHardware,
                context,
                Manifest.permission.LOCATION_HARDWARE);
        Runnable newServiceWork = new Runnable() {
            @Override
            public void run() {
                bindProvider(mLocationHardware);
            }
        };

        // prepare the connection to the provider
        mServiceWatcher = new ServiceWatcher(
                context,
                TAG,
                "com.android.location.service.FusedProvider",
                overlaySwitchResId,
                defaultServicePackageNameResId,
                initialPackageNameResId,
                newServiceWork,
                handler);
    
Methods Summary
private voidbindProvider(android.hardware.location.IFusedLocationHardware locationHardware)
Helper function to bind the FusedLocationHardware to the appropriate FusedProvider instance.

param
locationHardware The FusedLocationHardware instance to use for the binding operation.

        IFusedProvider provider = IFusedProvider.Stub.asInterface(mServiceWatcher.getBinder());

        if (provider == null) {
            Log.e(TAG, "No instance of FusedProvider found on FusedLocationHardware connected.");
            return;
        }

        try {
            provider.onFusedLocationHardwareChange(locationHardware);
        } catch (RemoteException e) {
            Log.e(TAG, e.toString());
        }
    
public static com.android.server.location.FusedProxycreateAndBind(android.content.Context context, android.os.Handler handler, android.hardware.location.IFusedLocationHardware locationHardware, int overlaySwitchResId, int defaultServicePackageNameResId, int initialPackageNameResId)
Creates an instance of the proxy and binds it to the appropriate FusedProvider.

param
context The context needed for construction.
param
handler The handler needed for construction.
param
locationHardware The instance of the Fused location hardware assigned to the proxy.
return
An instance of the proxy if it could be bound, null otherwise.

        FusedProxy fusedProxy = new FusedProxy(
                context,
                handler,
                locationHardware,
                overlaySwitchResId,
                defaultServicePackageNameResId,
                initialPackageNameResId);

        // try to bind the Fused provider
        if (!fusedProxy.mServiceWatcher.start()) {
            return null;
        }

        return fusedProxy;