• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-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 
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 MessageParcel *GetMessageParcelContainingInvalidString();
43 CStringWrapper *GetCallingDeviceID();
44 uint64_t GetCallingFullTokenID();
45 uint64_t GetCallingPid();
46 uint64_t GetCallingRealPid();
47 uint32_t GetCallingTokenID();
48 uint64_t GetCallingUid();
49 uint64_t GetFirstFullTokenID();
50 uint32_t GetFirstTokenID();
51 uint64_t SelfTokenID();
52 bool IsLocalCalling();
53 CStringWrapper *LocalDeviceID();
54 CStringWrapper *ResetCallingIdentity();
55 };
56 
57 struct RemoteServiceStub : public IPCObjectStub {
58 public:
59     RemoteServiceStub();
60     ~RemoteServiceStub();
61 
62     int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
63 
64     int Dump(int fd, const std::vector<std::u16string> &args) override;
65 };
66 
67 } // namespace OHOS
68 
69 #endif