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 "skeleton_wrapper.h" 17 18#include "ipc_skeleton.h" 19#include "ipc_thread_skeleton.h" 20namespace OHOS { 21namespace IpcRust { 22#ifdef CONFIG_IPC_SINGLE 23using namespace IPC_SINGLE; 24#endif 25bool SetMaxWorkThreadNum(int maxThreadNum) 26{ 27 return OHOS::IPCSkeleton::SetMaxWorkThreadNum(maxThreadNum); 28} 29 30void JoinWorkThread() 31{ 32 return OHOS::IPCSkeleton::JoinWorkThread(); 33} 34 35void StopWorkThread() 36{ 37 return OHOS::IPCSkeleton::StopWorkThread(); 38} 39 40uint64_t GetCallingPid() 41{ 42 return OHOS::IPCSkeleton::GetCallingPid(); 43} 44 45uint64_t GetCallingRealPid() 46{ 47 return OHOS::IPCSkeleton::GetCallingRealPid(); 48} 49 50uint64_t GetCallingUid() 51{ 52 return OHOS::IPCSkeleton ::GetCallingUid(); 53} 54 55uint32_t GetCallingTokenID() 56{ 57 return OHOS::IPCSkeleton ::GetCallingTokenID(); 58} 59 60uint64_t GetCallingFullTokenID() 61{ 62 return OHOS::IPCSkeleton ::GetCallingFullTokenID(); 63} 64 65uint32_t GetFirstTokenID() 66{ 67 return OHOS::IPCSkeleton ::GetFirstTokenID(); 68} 69 70uint64_t GetFirstFullTokenID() 71{ 72 return OHOS::IPCSkeleton ::GetFirstFullTokenID(); 73} 74 75uint64_t GetSelfTokenID() 76{ 77 return OHOS::IPCSkeleton::GetSelfTokenID(); 78} 79 80rust::string GetLocalDeviceID() 81{ 82 return OHOS::IPCSkeleton::GetLocalDeviceID(); 83} 84 85rust::string GetCallingDeviceID() 86{ 87 return OHOS::IPCSkeleton::GetCallingDeviceID(); 88} 89 90bool IsLocalCalling() 91{ 92 return OHOS::IPCSkeleton::IsLocalCalling(); 93} 94 95std::unique_ptr<IRemoteObjectWrapper> GetContextObject() 96{ 97 auto wrapper = std::make_unique<IRemoteObjectWrapper>(); 98 99 wrapper->is_raw_ = true; 100 wrapper->raw_ = OHOS::IPCSkeleton::GetContextObject(); 101 102 return wrapper; 103} 104 105int FlushCommands(IRemoteObjectWrapper &object) 106{ 107 return IPCSkeleton::FlushCommands(object.GetInner()); 108} 109 110rust::string ResetCallingIdentity() 111{ 112 return IPCSkeleton::ResetCallingIdentity(); 113} 114 115bool SetCallingIdentity(rust::str identity) 116{ 117 auto s = std::string(identity); 118 return IPCSkeleton::SetCallingIdentity(s); 119} 120 121bool IsHandlingTransaction() 122{ 123 if (IPCThreadSkeleton::GetActiveInvoker() != nullptr) { 124 return true; 125 } 126 127 return false; 128} 129 130} // namespace IpcRust 131} // namespace OHOS