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_STUB_H 17 #define OHOS_TEST_SERVICE_STUB_H 18 19 #include "test_service_base.h" 20 21 namespace OHOS { 22 class TestServiceStub : public IRemoteStub<ITestService> { 23 public: 24 TestServiceStub(bool serialInvokeFlag = false); 25 int OnRemoteRequest(uint32_t code, 26 MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 27 bool serialInvokeFlag_ = { false }; 28 private: 29 static constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_ID_TEST, "TestServiceStub" }; 30 int32_t TransferRawData(MessageParcel &data, MessageParcel &reply); 31 int32_t ReplyRawData(MessageParcel &data, MessageParcel &reply); 32 int32_t TransferToNextProcess(MessageParcel &data, MessageParcel &reply); 33 int32_t ReadAshmem(MessageParcel &data, MessageParcel &reply); 34 int32_t ServerSyncTransaction(MessageParcel &data, MessageParcel &reply); 35 int32_t ServerAsyncTransaction(MessageParcel &data, MessageParcel &reply); 36 int32_t ServerPingService(MessageParcel &data, MessageParcel &reply); 37 int32_t ServerGetFooService(MessageParcel &data, MessageParcel &reply); 38 int32_t ServerTransactFileDesc(MessageParcel &data, MessageParcel &reply); 39 int32_t ServerStringTransaction(MessageParcel &data, MessageParcel &reply); 40 int32_t ServerZtraceTransaction(MessageParcel &data, MessageParcel &reply); 41 int32_t ServerCallingUidAndPid(MessageParcel &data, MessageParcel &reply); 42 int32_t ServerNestingSend(MessageParcel &data, MessageParcel &reply); 43 int32_t ServerAccessTokenId(MessageParcel &data, MessageParcel &reply); 44 int32_t ServerAccessTokenId64(MessageParcel &data, MessageParcel &reply); 45 int32_t ServerMessageParcelAddped(MessageParcel &data, MessageParcel &reply); 46 int32_t ServerMessageParcelAddpedWithObject(MessageParcel &data, MessageParcel &reply); 47 int32_t ServerEnableSerialInvokeFlag(MessageParcel &data, MessageParcel &reply); 48 int32_t RegisterRemoteStub(MessageParcel &data, MessageParcel &reply); 49 int32_t UnRegisterRemoteStub(MessageParcel &data, MessageParcel &reply); 50 int32_t QueryRemoteProxy(MessageParcel &data, MessageParcel &reply); 51 int32_t ServerFlushAsyncCalls(MessageParcel &data, MessageParcel &reply); 52 void InitMessageProcessMap(); 53 54 using TestServiceStubFunc = int32_t(TestServiceStub::*)(MessageParcel &data, MessageParcel &reply); 55 std::map<uint32_t, TestServiceStubFunc> funcMap_; 56 }; 57 58 } // namespace OHOS 59 #endif // OHOS_TEST_SERVICE_STUB_H 60