• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 "work_scheduler_extension.h"
17 
18 #include "ability_loader.h"
19 #include "js_work_scheduler_extension.h"
20 
21 namespace OHOS {
22 namespace WorkScheduler {
Create(const std::unique_ptr<AbilityRuntime::Runtime> & runtime)23 WorkSchedulerExtension* WorkSchedulerExtension::Create(const std::unique_ptr<AbilityRuntime::Runtime>& runtime)
24 {
25     if (!runtime) {
26         return (new (std::nothrow) WorkSchedulerExtension());
27     }
28     switch (runtime->GetLanguage()) {
29         case AbilityRuntime::Runtime::Language::JS:
30             return JsWorkSchedulerExtension::Create(runtime);
31         default:
32             return (new (std::nothrow) WorkSchedulerExtension());
33     }
34 }
35 
Init(const std::shared_ptr<AppExecFwk::AbilityLocalRecord> & record,const std::shared_ptr<AppExecFwk::OHOSApplication> & application,std::shared_ptr<AppExecFwk::AbilityHandler> & handler,const sptr<IRemoteObject> & token)36 void WorkSchedulerExtension::Init(const std::shared_ptr<AppExecFwk::AbilityLocalRecord>& record,
37     const std::shared_ptr<AppExecFwk::OHOSApplication>& application,
38     std::shared_ptr<AppExecFwk::AbilityHandler>& handler,
39     const sptr<IRemoteObject>& token)
40 {
41     ExtensionBase<WorkSchedulerExtensionContext>::Init(record, application, handler, token);
42 }
43 
CreateAndInitContext(const std::shared_ptr<AppExecFwk::AbilityLocalRecord> & record,const std::shared_ptr<AppExecFwk::OHOSApplication> & application,std::shared_ptr<AppExecFwk::AbilityHandler> & handler,const sptr<IRemoteObject> & token)44 std::shared_ptr<WorkSchedulerExtensionContext> WorkSchedulerExtension::CreateAndInitContext(
45     const std::shared_ptr<AppExecFwk::AbilityLocalRecord>& record,
46     const std::shared_ptr<AppExecFwk::OHOSApplication>& application,
47     std::shared_ptr<AppExecFwk::AbilityHandler>& handler,
48     const sptr<IRemoteObject>& token)
49 {
50     std::shared_ptr<WorkSchedulerExtensionContext> context =
51         ExtensionBase<WorkSchedulerExtensionContext>::CreateAndInitContext(record, application, handler, token);
52     if (record == nullptr) {
53         return context;
54     }
55     return context;
56 }
57 
OnWorkStart(WorkInfo & workInfo)58 void WorkSchedulerExtension::OnWorkStart(WorkInfo& workInfo) {
59 }
60 
OnWorkStop(WorkInfo & workInfo)61 void WorkSchedulerExtension::OnWorkStop(WorkInfo& workInfo) {
62 }
63 } // namespace WorkScheduler
64 } // namespace OHOS