blob: 6ef936bad6be0d358a0f3bd771fecca4dbf46fb9 [file] [log] [blame]
Robin Pengc2b5ca92021-02-23 20:00:28 +08001/*
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>
Robin Pengc2b5ca92021-02-23 20:00:28 +080020#include <pixelstats/SysfsCollector.h>
Stephane Lee33a1ce72021-03-17 15:00:12 -070021#include <pixelstats/UeventListener.h>
Robin Pengc2b5ca92021-02-23 20:00:28 +080022
Denny cy Lee8101fbc2021-05-18 14:50:01 +080023#include <thread>
24
Robin Pengc2b5ca92021-02-23 20:00:28 +080025using android::hardware::google::pixel::SysfsCollector;
Stephane Lee33a1ce72021-03-17 15:00:12 -070026using android::hardware::google::pixel::UeventListener;
Robin Pengc2b5ca92021-02-23 20:00:28 +080027
28#define UFSHC_PATH(filename) "/dev/sys/block/bootdevice/" #filename
29const struct SysfsCollector::SysfsPaths sysfs_paths = {
Denny cy Lee8101fbc2021-05-18 14:50:01 +080030 .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 .CycleCountBinsPath = "/sys/class/power_supply/battery/cycle_counts",
35 .UFSLifetimeA = UFSHC_PATH(health_descriptor/life_time_estimation_a),
36 .UFSLifetimeB = UFSHC_PATH(health_descriptor/life_time_estimation_b),
37 .UFSLifetimeC = UFSHC_PATH(health_descriptor/life_time_estimation_c),
38 .UFSHostResetPath = UFSHC_PATH(err_stats/dev_reset_count),
39 .F2fsStatsPath = "/sys/fs/f2fs/",
40 .ImpedancePath = "/sys/devices/platform/audiometrics/speaker_impedance",
41 .CodecPath = "/sys/devices/platform/audiometrics/codec_state",
42 .EEPROMPath = "/dev/battery_history"};
Denny cy Leef2227732021-06-08 17:19:41 +080043const struct UeventListener::UeventPaths ueventPaths = {
44 .AudioUevent = "/devices/virtual/amcs/amcs",
45 .WirelessChargerPtmcPath = "/sys/class/power_supply/wireless/device/ptmc_id"};
Roger Fangd351a652021-05-06 16:45:25 +080046
Robin Pengc2b5ca92021-02-23 20:00:28 +080047int main() {
48 LOG(INFO) << "starting PixelStats";
49
Denny cy Leef2227732021-06-08 17:19:41 +080050 UeventListener ueventListener(ueventPaths);
Stephane Lee33a1ce72021-03-17 15:00:12 -070051 std::thread listenThread(&UeventListener::ListenForever, &ueventListener);
52 listenThread.detach();
53
Robin Pengc2b5ca92021-02-23 20:00:28 +080054 SysfsCollector collector(sysfs_paths);
55 collector.collect(); // This blocks forever.
56
57 return 0;
58}