• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (c) 2025 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 TEST_TOKEN_COMMON_H
17 #define TEST_TOKEN_COMMON_H
18 
19 #include "access_token.h"
20 #include "accesstoken_kit.h"
21 #include "atm_tools_param_info.h"
22 #include "nativetoken_kit.h"
23 #include "permission_def.h"
24 #include "permission_state_full.h"
25 #include "token_setproc.h"
26 
27 namespace OHOS {
28     namespace CameraStandard {
29         using namespace OHOS::Security::AccessToken;
30 
31         class TestToken {
32         public:
TestToken()33             TestToken() : TestToken(true) {}
TestToken(bool isSystemApp)34             TestToken(bool isSystemApp) : isSystemApp_(isSystemApp) {}
35             bool GetAllCameraPermission();
36             uint64_t GetMockedTokenId();
37             uint64_t GetOriginalTokenId();
38             void AddPermission(const std::string& permission);
39 
40         private:
41             static uint64_t GetTokenId(const AtmToolsParamInfo& info);
42             static uint64_t GetTokenIdFromProcess(const std::string& process);
43             static bool MockTokenId(const std::string& process);
44             static uint64_t shellTokenID_;
45             bool isSystemApp_ = true;
46             std::vector<std::string> permissions_;
47         };
48 
49     } // namespace CameraStandard
50 } // namespace OHOS
51 #endif
52