Robin Peng | c2b5ca9 | 2021-02-23 20:00:28 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #define LOG_TAG "pixelstats" |
| 18 | |
| 19 | #include <android-base/logging.h> |
Stephane Lee | 33a1ce7 | 2021-03-17 15:00:12 -0700 | [diff] [blame] | 20 | #include <thread> |
Robin Peng | c2b5ca9 | 2021-02-23 20:00:28 +0800 | [diff] [blame] | 21 | |
| 22 | #include <pixelstats/SysfsCollector.h> |
Stephane Lee | 33a1ce7 | 2021-03-17 15:00:12 -0700 | [diff] [blame] | 23 | #include <pixelstats/UeventListener.h> |
Robin Peng | c2b5ca9 | 2021-02-23 20:00:28 +0800 | [diff] [blame] | 24 | |
| 25 | using android::hardware::google::pixel::SysfsCollector; |
Stephane Lee | 33a1ce7 | 2021-03-17 15:00:12 -0700 | [diff] [blame] | 26 | using android::hardware::google::pixel::UeventListener; |
Robin Peng | c2b5ca9 | 2021-02-23 20:00:28 +0800 | [diff] [blame] | 27 | |
| 28 | #define UFSHC_PATH(filename) "/dev/sys/block/bootdevice/" #filename |
| 29 | const struct SysfsCollector::SysfsPaths sysfs_paths = { |
| 30 | .SlowioReadCntPath = UFSHC_PATH(slowio_read_cnt), |
| 31 | .SlowioWriteCntPath = UFSHC_PATH(slowio_write_cnt), |
| 32 | .SlowioUnmapCntPath = UFSHC_PATH(slowio_unmap_cnt), |
| 33 | .SlowioSyncCntPath = UFSHC_PATH(slowio_sync_cnt), |
| 34 | .UFSLifetimeA = UFSHC_PATH(health_descriptor/life_time_estimation_a), |
| 35 | .UFSLifetimeB = UFSHC_PATH(health_descriptor/life_time_estimation_b), |
| 36 | .UFSLifetimeC = UFSHC_PATH(health_descriptor/life_time_estimation_c), |
Ocean Chen | 91262dd | 2021-03-08 17:34:00 +0800 | [diff] [blame] | 37 | .UFSHostResetPath = UFSHC_PATH(err_stats/dev_reset_count), |
Robin Peng | c2b5ca9 | 2021-02-23 20:00:28 +0800 | [diff] [blame] | 38 | .F2fsStatsPath = "/sys/fs/f2fs/", |
Roger Fang | 1d6c433 | 2021-04-16 09:52:21 +0800 | [diff] [blame] | 39 | .ImpedancePath = "/sys/devices/platform/audiometrics/speaker_impedance", |
| 40 | .CodecPath = "/sys/devices/platform/audiometrics/codec_state", |
Robin Peng | c2b5ca9 | 2021-02-23 20:00:28 +0800 | [diff] [blame] | 41 | }; |
| 42 | |
Roger Fang | d351a65 | 2021-05-06 16:45:25 +0800 | [diff] [blame^] | 43 | const char *const kAudioUevent = "/devices/virtual/amcs/amcs"; |
| 44 | |
Robin Peng | c2b5ca9 | 2021-02-23 20:00:28 +0800 | [diff] [blame] | 45 | int main() { |
| 46 | LOG(INFO) << "starting PixelStats"; |
| 47 | |
Roger Fang | d351a65 | 2021-05-06 16:45:25 +0800 | [diff] [blame^] | 48 | UeventListener ueventListener(kAudioUevent); |
Stephane Lee | 33a1ce7 | 2021-03-17 15:00:12 -0700 | [diff] [blame] | 49 | std::thread listenThread(&UeventListener::ListenForever, &ueventListener); |
| 50 | listenThread.detach(); |
| 51 | |
Robin Peng | c2b5ca9 | 2021-02-23 20:00:28 +0800 | [diff] [blame] | 52 | SysfsCollector collector(sysfs_paths); |
| 53 | collector.collect(); // This blocks forever. |
| 54 | |
| 55 | return 0; |
| 56 | } |