destradaa | a4fa3b5 | 2014-07-09 10:46:39 -0700 | [diff] [blame] | 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 <JNIHelp.h> |
| 21 | |
| 22 | #include <android_runtime/AndroidRuntime.h> |
| 23 | #include <android_runtime/Log.h> |
| 24 | |
Ashutosh Joshi | c02b3b5 | 2016-11-19 11:16:07 -0800 | [diff] [blame] | 25 | // #include "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 | // |
destradaa | a4fa3b5 | 2014-07-09 10:46:39 -0700 | [diff] [blame] | 31 | |
| 32 | /** |
| 33 | * Initializes the ActivityRecognitionHardware class from the native side. |
| 34 | */ |
Ashutosh Joshi | c02b3b5 | 2016-11-19 11:16:07 -0800 | [diff] [blame] | 35 | static void class_init(JNIEnv* /*env*/, jclass /*clazz*/) { |
| 36 | ALOGE("activity_recognition HAL is deprecated. %s is effectively a no-op", |
| 37 | __FUNCTION__); |
destradaa | a4fa3b5 | 2014-07-09 10:46:39 -0700 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Initializes and connect the callbacks handlers in the HAL. |
| 42 | */ |
Ashutosh Joshi | c02b3b5 | 2016-11-19 11:16:07 -0800 | [diff] [blame] | 43 | static void initialize(JNIEnv* /*env*/, jobject /*obj*/) { |
| 44 | ALOGE("activity_recognition HAL is deprecated. %s is effectively a no-op", |
| 45 | __FUNCTION__); |
destradaa | a4fa3b5 | 2014-07-09 10:46:39 -0700 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | /** |
| 49 | * De-initializes the ActivityRecognitionHardware from the native side. |
| 50 | */ |
Ashutosh Joshi | c02b3b5 | 2016-11-19 11:16:07 -0800 | [diff] [blame] | 51 | static void release(JNIEnv* /*env*/, jobject /*obj*/) { |
| 52 | ALOGE("activity_recognition HAL is deprecated. %s is effectively a no-op", |
| 53 | __FUNCTION__); |
destradaa | a4fa3b5 | 2014-07-09 10:46:39 -0700 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Returns true if ActivityRecognition HAL is supported, false otherwise. |
| 58 | */ |
Ashutosh Joshi | c02b3b5 | 2016-11-19 11:16:07 -0800 | [diff] [blame] | 59 | static jboolean is_supported(JNIEnv* /*env*/, jclass /*clazz*/) { |
| 60 | ALOGE("activity_recognition HAL is deprecated. %s is effectively a no-op", |
| 61 | __FUNCTION__); |
destradaa | a4fa3b5 | 2014-07-09 10:46:39 -0700 | [diff] [blame] | 62 | return JNI_FALSE; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Gets an array representing the supported activities. |
| 67 | */ |
Ashutosh Joshi | c02b3b5 | 2016-11-19 11:16:07 -0800 | [diff] [blame] | 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; |
destradaa | a4fa3b5 | 2014-07-09 10:46:39 -0700 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Enables a given activity event to be actively monitored. |
| 76 | */ |
| 77 | static int enable_activity_event( |
Ashutosh Joshi | c02b3b5 | 2016-11-19 11:16:07 -0800 | [diff] [blame] | 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; |
destradaa | a4fa3b5 | 2014-07-09 10:46:39 -0700 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Disables a given activity event from being actively monitored. |
| 90 | */ |
| 91 | static int disable_activity_event( |
Ashutosh Joshi | c02b3b5 | 2016-11-19 11:16:07 -0800 | [diff] [blame] | 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; |
destradaa | a4fa3b5 | 2014-07-09 10:46:39 -0700 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Request flush for al batch buffers. |
| 103 | */ |
Ashutosh Joshi | c02b3b5 | 2016-11-19 11:16:07 -0800 | [diff] [blame] | 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; |
destradaa | a4fa3b5 | 2014-07-09 10:46:39 -0700 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | |
Daniel Micay | 76f6a86 | 2015-09-19 17:31:01 -0400 | [diff] [blame] | 111 | static const JNINativeMethod sMethods[] = { |
destradaa | a4fa3b5 | 2014-07-09 10:46:39 -0700 | [diff] [blame] | 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 | */ |
| 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 | } |