1 /*
2  * Copyright (C) 2007 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 #include <jni.h>
18 #include <JNIHelp.h>
19 
20 #include <sensorservice/SensorService.h>
21 
22 #include <cutils/properties.h>
23 #include <utils/Log.h>
24 #include <utils/misc.h>
25 
26 namespace android {
27 
android_server_SystemServer_nativeInit(JNIEnv * env,jobject clazz)28 static void android_server_SystemServer_nativeInit(JNIEnv* env, jobject clazz) {
29     char propBuf[PROPERTY_VALUE_MAX];
30     property_get("system_init.startsensorservice", propBuf, "1");
31     if (strcmp(propBuf, "1") == 0) {
32         // Start the sensor service
33         SensorService::instantiate();
34     }
35 }
36 
37 /*
38  * JNI registration.
39  */
40 static JNINativeMethod gMethods[] = {
41     /* name, signature, funcPtr */
42     { "nativeInit", "()V", (void*) android_server_SystemServer_nativeInit },
43 };
44 
register_android_server_SystemServer(JNIEnv * env)45 int register_android_server_SystemServer(JNIEnv* env)
46 {
47     return jniRegisterNativeMethods(env, "com/android/server/SystemServer",
48             gMethods, NELEM(gMethods));
49 }
50 
51 }; // namespace android
52