Merge "Register new AIDL SensorManager" am: 0b703be0c5
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2292559 Change-Id: I1d1734cd16e7ecf0206bb90912b22db7c6d678e0 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -132,6 +132,7 @@ cc_defaults {
|
|||||||
"libschedulerservicehidl",
|
"libschedulerservicehidl",
|
||||||
"libsensorservice",
|
"libsensorservice",
|
||||||
"libsensorservicehidl",
|
"libsensorservicehidl",
|
||||||
|
"libsensorserviceaidl",
|
||||||
"libgui",
|
"libgui",
|
||||||
"libtimestats_atoms_proto",
|
"libtimestats_atoms_proto",
|
||||||
"libusbhost",
|
"libusbhost",
|
||||||
@@ -180,6 +181,7 @@ cc_defaults {
|
|||||||
"android.hidl.token@1.0-utils",
|
"android.hidl.token@1.0-utils",
|
||||||
"android.frameworks.schedulerservice@1.0",
|
"android.frameworks.schedulerservice@1.0",
|
||||||
"android.frameworks.sensorservice@1.0",
|
"android.frameworks.sensorservice@1.0",
|
||||||
|
"android.frameworks.sensorservice-V1-ndk",
|
||||||
"android.frameworks.stats@1.0",
|
"android.frameworks.stats@1.0",
|
||||||
"android.frameworks.stats-V1-ndk",
|
"android.frameworks.stats-V1-ndk",
|
||||||
"android.system.suspend.control-V1-cpp",
|
"android.system.suspend.control-V1-cpp",
|
||||||
|
|||||||
@@ -14,35 +14,31 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <dlfcn.h>
|
#include <android-base/properties.h>
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#include <chrono>
|
|
||||||
#include <thread>
|
|
||||||
|
|
||||||
#include <jni.h>
|
|
||||||
#include <nativehelper/JNIHelp.h>
|
|
||||||
|
|
||||||
#include <android/binder_manager.h>
|
#include <android/binder_manager.h>
|
||||||
#include <android/binder_stability.h>
|
#include <android/binder_stability.h>
|
||||||
#include <android/hidl/manager/1.2/IServiceManager.h>
|
#include <android/hidl/manager/1.2/IServiceManager.h>
|
||||||
#include <binder/IServiceManager.h>
|
#include <binder/IServiceManager.h>
|
||||||
|
#include <bionic/malloc.h>
|
||||||
|
#include <bionic/reserved_signals.h>
|
||||||
|
#include <dlfcn.h>
|
||||||
#include <hidl/HidlTransportSupport.h>
|
#include <hidl/HidlTransportSupport.h>
|
||||||
#include <incremental_service.h>
|
#include <incremental_service.h>
|
||||||
|
#include <jni.h>
|
||||||
#include <memtrackproxy/MemtrackProxy.h>
|
#include <memtrackproxy/MemtrackProxy.h>
|
||||||
|
#include <nativehelper/JNIHelp.h>
|
||||||
|
#include <pthread.h>
|
||||||
#include <schedulerservice/SchedulingPolicyService.h>
|
#include <schedulerservice/SchedulingPolicyService.h>
|
||||||
|
#include <sensorserviceaidl/SensorManagerAidl.h>
|
||||||
#include <sensorservicehidl/SensorManager.h>
|
#include <sensorservicehidl/SensorManager.h>
|
||||||
#include <stats/StatsAidl.h>
|
#include <stats/StatsAidl.h>
|
||||||
#include <stats/StatsHal.h>
|
#include <stats/StatsHal.h>
|
||||||
|
#include <utils/AndroidThreads.h>
|
||||||
#include <bionic/malloc.h>
|
|
||||||
#include <bionic/reserved_signals.h>
|
|
||||||
|
|
||||||
#include <android-base/properties.h>
|
|
||||||
#include <utils/Log.h>
|
#include <utils/Log.h>
|
||||||
#include <utils/misc.h>
|
#include <utils/misc.h>
|
||||||
#include <utils/AndroidThreads.h>
|
|
||||||
|
#include <chrono>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
@@ -57,7 +53,9 @@ static void startStatsAidlService() {
|
|||||||
const std::string instance = std::string() + IStats::descriptor + "/default";
|
const std::string instance = std::string() + IStats::descriptor + "/default";
|
||||||
const binder_exception_t err =
|
const binder_exception_t err =
|
||||||
AServiceManager_addService(statsService->asBinder().get(), instance.c_str());
|
AServiceManager_addService(statsService->asBinder().get(), instance.c_str());
|
||||||
LOG_ALWAYS_FATAL_IF(err != EX_NONE, "Cannot register AIDL %s: %d", instance.c_str(), err);
|
if (err != EX_NONE) {
|
||||||
|
ALOGW("Cannot register AIDL %s: %d", instance.c_str(), err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void startStatsHidlService() {
|
static void startStatsHidlService() {
|
||||||
@@ -69,6 +67,42 @@ static void startStatsHidlService() {
|
|||||||
ALOGW_IF(err != android::OK, "Cannot register HIDL %s: %d", IStats::descriptor, err);
|
ALOGW_IF(err != android::OK, "Cannot register HIDL %s: %d", IStats::descriptor, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void startSensorManagerAidlService(JNIEnv* env) {
|
||||||
|
using ::aidl::android::frameworks::sensorservice::ISensorManager;
|
||||||
|
using ::android::frameworks::sensorservice::implementation::SensorManagerAidl;
|
||||||
|
|
||||||
|
JavaVM* vm;
|
||||||
|
LOG_ALWAYS_FATAL_IF(env->GetJavaVM(&vm) != JNI_OK, "Cannot get Java VM");
|
||||||
|
|
||||||
|
std::shared_ptr<SensorManagerAidl> sensorService =
|
||||||
|
ndk::SharedRefBase::make<SensorManagerAidl>(vm);
|
||||||
|
const std::string instance = std::string() + ISensorManager::descriptor + "/default";
|
||||||
|
const binder_exception_t err =
|
||||||
|
AServiceManager_addService(sensorService->asBinder().get(), instance.c_str());
|
||||||
|
LOG_ALWAYS_FATAL_IF(err != EX_NONE, "Cannot register AIDL %s: %d", instance.c_str(), err);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void startSensorManagerHidlService(JNIEnv* env) {
|
||||||
|
using ::android::frameworks::sensorservice::V1_0::ISensorManager;
|
||||||
|
using ::android::frameworks::sensorservice::V1_0::implementation::SensorManager;
|
||||||
|
using ::android::hardware::configureRpcThreadpool;
|
||||||
|
using ::android::hidl::manager::V1_0::IServiceManager;
|
||||||
|
|
||||||
|
JavaVM* vm;
|
||||||
|
LOG_ALWAYS_FATAL_IF(env->GetJavaVM(&vm) != JNI_OK, "Cannot get Java VM");
|
||||||
|
|
||||||
|
android::sp<ISensorManager> sensorService = new SensorManager(vm);
|
||||||
|
if (IServiceManager::Transport::HWBINDER ==
|
||||||
|
android::hardware::defaultServiceManager1_2()->getTransport(ISensorManager::descriptor,
|
||||||
|
"default")) {
|
||||||
|
android::status_t err = sensorService->registerAsService();
|
||||||
|
LOG_ALWAYS_FATAL_IF(err != android::OK, "Cannot register %s: %d",
|
||||||
|
ISensorManager::descriptor, err);
|
||||||
|
} else {
|
||||||
|
ALOGW("%s is deprecated. Skipping registration.", ISensorManager::descriptor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
@@ -78,6 +112,12 @@ static void android_server_SystemServer_startIStatsService(JNIEnv* /* env */, jo
|
|||||||
startStatsAidlService();
|
startStatsAidlService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void android_server_SystemServer_startISensorManagerService(JNIEnv* env,
|
||||||
|
jobject /* clazz */) {
|
||||||
|
startSensorManagerHidlService(env);
|
||||||
|
startSensorManagerAidlService(env);
|
||||||
|
}
|
||||||
|
|
||||||
static void android_server_SystemServer_startMemtrackProxyService(JNIEnv* env,
|
static void android_server_SystemServer_startMemtrackProxyService(JNIEnv* env,
|
||||||
jobject /* clazz */) {
|
jobject /* clazz */) {
|
||||||
using aidl::android::hardware::memtrack::MemtrackProxy;
|
using aidl::android::hardware::memtrack::MemtrackProxy;
|
||||||
@@ -93,35 +133,19 @@ static void android_server_SystemServer_startMemtrackProxyService(JNIEnv* env,
|
|||||||
LOG_ALWAYS_FATAL_IF(err != EX_NONE, "Cannot register %s: %d", memtrackProxyService, err);
|
LOG_ALWAYS_FATAL_IF(err != EX_NONE, "Cannot register %s: %d", memtrackProxyService, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void android_server_SystemServer_startHidlServices(JNIEnv* env, jobject /* clazz */) {
|
static void android_server_SystemServer_startHidlServices(JNIEnv* /* env */, jobject /* clazz */) {
|
||||||
using ::android::frameworks::schedulerservice::V1_0::ISchedulingPolicyService;
|
using ::android::frameworks::schedulerservice::V1_0::ISchedulingPolicyService;
|
||||||
using ::android::frameworks::schedulerservice::V1_0::implementation::SchedulingPolicyService;
|
using ::android::frameworks::schedulerservice::V1_0::implementation::SchedulingPolicyService;
|
||||||
using ::android::frameworks::sensorservice::V1_0::ISensorManager;
|
|
||||||
using ::android::frameworks::sensorservice::V1_0::implementation::SensorManager;
|
|
||||||
using ::android::hardware::configureRpcThreadpool;
|
using ::android::hardware::configureRpcThreadpool;
|
||||||
using ::android::hidl::manager::V1_0::IServiceManager;
|
using ::android::hidl::manager::V1_0::IServiceManager;
|
||||||
|
|
||||||
status_t err;
|
|
||||||
|
|
||||||
configureRpcThreadpool(5, false /* callerWillJoin */);
|
configureRpcThreadpool(5, false /* callerWillJoin */);
|
||||||
|
|
||||||
JavaVM *vm;
|
|
||||||
LOG_ALWAYS_FATAL_IF(env->GetJavaVM(&vm) != JNI_OK, "Cannot get Java VM");
|
|
||||||
|
|
||||||
sp<ISensorManager> sensorService = new SensorManager(vm);
|
|
||||||
if (IServiceManager::Transport::HWBINDER ==
|
|
||||||
hardware::defaultServiceManager1_2()->getTransport(ISensorManager::descriptor, "default")) {
|
|
||||||
err = sensorService->registerAsService();
|
|
||||||
LOG_ALWAYS_FATAL_IF(err != OK, "Cannot register %s: %d", ISensorManager::descriptor, err);
|
|
||||||
} else {
|
|
||||||
ALOGW("%s is deprecated. Skipping registration.", ISensorManager::descriptor);
|
|
||||||
}
|
|
||||||
|
|
||||||
sp<ISchedulingPolicyService> schedulingService = new SchedulingPolicyService();
|
sp<ISchedulingPolicyService> schedulingService = new SchedulingPolicyService();
|
||||||
if (IServiceManager::Transport::HWBINDER ==
|
if (IServiceManager::Transport::HWBINDER ==
|
||||||
hardware::defaultServiceManager1_2()->getTransport(ISchedulingPolicyService::descriptor,
|
hardware::defaultServiceManager1_2()->getTransport(ISchedulingPolicyService::descriptor,
|
||||||
"default")) {
|
"default")) {
|
||||||
err = schedulingService->registerAsService("default");
|
status_t err = schedulingService->registerAsService("default");
|
||||||
LOG_ALWAYS_FATAL_IF(err != OK, "Cannot register %s: %d",
|
LOG_ALWAYS_FATAL_IF(err != OK, "Cannot register %s: %d",
|
||||||
ISchedulingPolicyService::descriptor, err);
|
ISchedulingPolicyService::descriptor, err);
|
||||||
} else {
|
} else {
|
||||||
@@ -156,6 +180,8 @@ static void android_server_SystemServer_setIncrementalServiceSystemReady(JNIEnv*
|
|||||||
static const JNINativeMethod gMethods[] = {
|
static const JNINativeMethod gMethods[] = {
|
||||||
/* name, signature, funcPtr */
|
/* name, signature, funcPtr */
|
||||||
{"startIStatsService", "()V", (void*)android_server_SystemServer_startIStatsService},
|
{"startIStatsService", "()V", (void*)android_server_SystemServer_startIStatsService},
|
||||||
|
{"startISensorManagerService", "()V",
|
||||||
|
(void*)android_server_SystemServer_startISensorManagerService},
|
||||||
{"startMemtrackProxyService", "()V",
|
{"startMemtrackProxyService", "()V",
|
||||||
(void*)android_server_SystemServer_startMemtrackProxyService},
|
(void*)android_server_SystemServer_startMemtrackProxyService},
|
||||||
{"startHidlServices", "()V", (void*)android_server_SystemServer_startHidlServices},
|
{"startHidlServices", "()V", (void*)android_server_SystemServer_startHidlServices},
|
||||||
|
|||||||
@@ -464,6 +464,7 @@ public final class SystemServer implements Dumpable {
|
|||||||
private final long mRuntimeStartUptime;
|
private final long mRuntimeStartUptime;
|
||||||
|
|
||||||
private static final String START_HIDL_SERVICES = "StartHidlServices";
|
private static final String START_HIDL_SERVICES = "StartHidlServices";
|
||||||
|
private static final String START_SENSOR_MANAGER_SERVICE = "StartISensorManagerService";
|
||||||
private static final String START_BLOB_STORE_SERVICE = "startBlobStoreManagerService";
|
private static final String START_BLOB_STORE_SERVICE = "startBlobStoreManagerService";
|
||||||
|
|
||||||
private static final String SYSPROP_START_COUNT = "sys.system_server.start_count";
|
private static final String SYSPROP_START_COUNT = "sys.system_server.start_count";
|
||||||
@@ -482,6 +483,9 @@ public final class SystemServer implements Dumpable {
|
|||||||
/** Start the IStats services. This is a blocking call and can take time. */
|
/** Start the IStats services. This is a blocking call and can take time. */
|
||||||
private static native void startIStatsService();
|
private static native void startIStatsService();
|
||||||
|
|
||||||
|
/** Start the ISensorManager service. This is a blocking call and can take time. */
|
||||||
|
private static native void startISensorManagerService();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start the memtrack proxy service.
|
* Start the memtrack proxy service.
|
||||||
*/
|
*/
|
||||||
@@ -1595,9 +1599,16 @@ public final class SystemServer implements Dumpable {
|
|||||||
wm.onInitReady();
|
wm.onInitReady();
|
||||||
t.traceEnd();
|
t.traceEnd();
|
||||||
|
|
||||||
// Start receiving calls from HIDL services. Start in in a separate thread
|
// Start receiving calls from SensorManager services. Start in a separate thread
|
||||||
// because it need to connect to SensorManager. This has to start
|
// because it need to connect to SensorManager. This has to start
|
||||||
// after PHASE_WAIT_FOR_SENSOR_SERVICE is done.
|
// after PHASE_WAIT_FOR_SENSOR_SERVICE is done.
|
||||||
|
SystemServerInitThreadPool.submit(() -> {
|
||||||
|
TimingsTraceAndSlog traceLog = TimingsTraceAndSlog.newAsyncLog();
|
||||||
|
traceLog.traceBegin(START_SENSOR_MANAGER_SERVICE);
|
||||||
|
startISensorManagerService();
|
||||||
|
traceLog.traceEnd();
|
||||||
|
}, START_SENSOR_MANAGER_SERVICE);
|
||||||
|
|
||||||
SystemServerInitThreadPool.submit(() -> {
|
SystemServerInitThreadPool.submit(() -> {
|
||||||
TimingsTraceAndSlog traceLog = TimingsTraceAndSlog.newAsyncLog();
|
TimingsTraceAndSlog traceLog = TimingsTraceAndSlog.newAsyncLog();
|
||||||
traceLog.traceBegin(START_HIDL_SERVICES);
|
traceLog.traceBegin(START_HIDL_SERVICES);
|
||||||
|
|||||||
Reference in New Issue
Block a user