• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 "mock_native_token.h"
17 #include "hilog_wrapper.h"
18 
19 namespace OHOS {
20 namespace AppExecFwk {
SetNativeToken()21 void MockNativeToken::SetNativeToken()
22 {
23     uint64_t tokenId;
24     const char** perms = new const char* [6];
25     perms[0] = "ohos.permission.DISTRIBUTED_DATASYNC";
26     perms[1] = "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS";
27     perms[2] = "ohos.permission.UPDATE_CONFIGURATION";
28     perms[3] = "ohos.permission.GET_RUNNING_INFO";
29     perms[4] = "ohos.permission.MANAGE_MISSIONS";
30     perms[5] = "ohos.permission.CLEAN_BACKGROUND_PROCESSES";
31     NativeTokenInfoParams infoInstance = {
32         .dcapsNum = 0,
33         .permsNum = 6,
34         .aclsNum = 0,
35         .dcaps = nullptr,
36         .perms = perms,
37         .acls = nullptr,
38         .aplStr = "system_core",
39     };
40 
41     infoInstance.processName = "SetUpTestCase";
42     tokenId = GetAccessTokenId(&infoInstance);
43     SetSelfTokenID(tokenId);
44     delete[] perms;
45 }
46 }  // namespace AppExecFwk
47 }  // namespace OHOS