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

ActivityRecognitionProxy

public class ActivityRecognitionProxy extends Object
Proxy class to bind GmsCore to the ActivityRecognitionHardware.
hide

Fields Summary
private static final String
TAG
private final com.android.server.ServiceWatcher
mServiceWatcher
private final android.hardware.location.ActivityRecognitionHardware
mActivityRecognitionHardware
Constructors Summary
private ActivityRecognitionProxy(android.content.Context context, android.os.Handler handler, android.hardware.location.ActivityRecognitionHardware activityRecognitionHardware, int overlaySwitchResId, int defaultServicePackageNameResId, int initialPackageNameResId)


     
             
             
             
             
             
              
        mActivityRecognitionHardware = activityRecognitionHardware;

        Runnable newServiceWork = new Runnable() {
            @Override
            public void run() {
                bindProvider(mActivityRecognitionHardware);
            }
        };

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

        IActivityRecognitionHardwareWatcher watcher =
                IActivityRecognitionHardwareWatcher.Stub.asInterface(mServiceWatcher.getBinder());
        if (watcher == null) {
            Log.e(TAG, "No provider instance found on connection.");
            return;
        }

        try {
            watcher.onInstanceChanged(mActivityRecognitionHardware);
        } catch (RemoteException e) {
            Log.e(TAG, "Error delivering hardware interface.", e);
        }
    
public static com.android.server.location.ActivityRecognitionProxycreateAndBind(android.content.Context context, android.os.Handler handler, android.hardware.location.ActivityRecognitionHardware activityRecognitionHardware, int overlaySwitchResId, int defaultServicePackageNameResId, int initialPackageNameResId)
Creates an instance of the proxy and binds it to the appropriate FusedProvider.

return
An instance of the proxy if it could be bound, null otherwise.

        ActivityRecognitionProxy activityRecognitionProxy = new ActivityRecognitionProxy(
                context,
                handler,
                activityRecognitionHardware,
                overlaySwitchResId,
                defaultServicePackageNameResId,
                initialPackageNameResId);

        // try to bind the provider
        if (!activityRecognitionProxy.mServiceWatcher.start()) {
            Log.e(TAG, "ServiceWatcher could not start.");
            return null;
        }

        return activityRecognitionProxy;