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