1 /*
2  * Copyright (C) 2024 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 #include "nfc_access_token_mock.h"
16 
17 #include "accesstoken_kit.h"
18 #include "nativetoken_kit.h"
19 #include "token_setproc.h"
20 
21 namespace OHOS {
22 namespace NFC {
23 
SetNativeTokenInfo()24 void NfcAccessTokenMock::SetNativeTokenInfo()
25 {
26     constexpr int permissionNum = 3;
27     const char *perms[permissionNum] = {
28         "ohos.permission.MANAGE_SECURE_SETTINGS",
29         "ohos.permission.NFC_TAG",
30         "ohos.permission.NFC_CARD_EMULATION"
31     };
32     NativeTokenInfoParams infoInstance = {
33         .dcapsNum = 0,
34         .permsNum = permissionNum,
35         .aclsNum = 0,
36         .dcaps = nullptr,
37         .perms = perms,
38         .acls = nullptr,
39         .processName = "test_nfc_service",
40         .aplStr = "system_basic",
41     };
42     uint64_t tokenId = GetAccessTokenId(&infoInstance);
43     SetSelfTokenID(tokenId);
44     Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
45 }
46 }  // namespace NFC
47 }  // namespace OHOS
48