ActivityRecognitionProxypublic class ActivityRecognitionProxy extends Object Proxy class to bind GmsCore to the ActivityRecognitionHardware. |
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 void | bindProvider(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.ActivityRecognitionProxy | createAndBind(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.
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;
|
|