• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 #include "ipc_skeleton_imp.h"
16 
17 #include "ipc_skeleton.h"
18 #include "ipc_utils_ffi.h"
19 #include "iremote_invoker.h"
20 #include "remote_object_impl.h"
21 
22 namespace OHOS {
GetCallingPid()23 int32_t GetCallingPid()
24 {
25     return OHOS::IPCSkeleton::GetCallingPid();
26 }
27 
GetCallingUid()28 int32_t GetCallingUid()
29 {
30     return OHOS::IPCSkeleton::GetCallingUid();
31 }
32 
33 // 0:remoteObject 1:remoteProxy
GetContextObject()34 RetDataI64 GetContextObject()
35 {
36     sptr<IRemoteObject> object = IPCSkeleton::GetContextObject();
37     if (object == nullptr) {
38         ZLOGE(LOG_LABEL, "fatal error, could not get registry object");
39         return RetDataI64 { 0, 0 };
40     }
41     int32_t type = object->IsProxyObject() ? 1 : 0;
42     return RetDataI64{type, CJ_rpc_CreateRemoteObject(object)};
43 }
44 
GetCallingTokenId()45 uint32_t GetCallingTokenId()
46 {
47     return OHOS::IPCSkeleton::GetCallingTokenID();
48 }
49 
GetCallingDeviceID()50 char* GetCallingDeviceID()
51 {
52     return MallocCString(OHOS::IPCSkeleton::GetCallingDeviceID());
53 }
54 
GetLocalDeviceID()55 char* GetLocalDeviceID()
56 {
57     return MallocCString(OHOS::IPCSkeleton::GetLocalDeviceID());
58 }
59 
IsLocalCalling()60 bool IsLocalCalling()
61 {
62     return OHOS::IPCSkeleton::IsLocalCalling();
63 }
64 
FlushCmdBuffer(int64_t object)65 void FlushCmdBuffer(int64_t object)
66 {
67     sptr<IRemoteObject> target = CJ_rpc_getNativeRemoteObject(object);
68     IPCSkeleton::FlushCommands(target);
69 }
70 } // namespace OHOS