diff --git a/core/java/android/hardware/location/ActivityRecognitionHardware.java b/core/java/android/hardware/location/ActivityRecognitionHardware.java index 8acd1ff27917b..20d6338ec927c 100644 --- a/core/java/android/hardware/location/ActivityRecognitionHardware.java +++ b/core/java/android/hardware/location/ActivityRecognitionHardware.java @@ -88,34 +88,34 @@ public class ActivityRecognitionHardware extends IActivityRecognitionHardware.St return nativeIsSupported(); } + @android.annotation.EnforcePermission(android.Manifest.permission.LOCATION_HARDWARE) @Override public String[] getSupportedActivities() { - checkPermissions(); return mSupportedActivities; } + @android.annotation.EnforcePermission(android.Manifest.permission.LOCATION_HARDWARE) @Override public boolean isActivitySupported(String activity) { - checkPermissions(); int activityType = getActivityType(activity); return activityType != INVALID_ACTIVITY_TYPE; } + @android.annotation.EnforcePermission(android.Manifest.permission.LOCATION_HARDWARE) @Override public boolean registerSink(IActivityRecognitionHardwareSink sink) { - checkPermissions(); return mSinks.register(sink); } + @android.annotation.EnforcePermission(android.Manifest.permission.LOCATION_HARDWARE) @Override public boolean unregisterSink(IActivityRecognitionHardwareSink sink) { - checkPermissions(); return mSinks.unregister(sink); } + @android.annotation.EnforcePermission(android.Manifest.permission.LOCATION_HARDWARE) @Override public boolean enableActivityEvent(String activity, int eventType, long reportLatencyNs) { - checkPermissions(); int activityType = getActivityType(activity); if (activityType == INVALID_ACTIVITY_TYPE) { @@ -130,9 +130,9 @@ public class ActivityRecognitionHardware extends IActivityRecognitionHardware.St return false; } + @android.annotation.EnforcePermission(android.Manifest.permission.LOCATION_HARDWARE) @Override public boolean disableActivityEvent(String activity, int eventType) { - checkPermissions(); int activityType = getActivityType(activity); if (activityType == INVALID_ACTIVITY_TYPE) { @@ -147,9 +147,9 @@ public class ActivityRecognitionHardware extends IActivityRecognitionHardware.St return false; } + @android.annotation.EnforcePermission(android.Manifest.permission.LOCATION_HARDWARE) @Override public boolean flush() { - checkPermissions(); int result = nativeFlush(); return result == NATIVE_SUCCESS_RESULT; } diff --git a/core/java/android/hardware/location/IActivityRecognitionHardware.aidl b/core/java/android/hardware/location/IActivityRecognitionHardware.aidl index bc6b1830cd4f1..f093cd565ce3d 100644 --- a/core/java/android/hardware/location/IActivityRecognitionHardware.aidl +++ b/core/java/android/hardware/location/IActivityRecognitionHardware.aidl @@ -28,35 +28,42 @@ interface IActivityRecognitionHardware { /** * Gets an array of supported activities by hardware. */ + @EnforcePermission("LOCATION_HARDWARE") String[] getSupportedActivities(); /** * Returns true if the given activity is supported, false otherwise. */ + @EnforcePermission("LOCATION_HARDWARE") boolean isActivitySupported(in String activityType); /** * Registers a sink with Hardware Activity-Recognition. */ + @EnforcePermission("LOCATION_HARDWARE") boolean registerSink(in IActivityRecognitionHardwareSink sink); /** * Unregisters a sink with Hardware Activity-Recognition. */ + @EnforcePermission("LOCATION_HARDWARE") boolean unregisterSink(in IActivityRecognitionHardwareSink sink); /** * Enables tracking of a given activity/event type, if the activity is supported. */ + @EnforcePermission("LOCATION_HARDWARE") boolean enableActivityEvent(in String activityType, int eventType, long reportLatencyNs); /** * Disables tracking of a given activity/eventy type. */ + @EnforcePermission("LOCATION_HARDWARE") boolean disableActivityEvent(in String activityType, int eventType); /** * Requests hardware for all the activity events detected up to the given point in time. */ + @EnforcePermission("LOCATION_HARDWARE") boolean flush(); } \ No newline at end of file