• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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 #ifndef CONSTANT_H
17 #define CONSTANT_H
18 
19 #include <map>
20 #include <string>
21 
22 namespace OHOS {
23 namespace Security {
24 namespace AccessToken {
25 class Constant {
26 public:
27     enum OpCode {
28         OP_INVALID = -1,
29         OP_ANSWER_CALL = 0,
30         OP_READ_CALENDAR = 1,
31         OP_WRITE_CALENDAR = 2,
32         OP_SEND_MESSAGES = 3,
33         OP_WRITE_CALL_LOG = 4,
34         OP_READ_CALL_LOG = 5,
35         OP_READ_CELL_MESSAGES = 6,
36         OP_MICROPHONE = 7,
37         OP_RECEIVE_WAP_MESSAGES = 8,
38         OP_RECEIVE_SMS = 9,
39         OP_RECEIVE_MMS = 10,
40         OP_READ_MESSAGES = 11,
41         OP_READ_CONTACTS = 12,
42         OP_WRITE_CONTACTS = 13,
43         OP_LOCATION_IN_BACKGROUND = 14,
44         OP_LOCATION = 15,
45         OP_MEDIA_LOCATION = 16,
46         OP_APPROXIMATELY_LOCATION = 17,
47         OP_CAMERA = 18,
48         OP_READ_MEDIA = 19,
49         OP_WRITE_MEDIA = 20,
50         OP_ACTIVITY_MOTION = 21,
51         OP_READ_HEALTH_DATA = 22,
52         OP_MANAGE_VOICEMAIL = 23,
53         OP_DISTRIBUTED_DATASYNC = 24,
54         OP_READ_IMAGEVIDEO = 25,
55         OP_READ_AUDIO = 26,
56         OP_READ_DOCUMENT = 27,
57         OP_WRITE_IMAGEVIDEO = 28,
58         OP_WRITE_AUDIO = 29,
59         OP_WRITE_DOCUMENT = 30,
60         OP_READ_WHOLE_CALENDAR = 31,
61         OP_WRITE_WHOLE_CALENDAR = 32,
62     };
63 
64     enum ErrorCode {
65         FAILURE = -1,
66         SUCCESS = 0,
67     };
68 
69     const static int32_t MAX_TOTAL_RECORD = 10000;
70     const static int32_t MAX_DETAIL_RECORD = 10;
71     const static int64_t MILLISECONDS = 1000; // 1s = 1000ms
72     const static int64_t RECORD_DELETE_TIME = 30 * 86400 * MILLISECONDS;
73     const static int64_t PRECISE = 60 * MILLISECONDS;
74     const static int64_t LATEST_RECORD_TIME = 7 * 86400 * MILLISECONDS;
75 
76     const static std::map<std::string, int32_t> PERMISSION_OPCODE_MAP;
77 public:
78     static bool TransferPermissionToOpcode(const std::string& permissionName, int32_t& opCode);
79     static bool TransferOpcodeToPermission(int32_t opCode, std::string& permissionName);
80 };
81 } // namespace AccessToken
82 } // namespace Security
83 } // namespace OHOS
84 
85 #endif // CONSTANT_H
86