1 /*
2  * Copyright (c) 2024 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 ACCESS_FORM_MANAGER_ACCESS_PROXY_H
17 #define ACCESS_FORM_MANAGER_ACCESS_PROXY_H
18 
19 #include <iremote_proxy.h>
20 #include "form_instance.h"
21 #include "running_form_info.h"
22 #include "service_ipc_interface_code.h"
23 
24 namespace OHOS {
25 namespace Security {
26 namespace AccessToken {
27 class IJsFormStateObserver : public IRemoteBroker {
28 public:
29     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.aafwk.IJsFormStateObserver");
30 
31     virtual int32_t NotifyWhetherFormsVisible(const FormVisibilityType visibleType,
32         const std::string &bundleName, std::vector<FormInstance> &formInstances) = 0;
33 
34     enum class Message {
35         FORM_STATE_OBSERVER_NOTIFY_WHETHER_FORMS_VISIBLE = 4304,
36     };
37 };
38 
39 class IFormMgr : public IRemoteBroker {
40 public:
41     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.FormMgr")
42 
43     virtual int32_t RegisterAddObserver(const std::string &bundleName, const sptr<IRemoteObject> &callerToken) = 0;
44     virtual int32_t RegisterRemoveObserver(const std::string &bundleName, const sptr<IRemoteObject> &callerToken) = 0;
45     virtual bool HasFormVisible(const uint32_t tokenId) = 0;
46 
47     enum class Message {
48         FORM_MGR_REGISTER_ADD_OBSERVER = 3053,
49         FORM_MGR_REGISTER_REMOVE_OBSERVER = 3054,
50         FORM_MGR_HAS_FORM_VISIBLE_WITH_TOKENID = 3067,
51     };
52 };
53 
54 class FormManagerAccessProxy : public IRemoteProxy<IFormMgr> {
55 public:
FormManagerAccessProxy(const sptr<IRemoteObject> & impl)56     explicit FormManagerAccessProxy(const sptr<IRemoteObject>& impl) : IRemoteProxy<IFormMgr>(impl) {}
57 
58     virtual ~FormManagerAccessProxy() = default;
59 
60     int32_t RegisterAddObserver(const std::string &bundleName, const sptr<IRemoteObject> &callerToken) override;
61     int32_t RegisterRemoveObserver(const std::string &bundleName, const sptr<IRemoteObject> &callerToken) override;
62     bool HasFormVisible(const uint32_t tokenId) override;
63 private:
64     static inline BrokerDelegator<FormManagerAccessProxy> delegator_;
65 };
66 } // namespace AccessToken
67 } // namespace Security
68 } // namespace OHOS
69 #endif // ACCESS_FORM_MANAGER_ACCESS_PROXY_H
70