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 #ifndef OHOS_AAFWK_UI_SERVICE_STUB_H 16 #define OHOS_AAFWK_UI_SERVICE_STUB_H 17 18 #include <memory> 19 #include <map> 20 21 #include "ui_service_interface.h" 22 #include "nocopyable.h" 23 24 #include <iremote_object.h> 25 #include <iremote_stub.h> 26 27 namespace OHOS { 28 namespace Ace { 29 class UIServiceStub : public IRemoteStub<IUIService> { 30 public: 31 UIServiceStub(); 32 virtual ~UIServiceStub(); 33 34 int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; 35 36 private: 37 38 int OnRequestCallBackInner(MessageParcel& data, MessageParcel& reply); 39 int OnPushCallBackInner(MessageParcel& data, MessageParcel& reply); 40 int OnReturnRequestInner(MessageParcel& data, MessageParcel& reply); 41 using RequestFuncType = int (UIServiceStub::*)(MessageParcel& data, MessageParcel& reply); 42 std::map<uint32_t, RequestFuncType> requestFuncMap_; 43 44 DISALLOW_COPY_AND_MOVE(UIServiceStub); 45 }; 46 47 /** 48 * @class UIServiceCallbackRecipient 49 * UIServiceCallbackRecipient notices IRemoteBroker died. 50 */ 51 class UIServiceCallbackRecipient : public IRemoteObject::DeathRecipient { 52 public: 53 using RemoteDiedHandler = std::function<void(const wptr<IRemoteObject>&)>; 54 UIServiceCallbackRecipient(RemoteDiedHandler handler); 55 virtual ~UIServiceCallbackRecipient(); 56 virtual void OnRemoteDied(const wptr<IRemoteObject>& remote); 57 58 private: 59 RemoteDiedHandler handler_; 60 }; 61 } // namespace Ace 62 } // namespace OHOS 63 #endif // OHOS_AAFWK_UI_SERVICE_STUB_H 64