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
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user