• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 "ipc_skeleton.h"
17 #include "time_service_client.h"
18 #include "accesstoken_kit.h"
19 
20 namespace {
21     bool g_mockStartTimer = true;
22     bool g_mockGetTokenTypeFlag = true;
23 }
24 
MockStartTimer(bool mockRet)25 void MockStartTimer(bool mockRet)
26 {
27     g_mockStartTimer = mockRet;
28 }
29 
MockGetTokenTypeFlag(bool mockRet)30 void MockGetTokenTypeFlag(bool mockRet)
31 {
32     g_mockGetTokenTypeFlag = mockRet;
33 }
34 
35 namespace OHOS {
36 #ifdef CONFIG_IPC_SINGLE
37 using namespace IPC_SINGLE;
38 #endif
GetCallingUid()39 int32_t IPCSkeleton::GetCallingUid()
40 {
41     int32_t uid = 1;
42     return uid;
43 }
44 
GetCallingPid()45 int32_t IPCSkeleton::GetCallingPid()
46 {
47     int32_t pid = 1;
48     return pid;
49 }
50 
51 namespace MiscServices {
StartTimer(uint64_t timerId,uint64_t triggerTime)52 bool TimeServiceClient::StartTimer(uint64_t timerId, uint64_t triggerTime)
53 {
54     return g_mockStartTimer;
55 }
56 
StopTimer(uint64_t timerId)57 bool TimeServiceClient::StopTimer(uint64_t timerId)
58 {
59     return g_mockStartTimer;
60 }
61 
CreateTimer(std::shared_ptr<ITimerInfo> TimerOptions)62 uint64_t TimeServiceClient::CreateTimer(std::shared_ptr<ITimerInfo> TimerOptions)
63 {
64     return g_mockStartTimer;
65 }
66 
DestroyTimer(uint64_t timerId)67 bool TimeServiceClient::DestroyTimer(uint64_t timerId)
68 {
69     return g_mockStartTimer;
70 }
71 } // namespace MiscServices
72 
73 namespace Security {
74 namespace AccessToken {
GetTokenTypeFlag(AccessTokenID tokenID)75 ATokenTypeEnum AccessTokenKit::GetTokenTypeFlag(AccessTokenID tokenID)
76 {
77     if (g_mockGetTokenTypeFlag) {
78         return TypeATokenTypeEnum::TOKEN_SHELL;
79     }
80     return TypeATokenTypeEnum::TOKEN_HAP;
81 }
82 }
83 }
84 }  // namespace OHOS
85