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