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 
16 #include "mock_accesstoken_kit.h"
17 #include "mock_my_flag.h"
18 
19 namespace OHOS {
20 namespace Security {
21 namespace AccessToken {
22 using MyFlag = OHOS::AAFwk::MyFlag;
23 
GetTokenTypeFlag(AccessTokenID tokenID)24 ATokenTypeEnum AccessTokenKit::GetTokenTypeFlag(AccessTokenID tokenID)
25 {
26     if (MyFlag::tokenInfos.find(tokenID) != MyFlag::tokenInfos.end()) {
27         return MyFlag::tokenInfos[tokenID].tokenType;
28     }
29     return ATokenTypeEnum::TOKEN_INVALID;
30 }
31 
GetNativeTokenInfo(AccessTokenID tokenID,NativeTokenInfo & nativeTokenInfoRes)32 int AccessTokenKit::GetNativeTokenInfo(AccessTokenID tokenID, NativeTokenInfo& nativeTokenInfoRes)
33 {
34     if (MyFlag::tokenInfos.find(tokenID) != MyFlag::tokenInfos.end()) {
35         nativeTokenInfoRes.processName = MyFlag::tokenInfos[tokenID].processName;
36         return 0;
37     }
38     return -1;
39 }
40 
GetHapTokenInfo(AccessTokenID tokenID,HapTokenInfo & hapInfo)41 int AccessTokenKit::GetHapTokenInfo(AccessTokenID tokenID, HapTokenInfo &hapInfo)
42 {
43     if (MyFlag::tokenInfos.find(tokenID) != MyFlag::tokenInfos.end()) {
44         hapInfo.bundleName = MyFlag::tokenInfos[tokenID].bundleName;
45         return 0;
46     }
47     return -1;
48 }
49 } // namespace AccessToken
50 } // namespace Security
51 } // namespace OHOS