• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 "updater_ui.h"
17 #include <cstdio>
18 #ifdef HAVE_TERMIOS_H
19 #include <termios.h>
20 #elif defined(HAVE_TERMIO_H)
21 #include <termio.h>
22 #endif
23 
24 #include "securec.h"
25 #include "surface_dev.h"
26 #include "battery_log.h"
27 
28 namespace OHOS {
29 namespace HDI {
30 namespace Battery {
31 namespace V1_1 {
32 constexpr int32_t LABEL_HEIGHT = 15;
33 constexpr int32_t LABEL0_OFFSET = 0;
34 constexpr int32_t LABEL2_OFFSET = 1;
35 
TextLabelInit(TextLabel * t,const std::string & text,struct Bold bold,struct FocusInfo focus,View::BRGA888Pixel color)36 void TextLabelInit(TextLabel* t, const std::string& text, struct Bold bold,
37     struct FocusInfo focus, View::BRGA888Pixel color)
38 {
39     if (t != nullptr) {
40         t->SetText(text.c_str());
41         t->SetOutLineBold(bold.top, bold.bottom);
42         t->OnFocus(focus.focus);
43         t->SetBackgroundColor(&color);
44         t->SetFocusAble(focus.focusable);
45     }
46 }
47 
MenuItemInit(int32_t height,int32_t width,View::BRGA888Pixel bgColor,Frame * gHosFrame)48 void MenuItemInit(int32_t height, int32_t width, View::BRGA888Pixel bgColor, Frame* gHosFrame)
49 {
50     TextLabel* gTextLabel0 = nullptr;
51     TextLabel* gTextLabel2 = nullptr;
52 
53     if (gHosFrame == nullptr) {
54         BATTERY_HILOGD(FEATURE_CHARGING, "Frame is nullptr.");
55         return;
56     }
57     gTextLabel0 = new TextLabel(0, height * LABEL0_OFFSET / LABEL_HEIGHT, width, height /
58         LABEL_HEIGHT, gHosFrame);
59     struct FocusInfo info {true, true};
60     struct Bold bold {true, false};
61     TextLabelInit(gTextLabel0, "Reboot to normal system", bold, info, bgColor);
62     if (!gTextLabel0) {
63         BATTERY_HILOGD(FEATURE_CHARGING, "gTextLabel0 is nullptr.");
64         return;
65     }
66 
67     gTextLabel2 = new TextLabel(0, height * LABEL2_OFFSET / LABEL_HEIGHT, width, height /
68         LABEL_HEIGHT, gHosFrame);
69     info = {false, true};
70     bold = {false, false};
71     TextLabelInit(gTextLabel2, "Userdata reset", bold, info, bgColor);
72     if (!gTextLabel2) {
73         BATTERY_HILOGD(FEATURE_CHARGING, "gTextLabel2 is nullptr.");
74         return;
75     }
76 }
77 }  // namespace V1_1
78 }  // namespace Battery
79 }  // namespace HDI
80 }  // namespace OHOS
81