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