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 #ifndef IPC_RUST_TEST_H 17 #define IPC_RUST_TEST_H 18 19 #include <cstddef> 20 #include <cstdint> 21 #include <memory> 22 #include <string> 23 24 #include "ipc_types.h" 25 #include "iremote_object.h" 26 #include "iremote_stub.h" 27 #include "message_parcel.h" 28 #include "refbase.h" 29 30 namespace OHOS { 31 32 struct CStringWrapper { 33 public: 34 CStringWrapper(std::string *); 35 char *raw; 36 size_t len; 37 }; 38 39 extern "C" { 40 MessageParcel *GetTestMessageParcel(); 41 MessageParcel *ReadAndWrite(MessageParcel &data); 42 CStringWrapper *GetCallingDeviceID(); 43 uint64_t GetCallingFullTokenID(); 44 uint64_t GetCallingPid(); 45 uint64_t GetCallingRealPid(); 46 uint32_t GetCallingTokenID(); 47 uint64_t GetCallingUid(); 48 uint64_t GetFirstFullTokenID(); 49 uint32_t GetFirstTokenID(); 50 uint64_t SelfTokenID(); 51 bool IsLocalCalling(); 52 CStringWrapper *LocalDeviceID(); 53 CStringWrapper *ResetCallingIdentity(); 54 }; 55 56 struct RemoteServiceStub : public IPCObjectStub { 57 public: 58 RemoteServiceStub(); 59 ~RemoteServiceStub(); 60 61 int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 62 63 int Dump(int fd, const std::vector<std::u16string> &args) override; 64 }; 65 66 } // namespace OHOS 67 68 #endif