• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 "wallpaper_extension_ability.h"
17 
18 #include "connection_manager.h"
19 #include "hilog_wrapper.h"
20 #include "js_wallpaper_extension_ability.h"
21 #include "runtime.h"
22 #include "wallpaper_extension_context.h"
23 
24 namespace OHOS {
25 namespace AbilityRuntime {
26 using namespace OHOS::AppExecFwk;
Create(const std::unique_ptr<Runtime> & runtime)27 WallpaperExtensionAbility *WallpaperExtensionAbility::Create(const std::unique_ptr<Runtime> &runtime)
28 {
29     HILOG_INFO("jws WallpaperExtensionAbility::Create runtime");
30     if (!runtime) {
31         return new WallpaperExtensionAbility();
32     }
33     HILOG_INFO("jws WallpaperExtensionAbility::Create runtime");
34     switch (runtime->GetLanguage()) {
35         case Runtime::Language::JS:
36             return JsWallpaperExtensionAbility::Create(runtime);
37 
38         default:
39             return new WallpaperExtensionAbility();
40     }
41 }
42 
Init(const std::shared_ptr<AbilityLocalRecord> & record,const std::shared_ptr<OHOSApplication> & application,std::shared_ptr<AbilityHandler> & handler,const sptr<IRemoteObject> & token)43 void WallpaperExtensionAbility::Init(const std::shared_ptr<AbilityLocalRecord> &record,
44     const std::shared_ptr<OHOSApplication> &application, std::shared_ptr<AbilityHandler> &handler,
45     const sptr<IRemoteObject> &token)
46 {
47     HILOG_INFO("jws WallpaperExtensionAbility begin init context");
48     ExtensionBase<WallpaperExtensionContext>::Init(record, application, handler, token);
49     HILOG_INFO("WallpaperExtensionAbility begin init context");
50 }
51 
CreateAndInitContext(const std::shared_ptr<AbilityLocalRecord> & record,const std::shared_ptr<OHOSApplication> & application,std::shared_ptr<AbilityHandler> & handler,const sptr<IRemoteObject> & token)52 std::shared_ptr<WallpaperExtensionContext> WallpaperExtensionAbility::CreateAndInitContext(
53     const std::shared_ptr<AbilityLocalRecord> &record,
54     const std::shared_ptr<OHOSApplication> &application, std::shared_ptr<AbilityHandler> &handler,
55     const sptr<IRemoteObject> &token)
56 {
57     HILOG_INFO("jws WallpaperExtensionAbility begin init context");
58     std::shared_ptr<WallpaperExtensionContext> context =
59         ExtensionBase<WallpaperExtensionContext>::CreateAndInitContext(record, application, handler, token);
60     if (context == nullptr) {
61         HILOG_ERROR("WallpaperExtensionAbility::CreateAndInitContext context is nullptr");
62         return context;
63     }
64     return context;
65 }
66 } // namespace AbilityRuntime
67 } // namespace OHOS