Browse Source

Introduce VR recovery ui

A version of screen ui with specific adjustments for vr device
compatibility.

Bug: 37779982
Test: "adb reboot recovery" to view
Change-Id: If6b0f26c1b587f8d0176060685b5efb6c67593b1
Luke Song 4 years ago
parent
commit
a44dba7f4e
6 changed files with 144 additions and 8 deletions
  1. 12
    0
      Android.mk
  2. 11
    6
      screen_ui.cpp
  3. 4
    2
      screen_ui.h
  4. 23
    0
      vr_device.cpp
  5. 56
    0
      vr_ui.cpp
  6. 38
    0
      vr_ui.h

+ 12
- 0
Android.mk View File

@@ -76,6 +76,7 @@ LOCAL_SRC_FILES := \
76 76
     rotate_logs.cpp \
77 77
     screen_ui.cpp \
78 78
     ui.cpp \
79
+    vr_ui.cpp \
79 80
     wear_ui.cpp \
80 81
     wear_touch.cpp \
81 82
 
@@ -182,6 +183,17 @@ LOCAL_STATIC_LIBRARIES := \
182 183
 LOCAL_CFLAGS := -Werror
183 184
 include $(BUILD_STATIC_LIBRARY)
184 185
 
186
+# vr headset default device
187
+# ===============================
188
+include $(CLEAR_VARS)
189
+
190
+LOCAL_SRC_FILES := vr_device.cpp
191
+
192
+# should match TARGET_RECOVERY_UI_LIB set in BoardConfig.mk
193
+LOCAL_MODULE := librecovery_ui_vr
194
+
195
+include $(BUILD_STATIC_LIBRARY)
196
+
185 197
 include \
186 198
     $(LOCAL_PATH)/applypatch/Android.mk \
187 199
     $(LOCAL_PATH)/boot_control/Android.mk \

+ 11
- 6
screen_ui.cpp View File

@@ -256,6 +256,10 @@ void ScreenRecoveryUI::DrawHorizontalRule(int* y) {
256 256
     *y += 4;
257 257
 }
258 258
 
259
+void ScreenRecoveryUI::DrawHighlightBar(int x, int y, int width, int height) const {
260
+    gr_fill(x, y, x + width, y + height);
261
+}
262
+
259 263
 void ScreenRecoveryUI::DrawTextLine(int x, int* y, const char* line, bool bold) const {
260 264
     gr_text(gr_sys_font(), x, *y, line, bold);
261 265
     *y += char_height_ + 4;
@@ -310,15 +314,14 @@ void ScreenRecoveryUI::draw_screen_locked() {
310 314
                 if (i == menu_sel) {
311 315
                     // Draw the highlight bar.
312 316
                     SetColor(IsLongPress() ? MENU_SEL_BG_ACTIVE : MENU_SEL_BG);
313
-                    gr_fill(0, y - 2, gr_fb_width(), y + char_height_ + 2);
317
+                    DrawHighlightBar(0, y - 2, gr_fb_width(), char_height_ + 4);
314 318
                     // Bold white text for the selected item.
315 319
                     SetColor(MENU_SEL_FG);
316
-                    gr_text(gr_sys_font(), 4, y, menu_[i], true);
320
+                    DrawTextLine(TEXT_INDENT, &y, menu_[i], true);
317 321
                     SetColor(MENU);
318 322
                 } else {
319
-                    gr_text(gr_sys_font(), 4, y, menu_[i], false);
323
+                    DrawTextLine(TEXT_INDENT, &y, menu_[i], false);
320 324
                 }
321
-                y += char_height_ + 4;
322 325
             }
323 326
             DrawHorizontalRule(&y);
324 327
         }
@@ -329,10 +332,11 @@ void ScreenRecoveryUI::draw_screen_locked() {
329 332
         SetColor(LOG);
330 333
         int row = (text_top_ + text_rows_ - 1) % text_rows_;
331 334
         size_t count = 0;
332
-        for (int ty = gr_fb_height() - char_height_;
335
+        for (int ty = gr_fb_height() - char_height_ - log_bottom_offset_;
333 336
              ty >= y && count < text_rows_;
334 337
              ty -= char_height_, ++count) {
335
-            gr_text(gr_sys_font(), 0, ty, text_[row], false);
338
+            int temp_y = ty;
339
+            DrawTextLine(0, &temp_y, text_[row], false);
336 340
             --row;
337 341
             if (row < 0) row = text_rows_ - 1;
338 342
         }
@@ -453,6 +457,7 @@ bool ScreenRecoveryUI::InitTextParams() {
453 457
     gr_font_size(gr_sys_font(), &char_width_, &char_height_);
454 458
     text_rows_ = gr_fb_height() / char_height_;
455 459
     text_cols_ = gr_fb_width() / char_width_;
460
+    log_bottom_offset_ = 0;
456 461
     return true;
457 462
 }
458 463
 

+ 4
- 2
screen_ui.h View File

@@ -107,6 +107,7 @@ class ScreenRecoveryUI : public RecoveryUI {
107 107
     // Log text overlay, displayed when a magic key is pressed.
108 108
     char** text_;
109 109
     size_t text_col_, text_row_, text_top_;
110
+    int log_bottom_offset_;
110 111
 
111 112
     bool show_text;
112 113
     bool show_text_ever;   // has show_text ever been true?
@@ -165,8 +166,9 @@ class ScreenRecoveryUI : public RecoveryUI {
165 166
     virtual int GetProgressBaseline();
166 167
     virtual int GetTextBaseline();
167 168
 
168
-    void DrawHorizontalRule(int* y);
169
-    void DrawTextLine(int x, int* y, const char* line, bool bold) const;
169
+    virtual void DrawHorizontalRule(int* y);
170
+    virtual void DrawHighlightBar(int x, int y, int width, int height) const;
171
+    virtual void DrawTextLine(int x, int* y, const char* line, bool bold) const;
170 172
     void DrawTextLines(int x, int* y, const char* const* lines) const;
171 173
 };
172 174
 

+ 23
- 0
vr_device.cpp View File

@@ -0,0 +1,23 @@
1
+/*
2
+ * Copyright (C) 2017 The Android Open Source Project
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *      http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+#include "device.h"
18
+#include "vr_ui.h"
19
+
20
+Device* make_device() {
21
+    return new Device(new VrRecoveryUI);
22
+}
23
+

+ 56
- 0
vr_ui.cpp View File

@@ -0,0 +1,56 @@
1
+/*
2
+ * Copyright (C) 2017 The Android Open Source Project
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *      http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+#include "vr_ui.h"
18
+
19
+#include <minui/minui.h>
20
+
21
+VrRecoveryUI::VrRecoveryUI() :
22
+  x_offset(400),
23
+  y_offset(400),
24
+  stereo_offset(100) {
25
+}
26
+
27
+bool VrRecoveryUI::InitTextParams() {
28
+  if (gr_init() < 0) {
29
+    return false;
30
+  }
31
+
32
+  gr_font_size(gr_sys_font(), &char_width_, &char_height_);
33
+  int mid_divide = gr_fb_width() / 2;
34
+  text_rows_ = (gr_fb_height() - 2 * y_offset) / char_height_;
35
+  text_cols_ = (mid_divide - x_offset - stereo_offset) / char_width_;
36
+  log_bottom_offset_ = gr_fb_height() - 2 * y_offset;
37
+  return true;
38
+}
39
+
40
+void VrRecoveryUI::DrawHorizontalRule(int* y) {
41
+  SetColor(MENU);
42
+  *y += 4;
43
+  gr_fill(0, *y + y_offset, gr_fb_width(), *y + y_offset + 2);
44
+  *y += 4;
45
+}
46
+
47
+void VrRecoveryUI::DrawHighlightBar(int x, int y, int width, int height) const {
48
+  gr_fill(x, y + y_offset, x + width, y + y_offset + height);
49
+}
50
+
51
+void VrRecoveryUI::DrawTextLine(int x, int* y, const char* line, bool bold) const {
52
+  int mid_divide = gr_fb_width() / 2;
53
+  gr_text(gr_sys_font(), x + x_offset + stereo_offset, *y + y_offset, line, bold);
54
+  gr_text(gr_sys_font(), x + x_offset - stereo_offset + mid_divide, *y + y_offset, line, bold);
55
+  *y += char_height_ + 4;
56
+}

+ 38
- 0
vr_ui.h View File

@@ -0,0 +1,38 @@
1
+/*
2
+ * Copyright (C) 2017 The Android Open Source Project
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *      http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+#ifndef RECOVERY_VR_UI_H
18
+#define RECOVERY_VR_UI_H
19
+
20
+#include "screen_ui.h"
21
+
22
+class VrRecoveryUI : public ScreenRecoveryUI {
23
+  public:
24
+    VrRecoveryUI();
25
+
26
+  protected:
27
+    // Pixel offsets to move drawing functions to visible range.
28
+    // Can vary per device depending on screen size and lens distortion.
29
+    int x_offset, y_offset, stereo_offset;
30
+
31
+    bool InitTextParams() override;
32
+
33
+    void DrawHorizontalRule(int* y) override;
34
+    void DrawHighlightBar(int x, int y, int width, int height) const override;
35
+    void DrawTextLine(int x, int* y, const char* line, bool bold) const override;
36
+};
37
+
38
+#endif  // RECOVERY_VR_UI_H