• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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>
20 #include <utils/StrongPointer.h>
21 
22 #include <pixelstats/SysfsCollector.h>
23 #include <pixelstats/DropDetect.h>
24 #include <pixelstats/UeventListener.h>
25 
26 using android::sp;
27 using android::hardware::google::pixel::SysfsCollector;
28 using android::hardware::google::pixel::DropDetect;
29 using android::hardware::google::pixel::UeventListener;
30 
31 const struct SysfsCollector::SysfsPaths sysfs_paths = {
32     .SlowioReadCntPath = "/sys/devices/platform/soc/7c4000.sdhci/mmc_host/mmc0/slowio_read_cnt",
33     .SlowioWriteCntPath = "/sys/devices/platform/soc/7c4000.sdhci/mmc_host/mmc0/slowio_write_cnt",
34     .SlowioUnmapCntPath =
35         "/sys/devices/platform/soc/7c4000.sdhci/mmc_host/mmc0/slowio_discard_cnt",
36     .SlowioSyncCntPath = "/sys/devices/platform/soc/7c4000.sdhci/mmc_host/mmc0/slowio_flush_cnt",
37     .CycleCountBinsPath = "/sys/class/power_supply/bms/device/cycle_counts_bins",
38     .ImpedancePath = "/sys/class/misc/msm_cirrus_playback/resistance_left_right",
39     .CodecPath =
40         "/sys/devices/platform/soc/c440000.qcom,spmi/spmi-0/spmi0-03/"
41         "c440000.qcom,spmi:qcom,pm660l@3:analog-codec@f000/codec_state",
42     .Codec1Path =
43         "/sys/devices/platform/soc/a88000.i2c/i2c-0/0-0057/codec_state",
44 };
45 
main()46 int main() {
47     LOG(INFO) << "starting PixelStats";
48 
49     sp<DropDetect> dropDetector = DropDetect::start();
50     if (!dropDetector) {
51         LOG(ERROR) << "Unable to launch drop detection";
52         return 1;
53     }
54 
55     UeventListener ueventListener("");
56     std::thread listenThread(&UeventListener::ListenForever, &ueventListener);
57     listenThread.detach();
58 
59     SysfsCollector collector(sysfs_paths);
60     collector.collect();  // This blocks forever.
61 
62     return 0;
63 }
64