Merge "Add memtrackproxy system server service" into sc-dev

This commit is contained in:
Kalesh Singh
2021-04-07 13:21:20 +00:00
committed by Android (Google) Code Review
3 changed files with 33 additions and 1 deletions

View File

@@ -95,8 +95,8 @@ cc_defaults {
"libaudioclient",
"libbase",
"libappfuse",
"libbinder",
"libbinder_ndk",
"libbinder",
"libcutils",
"libcrypto",
"liblog",
@@ -105,6 +105,7 @@ cc_defaults {
"libhardware_legacy",
"libhidlbase",
"libmeminfo",
"libmemtrackproxy",
"libmtp",
"libnativehelper",
"libnativewindow",
@@ -154,6 +155,7 @@ cc_defaults {
"android.hardware.input.classifier@1.0",
"android.hardware.ir@1.0",
"android.hardware.light@2.0",
"android.hardware.memtrack-V1-ndk_platform",
"android.hardware.power@1.0",
"android.hardware.power@1.1",
"android.hardware.power-V1-cpp",

View File

@@ -24,11 +24,13 @@
#include <nativehelper/JNIHelp.h>
#include <android/binder_manager.h>
#include <android/binder_stability.h>
#include <android/hidl/manager/1.2/IServiceManager.h>
#include <binder/IServiceManager.h>
#include <hidl/HidlTransportSupport.h>
#include <incremental_service.h>
#include <memtrackproxy/MemtrackProxy.h>
#include <schedulerservice/SchedulingPolicyService.h>
#include <sensorservice/SensorService.h>
#include <sensorservicehidl/SensorManager.h>
@@ -83,6 +85,21 @@ static void android_server_SystemServer_startSensorService(JNIEnv* /* env */, jo
}
}
static void android_server_SystemServer_startMemtrackProxyService(JNIEnv* env,
jobject /* clazz */) {
using aidl::android::hardware::memtrack::MemtrackProxy;
const char* memtrackProxyService = "memtrack.proxy";
std::shared_ptr<MemtrackProxy> memtrack_proxy = ndk::SharedRefBase::make<MemtrackProxy>();
auto binder = memtrack_proxy->asBinder();
AIBinder_forceDowngradeToLocalStability(binder.get());
const binder_exception_t err = AServiceManager_addService(binder.get(), memtrackProxyService);
LOG_ALWAYS_FATAL_IF(err != EX_NONE, "Cannot register %s: %d", memtrackProxyService, err);
}
static void android_server_SystemServer_startHidlServices(JNIEnv* env, jobject /* clazz */) {
using ::android::frameworks::schedulerservice::V1_0::ISchedulingPolicyService;
using ::android::frameworks::schedulerservice::V1_0::implementation::SchedulingPolicyService;
@@ -144,6 +161,8 @@ static void android_server_SystemServer_setIncrementalServiceSystemReady(JNIEnv*
static const JNINativeMethod gMethods[] = {
/* name, signature, funcPtr */
{"startSensorService", "()V", (void*)android_server_SystemServer_startSensorService},
{"startMemtrackProxyService", "()V",
(void*)android_server_SystemServer_startMemtrackProxyService},
{"startHidlServices", "()V", (void*)android_server_SystemServer_startHidlServices},
{"initZygoteChildHeapProfiling", "()V",
(void*)android_server_SystemServer_initZygoteChildHeapProfiling},

View File

@@ -453,6 +453,11 @@ public final class SystemServer implements Dumpable {
*/
private static native void startSensorService();
/**
* Start the memtrack proxy service.
*/
private static native void startMemtrackProxyService();
/**
* Start all HIDL services that are run inside the system server. This may take some time.
*/
@@ -1024,6 +1029,12 @@ public final class SystemServer implements Dumpable {
mSystemServiceManager.startService(PowerStatsService.class);
t.traceEnd();
// Start MemtrackProxyService before ActivityManager, so that early calls
// to Memtrack::getMemory() don't fail.
t.traceBegin("MemtrackProxyService");
startMemtrackProxyService();
t.traceEnd();
// Activity manager runs the show.
t.traceBegin("StartActivityManager");
// TODO: Might need to move after migration to WM.