diff options
| author | 2021-02-01 23:47:16 +0000 | |
|---|---|---|
| committer | 2021-02-17 02:04:16 +0000 | |
| commit | 2c62b7c16ae0487af9ac493f4619e05375a8a4ca (patch) | |
| tree | 70d487862e71df06730e00af46b15ec3ae5ba7e0 | |
| parent | 4245e30aec8fd92e363a3d514aa8228eac04cba8 (diff) | |
Stats: added registration for AIDL version of the service
Bug: 179081954
Test: build, flash & run aidl_stats_client
Change-Id: I73dc126c39465aa6c415307285c7f57a6e9a129d
| -rw-r--r-- | services/core/jni/Android.bp | 2 | ||||
| -rw-r--r-- | services/core/jni/com_android_server_SystemServer.cpp | 35 |
2 files changed, 31 insertions, 6 deletions
diff --git a/services/core/jni/Android.bp b/services/core/jni/Android.bp index 11e3ecfbb90d..30984e927926 100644 --- a/services/core/jni/Android.bp +++ b/services/core/jni/Android.bp @@ -88,6 +88,7 @@ cc_defaults { "libbase", "libappfuse", "libbinder", + "libbinder_ndk", "libcutils", "libcrypto", "liblog", @@ -163,6 +164,7 @@ cc_defaults { "android.frameworks.schedulerservice@1.0", "android.frameworks.sensorservice@1.0", "android.frameworks.stats@1.0", + "android.frameworks.stats-V1-ndk_platform", "android.system.suspend.control-V1-cpp", "android.system.suspend.control.internal-cpp", "android.system.suspend@1.0", diff --git a/services/core/jni/com_android_server_SystemServer.cpp b/services/core/jni/com_android_server_SystemServer.cpp index 729fa71af169..a73f6c6d8c2d 100644 --- a/services/core/jni/com_android_server_SystemServer.cpp +++ b/services/core/jni/com_android_server_SystemServer.cpp @@ -23,6 +23,7 @@ #include <jni.h> #include <nativehelper/JNIHelp.h> +#include <android/binder_manager.h> #include <android/hidl/manager/1.2/IServiceManager.h> #include <binder/IServiceManager.h> #include <hidl/HidlTransportSupport.h> @@ -31,6 +32,7 @@ #include <schedulerservice/SchedulingPolicyService.h> #include <sensorservice/SensorService.h> #include <sensorservicehidl/SensorManager.h> +#include <stats/StatsAidl.h> #include <stats/StatsHal.h> #include <bionic/malloc.h> @@ -45,6 +47,31 @@ using android::base::GetIntProperty; using namespace std::chrono_literals; +namespace { + +static void startStatsAidlService() { + using aidl::android::frameworks::stats::IStats; + using aidl::android::frameworks::stats::StatsHal; + + std::shared_ptr<StatsHal> statsService = ndk::SharedRefBase::make<StatsHal>(); + + const std::string instance = std::string() + IStats::descriptor + "/default"; + const binder_exception_t err = + AServiceManager_addService(statsService->asBinder().get(), instance.c_str()); + LOG_ALWAYS_FATAL_IF(err != EX_NONE, "Cannot register %s: %d", instance.c_str(), err); +} + +static void startStatsHidlService() { + using android::frameworks::stats::V1_0::IStats; + using android::frameworks::stats::V1_0::implementation::StatsHal; + + android::sp<IStats> statsHal = new StatsHal(); + const android::status_t err = statsHal->registerAsService(); + LOG_ALWAYS_FATAL_IF(err != android::OK, "Cannot register %s: %d", IStats::descriptor, err); +} + +} // namespace + namespace android { static void android_server_SystemServer_startSensorService(JNIEnv* /* env */, jobject /* clazz */) { @@ -54,7 +81,6 @@ static void android_server_SystemServer_startSensorService(JNIEnv* /* env */, jo SensorService::publish(false /* allowIsolated */, IServiceManager::DUMP_FLAG_PRIORITY_CRITICAL); } - } static void android_server_SystemServer_startHidlServices(JNIEnv* env, jobject /* clazz */) { @@ -62,8 +88,6 @@ static void android_server_SystemServer_startHidlServices(JNIEnv* env, jobject / 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::frameworks::stats::V1_0::IStats; - using ::android::frameworks::stats::V1_0::implementation::StatsHal; using ::android::hardware::configureRpcThreadpool; using ::android::hidl::manager::V1_0::IServiceManager; @@ -89,9 +113,8 @@ static void android_server_SystemServer_startHidlServices(JNIEnv* env, jobject / ALOGW("%s is deprecated. Skipping registration.", ISchedulingPolicyService::descriptor); } - sp<IStats> statsHal = new StatsHal(); - err = statsHal->registerAsService(); - LOG_ALWAYS_FATAL_IF(err != OK, "Cannot register %s: %d", IStats::descriptor, err); + startStatsAidlService(); + startStatsHidlService(); } static void android_server_SystemServer_initZygoteChildHeapProfiling(JNIEnv* /* env */, |