• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2014, The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #define LOG_TAG "ActivityRecognitionHardware"
18 
19 #include <jni.h>
20 #include <nativehelper/JNIHelp.h>
21 
22 #include <android_runtime/AndroidRuntime.h>
23 #include <android_runtime/Log.h>
24 
25 // #include <hardware/activity_recognition.h>
26 // The activity recognition HAL is being deprecated. This means -
27 //    i) Android framework code shall not depend on activity recognition
28 //       being provided through the activity_recognition.h interface.
29 //   ii) activity recognition HAL will not be binderized as the other HALs.
30 //
31 
32 /**
33  * Initializes the ActivityRecognitionHardware class from the native side.
34  */
class_init(JNIEnv *,jclass)35 static void class_init(JNIEnv* /*env*/, jclass /*clazz*/) {
36     ALOGE("activity_recognition HAL is deprecated. %s is effectively a no-op",
37           __FUNCTION__);
38 }
39 
40 /**
41  * Initializes and connect the callbacks handlers in the HAL.
42  */
initialize(JNIEnv *,jobject)43 static void initialize(JNIEnv* /*env*/, jobject /*obj*/) {
44     ALOGE("activity_recognition HAL is deprecated. %s is effectively a no-op",
45           __FUNCTION__);
46 }
47 
48 /**
49  * De-initializes the ActivityRecognitionHardware from the native side.
50  */
release(JNIEnv *,jobject)51 static void release(JNIEnv* /*env*/, jobject /*obj*/) {
52     ALOGE("activity_recognition HAL is deprecated. %s is effectively a no-op",
53           __FUNCTION__);
54 }
55 
56 /**
57  * Returns true if ActivityRecognition HAL is supported, false otherwise.
58  */
is_supported(JNIEnv *,jclass)59 static jboolean is_supported(JNIEnv* /*env*/, jclass /*clazz*/) {
60     ALOGE("activity_recognition HAL is deprecated. %s is effectively a no-op",
61           __FUNCTION__);
62     return JNI_FALSE;
63 }
64 
65 /**
66  * Gets an array representing the supported activities.
67  */
get_supported_activities(JNIEnv *,jobject)68 static jobjectArray get_supported_activities(JNIEnv* /*env*/, jobject /*obj*/) {
69     ALOGE("activity_recognition HAL is deprecated. %s is effectively a no-op",
70           __FUNCTION__);
71     return NULL;
72 }
73 
74 /**
75  * Enables a given activity event to be actively monitored.
76  */
enable_activity_event(JNIEnv *,jobject,jint,jint,jlong)77 static int enable_activity_event(
78         JNIEnv* /*env*/,
79         jobject /*obj*/,
80         jint /*activity_handle*/,
81         jint /*event_type*/,
82         jlong /*report_latency_ns*/) {
83     ALOGE("activity_recognition HAL is deprecated. %s is effectively a no-op",
84           __FUNCTION__);
85     return android::NO_INIT;
86 }
87 
88 /**
89  * Disables a given activity event from being actively monitored.
90  */
disable_activity_event(JNIEnv *,jobject,jint,jint)91 static int disable_activity_event(
92         JNIEnv* /*env*/,
93         jobject /*obj*/,
94         jint /*activity_handle*/,
95         jint /*event_type*/) {
96     ALOGE("activity_recognition HAL is deprecated. %s is effectively a no-op",
97           __FUNCTION__);
98     return android::NO_INIT;
99 }
100 
101 /**
102  * Request flush for al batch buffers.
103  */
flush(JNIEnv *,jobject)104 static int flush(JNIEnv* /*env*/, jobject /*obj*/) {
105     ALOGE("activity_recognition HAL is deprecated. %s is effectively a no-op",
106           __FUNCTION__);
107     return android::NO_INIT;
108 }
109 
110 
111 static const JNINativeMethod sMethods[] = {
112     // {"name", "signature", (void*) functionPointer },
113     { "nativeClassInit", "()V", (void*) class_init },
114     { "nativeInitialize", "()V", (void*) initialize },
115     { "nativeRelease", "()V", (void*) release },
116     { "nativeIsSupported", "()Z", (void*) is_supported },
117     { "nativeGetSupportedActivities", "()[Ljava/lang/String;", (void*) get_supported_activities },
118     { "nativeEnableActivityEvent", "(IIJ)I", (void*) enable_activity_event },
119     { "nativeDisableActivityEvent", "(II)I", (void*) disable_activity_event },
120     { "nativeFlush", "()I", (void*) flush },
121 };
122 
123 /**
124  * Registration method invoked in JNI load.
125  */
register_android_hardware_location_ActivityRecognitionHardware(JNIEnv * env)126 int register_android_hardware_location_ActivityRecognitionHardware(JNIEnv* env) {
127     return jniRegisterNativeMethods(
128             env,
129             "android/hardware/location/ActivityRecognitionHardware",
130             sMethods,
131             NELEM(sMethods));
132 }
133