diff options
Diffstat (limited to 'location/lib/java/com/android/location/provider/ActivityRecognitionProvider.java')
-rw-r--r-- | location/lib/java/com/android/location/provider/ActivityRecognitionProvider.java | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/location/lib/java/com/android/location/provider/ActivityRecognitionProvider.java b/location/lib/java/com/android/location/provider/ActivityRecognitionProvider.java index da33464..bc2dae1 100644 --- a/location/lib/java/com/android/location/provider/ActivityRecognitionProvider.java +++ b/location/lib/java/com/android/location/provider/ActivityRecognitionProvider.java @@ -31,8 +31,7 @@ import java.util.HashSet; */ public final class ActivityRecognitionProvider { private final IActivityRecognitionHardware mService; - private final HashSet<Sink> mSinkSet = new HashSet<Sink>(); - private final SinkTransport mSinkTransport = new SinkTransport(); + private final HashSet<Sink> mSinkSet = new HashSet<>(); // the following constants must remain in sync with activity_recognition.h @@ -43,6 +42,8 @@ public final class ActivityRecognitionProvider { public static final String ACTIVITY_STILL = "android.activity_recognition.still"; public static final String ACTIVITY_TILTING = "android.activity_recognition.tilting"; + // NOTE: when adding an additional EVENT_TYPE_, EVENT_TYPE_COUNT needs to be updated in + // android.hardware.location.ActivityRecognitionHardware public static final int EVENT_TYPE_FLUSH_COMPLETE = 0; public static final int EVENT_TYPE_ENTER = 1; public static final int EVENT_TYPE_EXIT = 2; @@ -60,7 +61,7 @@ public final class ActivityRecognitionProvider { throws RemoteException { Preconditions.checkNotNull(service); mService = service; - mService.registerSink(mSinkTransport); + mService.registerSink(new SinkTransport()); } public String[] getSupportedActivities() throws RemoteException { @@ -102,26 +103,23 @@ public final class ActivityRecognitionProvider { private final class SinkTransport extends IActivityRecognitionHardwareSink.Stub { @Override - public void onActivityChanged( - android.hardware.location.ActivityChangedEvent activityChangedEvent) { + public void onActivityChanged(android.hardware.location.ActivityChangedEvent event) { Collection<Sink> sinks; synchronized (mSinkSet) { if (mSinkSet.isEmpty()) { return; } - - sinks = new ArrayList<Sink>(mSinkSet); + sinks = new ArrayList<>(mSinkSet); } // translate the event from platform internal and GmsCore types - ArrayList<ActivityRecognitionEvent> gmsEvents = - new ArrayList<ActivityRecognitionEvent>(); - for (android.hardware.location.ActivityRecognitionEvent event - : activityChangedEvent.getActivityRecognitionEvents()) { + ArrayList<ActivityRecognitionEvent> gmsEvents = new ArrayList<>(); + for (android.hardware.location.ActivityRecognitionEvent reportingEvent + : event.getActivityRecognitionEvents()) { ActivityRecognitionEvent gmsEvent = new ActivityRecognitionEvent( - event.getActivity(), - event.getEventType(), - event.getTimestampNs()); + reportingEvent.getActivity(), + reportingEvent.getEventType(), + reportingEvent.getTimestampNs()); gmsEvents.add(gmsEvent); } ActivityChangedEvent gmsEvent = new ActivityChangedEvent(gmsEvents); |