• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
OnStart(const Want & want)49 void Launcher::OnStart(const Want &want)
50 {
51     HILOG_DEBUG(HILOG_MODULE_APP, "%s", __func__);
52 }
53 
OnInactive()54 void Launcher::OnInactive()
55 {
56     HILOG_DEBUG(HILOG_MODULE_APP, "%s", __func__);
57 }
58 
OnActive(const Want & want)59 void Launcher::OnActive(const Want &want)
60 {
61     HILOG_DEBUG(HILOG_MODULE_APP, "%s", __func__);
62     InitUI();
63 }
64 
OnBackground()65 void Launcher::OnBackground()
66 {
67     HILOG_DEBUG(HILOG_MODULE_APP, "%s", __func__);
68     DeleteUI();
69 }
70 
OnStop()71 void Launcher::OnStop()
72 {
73     HILOG_DEBUG(HILOG_MODULE_APP, "%s", __func__);
74     DeleteUI();
75 }
76 } // namespace OHOS
77 
78 extern "C" int InstallNativeAbility(const AbilityInfo *abilityInfo, const OHOS::SliteAbility *ability);
InstallLauncher()79 extern "C" void InstallLauncher()
80 {
81     OHOS::Launcher *launcher = OHOS::Launcher::GetInstance();
82     InstallNativeAbility(NULL, launcher);
83 }
84