diff options
author | destradaa <destradaa@google.com> | 2014-07-17 20:58:46 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-07-17 18:11:21 +0000 |
commit | 6ccb5f894e11a0ee59c0632643f265427731536e (patch) | |
tree | 9c81ea384fe5c2f64ca2f5a67023058bfc5d23a0 /core/java/android/hardware | |
parent | f83ccb964796ee9b2eca2e50fdf652f3aff0e333 (diff) | |
parent | 3b0224dc3c2e7ffb93dc56970395003d0e387545 (diff) | |
download | frameworks_base-6ccb5f894e11a0ee59c0632643f265427731536e.zip frameworks_base-6ccb5f894e11a0ee59c0632643f265427731536e.tar.gz frameworks_base-6ccb5f894e11a0ee59c0632643f265427731536e.tar.bz2 |
Merge "Fix exceptions in ActivityRecognition platform stack." into lmp-dev
Diffstat (limited to 'core/java/android/hardware')
3 files changed, 35 insertions, 11 deletions
diff --git a/core/java/android/hardware/location/ActivityChangedEvent.java b/core/java/android/hardware/location/ActivityChangedEvent.java index 0a89207..16cfe6e 100644 --- a/core/java/android/hardware/location/ActivityChangedEvent.java +++ b/core/java/android/hardware/location/ActivityChangedEvent.java @@ -76,4 +76,17 @@ public class ActivityChangedEvent implements Parcelable { parcel.writeInt(activityRecognitionEventArray.length); parcel.writeTypedArray(activityRecognitionEventArray, flags); } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder("[ ActivityChangedEvent:"); + + for (ActivityRecognitionEvent event : mActivityRecognitionEvents) { + builder.append("\n "); + builder.append(event.toString()); + } + builder.append("\n]"); + + return builder.toString(); + } } diff --git a/core/java/android/hardware/location/ActivityRecognitionEvent.java b/core/java/android/hardware/location/ActivityRecognitionEvent.java index 5aeb899..190030a 100644 --- a/core/java/android/hardware/location/ActivityRecognitionEvent.java +++ b/core/java/android/hardware/location/ActivityRecognitionEvent.java @@ -75,4 +75,13 @@ public class ActivityRecognitionEvent implements Parcelable { parcel.writeInt(mEventType); parcel.writeLong(mTimestampNs); } + + @Override + public String toString() { + return String.format( + "Activity='%s', EventType=%s, TimestampNs=%s", + mActivity, + mEventType, + mTimestampNs); + } } diff --git a/core/java/android/hardware/location/ActivityRecognitionHardware.java b/core/java/android/hardware/location/ActivityRecognitionHardware.java index a4ce4ac..5d3953a 100644 --- a/core/java/android/hardware/location/ActivityRecognitionHardware.java +++ b/core/java/android/hardware/location/ActivityRecognitionHardware.java @@ -134,8 +134,8 @@ public class ActivityRecognitionHardware extends IActivityRecognitionHardware.St * Called by the Activity-Recognition HAL. */ private void onActivityChanged(Event[] events) { - int size = mSinks.beginBroadcast(); - if (size == 0 || events == null || events.length == 0) { + if (events == null || events.length == 0) { + Log.d(TAG, "No events to broadcast for onActivityChanged."); return; } @@ -151,6 +151,7 @@ public class ActivityRecognitionHardware extends IActivityRecognitionHardware.St ActivityChangedEvent activityChangedEvent = new ActivityChangedEvent(activityRecognitionEventArray); + int size = mSinks.beginBroadcast(); for (int i = 0; i < size; ++i) { IActivityRecognitionHardwareSink sink = mSinks.getBroadcastItem(i); try { @@ -181,8 +182,8 @@ public class ActivityRecognitionHardware extends IActivityRecognitionHardware.St return INVALID_ACTIVITY_TYPE; } - int supporteActivitiesLength = mSupportedActivities.length; - for (int i = 0; i < supporteActivitiesLength; ++i) { + int supportedActivitiesLength = mSupportedActivities.length; + for (int i = 0; i < supportedActivitiesLength; ++i) { if (activity.equals(mSupportedActivities[i])) { return i; } @@ -198,7 +199,7 @@ public class ActivityRecognitionHardware extends IActivityRecognitionHardware.St mContext.enforceCallingPermission(HARDWARE_PERMISSION, message); } - private static String[] fetchSupportedActivities() { + private String[] fetchSupportedActivities() { String[] supportedActivities = nativeGetSupportedActivities(); if (supportedActivities != null) { return supportedActivities; @@ -211,14 +212,15 @@ public class ActivityRecognitionHardware extends IActivityRecognitionHardware.St static { nativeClassInit(); } private static native void nativeClassInit(); - private static native void nativeInitialize(); - private static native void nativeRelease(); private static native boolean nativeIsSupported(); - private static native String[] nativeGetSupportedActivities(); - private static native int nativeEnableActivityEvent( + + private native void nativeInitialize(); + private native void nativeRelease(); + private native String[] nativeGetSupportedActivities(); + private native int nativeEnableActivityEvent( int activityType, int eventType, long reportLatenceNs); - private static native int nativeDisableActivityEvent(int activityType, int eventType); - private static native int nativeFlush(); + private native int nativeDisableActivityEvent(int activityType, int eventType); + private native int nativeFlush(); } |