• 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 #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 #include "base/utils/macros.h"
28 
29 namespace OHOS {
30 namespace Ace {
31 class ACE_FORCE_EXPORT UIServiceStub : public IRemoteStub<IUIService> {
32 public:
33     UIServiceStub();
34     ~UIServiceStub() override;
35     int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override;
36 
37 private:
38     int32_t OnRequestCallBackInner(MessageParcel& data, MessageParcel& reply);
39     int32_t OnPushCallBackInner(MessageParcel& data, MessageParcel& reply);
40     int32_t OnReturnRequestInner(MessageParcel& data, MessageParcel& reply);
41     using RequestFuncType = int32_t (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     explicit UIServiceCallbackRecipient(RemoteDiedHandler handler);
55     ~UIServiceCallbackRecipient() override;
56     void OnRemoteDied(const wptr<IRemoteObject>& remote) override;
57 
58 private:
59     RemoteDiedHandler handler_;
60 };
61 }  // namespace Ace
62 }  // namespace OHOS
63 #endif  // OHOS_AAFWK_UI_SERVICE_STUB_H
64