1 /*
2 * Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
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 #include "launcher.h"
16 #include "log.h"
17
18 #define LAUNCHER_GIF_PATH "/data/img/launcher.gif"
19
20 namespace OHOS
21 {
InitUI()22 void Launcher::InitUI()
23 {
24 rootView_ = RootView::GetInstance();
25 rootView_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
26 HILOG_DEBUG(HILOG_MODULE_APP, "rootView %d-%d", rootView_->GetWidth(), rootView_->GetHeight());
27
28 gifImageView_ = new UIImageView();
29 gifImageView_->SetPosition(25, 75, 400, 300);
30 gifImageView_->SetSrc(LAUNCHER_GIF_PATH);
31 rootView_->Add(gifImageView_);
32 rootView_->Invalidate();
33 }
34
DeleteUI()35 void Launcher::DeleteUI()
36 {
37 HILOG_DEBUG(HILOG_MODULE_APP, "%s", __func__);
38 if (gifImageView_ != nullptr) {
39 delete gifImageView_;
40 gifImageView_ = nullptr;
41 }
42 }
43
~Launcher()44 Launcher::~Launcher()
45 {
46 DeleteUI();
47 }
48
OnCreate(const Want & want)49 void Launcher::OnCreate(const Want &want)
50 {
51 HILOG_DEBUG(HILOG_MODULE_APP, "%s", __func__);
52 }
53
OnForeground(const Want & want)54 void Launcher::OnForeground(const Want &want)
55 {
56 HILOG_DEBUG(HILOG_MODULE_APP, "%s", __func__);
57 InitUI();
58 }
59
OnBackground()60 void Launcher::OnBackground()
61 {
62 HILOG_DEBUG(HILOG_MODULE_APP, "%s", __func__);
63 DeleteUI();
64 }
65
OnDestroy()66 void Launcher::OnDestroy()
67 {
68 HILOG_DEBUG(HILOG_MODULE_APP, "%s", __func__);
69 DeleteUI();
70 }
71 } // namespace OHOS
72
73 extern "C" int InstallNativeAbility(const AbilityInfo *abilityInfo, const OHOS::SliteAbility *ability);
InstallLauncher()74 extern "C" void InstallLauncher()
75 {
76 OHOS::Launcher *launcher = OHOS::Launcher::GetInstance();
77 InstallNativeAbility(NULL, launcher);
78 }
79