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