• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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_COMMON_EVENT_SERVICE_STATIC_SUBSCRIBER_EXTENSION_H
17 #define OHOS_COMMON_EVENT_SERVICE_STATIC_SUBSCRIBER_EXTENSION_H
18 
19 #include "common_event_data.h"
20 #include "extension_base.h"
21 #include "runtime.h"
22 #include "static_subscriber_extension_context.h"
23 
24 namespace OHOS {
25 namespace EventFwk {
26 class StaticSubscriberExtension : public AbilityRuntime::ExtensionBase<StaticSubscriberExtensionContext> {
27 public:
28     StaticSubscriberExtension() = default;
29     virtual ~StaticSubscriberExtension() = default;
30 
31     std::shared_ptr<StaticSubscriberExtensionContext> CreateAndInitContext(
32         const std::shared_ptr<AppExecFwk::AbilityLocalRecord>& record,
33         const std::shared_ptr<AppExecFwk::OHOSApplication>& application,
34         std::shared_ptr<AppExecFwk::AbilityHandler>& handler,
35         const sptr<IRemoteObject>& token) override;
36 
37     void Init(const std::shared_ptr<AppExecFwk::AbilityLocalRecord>& record,
38         const std::shared_ptr<AppExecFwk::OHOSApplication>& application,
39         std::shared_ptr<AppExecFwk::AbilityHandler>& handler,
40         const sptr<IRemoteObject>& token) override;
41 
42     static StaticSubscriberExtension* Create(const std::unique_ptr<AbilityRuntime::Runtime>& runtime);
43 
44     virtual void OnReceiveEvent(std::shared_ptr<CommonEventData> data);
45 };
46 } // namespace EventFwk
47 } // namespace OHOS
48 #endif // OHOS_COMMON_EVENT_SERVICE_STATIC_SUBSCRIBER_EXTENSION_H
49