diff options
| author | Robert Lee <lerobert@google.com> | 2019-01-10 17:42:34 +0800 |
|---|---|---|
| committer | Robert Lee <lerobert@google.com> | 2019-01-21 13:41:35 +0800 |
| commit | de907087c19c9e4773b2f741cf33d7beddd22bf5 (patch) | |
| tree | d889d1957dc0cf6ccba474a4439d279a55edf528 /pixelstats | |
| parent | 42407c409bfe3dda8401dc136cdb1ea3e50f1ac0 (diff) | |
| download | platform_hardware_google_pixel-de907087c19c9e4773b2f741cf33d7beddd22bf5.tar.gz platform_hardware_google_pixel-de907087c19c9e4773b2f741cf33d7beddd22bf5.tar.bz2 platform_hardware_google_pixel-de907087c19c9e4773b2f741cf33d7beddd22bf5.zip | |
pixelstats: add support 3 mics broken report
Bug: 120215794
Test: manual test from pixelstats
Change-Id: If605027ae3070327c046fdca99bc5a57fe1ca862
Signed-off-by: Robert Lee <lerobert@google.com>
Diffstat (limited to 'pixelstats')
| -rw-r--r-- | pixelstats/UeventListener.cpp | 62 | ||||
| -rw-r--r-- | pixelstats/include/pixelstats/UeventListener.h | 1 |
2 files changed, 44 insertions, 19 deletions
diff --git a/pixelstats/UeventListener.cpp b/pixelstats/UeventListener.cpp index 0908382..dca95cf 100644 --- a/pixelstats/UeventListener.cpp +++ b/pixelstats/UeventListener.cpp @@ -140,29 +140,53 @@ void UeventListener::ReportUsbAudioUevents(const char *driver, const char *produ } } +void UeventListener::ReportMicBroken(const int mic) { + sp<IStats> stats_client = IStats::tryGetService(); + if (stats_client) { + HardwareFailed failure = {.hardwareType = HardwareFailed::HardwareType::MICROPHONE, + .hardwareLocation = mic, + .errorCode = HardwareFailed::HardwareErrorCode::COMPLETE}; + Return<void> ret = stats_client->reportHardwareFailed(failure); + if (!ret.isOk()) + 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("Couldn't connect to PixelStats service for mic break"); + return; + } + client->reportHardwareFailed(IPixelStats::HardwareType::MICROPHONE, mic, + IPixelStats::HardwareErrorCode::COMPLETE); +} + void UeventListener::ReportMicBroken(const char *devpath, const char *mic_break_status) { if (!devpath || !mic_break_status) return; - if (!strcmp(devpath, ("DEVPATH=" + kAudioUevent).c_str()) && - !strcmp(mic_break_status, "MIC_BREAK_STATUS=true")) { - sp<IStats> stats_client = IStats::tryGetService(); - if (stats_client) { - HardwareFailed failure = {.hardwareType = HardwareFailed::HardwareType::MICROPHONE, - .hardwareLocation = 0, - .errorCode = HardwareFailed::HardwareErrorCode::COMPLETE}; - Return<void> ret = stats_client->reportHardwareFailed(failure); - if (!ret.isOk()) - 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("Couldn't connect to PixelStats service for mic break"); - return; + if (!strcmp(devpath, ("DEVPATH=" + kAudioUevent).c_str())) { + std::vector<std::string> value = android::base::Split(mic_break_status, "="); + + if (value.size() == 2 && !value[0].compare("MIC_BREAK_STATUS")) { + if (!value[1].compare("true")) + ReportMicBroken(0); + else { + int mic_status = atoi(value[1].c_str()); + + if (mic_status > 0 && mic_status <= 7) { + for (int mic_bit = 0; mic_bit < 3; mic_bit++) + if (mic_status & (0x1 << mic_bit)) + ReportMicBroken(mic_bit); + } else if (mic_status == 0) { + // mic is ok + return; + } else { + // should not enter here + ALOGE("invalid mic status"); + return; + } + } } - client->reportHardwareFailed(IPixelStats::HardwareType::MICROPHONE, 0, - IPixelStats::HardwareErrorCode::COMPLETE); } } diff --git a/pixelstats/include/pixelstats/UeventListener.h b/pixelstats/include/pixelstats/UeventListener.h index 40d5179..98fc9d2 100644 --- a/pixelstats/include/pixelstats/UeventListener.h +++ b/pixelstats/include/pixelstats/UeventListener.h @@ -41,6 +41,7 @@ class UeventListener { void ReportUsbConnectorUevents(const char *power_supply_typec_mode); void ReportUsbAudioUevents(const char *driver, const char *product, const char *action); void ReportMicBroken(const char *devpath, const char *mic_break_status); + void ReportMicBroken(const int mic); const std::string kAudioUevent; |
