From 420e45e9cb004ea6c6e11f69adcdbf3dac5fc800 Mon Sep 17 00:00:00 2001 From: Ashutosh Joshi Date: Tue, 20 Dec 2016 16:34:41 -0800 Subject: [PATCH] Move ContextHubService to a better location. Move ContextHub service from system core to a more appropriate place for a service. Test: GTS tests pass. Change-Id: Ie0f25414fc472a0214c0dd94e7ad4564cd38f842 --- core/java/android/hardware/location/ContextHubManager.java | 3 +-- core/jni/Android.mk | 1 - core/jni/AndroidRuntime.cpp | 2 -- preloaded-classes | 1 - .../java/com/android/server/ContextHubSystemService.java | 4 ++-- .../com/android/server}/location/ContextHubService.java | 14 ++++++++++---- services/core/jni/Android.mk | 1 + .../jni/com_android_server_location_ContextHubService.cpp | 12 +++++------- services/core/jni/onload.cpp | 2 ++ 9 files changed, 21 insertions(+), 19 deletions(-) rename {core/java/android/hardware => services/core/java/com/android/server}/location/ContextHubService.java (97%) rename core/jni/android_hardware_location_ContextHubService.cpp => services/core/jni/com_android_server_location_ContextHubService.cpp (99%) diff --git a/core/java/android/hardware/location/ContextHubManager.java b/core/java/android/hardware/location/ContextHubManager.java index 0b919c7b0870..7c4df473a9da 100644 --- a/core/java/android/hardware/location/ContextHubManager.java +++ b/core/java/android/hardware/location/ContextHubManager.java @@ -362,8 +362,7 @@ public final class ContextHubManager { public ContextHubManager(Context context, Looper mainLooper) throws ServiceNotFoundException { mMainLooper = mainLooper; mService = IContextHubService.Stub.asInterface( - ServiceManager.getServiceOrThrow(ContextHubService.CONTEXTHUB_SERVICE)); - + ServiceManager.getServiceOrThrow(Context.CONTEXTHUB_SERVICE)); try { mService.registerCallback(mClientCallback); } catch (RemoteException e) { diff --git a/core/jni/Android.mk b/core/jni/Android.mk index 35550579243c..9aaf9a7022b6 100644 --- a/core/jni/Android.mk +++ b/core/jni/Android.mk @@ -165,7 +165,6 @@ LOCAL_SRC_FILES:= \ android_hardware_UsbDevice.cpp \ android_hardware_UsbDeviceConnection.cpp \ android_hardware_UsbRequest.cpp \ - android_hardware_location_ContextHubService.cpp \ android_hardware_location_ActivityRecognitionHardware.cpp \ android_util_FileObserver.cpp \ android/opengl/poly_clip.cpp.arm \ diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp index d47c6b72ec0f..6c9a764c9be9 100644 --- a/core/jni/AndroidRuntime.cpp +++ b/core/jni/AndroidRuntime.cpp @@ -94,7 +94,6 @@ extern int register_android_hardware_UsbDevice(JNIEnv *env); extern int register_android_hardware_UsbDeviceConnection(JNIEnv *env); extern int register_android_hardware_UsbRequest(JNIEnv *env); extern int register_android_hardware_location_ActivityRecognitionHardware(JNIEnv* env); -extern int register_android_hardware_location_ContextHubService(JNIEnv* env); extern int register_android_media_AudioRecord(JNIEnv *env); extern int register_android_media_AudioSystem(JNIEnv *env); @@ -1380,7 +1379,6 @@ static const RegJNIRec gRegJNI[] = { REG_JNI(register_android_hardware_UsbDeviceConnection), REG_JNI(register_android_hardware_UsbRequest), REG_JNI(register_android_hardware_location_ActivityRecognitionHardware), - REG_JNI(register_android_hardware_location_ContextHubService), REG_JNI(register_android_media_AudioRecord), REG_JNI(register_android_media_AudioSystem), REG_JNI(register_android_media_AudioTrack), diff --git a/preloaded-classes b/preloaded-classes index da3861a4b642..86cbb69bdd9e 100644 --- a/preloaded-classes +++ b/preloaded-classes @@ -1006,7 +1006,6 @@ android.hardware.input.InputManager$InputDevicesChangedListener # android.hardware.location.IActivityRecognitionHardware # android.hardware.location.IActivityRecognitionHardware$Stub android.hardware.location.ContextHubManager -android.hardware.location.ContextHubService android.hardware.location.IContextHubService android.hardware.location.IContextHubService$Stub android.hardware.radio.RadioManager diff --git a/services/core/java/com/android/server/ContextHubSystemService.java b/services/core/java/com/android/server/ContextHubSystemService.java index 1b85632b806c..5d4317cbdae3 100644 --- a/services/core/java/com/android/server/ContextHubSystemService.java +++ b/services/core/java/com/android/server/ContextHubSystemService.java @@ -16,7 +16,7 @@ package com.android.server; -import android.hardware.location.ContextHubService; +import com.android.server.location.ContextHubService; import android.content.Context; import android.util.Log; @@ -37,7 +37,7 @@ class ContextHubSystemService extends SystemService { public void onBootPhase(int phase) { if (phase == SystemService.PHASE_SYSTEM_SERVICES_READY) { Log.d(TAG, "onBootPhase: PHASE_SYSTEM_SERVICES_READY"); - publishBinderService(ContextHubService.CONTEXTHUB_SERVICE, mContextHubService); + publishBinderService(Context.CONTEXTHUB_SERVICE, mContextHubService); } } } diff --git a/core/java/android/hardware/location/ContextHubService.java b/services/core/java/com/android/server/location/ContextHubService.java similarity index 97% rename from core/java/android/hardware/location/ContextHubService.java rename to services/core/java/com/android/server/location/ContextHubService.java index 35df015aaeb6..30c4f3b0b304 100644 --- a/core/java/android/hardware/location/ContextHubService.java +++ b/services/core/java/com/android/server/location/ContextHubService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package android.hardware.location; +package com.android.server.location; import java.io.FileDescriptor; import java.io.PrintWriter; @@ -26,6 +26,14 @@ import java.util.HashMap; import android.Manifest; import android.content.Context; import android.content.pm.PackageManager; +import android.hardware.location.ContextHubInfo; +import android.hardware.location.ContextHubManager; +import android.hardware.location.ContextHubMessage; +import android.hardware.location.IContextHubService; +import android.hardware.location.IContextHubCallback; +import android.hardware.location.NanoAppFilter; +import android.hardware.location.NanoApp; +import android.hardware.location.NanoAppInstanceInfo; import android.os.RemoteCallbackList; import android.os.RemoteException; import android.os.ServiceManager; @@ -42,8 +50,6 @@ import java.util.concurrent.ConcurrentHashMap; * @hide */ public class ContextHubService extends IContextHubService.Stub { - public static final String CONTEXTHUB_SERVICE = "contexthub_service"; - private static final String TAG = "ContextHubService"; private static final String HARDWARE_PERMISSION = Manifest.permission.LOCATION_HARDWARE; private static final String ENFORCE_HW_PERMISSION_MESSAGE = "Permission '" @@ -302,7 +308,7 @@ public class ContextHubService extends IContextHubService.Stub { protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { if (mContext.checkCallingOrSelfPermission("android.permission.DUMP") != PackageManager.PERMISSION_GRANTED) { - pw.println("Permission Denial: can't dump contexthub_service"); + pw.println("Permission Denial: can't dump contexthub service"); return; } diff --git a/services/core/jni/Android.mk b/services/core/jni/Android.mk index 3e8e42063bc1..b34021357099 100644 --- a/services/core/jni/Android.mk +++ b/services/core/jni/Android.mk @@ -15,6 +15,7 @@ LOCAL_SRC_FILES += \ $(LOCAL_REL_DIR)/com_android_server_input_InputManagerService.cpp \ $(LOCAL_REL_DIR)/com_android_server_input_InputWindowHandle.cpp \ $(LOCAL_REL_DIR)/com_android_server_lights_LightsService.cpp \ + $(LOCAL_REL_DIR)/com_android_server_location_ContextHubService.cpp \ $(LOCAL_REL_DIR)/com_android_server_location_GnssLocationProvider.cpp \ $(LOCAL_REL_DIR)/com_android_server_location_FlpHardwareProvider.cpp \ $(LOCAL_REL_DIR)/com_android_server_power_PowerManagerService.cpp \ diff --git a/core/jni/android_hardware_location_ContextHubService.cpp b/services/core/jni/com_android_server_location_ContextHubService.cpp similarity index 99% rename from core/jni/android_hardware_location_ContextHubService.cpp rename to services/core/jni/com_android_server_location_ContextHubService.cpp index 4391d93721b1..762aec82d7f5 100644 --- a/core/jni/android_hardware_location_ContextHubService.cpp +++ b/services/core/jni/com_android_server_location_ContextHubService.cpp @@ -937,7 +937,7 @@ static int init_jni(JNIEnv *env, jobject instance) { env->FindClass("android/hardware/location/ContextHubInfo"); db.jniInfo.contextHubServiceClass = - env->FindClass("android/hardware/location/ContextHubService"); + env->FindClass("com/android/server/location/ContextHubService"); db.jniInfo.memoryRegionsClass = env->FindClass("android/hardware/location/MemoryRegion"); @@ -1216,14 +1216,12 @@ static const JNINativeMethod gContextHubServiceMethods[] = { (void*)nativeSendMessage } }; -}//namespace android - -using namespace android; - -int register_android_hardware_location_ContextHubService(JNIEnv *env) +int register_android_server_location_ContextHubService(JNIEnv *env) { - RegisterMethodsOrDie(env, "android/hardware/location/ContextHubService", + RegisterMethodsOrDie(env, "com/android/server/location/ContextHubService", gContextHubServiceMethods, NELEM(gContextHubServiceMethods)); return 0; } + +}//namespace android diff --git a/services/core/jni/onload.cpp b/services/core/jni/onload.cpp index c291ba0dc24a..975867852f5c 100644 --- a/services/core/jni/onload.cpp +++ b/services/core/jni/onload.cpp @@ -36,6 +36,7 @@ int register_android_server_UsbMidiDevice(JNIEnv* env); int register_android_server_UsbHostManager(JNIEnv* env); int register_android_server_vr_VrManagerService(JNIEnv* env); int register_android_server_VibratorService(JNIEnv* env); +int register_android_server_location_ContextHubService(JNIEnv* env); int register_android_server_location_GnssLocationProvider(JNIEnv* env); int register_android_server_location_FlpHardwareProvider(JNIEnv* env); int register_android_server_connectivity_Vpn(JNIEnv* env); @@ -73,6 +74,7 @@ extern "C" jint JNI_OnLoad(JavaVM* vm, void* /* reserved */) register_android_server_vr_VrManagerService(env); register_android_server_VibratorService(env); register_android_server_SystemServer(env); + register_android_server_location_ContextHubService(env); register_android_server_location_GnssLocationProvider(env); register_android_server_location_FlpHardwareProvider(env); register_android_server_connectivity_Vpn(env); -- 2.11.0