Merge "Migrate StatsHal" am: e566dd697b

Change-Id: I7ba166dc3b0d0e41452dcd581b8bc8165ef6b0e2
This commit is contained in:
Automerger Merge Worker
2020-02-07 18:17:51 +00:00
9 changed files with 11 additions and 214 deletions

View File

@@ -231,8 +231,6 @@ cc_binary {
shared_libs: ["libgtest_prod"],
vintf_fragments: ["android.frameworks.stats@1.0-service.xml"],
init_rc: ["statsd.rc"],
}

View File

@@ -1,11 +0,0 @@
<manifest version="1.0" type="framework">
<hal>
<name>android.frameworks.stats</name>
<transport>hwbinder</transport>
<version>1.0</version>
<interface>
<name>IStats</name>
<instance>default</instance>
</interface>
</hal>
</manifest>

View File

@@ -1453,7 +1453,6 @@ Status StatsService::sendWatchdogRollbackOccurredAtom(const int32_t rollbackType
return Status::ok();
}
Status StatsService::getRegisteredExperimentIds(std::vector<int64_t>* experimentIdsOut) {
uid_t uid = IPCThreadState::self()->getCallingUid();
@@ -1481,103 +1480,6 @@ Status StatsService::getRegisteredExperimentIds(std::vector<int64_t>* experiment
return Status::ok();
}
hardware::Return<void> StatsService::reportSpeakerImpedance(
const SpeakerImpedance& speakerImpedance) {
android::util::stats_write(android::util::SPEAKER_IMPEDANCE_REPORTED,
speakerImpedance.speakerLocation, speakerImpedance.milliOhms);
return hardware::Void();
}
hardware::Return<void> StatsService::reportHardwareFailed(const HardwareFailed& hardwareFailed) {
android::util::stats_write(android::util::HARDWARE_FAILED, int32_t(hardwareFailed.hardwareType),
hardwareFailed.hardwareLocation, int32_t(hardwareFailed.errorCode));
return hardware::Void();
}
hardware::Return<void> StatsService::reportPhysicalDropDetected(
const PhysicalDropDetected& physicalDropDetected) {
android::util::stats_write(android::util::PHYSICAL_DROP_DETECTED,
int32_t(physicalDropDetected.confidencePctg), physicalDropDetected.accelPeak,
physicalDropDetected.freefallDuration);
return hardware::Void();
}
hardware::Return<void> StatsService::reportChargeCycles(const ChargeCycles& chargeCycles) {
std::vector<int32_t> buckets = chargeCycles.cycleBucket;
int initialSize = buckets.size();
for (int i = 0; i < 10 - initialSize; i++) {
buckets.push_back(-1); // Push -1 for buckets that do not exist.
}
android::util::stats_write(android::util::CHARGE_CYCLES_REPORTED, buckets[0], buckets[1],
buckets[2], buckets[3], buckets[4], buckets[5], buckets[6], buckets[7], buckets[8],
buckets[9]);
return hardware::Void();
}
hardware::Return<void> StatsService::reportBatteryHealthSnapshot(
const BatteryHealthSnapshotArgs& batteryHealthSnapshotArgs) {
android::util::stats_write(android::util::BATTERY_HEALTH_SNAPSHOT,
int32_t(batteryHealthSnapshotArgs.type), batteryHealthSnapshotArgs.temperatureDeciC,
batteryHealthSnapshotArgs.voltageMicroV, batteryHealthSnapshotArgs.currentMicroA,
batteryHealthSnapshotArgs.openCircuitVoltageMicroV,
batteryHealthSnapshotArgs.resistanceMicroOhm, batteryHealthSnapshotArgs.levelPercent);
return hardware::Void();
}
hardware::Return<void> StatsService::reportSlowIo(const SlowIo& slowIo) {
android::util::stats_write(android::util::SLOW_IO, int32_t(slowIo.operation), slowIo.count);
return hardware::Void();
}
hardware::Return<void> StatsService::reportBatteryCausedShutdown(
const BatteryCausedShutdown& batteryCausedShutdown) {
android::util::stats_write(android::util::BATTERY_CAUSED_SHUTDOWN,
batteryCausedShutdown.voltageMicroV);
return hardware::Void();
}
hardware::Return<void> StatsService::reportUsbPortOverheatEvent(
const UsbPortOverheatEvent& usbPortOverheatEvent) {
android::util::stats_write(android::util::USB_PORT_OVERHEAT_EVENT_REPORTED,
usbPortOverheatEvent.plugTemperatureDeciC, usbPortOverheatEvent.maxTemperatureDeciC,
usbPortOverheatEvent.timeToOverheat, usbPortOverheatEvent.timeToHysteresis,
usbPortOverheatEvent.timeToInactive);
return hardware::Void();
}
hardware::Return<void> StatsService::reportSpeechDspStat(
const SpeechDspStat& speechDspStat) {
android::util::stats_write(android::util::SPEECH_DSP_STAT_REPORTED,
speechDspStat.totalUptimeMillis, speechDspStat.totalDowntimeMillis,
speechDspStat.totalCrashCount, speechDspStat.totalRecoverCount);
return hardware::Void();
}
hardware::Return<void> StatsService::reportVendorAtom(const VendorAtom& vendorAtom) {
std::string reverseDomainName = (std::string) vendorAtom.reverseDomainName;
if (vendorAtom.atomId < 100000 || vendorAtom.atomId >= 200000) {
ALOGE("Atom ID %ld is not a valid vendor atom ID", (long) vendorAtom.atomId);
return hardware::Void();
}
if (reverseDomainName.length() > 50) {
ALOGE("Vendor atom reverse domain name %s is too long.", reverseDomainName.c_str());
return hardware::Void();
}
LogEvent event(getWallClockSec() * NS_PER_SEC, getElapsedRealtimeNs(), vendorAtom);
mProcessor->OnLogEvent(&event);
return hardware::Void();
}
void StatsService::binderDied(const wp <IBinder>& who) {
ALOGW("statscompanion service died");
StatsdStats::getInstance().noteSystemServerRestart(getWallClockSec());

View File

@@ -53,7 +53,6 @@ namespace statsd {
using android::hardware::Return;
class StatsService : public BnStatsManager,
public IStats,
public IBinder::DeathRecipient {
public:
StatsService(const sp<Looper>& handlerLooper, std::shared_ptr<LogEventQueue> queue);
@@ -209,61 +208,6 @@ public:
*/
virtual Status getRegisteredExperimentIds(std::vector<int64_t>* expIdsOut);
/**
* Binder call to get SpeakerImpedance atom.
*/
virtual Return<void> reportSpeakerImpedance(const SpeakerImpedance& speakerImpedance) override;
/**
* Binder call to get HardwareFailed atom.
*/
virtual Return<void> reportHardwareFailed(const HardwareFailed& hardwareFailed) override;
/**
* Binder call to get PhysicalDropDetected atom.
*/
virtual Return<void> reportPhysicalDropDetected(
const PhysicalDropDetected& physicalDropDetected) override;
/**
* Binder call to get ChargeCyclesReported atom.
*/
virtual Return<void> reportChargeCycles(const ChargeCycles& chargeCycles) override;
/**
* Binder call to get BatteryHealthSnapshot atom.
*/
virtual Return<void> reportBatteryHealthSnapshot(
const BatteryHealthSnapshotArgs& batteryHealthSnapshotArgs) override;
/**
* Binder call to get SlowIo atom.
*/
virtual Return<void> reportSlowIo(const SlowIo& slowIo) override;
/**
* Binder call to get BatteryCausedShutdown atom.
*/
virtual Return<void> reportBatteryCausedShutdown(
const BatteryCausedShutdown& batteryCausedShutdown) override;
/**
* Binder call to get UsbPortOverheatEvent atom.
*/
virtual Return<void> reportUsbPortOverheatEvent(
const UsbPortOverheatEvent& usbPortOverheatEvent) override;
/**
* Binder call to get Speech DSP state atom.
*/
virtual Return<void> reportSpeechDspStat(
const SpeechDspStat& speechDspStat) override;
/**
* Binder call to get vendor atom.
*/
virtual Return<void> reportVendorAtom(const VendorAtom& vendorAtom) override;
/** IBinder::DeathRecipient */
virtual void binderDied(const wp<IBinder>& who) override;

View File

@@ -206,37 +206,6 @@ LogEvent::LogEvent(const string& trainName, int64_t trainVersionCode, bool requi
mValues.push_back(FieldValue(Field(mTagId, getSimpleField(8)), Value(userId)));
}
LogEvent::LogEvent(int64_t wallClockTimestampNs, int64_t elapsedTimestampNs,
const VendorAtom& vendorAtom) {
mLogdTimestampNs = wallClockTimestampNs;
mElapsedTimestampNs = elapsedTimestampNs;
mTagId = vendorAtom.atomId;
mLogUid = AID_STATSD;
mValues.push_back(
FieldValue(Field(mTagId, getSimpleField(1)), Value(vendorAtom.reverseDomainName)));
for (int i = 0; i < (int)vendorAtom.values.size(); i++) {
switch (vendorAtom.values[i].getDiscriminator()) {
case VendorAtom::Value::hidl_discriminator::intValue:
mValues.push_back(FieldValue(Field(mTagId, getSimpleField(i + 2)),
Value(vendorAtom.values[i].intValue())));
break;
case VendorAtom::Value::hidl_discriminator::longValue:
mValues.push_back(FieldValue(Field(mTagId, getSimpleField(i + 2)),
Value(vendorAtom.values[i].longValue())));
break;
case VendorAtom::Value::hidl_discriminator::floatValue:
mValues.push_back(FieldValue(Field(mTagId, getSimpleField(i + 2)),
Value(vendorAtom.values[i].floatValue())));
break;
case VendorAtom::Value::hidl_discriminator::stringValue:
mValues.push_back(FieldValue(Field(mTagId, getSimpleField(i + 2)),
Value(vendorAtom.values[i].stringValue())));
break;
}
}
}
LogEvent::LogEvent(int64_t wallClockTimestampNs, int64_t elapsedTimestampNs,
const InstallTrainInfo& trainInfo) {
mLogdTimestampNs = wallClockTimestampNs;

View File

@@ -18,7 +18,6 @@
#include "FieldValue.h"
#include <android/frameworks/stats/1.0/types.h>
#include <android/os/StatsLogEventWrapper.h>
#include <android/util/ProtoOutputStream.h>
#include <log/log_event_list.h>
@@ -29,8 +28,6 @@
#include <string>
#include <vector>
using namespace android::frameworks::stats::V1_0;
namespace android {
namespace os {
namespace statsd {
@@ -110,9 +107,6 @@ public:
bool rollbackEnabled, bool requiresLowLatencyMonitor, int32_t state,
const std::vector<uint8_t>& experimentIds, int32_t userId);
explicit LogEvent(int64_t wallClockTimestampNs, int64_t elapsedTimestampNs,
const VendorAtom& vendorAtom);
explicit LogEvent(int64_t wallClockTimestampNs, int64_t elapsedTimestampNs,
const InstallTrainInfo& installTrainInfo);

View File

@@ -80,8 +80,6 @@ int main(int /*argc*/, char** /*argv*/) {
ps->giveThreadPoolName();
IPCThreadState::self()->disableBackgroundScheduling(true);
::android::hardware::configureRpcThreadpool(4 /*threads*/, false /*willJoin*/);
std::shared_ptr<LogEventQueue> eventQueue =
std::make_shared<LogEventQueue>(2000 /*buffer limit. Buffer is NOT pre-allocated*/);
@@ -94,12 +92,6 @@ int main(int /*argc*/, char** /*argv*/) {
return -1;
}
auto ret = gStatsService->registerAsService();
if (ret != ::android::OK) {
ALOGE("Failed to add service as HIDL service");
return 1; // or handle error
}
registerSigHandler();
gStatsService->sayHiToStatsCompanion();

View File

@@ -93,7 +93,8 @@ cc_defaults {
"libschedulerservicehidl",
"libsensorservice",
"libsensorservicehidl",
"libgui",
"libstatshidl",
"libgui",
"libusbhost",
"libtinyalsa",
"libEGL",
@@ -132,7 +133,8 @@ cc_defaults {
"android.hardware.vr@1.0",
"android.frameworks.schedulerservice@1.0",
"android.frameworks.sensorservice@1.0",
"android.system.suspend@1.0",
"android.frameworks.stats@1.0",
"android.system.suspend@1.0",
"suspend_control_aidl_interface-cpp",
],

View File

@@ -29,6 +29,7 @@
#include <schedulerservice/SchedulingPolicyService.h>
#include <sensorservice/SensorService.h>
#include <sensorservicehidl/SensorManager.h>
#include <stats/StatsHal.h>
#include <bionic/malloc.h>
#include <bionic/reserved_signals.h>
@@ -59,6 +60,8 @@ 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;
status_t err;
@@ -75,6 +78,10 @@ static void android_server_SystemServer_startHidlServices(JNIEnv* env, jobject /
sp<ISchedulingPolicyService> schedulingService = new SchedulingPolicyService();
err = schedulingService->registerAsService();
ALOGE_IF(err != OK, "Cannot register %s: %d", ISchedulingPolicyService::descriptor, err);
sp<IStats> statsHal = new StatsHal();
err = statsHal->registerAsService();
ALOGE_IF(err != OK, "Cannot register %s: %d", IStats::descriptor, err);
}
static void android_server_SystemServer_initZygoteChildHeapProfiling(JNIEnv* /* env */,