• 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 #include "static_subscriber_extension.h"
17 
18 #include "event_log_wrapper.h"
19 #include "runtime.h"
20 #include "static_subscriber_extension_context.h"
21 
22 namespace OHOS {
23 namespace EventFwk {
24 using namespace OHOS::AppExecFwk;
Create(const std::unique_ptr<AbilityRuntime::Runtime> & runtime)25 StaticSubscriberExtension* StaticSubscriberExtension::Create(const std::unique_ptr<AbilityRuntime::Runtime>& runtime)
26 {
27     return new (std::nothrow) StaticSubscriberExtension();
28 }
29 
Init(const std::shared_ptr<AbilityLocalRecord> & record,const std::shared_ptr<OHOSApplication> & application,std::shared_ptr<AbilityHandler> & handler,const sptr<IRemoteObject> & token)30 void StaticSubscriberExtension::Init(const std::shared_ptr<AbilityLocalRecord>& record,
31     const std::shared_ptr<OHOSApplication>& application,
32     std::shared_ptr<AbilityHandler>& handler,
33     const sptr<IRemoteObject>& token)
34 {
35     EVENT_LOGD("Init");
36     ExtensionBase<StaticSubscriberExtensionContext>::Init(record, application, handler, token);
37 }
38 
CreateAndInitContext(const std::shared_ptr<AbilityLocalRecord> & record,const std::shared_ptr<OHOSApplication> & application,std::shared_ptr<AbilityHandler> & handler,const sptr<IRemoteObject> & token)39 std::shared_ptr<StaticSubscriberExtensionContext> StaticSubscriberExtension::CreateAndInitContext(
40     const std::shared_ptr<AbilityLocalRecord>& record,
41     const std::shared_ptr<OHOSApplication>& application,
42     std::shared_ptr<AbilityHandler>& handler,
43     const sptr<IRemoteObject>& token)
44 {
45     std::shared_ptr<StaticSubscriberExtensionContext> context =
46         ExtensionBase<StaticSubscriberExtensionContext>::CreateAndInitContext(record, application, handler, token);
47     if (record == nullptr) {
48         EVENT_LOGE("record is nullptr");
49         return context;
50     }
51     return context;
52 }
53 
OnReceiveEvent(std::shared_ptr<CommonEventData> data)54 void StaticSubscriberExtension::OnReceiveEvent(std::shared_ptr<CommonEventData> data)
55 {
56     EVENT_LOGD("OnReceiveEvent called.");
57 }
58 } // namespace EventFwk
59 } // namespace OHOS
60