diff options
-rw-r--r-- | health/Android.bp | 1 | ||||
-rw-r--r-- | health/BatteryMetricsLogger.cpp | 94 | ||||
-rw-r--r-- | health/LowBatteryShutdownMetrics.cpp | 9 | ||||
-rw-r--r-- | health/include/pixelhealth/BatteryMetricsLogger.h | 28 | ||||
-rw-r--r-- | health/include/pixelhealth/LowBatteryShutdownMetrics.h | 4 | ||||
-rw-r--r-- | pixelstats/Android.bp | 1 | ||||
-rw-r--r-- | pixelstats/DropDetect.cpp | 10 | ||||
-rw-r--r-- | pixelstats/SysfsCollector.cpp | 38 | ||||
-rw-r--r-- | pixelstats/UeventListener.cpp | 118 | ||||
-rw-r--r-- | pixelstats/include/pixelstats/SysfsCollector.h | 6 | ||||
-rw-r--r-- | pixelstats/include/pixelstats/UeventListener.h | 8 |
11 files changed, 50 insertions, 267 deletions
diff --git a/health/Android.bp b/health/Android.bp index cff31327..99d65826 100644 --- a/health/Android.bp +++ b/health/Android.bp @@ -25,7 +25,6 @@ cc_library { shared_libs: [ "android.frameworks.stats@1.0", - "hardware.google.pixelstats@1.0", "libbase", "libcutils", "libhidlbase", diff --git a/health/BatteryMetricsLogger.cpp b/health/BatteryMetricsLogger.cpp index 3a9beb5d..b5e89918 100644 --- a/health/BatteryMetricsLogger.cpp +++ b/health/BatteryMetricsLogger.cpp @@ -26,7 +26,6 @@ namespace health { using android::sp; using android::frameworks::stats::V1_0::BatteryHealthSnapshotArgs; using android::frameworks::stats::V1_0::IStats; -using ::hardware::google::pixelstats::V1_0::IPixelStats; BatteryMetricsLogger::BatteryMetricsLogger(const char *const batt_res, const char *const batt_ocv, int sample_period, int upload_period) @@ -48,53 +47,29 @@ int64_t BatteryMetricsLogger::getTime(void) { return nanoseconds_to_seconds(systemTime(SYSTEM_TIME_BOOTTIME)); } -bool BatteryMetricsLogger::uploadOutlierMetric(sp<IPixelStats> client, sp<IStats> stats_client, - sampleType type) { - IPixelStats::BatteryHealthSnapshotArgs min_ss = { - .type = static_cast<IPixelStats::BatterySnapshotType>(0), - .temperatureDeciC = min_[type][TEMP], - .voltageMicroV = min_[type][VOLT], - .currentMicroA = min_[type][CURR], - .openCircuitVoltageMicroV = min_[type][OCV], - .resistanceMicroOhm = min_[type][RES], - .levelPercent = min_[type][SOC]}; - IPixelStats::BatteryHealthSnapshotArgs max_ss = { - .type = static_cast<IPixelStats::BatterySnapshotType>(0), - .temperatureDeciC = max_[type][TEMP], - .voltageMicroV = max_[type][VOLT], - .currentMicroA = max_[type][CURR], - .openCircuitVoltageMicroV = max_[type][OCV], - .resistanceMicroOhm = max_[type][RES], - .levelPercent = max_[type][SOC]}; - +bool BatteryMetricsLogger::uploadOutlierMetric(sp<IStats> stats_client, sampleType type) { BatteryHealthSnapshotArgs min_stats_ss = { - .type = static_cast<BatteryHealthSnapshotArgs::BatterySnapshotType>(0), - .temperatureDeciC = min_[type][TEMP], - .voltageMicroV = min_[type][VOLT], - .currentMicroA = min_[type][CURR], - .openCircuitVoltageMicroV = min_[type][OCV], - .resistanceMicroOhm = min_[type][RES], - .levelPercent = min_[type][SOC]}; + .type = static_cast<BatteryHealthSnapshotArgs::BatterySnapshotType>(0), + .temperatureDeciC = min_[type][TEMP], + .voltageMicroV = min_[type][VOLT], + .currentMicroA = min_[type][CURR], + .openCircuitVoltageMicroV = min_[type][OCV], + .resistanceMicroOhm = min_[type][RES], + .levelPercent = min_[type][SOC]}; BatteryHealthSnapshotArgs max_stats_ss = { - .type = static_cast<BatteryHealthSnapshotArgs::BatterySnapshotType>(0), - .temperatureDeciC = max_[type][TEMP], - .voltageMicroV = max_[type][VOLT], - .currentMicroA = max_[type][CURR], - .openCircuitVoltageMicroV = max_[type][OCV], - .resistanceMicroOhm = max_[type][RES], - .levelPercent = max_[type][SOC]}; - if (kSnapshotType[type] < 0) + .type = static_cast<BatteryHealthSnapshotArgs::BatterySnapshotType>(0), + .temperatureDeciC = max_[type][TEMP], + .voltageMicroV = max_[type][VOLT], + .currentMicroA = max_[type][CURR], + .openCircuitVoltageMicroV = max_[type][OCV], + .resistanceMicroOhm = max_[type][RES], + .levelPercent = max_[type][SOC]}; + if (kStatsSnapshotType[type] < 0) return false; - min_ss.type = (IPixelStats::BatterySnapshotType)kSnapshotType[type]; - max_ss.type = (IPixelStats::BatterySnapshotType)(kSnapshotType[type] + 1); - min_stats_ss.type = (BatteryHealthSnapshotArgs::BatterySnapshotType)kStatsSnapshotType[type]; max_stats_ss.type = - (BatteryHealthSnapshotArgs::BatterySnapshotType)(kStatsSnapshotType[type] + 1); - - client->reportBatteryHealthSnapshot(min_ss); - client->reportBatteryHealthSnapshot(max_ss); + (BatteryHealthSnapshotArgs::BatterySnapshotType)(kStatsSnapshotType[type] + 1); stats_client->reportBatteryHealthSnapshot(min_stats_ss); stats_client->reportBatteryHealthSnapshot(max_stats_ss); @@ -123,15 +98,9 @@ bool BatteryMetricsLogger::uploadMetrics(void) { return false; } - sp<IPixelStats> client = IPixelStats::tryGetService(); - if (!client) { - LOG(ERROR) << "Unable to connect to PixelStats service"; - return false; - } - // Only log and upload the min and max for metric types we want to upload for (int metric = 0; metric < NUM_FIELDS; metric++) { - if ((metric == RES && num_res_samples_ == 0) || kSnapshotType[metric] < 0) + if ((metric == RES && num_res_samples_ == 0) || kStatsSnapshotType[metric] < 0) continue; std::string log_min = "min-" + std::to_string(metric) + " "; std::string log_max = "max-" + std::to_string(metric) + " "; @@ -142,28 +111,19 @@ bool BatteryMetricsLogger::uploadMetrics(void) { LOG(INFO) << log_min; LOG(INFO) << log_max; // Upload min/max metrics - uploadOutlierMetric(client, stats_client, static_cast<sampleType>(metric)); + uploadOutlierMetric(stats_client, static_cast<sampleType>(metric)); } // Upload average metric - IPixelStats::BatteryHealthSnapshotArgs avg_res_ss = { - .type = IPixelStats::BatterySnapshotType::AVG_RESISTANCE, - .temperatureDeciC = 0, - .voltageMicroV = 0, - .currentMicroA = 0, - .openCircuitVoltageMicroV = 0, - .resistanceMicroOhm = avg_resistance, - .levelPercent = 0}; BatteryHealthSnapshotArgs avg_res_ss_stats = { - .type = BatteryHealthSnapshotArgs::BatterySnapshotType::AVG_RESISTANCE, - .temperatureDeciC = 0, - .voltageMicroV = 0, - .currentMicroA = 0, - .openCircuitVoltageMicroV = 0, - .resistanceMicroOhm = avg_resistance, - .levelPercent = 0}; + .type = BatteryHealthSnapshotArgs::BatterySnapshotType::AVG_RESISTANCE, + .temperatureDeciC = 0, + .voltageMicroV = 0, + .currentMicroA = 0, + .openCircuitVoltageMicroV = 0, + .resistanceMicroOhm = avg_resistance, + .levelPercent = 0}; if (num_res_samples_) { - client->reportBatteryHealthSnapshot(avg_res_ss); stats_client->reportBatteryHealthSnapshot(avg_res_ss_stats); } @@ -215,7 +175,7 @@ bool BatteryMetricsLogger::recordSample(struct android::BatteryProperties *props for (int metric = 0; metric < NUM_FIELDS; metric++) { // Discard resistance min/max when charging if ((metric == RES && props->batteryStatus == android::BATTERY_STATUS_CHARGING) || - kSnapshotType[metric] < 0) + kStatsSnapshotType[metric] < 0) continue; if (num_samples_ == 0 || (metric == RES && num_res_samples_ == 0) || sample[metric] < min_[metric][metric]) { diff --git a/health/LowBatteryShutdownMetrics.cpp b/health/LowBatteryShutdownMetrics.cpp index 11b89cd9..2dd07d1e 100644 --- a/health/LowBatteryShutdownMetrics.cpp +++ b/health/LowBatteryShutdownMetrics.cpp @@ -16,7 +16,6 @@ */ #include <android/frameworks/stats/1.0/IStats.h> -#include <hardware/google/pixelstats/1.0/IPixelStats.h> #include <pixelhealth/LowBatteryShutdownMetrics.h> namespace hardware { @@ -31,7 +30,6 @@ using android::base::ReadFileToString; using android::base::SetProperty; using android::frameworks::stats::V1_0::BatteryCausedShutdown; using android::frameworks::stats::V1_0::IStats; -using ::hardware::google::pixelstats::V1_0::IPixelStats; LowBatteryShutdownMetrics::LowBatteryShutdownMetrics(const char *const voltage_avg, const char *const persist_prop) @@ -54,12 +52,6 @@ bool LowBatteryShutdownMetrics::uploadVoltageAvg(void) { return false; } - sp<IPixelStats> client = IPixelStats::tryGetService(); - if (!client) { - LOG(ERROR) << "Unable to connect to PixelStats service"; - return false; - } - // Process and upload comma-delimited last voltage values int32_t voltage_avg; for (const auto &item : android::base::Split(prop_contents, ",")) { @@ -68,7 +60,6 @@ bool LowBatteryShutdownMetrics::uploadVoltageAvg(void) { continue; } LOG(INFO) << "Uploading voltage_avg: " << std::to_string(voltage_avg); - client->reportBatteryCausedShutdown(voltage_avg); BatteryCausedShutdown shutdown = {.voltageMicroV = voltage_avg}; stats_client->reportBatteryCausedShutdown(shutdown); } diff --git a/health/include/pixelhealth/BatteryMetricsLogger.h b/health/include/pixelhealth/BatteryMetricsLogger.h index 2a92812a..bf1d8400 100644 --- a/health/include/pixelhealth/BatteryMetricsLogger.h +++ b/health/include/pixelhealth/BatteryMetricsLogger.h @@ -27,7 +27,6 @@ #include <string> #include <android/frameworks/stats/1.0/IStats.h> -#include <hardware/google/pixelstats/1.0/IPixelStats.h> namespace hardware { namespace google { @@ -37,7 +36,6 @@ namespace health { using android::sp; using android::frameworks::stats::V1_0::BatteryHealthSnapshotArgs; using android::frameworks::stats::V1_0::IStats; -using ::hardware::google::pixelstats::V1_0::IPixelStats; class BatteryMetricsLogger { public: @@ -57,24 +55,14 @@ class BatteryMetricsLogger { NUM_FIELDS, // do not reference }; - const int kSnapshotType[NUM_FIELDS] = { - -1, - (int)IPixelStats::BatterySnapshotType::MIN_CURRENT, - (int)IPixelStats::BatterySnapshotType::MIN_VOLTAGE, - (int)IPixelStats::BatterySnapshotType::MIN_TEMP, - (int)IPixelStats::BatterySnapshotType::MIN_BATT_LEVEL, - (int)IPixelStats::BatterySnapshotType::MIN_RESISTANCE, - -1, - }; - const int kStatsSnapshotType[NUM_FIELDS] = { - -1, - (int)BatteryHealthSnapshotArgs::BatterySnapshotType::MIN_CURRENT, - (int)BatteryHealthSnapshotArgs::BatterySnapshotType::MIN_VOLTAGE, - (int)BatteryHealthSnapshotArgs::BatterySnapshotType::MIN_TEMP, - (int)BatteryHealthSnapshotArgs::BatterySnapshotType::MIN_BATT_LEVEL, - (int)BatteryHealthSnapshotArgs::BatterySnapshotType::MIN_RESISTANCE, - -1, + -1, + (int)BatteryHealthSnapshotArgs::BatterySnapshotType::MIN_CURRENT, + (int)BatteryHealthSnapshotArgs::BatterySnapshotType::MIN_VOLTAGE, + (int)BatteryHealthSnapshotArgs::BatterySnapshotType::MIN_TEMP, + (int)BatteryHealthSnapshotArgs::BatterySnapshotType::MIN_BATT_LEVEL, + (int)BatteryHealthSnapshotArgs::BatterySnapshotType::MIN_RESISTANCE, + -1, }; const char *const kBatteryResistance; @@ -99,7 +87,7 @@ class BatteryMetricsLogger { int64_t getTime(); bool recordSample(struct android::BatteryProperties *props); bool uploadMetrics(); - bool uploadOutlierMetric(sp<IPixelStats> client, sp<IStats> stats_client, sampleType type); + bool uploadOutlierMetric(sp<IStats> stats_client, sampleType type); }; } // namespace health diff --git a/health/include/pixelhealth/LowBatteryShutdownMetrics.h b/health/include/pixelhealth/LowBatteryShutdownMetrics.h index 7dc3ee6c..b49d5aed 100644 --- a/health/include/pixelhealth/LowBatteryShutdownMetrics.h +++ b/health/include/pixelhealth/LowBatteryShutdownMetrics.h @@ -35,8 +35,8 @@ namespace health { class LowBatteryShutdownMetrics { public: LowBatteryShutdownMetrics( - const char *const voltage_avg, - const char *const persist_prop = "persist.vendor.shutdown.voltage_avg"); + const char *const voltage_avg, + const char *const persist_prop = "persist.vendor.shutdown.voltage_avg"); void logShutdownVoltage(struct android::BatteryProperties *props); private: diff --git a/pixelstats/Android.bp b/pixelstats/Android.bp index c98c6341..ea052a45 100644 --- a/pixelstats/Android.bp +++ b/pixelstats/Android.bp @@ -29,7 +29,6 @@ cc_library { ], shared_libs: [ "android.frameworks.stats@1.0", - "hardware.google.pixelstats@1.0", "libbase", "libbinder", "libcutils", diff --git a/pixelstats/DropDetect.cpp b/pixelstats/DropDetect.cpp index e61d1ee6..5d51b760 100644 --- a/pixelstats/DropDetect.cpp +++ b/pixelstats/DropDetect.cpp @@ -20,7 +20,6 @@ #include <chre_host/socket_client.h> #include <android/frameworks/stats/1.0/IStats.h> -#include <hardware/google/pixelstats/1.0/IPixelStats.h> #define LOG_TAG "pixelstats-vendor" #include <log/log.h> @@ -32,7 +31,6 @@ using android::chre::IChreMessageHandlers; using android::chre::SocketClient; using android::frameworks::stats::V1_0::IStats; using android::frameworks::stats::V1_0::PhysicalDropDetected; -using ::hardware::google::pixelstats::V1_0::IPixelStats; // following convention of CHRE code. namespace fbs = ::chre::fbs; @@ -145,14 +143,6 @@ void DropDetect::handleNanoappMessage(const fbs::NanoappMessageT &message) { ALOGE("Unable to report physical drop to Stats service"); } else ALOGE("Unable to connect to Stats service"); - - sp<IPixelStats> client = IPixelStats::tryGetService(); - if (!client) { - ALOGE("Unable to connect to PixelStats service"); - return; - } - client->reportPhysicalDropDetected(confidence, accel_magnitude_peak_1000ths_g, - free_fall_duration_ms); } } // namespace pixel diff --git a/pixelstats/SysfsCollector.cpp b/pixelstats/SysfsCollector.cpp index 2beabb52..c0909b71 100644 --- a/pixelstats/SysfsCollector.cpp +++ b/pixelstats/SysfsCollector.cpp @@ -22,7 +22,6 @@ #include <android-base/parseint.h> #include <android-base/strings.h> #include <android/frameworks/stats/1.0/IStats.h> -#include <hardware/google/pixelstats/1.0/IPixelStats.h> #include <utils/Log.h> #include <utils/StrongPointer.h> #include <utils/Timers.h> @@ -43,7 +42,6 @@ using android::frameworks::stats::V1_0::IStats; using android::frameworks::stats::V1_0::SlowIo; using android::frameworks::stats::V1_0::SpeakerImpedance; using android::frameworks::stats::V1_0::SpeechDspStat; -using ::hardware::google::pixelstats::V1_0::IPixelStats; SysfsCollector::SysfsCollector(const struct SysfsPaths &sysfs_paths) : kSlowioReadCntPath(sysfs_paths.SlowioReadCntPath), @@ -57,7 +55,7 @@ SysfsCollector::SysfsCollector(const struct SysfsPaths &sysfs_paths) kSpeechDspPath(sysfs_paths.SpeechDspPath) {} /** - * Read the contents of kCycleCountBinsPath and report them via IPixelStats HAL. + * Read the contents of kCycleCountBinsPath and report them via IStats HAL. * The contents are expected to be N buckets total, the nth of which indicates the * number of times battery %-full has been increased with the n/N% full bucket. */ @@ -82,7 +80,6 @@ void SysfsCollector::logBatteryChargeCycles() { cycles.cycleBucket = charge_cycles; std::replace(file_contents.begin(), file_contents.end(), ' ', ','); - pixelstats_->reportChargeCycles(android::base::Trim(file_contents)); stats_->reportChargeCycles(cycles); } @@ -106,8 +103,6 @@ void SysfsCollector::logCodecFailed() { .hardwareLocation = 0, .errorCode = HardwareFailed::HardwareErrorCode::COMPLETE}; stats_->reportHardwareFailed(failed); - pixelstats_->reportHardwareFailed(IPixelStats::HardwareType::CODEC, 0, - IPixelStats::HardwareErrorCode::COMPLETE); } } @@ -128,13 +123,14 @@ void SysfsCollector::logCodec1Failed() { return; } else { ALOGE("%s report hardware fail", kCodec1Path); - pixelstats_->reportHardwareFailed(IPixelStats::HardwareType::CODEC, 1, - IPixelStats::HardwareErrorCode::COMPLETE); + HardwareFailed failed = {.hardwareType = HardwareFailed::HardwareType::CODEC, + .hardwareLocation = 1, + .errorCode = HardwareFailed::HardwareErrorCode::COMPLETE}; + stats_->reportHardwareFailed(failed); } } void SysfsCollector::reportSlowIoFromFile(const char *path, - const IPixelStats::IoOperation &operation, const SlowIo::IoOperation &operation_s) { std::string file_contents; if (path == nullptr || strlen(path) == 0) { @@ -151,7 +147,6 @@ void SysfsCollector::reportSlowIoFromFile(const char *path, } else if (slow_io_count > 0) { SlowIo slowio = {.operation = operation_s, .count = slow_io_count}; stats_->reportSlowIo(slowio); - pixelstats_->reportSlowIo(operation, slow_io_count); } // Clear the stats if (!android::base::WriteStringToFile("0", path, true)) { @@ -164,14 +159,10 @@ void SysfsCollector::reportSlowIoFromFile(const char *path, * Check for slow IO operations. */ void SysfsCollector::logSlowIO() { - reportSlowIoFromFile(kSlowioReadCntPath, IPixelStats::IoOperation::READ, - SlowIo::IoOperation::READ); - reportSlowIoFromFile(kSlowioWriteCntPath, IPixelStats::IoOperation::WRITE, - SlowIo::IoOperation::WRITE); - reportSlowIoFromFile(kSlowioUnmapCntPath, IPixelStats::IoOperation::UNMAP, - SlowIo::IoOperation::UNMAP); - reportSlowIoFromFile(kSlowioSyncCntPath, IPixelStats::IoOperation::SYNC, - SlowIo::IoOperation::SYNC); + reportSlowIoFromFile(kSlowioReadCntPath, SlowIo::IoOperation::READ); + reportSlowIoFromFile(kSlowioWriteCntPath, SlowIo::IoOperation::WRITE); + reportSlowIoFromFile(kSlowioUnmapCntPath, SlowIo::IoOperation::UNMAP); + reportSlowIoFromFile(kSlowioSyncCntPath, SlowIo::IoOperation::SYNC); } /** @@ -199,8 +190,6 @@ void SysfsCollector::logSpeakerImpedance() { .milliOhms = static_cast<int32_t>(right * 1000)}; stats_->reportSpeakerImpedance(left_obj); stats_->reportSpeakerImpedance(right_obj); - pixelstats_->reportSpeakerImpedance(0, left * 1000); - pixelstats_->reportSpeakerImpedance(1, right * 1000); } /** @@ -240,11 +229,6 @@ void SysfsCollector::logAll() { ALOGE("Unable to connect to Stats service"); return; } - pixelstats_ = IPixelStats::tryGetService(); - if (!pixelstats_) { - ALOGE("Unable to connect to PixelStats service"); - return; - } logBatteryChargeCycles(); logCodecFailed(); @@ -253,12 +237,12 @@ void SysfsCollector::logAll() { logSpeakerImpedance(); logSpeechDspStat(); - pixelstats_.clear(); + stats_.clear(); } /** * Loop forever collecting stats from sysfs nodes and reporting them via - * IPixelStats. + * IStats. */ void SysfsCollector::collect(void) { int timerfd = timerfd_create(CLOCK_BOOTTIME, 0); diff --git a/pixelstats/UeventListener.cpp b/pixelstats/UeventListener.cpp index 68af3c8e..5d0ffcf4 100644 --- a/pixelstats/UeventListener.cpp +++ b/pixelstats/UeventListener.cpp @@ -24,7 +24,6 @@ #include <android-base/strings.h> #include <android/frameworks/stats/1.0/IStats.h> #include <cutils/uevent.h> -#include <hardware/google/pixelstats/1.0/IPixelStats.h> #include <log/log.h> #include <utils/StrongPointer.h> @@ -36,7 +35,6 @@ using android::base::ReadFileToString; using android::frameworks::stats::V1_0::HardwareFailed; using android::frameworks::stats::V1_0::IStats; using android::frameworks::stats::V1_0::UsbPortOverheatEvent; -using ::hardware::google::pixelstats::V1_0::IPixelStats; namespace android { namespace hardware { @@ -62,104 +60,6 @@ bool UeventListener::ReadFileToInt(const char *const path, int *val) { return true; } -// Report connection & disconnection of devices into the USB-C connector. -void UeventListener::ReportUsbConnectorUevents(const char *power_supply_typec_mode) { - if (!power_supply_typec_mode) { - // No mode reported -> No reporting. - return; - } - - // It's attached if the string *doesn't* match. - int attached = !!strcmp(power_supply_typec_mode, "POWER_SUPPLY_TYPEC_MODE=Nothing attached"); - if (attached == is_usb_attached_) { - return; - } - is_usb_attached_ = attached; - - sp<IPixelStats> client = IPixelStats::tryGetService(); - if (!client) { - ALOGE("Unable to connect to PixelStats service"); - return; - } - - if (attached) { - client->reportUsbConnectorConnected(); - usb_connect_time_ = android::base::Timer(); - } else { - client->reportUsbConnectorDisconnected(usb_connect_time_.duration().count()); - } -} - -// Report connection & disconnection of USB audio devices. -void UeventListener::ReportUsbAudioUevents(const char *driver, const char *product, - const char *action) { - // driver is not provided on remove, so it can be NULL. Check in remove branch. - if (!product || !action) { - return; - } - - // The PRODUCT of a USB audio device is PRODUCT=VID/PID/VERSION - std::vector<std::string> halves = android::base::Split(product, "="); - if (halves.size() != 2) { - return; - } - std::vector<std::string> vidPidVer = android::base::Split(halves[1], "/"); - if (vidPidVer.size() != 3) { - return; - } - - // Parse the VID/PID as hex values. - const int kBaseHex = 16; - int32_t vid, pid; - char *vidEnd = NULL, *pidEnd = NULL; - - const char *vidC = vidPidVer[0].c_str(); - vid = strtol(vidC, &vidEnd, kBaseHex); - if ((vidC == vidEnd) || !vidEnd || (*vidEnd != '\0')) { - return; - } - - const char *pidC = vidPidVer[1].c_str(); - pid = strtol(pidC, &pidEnd, kBaseHex); - if ((pidC == pidEnd) || !pidEnd || (*pidEnd != '\0')) { - return; - } - - /* A uevent is generated for each audio interface - only report the first connected one - * for each device by storing its PRODUCT= string in attached_product_, and clearing - * it on disconnect. This also means we will only report the first USB audio device attached - * to the system. Only attempt to connect to the HAL when reporting an event. - */ - if (!attached_product_ && !strcmp(action, "ACTION=add")) { - if (!driver || strcmp(driver, "DRIVER=snd-usb-audio")) { - return; - } - usb_audio_connect_time_ = android::base::Timer(); - attached_product_ = strdup(product); - - sp<IPixelStats> client = IPixelStats::tryGetService(); - if (!client) { - ALOGE("Couldn't connect to PixelStats service for audio connect"); - return; - } - client->reportUsbAudioConnected(vid, pid); - } else if (attached_product_ && !strcmp(action, "ACTION=remove")) { - if (strcmp(attached_product_, product)) { - // Not the expected product detaching. - return; - } - free(attached_product_); - attached_product_ = NULL; - - sp<IPixelStats> client = IPixelStats::tryGetService(); - if (!client) { - ALOGE("Couldn't connect to PixelStats service for audio disconnect"); - return; - } - client->reportUsbAudioDisconnected(vid, pid, usb_audio_connect_time_.duration().count()); - } -} - void UeventListener::ReportMicBrokenOrDegraded(const int mic, const bool isbroken) { sp<IStats> stats_client = IStats::tryGetService(); @@ -174,18 +74,6 @@ void UeventListener::ReportMicBrokenOrDegraded(const int mic, const bool isbroke ALOGE("Unable to report physical drop to Stats service"); } else ALOGE("Unable to connect to Stats service"); - - /* TODO: IPixelStats will be deprecated soon */ - if (!isbroken) - return; - - sp<IPixelStats> client = IPixelStats::tryGetService(); - if (!client) { - ALOGE("Couldn't connect to PixelStats service for mic break"); - return; - } - client->reportHardwareFailed(IPixelStats::HardwareType::MICROPHONE, mic, - IPixelStats::HardwareErrorCode::COMPLETE); } void UeventListener::ReportMicStatusUevents(const char *devpath, const char *mic_status) { @@ -302,8 +190,6 @@ bool UeventListener::ProcessUevent() { } /* Process the strings recorded. */ - ReportUsbConnectorUevents(power_supply_typec_mode); - ReportUsbAudioUevents(driver, product, action); ReportMicStatusUevents(devpath, mic_break_status); ReportMicStatusUevents(devpath, mic_degrade_status); ReportUsbPortOverheatEvent(driver); @@ -314,9 +200,7 @@ bool UeventListener::ProcessUevent() { UeventListener::UeventListener(const std::string audio_uevent, const std::string overheat_path) : kAudioUevent(audio_uevent), kUsbPortOverheatPath(overheat_path), - uevent_fd_(-1), - is_usb_attached_(false), - attached_product_(nullptr) {} + uevent_fd_(-1) {} /* Thread function to continuously monitor uevents. * Exit after kMaxConsecutiveErrors to prevent spinning. */ diff --git a/pixelstats/include/pixelstats/SysfsCollector.h b/pixelstats/include/pixelstats/SysfsCollector.h index 8bf95b83..0d475f10 100644 --- a/pixelstats/include/pixelstats/SysfsCollector.h +++ b/pixelstats/include/pixelstats/SysfsCollector.h @@ -18,13 +18,11 @@ #define HARDWARE_GOOGLE_PIXEL_PIXELSTATS_SYSFSCOLLECTOR_H #include <android/frameworks/stats/1.0/IStats.h> -#include <hardware/google/pixelstats/1.0/IPixelStats.h> #include <utils/StrongPointer.h> using android::sp; using android::frameworks::stats::V1_0::IStats; using android::frameworks::stats::V1_0::SlowIo; -using ::hardware::google::pixelstats::V1_0::IPixelStats; namespace android { namespace hardware { @@ -58,8 +56,7 @@ class SysfsCollector { void logSpeakerImpedance(); void logSpeechDspStat(); - void reportSlowIoFromFile(const char *path, const IPixelStats::IoOperation &operation, - const SlowIo::IoOperation &operation_s); + void reportSlowIoFromFile(const char *path, const SlowIo::IoOperation &operation_s); const char *const kSlowioReadCntPath; const char *const kSlowioWriteCntPath; @@ -70,7 +67,6 @@ class SysfsCollector { const char *const kCodecPath; const char *const kCodec1Path; const char *const kSpeechDspPath; - sp<IPixelStats> pixelstats_; sp<IStats> stats_; }; diff --git a/pixelstats/include/pixelstats/UeventListener.h b/pixelstats/include/pixelstats/UeventListener.h index c146768e..ce3a64fd 100644 --- a/pixelstats/include/pixelstats/UeventListener.h +++ b/pixelstats/include/pixelstats/UeventListener.h @@ -19,7 +19,6 @@ #include <android-base/chrono_utils.h> #include <android/frameworks/stats/1.0/IStats.h> -#include <hardware/google/pixelstats/1.0/IPixelStats.h> using android::frameworks::stats::V1_0::UsbPortOverheatEvent; @@ -45,8 +44,6 @@ class UeventListener { private: bool ReadFileToInt(const std::string &path, int *val); bool ReadFileToInt(const char *path, int *val); - void ReportUsbConnectorUevents(const char *power_supply_typec_mode); - void ReportUsbAudioUevents(const char *driver, const char *product, const char *action); void ReportMicStatusUevents(const char *devpath, const char *mic_status); void ReportMicBrokenOrDegraded(const int mic, const bool isBroken); void ReportUsbPortOverheatEvent(const char *driver); @@ -55,11 +52,6 @@ class UeventListener { const std::string kUsbPortOverheatPath; int uevent_fd_; - - bool is_usb_attached_; // Tracks USB port connectivity state. - android::base::Timer usb_connect_time_; // Time of last USB port connection. - android::base::Timer usb_audio_connect_time_; // Time of last USB audio connection. - char *attached_product_; // PRODUCT= string of currently attached USB audio device. }; } // namespace pixel |