Add AIDL interface and puller implementation for automotive devices.
Changes:
- Adds hidden ICarStatsService AIDL API.
- Adds CarStatsPuller for pulling atoms from ICarStatsService.
- Pulls VmsClientStats via CarStatsPuller.
Bug: 141697665
Test: Manual testing on hawk using statsd_testdrive
Change-Id: I44e104d430f64b1bd3dce96e9749df79ab3d2fbf
Merged-In: I44e104d430f64b1bd3dce96e9749df79ab3d2fbf
(cherry picked from commit 9dc13578f7)
This commit is contained in:
@@ -50,6 +50,7 @@ cc_defaults {
|
|||||||
|
|
||||||
srcs: [
|
srcs: [
|
||||||
":statsd_aidl",
|
":statsd_aidl",
|
||||||
|
":ICarStatsService.aidl",
|
||||||
"src/active_config_list.proto",
|
"src/active_config_list.proto",
|
||||||
"src/statsd_config.proto",
|
"src/statsd_config.proto",
|
||||||
"src/uid_data.proto",
|
"src/uid_data.proto",
|
||||||
@@ -69,6 +70,7 @@ cc_defaults {
|
|||||||
"src/config/ConfigKey.cpp",
|
"src/config/ConfigKey.cpp",
|
||||||
"src/config/ConfigListener.cpp",
|
"src/config/ConfigListener.cpp",
|
||||||
"src/config/ConfigManager.cpp",
|
"src/config/ConfigManager.cpp",
|
||||||
|
"src/external/CarStatsPuller.cpp",
|
||||||
"src/external/GpuStatsPuller.cpp",
|
"src/external/GpuStatsPuller.cpp",
|
||||||
"src/external/Perfetto.cpp",
|
"src/external/Perfetto.cpp",
|
||||||
"src/external/StatsPuller.cpp",
|
"src/external/StatsPuller.cpp",
|
||||||
|
|||||||
96
cmds/statsd/src/external/CarStatsPuller.cpp
vendored
Normal file
96
cmds/statsd/src/external/CarStatsPuller.cpp
vendored
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define DEBUG false
|
||||||
|
#include "Log.h"
|
||||||
|
|
||||||
|
#include <binder/IServiceManager.h>
|
||||||
|
#include <com/android/internal/car/ICarStatsService.h>
|
||||||
|
|
||||||
|
#include "CarStatsPuller.h"
|
||||||
|
#include "logd/LogEvent.h"
|
||||||
|
#include "stats_log_util.h"
|
||||||
|
|
||||||
|
using android::binder::Status;
|
||||||
|
using com::android::internal::car::ICarStatsService;
|
||||||
|
|
||||||
|
namespace android {
|
||||||
|
namespace os {
|
||||||
|
namespace statsd {
|
||||||
|
|
||||||
|
static std::mutex gCarStatsMutex;
|
||||||
|
static sp<ICarStatsService> gCarStats = nullptr;
|
||||||
|
|
||||||
|
class CarStatsDeathRecipient : public android::IBinder::DeathRecipient {
|
||||||
|
public:
|
||||||
|
CarStatsDeathRecipient() = default;
|
||||||
|
~CarStatsDeathRecipient() override = default;
|
||||||
|
|
||||||
|
// android::IBinder::DeathRecipient override:
|
||||||
|
void binderDied(const android::wp<android::IBinder>& /* who */) override {
|
||||||
|
ALOGE("Car service has died");
|
||||||
|
std::lock_guard<std::mutex> lock(gCarStatsMutex);
|
||||||
|
if (gCarStats) {
|
||||||
|
sp<IBinder> binder = IInterface::asBinder(gCarStats);
|
||||||
|
binder->unlinkToDeath(this);
|
||||||
|
gCarStats = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static sp<CarStatsDeathRecipient> gDeathRecipient = new CarStatsDeathRecipient();
|
||||||
|
|
||||||
|
static sp<ICarStatsService> getCarService() {
|
||||||
|
std::lock_guard<std::mutex> lock(gCarStatsMutex);
|
||||||
|
if (!gCarStats) {
|
||||||
|
const sp<IBinder> binder = defaultServiceManager()->checkService(String16("car_stats"));
|
||||||
|
if (!binder) {
|
||||||
|
ALOGW("Car service is unavailable");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
gCarStats = interface_cast<ICarStatsService>(binder);
|
||||||
|
binder->linkToDeath(gDeathRecipient);
|
||||||
|
}
|
||||||
|
return gCarStats;
|
||||||
|
}
|
||||||
|
|
||||||
|
CarStatsPuller::CarStatsPuller(const int tagId) : StatsPuller(tagId) {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CarStatsPuller::PullInternal(std::vector<std::shared_ptr<LogEvent>>* data) {
|
||||||
|
const sp<ICarStatsService> carService = getCarService();
|
||||||
|
if (!carService) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<StatsLogEventWrapper> returned_value;
|
||||||
|
Status status = carService->pullData(mTagId, &returned_value);
|
||||||
|
if (!status.isOk()) {
|
||||||
|
ALOGW("CarStatsPuller::pull failed for %d", mTagId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
data->clear();
|
||||||
|
for (const StatsLogEventWrapper& it : returned_value) {
|
||||||
|
LogEvent::createLogEvents(it, *data);
|
||||||
|
}
|
||||||
|
VLOG("CarStatsPuller::pull succeeded for %d", mTagId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace statsd
|
||||||
|
} // namespace os
|
||||||
|
} // namespace android
|
||||||
36
cmds/statsd/src/external/CarStatsPuller.h
vendored
Normal file
36
cmds/statsd/src/external/CarStatsPuller.h
vendored
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "StatsPuller.h"
|
||||||
|
|
||||||
|
namespace android {
|
||||||
|
namespace os {
|
||||||
|
namespace statsd {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pull atoms from CarService.
|
||||||
|
*/
|
||||||
|
class CarStatsPuller : public StatsPuller {
|
||||||
|
public:
|
||||||
|
explicit CarStatsPuller(const int tagId);
|
||||||
|
bool PullInternal(std::vector<std::shared_ptr<LogEvent>>* data) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace statsd
|
||||||
|
} // namespace os
|
||||||
|
} // namespace android
|
||||||
@@ -27,6 +27,7 @@
|
|||||||
#include "../logd/LogEvent.h"
|
#include "../logd/LogEvent.h"
|
||||||
#include "../stats_log_util.h"
|
#include "../stats_log_util.h"
|
||||||
#include "../statscompanion_util.h"
|
#include "../statscompanion_util.h"
|
||||||
|
#include "CarStatsPuller.h"
|
||||||
#include "GpuStatsPuller.h"
|
#include "GpuStatsPuller.h"
|
||||||
#include "PowerStatsPuller.h"
|
#include "PowerStatsPuller.h"
|
||||||
#include "ResourceHealthManagerPuller.h"
|
#include "ResourceHealthManagerPuller.h"
|
||||||
@@ -267,6 +268,10 @@ std::map<int, PullAtomInfo> StatsPullerManager::kAllPullAtomInfo = {
|
|||||||
// App ops
|
// App ops
|
||||||
{android::util::APP_OPS,
|
{android::util::APP_OPS,
|
||||||
{.puller = new StatsCompanionServicePuller(android::util::APP_OPS)}},
|
{.puller = new StatsCompanionServicePuller(android::util::APP_OPS)}},
|
||||||
|
// VmsClientStats
|
||||||
|
{android::util::VMS_CLIENT_STATS,
|
||||||
|
{.additiveFields = {5, 6, 7, 8, 9, 10},
|
||||||
|
.puller = new CarStatsPuller(android::util::VMS_CLIENT_STATS)}},
|
||||||
};
|
};
|
||||||
|
|
||||||
StatsPullerManager::StatsPullerManager() : mNextPullTimeNs(NO_ALARM_UPDATE) {
|
StatsPullerManager::StatsPullerManager() : mNextPullTimeNs(NO_ALARM_UPDATE) {
|
||||||
|
|||||||
@@ -7,3 +7,8 @@ filegroup {
|
|||||||
name: "IDropBoxManagerService.aidl",
|
name: "IDropBoxManagerService.aidl",
|
||||||
srcs: ["com/android/internal/os/IDropBoxManagerService.aidl"],
|
srcs: ["com/android/internal/os/IDropBoxManagerService.aidl"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filegroup {
|
||||||
|
name: "ICarStatsService.aidl",
|
||||||
|
srcs: ["com/android/internal/car/ICarStatsService.aidl"],
|
||||||
|
}
|
||||||
|
|||||||
31
core/java/com/android/internal/car/ICarStatsService.aidl
Normal file
31
core/java/com/android/internal/car/ICarStatsService.aidl
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.internal.car;
|
||||||
|
|
||||||
|
import android.os.StatsLogEventWrapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for pulling statsd atoms from automotive devices.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
interface ICarStatsService {
|
||||||
|
/**
|
||||||
|
* Pull the specified atom. Results will be sent to statsd when complete.
|
||||||
|
*/
|
||||||
|
StatsLogEventWrapper[] pullData(int atomId);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user