1 /*
2 * Copyright (c) 2020-2022 Huawei Device Co., Ltd.
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 #include <hilog_common.h>
17 #include <log_utils.h>
18
19 #include "log_domains.h"
20
21 namespace OHOS {
22 namespace HiviewDFX {
23 using namespace std;
24
25 static const KVMap<uint32_t, string> g_DomainList({
26 {0xD000100, "Bluetooth"},
27 {0xD000300, "NFC"},
28 {0xD000F00, "For test using"},
29 {0xD001100, "AppExecFwk"},
30 {0xD001200, "Notification"},
31 {0xD001300, "AAFwk"},
32 {0xD001400, "Graphics"},
33 {0xD001500, "Communication"},
34 {0xD001600, "DistributedData"},
35 {0xD001700, "Resource"},
36 {0xD001800, "SAMgr"},
37 {0xD001B00, "Account"},
38 {0xD001C00, "MiscService"},
39 {0xD001D00, "Barrierfree"},
40 {0xD001E00, "Global"},
41 {0xD001F00, "Telephony"},
42 {0xD002100, "AI"},
43 {0xD002200, "MSDP"},
44 {0xD002300, "Location"},
45 {0xD002400, "UserIAM"},
46 {0xD002500, "Drivers"},
47 {0xD002600, "Kernel"},
48 {0xD002700, "Sensors"},
49 {0xD002800, "MultiModelInput"},
50 {0xD002900, "Power"},
51 {0xD002A00, "USB"},
52 {0xD002B00, "MultiMedia"},
53 {0xD002C00, "StartUp"},
54 {0xD002D00, "DFX"},
55 {0xD002E00, "Update"},
56 {0xD002F00, "Security"},
57 {0xD003100, "TestSystem"},
58 {0xD003200, "TestSystem"},
59 {0xD003900, "Ace"},
60 {0xD003B00, "JSConsole"},
61 {0xD003D00, "Utils"},
62 {0xD003F00, "CompilerRuntime"},
63 {0xD004100, "DistributedHardware"},
64 {0xD004200, "Windows"},
65 {0xD004300, "Storage"},
66 {0xD004400, "DeviceProfile"},
67 {0xD004500, "WebView"},
68 {0xD004600, "Interconnection"},
69 {0xD004700, "Cloud"},
70 {0xD004800, "Manufacture"},
71 {0xD004900, "HealthSport"},
72 {0xD005100, "PcService"},
73 {0xD005200, "WpaSupplicant"},
74 {0xD005300, "Push"},
75 {0xD005400, "CarService"},
76 {0xD005500, "DeviceCloudGateway"},
77 {0xD005600, "AppSecurityPrivacy"},
78 {0xD005700, "DSoftBus"},
79 {0xD005800, "FindNetwork"},
80 {0xD005900, "VirtService"},
81 {0xD005A00, "AccessControl"},
82 {0xD005B00, "Tee"},
83 {0xD005C00, "Connectivity"},
84 {0xD005D00, "XTS"},
85 {0xD00AD00, "ASystem"},
86 }, __UINT32_MAX__, "Invalid");
87
88 static const uint32_t APP_DOMAIN_MASK = 0xFFFF0000;
89 static const uint32_t OS_SUB_DOMAIN_MASK = 0xFFFFFF00;
IsValidDomain(LogType type,uint32_t domain)90 bool IsValidDomain(LogType type, uint32_t domain)
91 {
92 if (type == LOG_APP) {
93 if ((domain & APP_DOMAIN_MASK) == 0) {
94 return true;
95 }
96 return false;
97 } else {
98 if (domain >= DOMAIN_OS_MIN && domain <= DOMAIN_OS_MAX) {
99 return g_DomainList.IsValidKey((domain & OS_SUB_DOMAIN_MASK));
100 }
101 return false;
102 }
103 }
104 } // namespace HiviewDFX
105 } // namespace OHOS