1 /* 2 * Copyright 2025 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 #pragma once 18 19 #include <aidl/android/frameworks/stats/IStats.h> 20 #include <hardware/google/pixel/pixelstats/pixelatoms.pb.h> 21 22 #include "SessionMetrics.h" 23 24 namespace aidl { 25 namespace google { 26 namespace hardware { 27 namespace power { 28 namespace impl { 29 namespace pixel { 30 31 using aidl::android::frameworks::stats::IStats; 32 using android::frameworks::stats::VendorAtomValue; 33 34 class MetricUploader { 35 public: 36 ~MetricUploader() = default; 37 MetricUploader(MetricUploader const &) = delete; 38 MetricUploader(MetricUploader &&) = delete; 39 MetricUploader &operator=(MetricUploader const &) = delete; 40 MetricUploader &operator=(MetricUploader &&) = delete; 41 42 bool init(); 43 bool uploadMetrics(const SessionJankStatsWithThermal &sessMetrics); 44 45 // Singleton getInstance()46 static MetricUploader *getInstance() { 47 static MetricUploader instance{}; 48 return &instance; 49 } 50 51 private: 52 MetricUploader() = default; 53 bool reportAtom(const int32_t &atomId, std::vector<VendorAtomValue> &&values); 54 bool connectIStatsService(); 55 56 std::shared_ptr<IStats> mIStatsClient; 57 }; 58 59 } // namespace pixel 60 } // namespace impl 61 } // namespace power 62 } // namespace hardware 63 } // namespace google 64 } // namespace aidl 65