blob: 1c9ab9403298eabe6ca934597352d5a6377908a0 [file] [log] [blame]
destradaaa4fa3b52014-07-09 10:46:39 -07001/*
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>
Steven Moreland2279b252017-07-19 09:50:45 -070020#include <nativehelper/JNIHelp.h>
destradaaa4fa3b52014-07-09 10:46:39 -070021
22#include <android_runtime/AndroidRuntime.h>
23#include <android_runtime/Log.h>
24
Colin Crossaf737302017-04-20 12:20:20 -070025// #include <hardware/activity_recognition.h>
Ashutosh Joshic02b3b52016-11-19 11:16:07 -080026// 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//
destradaaa4fa3b52014-07-09 10:46:39 -070031
32/**
33 * Initializes the ActivityRecognitionHardware class from the native side.
34 */
Ashutosh Joshic02b3b52016-11-19 11:16:07 -080035static void class_init(JNIEnv* /*env*/, jclass /*clazz*/) {
36 ALOGE("activity_recognition HAL is deprecated. %s is effectively a no-op",
37 __FUNCTION__);
destradaaa4fa3b52014-07-09 10:46:39 -070038}
39
40/**
41 * Initializes and connect the callbacks handlers in the HAL.
42 */
Ashutosh Joshic02b3b52016-11-19 11:16:07 -080043static void initialize(JNIEnv* /*env*/, jobject /*obj*/) {
44 ALOGE("activity_recognition HAL is deprecated. %s is effectively a no-op",
45 __FUNCTION__);
destradaaa4fa3b52014-07-09 10:46:39 -070046}
47
48/**
49 * De-initializes the ActivityRecognitionHardware from the native side.
50 */
Ashutosh Joshic02b3b52016-11-19 11:16:07 -080051static void release(JNIEnv* /*env*/, jobject /*obj*/) {
52 ALOGE("activity_recognition HAL is deprecated. %s is effectively a no-op",
53 __FUNCTION__);
destradaaa4fa3b52014-07-09 10:46:39 -070054}
55
56/**
57 * Returns true if ActivityRecognition HAL is supported, false otherwise.
58 */
Ashutosh Joshic02b3b52016-11-19 11:16:07 -080059static jboolean is_supported(JNIEnv* /*env*/, jclass /*clazz*/) {
60 ALOGE("activity_recognition HAL is deprecated. %s is effectively a no-op",
61 __FUNCTION__);
destradaaa4fa3b52014-07-09 10:46:39 -070062 return JNI_FALSE;
63}
64
65/**
66 * Gets an array representing the supported activities.
67 */
Ashutosh Joshic02b3b52016-11-19 11:16:07 -080068static 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;
destradaaa4fa3b52014-07-09 10:46:39 -070072}
73
74/**
75 * Enables a given activity event to be actively monitored.
76 */
77static int enable_activity_event(
Ashutosh Joshic02b3b52016-11-19 11:16:07 -080078 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;
destradaaa4fa3b52014-07-09 10:46:39 -070086}
87
88/**
89 * Disables a given activity event from being actively monitored.
90 */
91static int disable_activity_event(
Ashutosh Joshic02b3b52016-11-19 11:16:07 -080092 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;
destradaaa4fa3b52014-07-09 10:46:39 -070099}
100
101/**
102 * Request flush for al batch buffers.
103 */
Ashutosh Joshic02b3b52016-11-19 11:16:07 -0800104static 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;
destradaaa4fa3b52014-07-09 10:46:39 -0700108}
109
110
Daniel Micay76f6a862015-09-19 17:31:01 -0400111static const JNINativeMethod sMethods[] = {
destradaaa4fa3b52014-07-09 10:46:39 -0700112 // {"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 */
126int register_android_hardware_location_ActivityRecognitionHardware(JNIEnv* env) {
127 return jniRegisterNativeMethods(
128 env,
129 "android/hardware/location/ActivityRecognitionHardware",
130 sMethods,
131 NELEM(sMethods));
132}