• 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 "form_render_service_extension.h"
17 
18 #include "ability_info.h"
19 #include "context_impl.h"
20 #include "form_render_impl.h"
21 #include "hitrace_meter.h"
22 #include "hilog_wrapper.h"
23 #include "service_extension_context.h"
24 
25 namespace OHOS {
26 namespace AbilityRuntime {
27 using namespace OHOS::AppExecFwk::FormRender;
28 
Create(const std::unique_ptr<Runtime> & runtime)29 FormRenderServiceExtension* FormRenderServiceExtension::Create(const std::unique_ptr<Runtime>& runtime)
30 {
31     return new (std::nothrow) FormRenderServiceExtension(static_cast<Runtime&>(*runtime));
32 }
33 
FormRenderServiceExtension(Runtime & runtime)34 FormRenderServiceExtension::FormRenderServiceExtension(Runtime& runtime) : runtime_(runtime) {}
35 FormRenderServiceExtension::~FormRenderServiceExtension() = default;
36 
Init(const std::shared_ptr<AbilityLocalRecord> & record,const std::shared_ptr<OHOSApplication> & application,std::shared_ptr<AbilityHandler> & handler,const sptr<IRemoteObject> & token)37 void FormRenderServiceExtension::Init(const std::shared_ptr<AbilityLocalRecord> &record,
38     const std::shared_ptr<OHOSApplication> &application, std::shared_ptr<AbilityHandler> &handler,
39     const sptr<IRemoteObject> &token)
40 {
41     ServiceExtension::Init(record, application, handler, token);
42 }
43 
OnStart(const AAFwk::Want & want)44 void FormRenderServiceExtension::OnStart(const AAFwk::Want &want)
45 {
46     Extension::OnStart(want);
47     HILOG_INFO("FormRenderServiceExtension OnStart begin..");
48 }
49 
OnStop()50 void FormRenderServiceExtension::OnStop()
51 {
52     ServiceExtension::OnStop();
53     HILOG_INFO("FormRenderServiceExtension OnStop begin.");
54 }
55 
OnConnect(const AAFwk::Want & want)56 sptr<IRemoteObject> FormRenderServiceExtension::OnConnect(const AAFwk::Want &want)
57 {
58     HILOG_INFO("%{public}s begin.", __func__);
59     return OHOS::DelayedSingleton<FormRenderImpl>::GetInstance()->AsObject();
60 }
61 
OnConnect(const AAFwk::Want & want,AppExecFwk::AbilityTransactionCallbackInfo<sptr<IRemoteObject>> * callbackInfo,bool & isAsyncCallback)62 sptr<IRemoteObject> FormRenderServiceExtension::OnConnect(const AAFwk::Want &want,
63     AppExecFwk::AbilityTransactionCallbackInfo<sptr<IRemoteObject>> *callbackInfo, bool &isAsyncCallback)
64 {
65     HILOG_INFO("%{public}s begin multiParams.", __func__);
66     return OHOS::DelayedSingleton<FormRenderImpl>::GetInstance()->AsObject();
67 }
68 
OnDisconnect(const AAFwk::Want & want)69 void FormRenderServiceExtension::OnDisconnect(const AAFwk::Want &want)
70 {
71     HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
72     Extension::OnDisconnect(want);
73     HILOG_DEBUG("%{public}s begin.", __func__);
74 }
75 
OnDisconnect(const AAFwk::Want & want,AppExecFwk::AbilityTransactionCallbackInfo<> * callbackInfo,bool & isAsyncCallback)76 void FormRenderServiceExtension::OnDisconnect(const AAFwk::Want &want,
77     AppExecFwk::AbilityTransactionCallbackInfo<> *callbackInfo, bool &isAsyncCallback)
78 {
79     HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
80     Extension::OnDisconnect(want);
81     HILOG_DEBUG("%{public}s begin.", __func__);
82 }
83 
OnCommand(const AAFwk::Want & want,bool restart,int startId)84 void FormRenderServiceExtension::OnCommand(const AAFwk::Want &want, bool restart, int startId)
85 {
86     Extension::OnCommand(want, restart, startId);
87     HILOG_INFO("%{public}s begin restart=%{public}s,startId=%{public}d.",
88         __func__,
89         restart ? "true" : "false",
90         startId);
91 }
92 
OnConfigurationUpdated(const AppExecFwk::Configuration & configuration)93 void FormRenderServiceExtension::OnConfigurationUpdated(const AppExecFwk::Configuration& configuration)
94 {
95     Extension::OnConfigurationUpdated(configuration);
96     HILOG_INFO("%{public}s called.", __func__);
97     auto config = std::make_shared<AppExecFwk::Configuration>(configuration);
98     OHOS::DelayedSingleton<FormRenderImpl>::GetInstance()->OnConfigurationUpdated(config);
99 }
100 }
101 }
102