• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 OHOS_TEST_SERVICE_SKELETON_H
17 #define OHOS_TEST_SERVICE_SKELETON_H
18 
19 #include <map>
20 #include "ipc_debug.h"
21 #include "iremote_broker.h"
22 #include "iremote_stub.h"
23 #include "iremote_proxy.h"
24 #include "foo_service.h"
25 #include "ipc_file_descriptor.h"
26 #include "log_tags.h"
27 
28 namespace OHOS {
29 
30 class ITestService : public IRemoteBroker {
31 public:
32     enum {
33         TRANS_ID_SYNC_TRANSACTION = 1,
34         TRANS_ID_ASYNC_TRANSACTION = 2,
35         TRANS_ID_PING_SERVICE = 3,
36         TRANS_ID_GET_FOO_SERVICE = 4,
37         TRANS_ID_TRANSACT_FILE_DESC = 5,
38         TRANS_ID_STRING_TRANSACTION = 6,
39         TRANS_ID_ZTRACE_TRANSACTION = 7,
40         TRANS_ID_LOOP_TRANSACTION = 8,
41         TRANS_ID_DUMP_SERVICE = 9,
42         TRANS_ID_RAWDATA_TRANSACTION = 10,
43         TRANS_ID_RAWDATA_REPLY = 11,
44         TRANS_ID_CALLING_UID_PID = 12,
45         TRANS_ID_FLUSH_ASYNC_CALLS = 13,
46         TRANS_ID_MULTIPLE_PROCESSES = 14,
47         TRANS_ID_ASHMEM = 15,
48         TRANS_ID_ASYNC_DUMP_SERVICE = 16,
49         TRANS_ID_NESTING_SEND = 17,
50         TRANS_ID_ACCESS_TOKENID = 18,
51         TRANS_MESSAGE_PARCEL_ADDPED = 19,
52         TRANS_MESSAGE_PARCEL_ADDPED_WITH_OBJECT = 20,
53         TRANS_ID_ACCESS_TOKENID_64 = 21,
54         TRANS_ENABLE_SERIAL_INVOKE_FLAG = 22,
55         TRANS_ID_REGISTER_REMOTE_STUB_OBJECT = 23,
56         TRANS_ID_UNREGISTER_REMOTE_STUB_OBJECT = 24,
57         TRANS_ID_QUERY_REMOTE_PROXY_OBJECT = 25,
58         TRANS_ID_QUERY_THREAD_INVOCATION_STATE = 26,
59     };
60 public:
61     virtual int TestSyncTransaction(int value, int &reply, int delayTime = 0) = 0;
62     virtual int TestAsyncTransaction(int data, int timeout = 0) = 0;
63     virtual int TestAsyncCallbackTrans(int data, int &reply, int timeout = 0) = 0;
64     virtual int TestGetFileDescriptor() = 0;
65     virtual int TestPingService(const std::u16string &serviceName) = 0;
66     virtual int TestStringTransaction(const std::string &data) = 0;
67     virtual int TestZtraceTransaction(std::string &send, std::string &reply, int len) = 0;
68     virtual int TestDumpService() = 0;
69     virtual int TestRawDataTransaction(int length, int &reply) = 0;
70     virtual int TestRawDataReply(int length) = 0;
71     virtual sptr<IFoo> TestGetFooService() = 0;
72     virtual int TestCallingUidPid() = 0;
73     virtual int TestFlushAsyncCalls(int count, int length) = 0;
74     virtual int TestMultipleProcesses(int data, int &rep, int delayTime) = 0;
75     virtual std::u16string TestAshmem(sptr<Ashmem> ashmem, int32_t contentSize) = 0;
76     virtual int TestNestingSend(int sendCode, int &replyCode) = 0;
77     virtual int TestAccessTokenID(int32_t ftoken_expected) = 0;
78     virtual int TestAccessTokenID64(uint64_t token_expected, uint64_t ftoken_expected) = 0;
79     virtual int TestMessageParcelAppend(MessageParcel &dst, MessageParcel &src) = 0;
80     virtual int TestMessageParcelAppendWithIpc(MessageParcel &dst, MessageParcel &src,
81         MessageParcel &reply, bool withObject) = 0;
82     virtual int TestEnableSerialInvokeFlag() = 0;
83 
84     virtual int TestRegisterRemoteStub(const char *descriptor, const sptr<IRemoteObject> object) = 0;
85     virtual int TestUnRegisterRemoteStub(const char *descriptor) = 0;
86     virtual sptr<IRemoteObject> TestQueryRemoteProxy(const char *descriptor) = 0;
87     virtual int TestSendTooManyRequest(int data, int &reply) = 0;
88     virtual int TestMultiThreadSendRequest(int data, int &reply) = 0;
89     virtual int TestQueryThreadInvocationState() = 0;
90 
91 public:
92     DECLARE_INTERFACE_DESCRIPTOR(u"test.ipc.ITestService");
93 };
94 
95 } // namespace OHOS
96 #endif // OHOS_TEST_SERVICE_SKELETON_H
97