• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 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 #ifndef ANDROID_MEDIA_ECO_DEBUG_H_
18 #define ANDROID_MEDIA_ECO_DEBUG_H_
19 
20 #include <cutils/atomic.h>
21 #include <cutils/properties.h>
22 
23 #include "ECOData.h"
24 
25 namespace android {
26 namespace media {
27 namespace eco {
28 using aidl::android::media::eco::ECOData;
29 using aidl::android::media::eco::ECODataStatus;
30 
31 static const char* kDisableEcoServiceProperty = "vendor.media.ecoservice.disable";
32 static const char* kDebugLogsLevelProperty = "vendor.media.ecoservice.log.level";
33 static const char* kDebugLogStats = "vendor.media.ecoservice.log.stats";
34 static const char* kDebugLogStatsSize = "vendor.media.ecoservice.log.stats.size";
35 static const char* kDebugLogInfos = "vendor.media.ecoservice.log.info";
36 static const char* kDebugLogInfosSize = "vendor.media.ecoservice.log.info.size";
37 
38 // A debug variable that should only be accessed by ECOService through updateLogLevel. It is rare
39 // that this variable will have race condition. But if so, it is ok as this is just for debugging.
40 extern uint32_t gECOLogLevel;
41 
42 enum ECOLogLevel : uint32_t {
43     ECO_MSGLEVEL_DEBUG = 0x01,    ///< debug logs
44     ECO_MSGLEVEL_VERBOSE = 0x02,  ///< very detailed logs
45     ECO_MSGLEVEL_ALL = 0x03,      ///< both debug logs and detailed logs
46 };
47 
48 #define ECOLOGV(format, args...) ALOGD_IF((gECOLogLevel & ECO_MSGLEVEL_VERBOSE), format, ##args)
49 #define ECOLOGD(format, args...) ALOGD_IF((gECOLogLevel & ECO_MSGLEVEL_DEBUG), format, ##args)
50 #define ECOLOGI(format, args...) ALOGI(format, ##args)
51 #define ECOLOGW(format, args...) ALOGW(format, ##args)
52 #define ECOLOGE(format, args...) ALOGE(format, ##args)
53 
54 void updateLogLevel();
55 
56 // Convenience methods for constructing binder::Status objects for error returns
57 #define STATUS_ERROR(errorCode, errorString) ndk::ScopedAStatus::fromServiceSpecificError(errorCode)
58 
59 #define STATUS_ERROR_FMT(errorCode, errorString, ...) \
60     ndk::ScopedAStatus::fromServiceSpecificError(errorCode)
61 
62 }  // namespace eco
63 }  // namespace media
64 }  // namespace android
65 
66 #endif  // ANDROID_MEDIA_ECO_DEBUG_H_
67