Migrate StatsHal
Test: bit VtsHalStatsV1_0TargetTest:* Bug: 148794952 Change-Id: I19ff6edf78bd84a95d8c0ae3a1adda99d4232aa5
This commit is contained in:
@@ -118,7 +118,6 @@ cc_defaults {
|
||||
],
|
||||
|
||||
static_libs: [
|
||||
"android.frameworks.stats@1.0",
|
||||
"libbase",
|
||||
"libcutils",
|
||||
"libprotoutil",
|
||||
@@ -128,7 +127,6 @@ cc_defaults {
|
||||
],
|
||||
shared_libs: [
|
||||
"libbinder",
|
||||
"libhidlbase",
|
||||
"libincident",
|
||||
"liblog",
|
||||
"libservices",
|
||||
@@ -222,8 +220,6 @@ cc_binary {
|
||||
|
||||
shared_libs: ["libgtest_prod"],
|
||||
|
||||
vintf_fragments: ["android.frameworks.stats@1.0-service.xml"],
|
||||
|
||||
init_rc: ["statsd.rc"],
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -1354,7 +1354,6 @@ Status StatsService::sendWatchdogRollbackOccurredAtom(const int32_t rollbackType
|
||||
return Status::ok();
|
||||
}
|
||||
|
||||
|
||||
Status StatsService::getRegisteredExperimentIds(std::vector<int64_t>* experimentIdsOut) {
|
||||
ENFORCE_UID(AID_SYSTEM);
|
||||
// TODO: add verifier permission
|
||||
@@ -1372,103 +1371,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());
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
#include "shell/ShellSubscriber.h"
|
||||
#include "statscompanion_util.h"
|
||||
|
||||
#include <android/frameworks/stats/1.0/IStats.h>
|
||||
#include <android/frameworks/stats/1.0/types.h>
|
||||
#include <android/os/BnStatsd.h>
|
||||
#include <android/os/IPendingIntentRef.h>
|
||||
#include <android/os/IStatsCompanionService.h>
|
||||
@@ -41,7 +39,6 @@
|
||||
|
||||
using namespace android;
|
||||
using namespace android::binder;
|
||||
using namespace android::frameworks::stats::V1_0;
|
||||
using namespace android::os;
|
||||
using namespace std;
|
||||
|
||||
@@ -49,10 +46,7 @@ namespace android {
|
||||
namespace os {
|
||||
namespace statsd {
|
||||
|
||||
using android::hardware::Return;
|
||||
|
||||
class StatsService : public BnStatsd,
|
||||
public IStats,
|
||||
public IBinder::DeathRecipient {
|
||||
public:
|
||||
StatsService(const sp<Looper>& handlerLooper, std::shared_ptr<LogEventQueue> queue);
|
||||
@@ -207,61 +201,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;
|
||||
|
||||
|
||||
@@ -194,37 +194,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;
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#include "FieldValue.h"
|
||||
|
||||
#include <android/frameworks/stats/1.0/types.h>
|
||||
#include <android/util/ProtoOutputStream.h>
|
||||
#include <private/android_logger.h>
|
||||
#include <stats_event_list.h>
|
||||
@@ -27,8 +26,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace android::frameworks::stats::V1_0;
|
||||
|
||||
namespace android {
|
||||
namespace os {
|
||||
namespace statsd {
|
||||
@@ -102,9 +99,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);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include <binder/IPCThreadState.h>
|
||||
#include <binder/IServiceManager.h>
|
||||
#include <binder/ProcessState.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
#include <utils/Looper.h>
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -75,8 +74,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*/);
|
||||
|
||||
@@ -89,12 +86,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();
|
||||
|
||||
@@ -109,6 +109,7 @@ cc_defaults {
|
||||
"libinputservice",
|
||||
"libprotobuf-cpp-lite",
|
||||
"libprotoutil",
|
||||
"libstatshidl",
|
||||
"libstatspull",
|
||||
"libstatssocket",
|
||||
"libstatslog",
|
||||
@@ -155,6 +156,7 @@ cc_defaults {
|
||||
"android.hardware.vr@1.0",
|
||||
"android.frameworks.schedulerservice@1.0",
|
||||
"android.frameworks.sensorservice@1.0",
|
||||
"android.frameworks.stats@1.0",
|
||||
"android.system.suspend@1.0",
|
||||
"service.incremental",
|
||||
"suspend_control_aidl_interface-cpp",
|
||||
|
||||
@@ -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 */,
|
||||
|
||||
Reference in New Issue
Block a user