summaryrefslogtreecommitdiffstats
path: root/core/java/android/hardware
diff options
context:
space:
mode:
authordestradaa <destradaa@google.com>2014-07-16 14:28:06 -0700
committerdestradaa <destradaa@google.com>2014-07-17 11:09:46 -0700
commit3b0224dc3c2e7ffb93dc56970395003d0e387545 (patch)
tree124600c9f791f7fc8df131c1a9cd07281df90985 /core/java/android/hardware
parent69eef8a0d250ae1b50b510499014e109bd2c6112 (diff)
downloadframeworks_base-3b0224dc3c2e7ffb93dc56970395003d0e387545.zip
frameworks_base-3b0224dc3c2e7ffb93dc56970395003d0e387545.tar.gz
frameworks_base-3b0224dc3c2e7ffb93dc56970395003d0e387545.tar.bz2
Fix exceptions in ActivityRecognition platform stack.
b/16348349 Change-Id: I1f85283c86130b86389a1be7da49904658b0558c
Diffstat (limited to 'core/java/android/hardware')
-rw-r--r--core/java/android/hardware/location/ActivityChangedEvent.java13
-rw-r--r--core/java/android/hardware/location/ActivityRecognitionEvent.java9
-rw-r--r--core/java/android/hardware/location/ActivityRecognitionHardware.java24
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();
}