1 /* 2 * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef X_POWER_COMMONT_H 17 #define X_POWER_COMMONT_H 18 19 #include <functional> 20 #include <map> 21 #include <string> 22 23 #include "xpower_plugin_config.pb.h" 24 25 26 struct OptimizeConfig { 27 std::uint32_t messageType; 28 std::string packageName; 29 std::function<void(const std::uint32_t, const std::uint8_t *, size_t)> callback; 30 }; 31 32 enum OptimizeMessageType : uint32_t { 33 MESSAGE_OPTIMIZE_STOP = 0, 34 MESSAGE_REAL_BATTERY = 1 << 0, 35 MESSAGE_APP_STATISTIC = 1 << 1, 36 MESSAGE_APP_DETAIL = 1 << 2, 37 MESSAGE_COMPONENT_TOP = 1 << 3, 38 MESSAGE_ABNORMAL_EVENTS = 1 << 4, 39 MESSAGE_THERMAL_REPORT = 1 << 5, 40 MESSAGE_OPTIMIZE_MAX = (MESSAGE_THERMAL_REPORT << 1) - 1, 41 }; 42 struct PowerOptimizeData { 43 std::unique_ptr<uint8_t[]> baseData; // save the powere message data 44 size_t length; 45 std::uint32_t messageType; 46 }; 47 using StartOptimizeMode = void *(*)(struct OptimizeConfig &); 48 using StopOptimizeMode = bool (*)(void *); 49 50 #endif