Move librecovery_ui to a sub-directory

This helps to expose librecovery_ui for device specific RecoveryUi.

Bug: 76436783
Test: mma, unit tests pass
Change-Id: Ic6c3d301d5833e4a592e6ea9d9d059bc4e4919be
This commit is contained in:
Tianjie Xu 2018-08-20 13:40:47 -07:00 committed by xunchang
parent 9d2a945e9b
commit b5108c372c
25 changed files with 138 additions and 119 deletions

View file

@ -26,77 +26,6 @@ cc_defaults {
], ],
} }
cc_library {
name: "librecovery_ui",
recovery_available: true,
defaults: [
"recovery_defaults",
],
srcs: [
"device.cpp",
"screen_ui.cpp",
"ui.cpp",
"vr_ui.cpp",
"wear_ui.cpp"
],
static_libs: [
"libminui",
"libotautil",
"libfstab",
],
shared_libs: [
"libbase",
"libpng",
"libz",
],
}
// Generic device that uses ScreenRecoveryUI.
cc_library_static {
name: "librecovery_ui_default",
recovery_available: true,
defaults: [
"recovery_defaults",
],
srcs: [
"default_device.cpp",
],
}
// The default wear device that uses WearRecoveryUI.
cc_library_static {
name: "librecovery_ui_wear",
recovery_available: true,
defaults: [
"recovery_defaults",
],
srcs: [
"wear_device.cpp",
],
}
// The default VR device that uses VrRecoveryUI.
cc_library_static {
name: "librecovery_ui_vr",
recovery_available: true,
defaults: [
"recovery_defaults",
],
srcs: [
"vr_device.cpp",
],
}
cc_library_static { cc_library_static {
name: "librecovery_fastboot", name: "librecovery_fastboot",
recovery_available: true, recovery_available: true,
@ -113,6 +42,7 @@ cc_library_static {
"libbootloader_message", "libbootloader_message",
"libcutils", "libcutils",
"liblog", "liblog",
"librecovery_ui",
], ],
static_libs: [ static_libs: [
@ -180,6 +110,10 @@ cc_library_static {
"roots.cpp", "roots.cpp",
], ],
shared_libs: [
"librecovery_ui",
],
include_dirs: [ include_dirs: [
"system/vold", "system/vold",
], ],

View file

@ -32,7 +32,7 @@
#include "common.h" #include "common.h"
#include "fuse_sideload.h" #include "fuse_sideload.h"
#include "install.h" #include "install.h"
#include "ui.h" #include "recovery_ui/ui.h"
int apply_from_adb(bool* wipe_cache) { int apply_from_adb(bool* wipe_cache) {
// Save the usb state to restore after the sideload operation. // Save the usb state to restore after the sideload operation.

View file

@ -27,8 +27,7 @@
#include <android-base/properties.h> #include <android-base/properties.h>
#include <bootloader_message/bootloader_message.h> #include <bootloader_message/bootloader_message.h>
#include "device.h" #include "recovery_ui/ui.h"
#include "ui.h"
static const std::vector<std::pair<std::string, Device::BuiltinAction>> kFastbootMenuActions{ static const std::vector<std::pair<std::string, Device::BuiltinAction>> kFastbootMenuActions{
{ "Reboot system now", Device::REBOOT }, { "Reboot system now", Device::REBOOT },

View file

@ -19,6 +19,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "device.h" #include "recovery_ui/device.h"
Device::BuiltinAction StartFastboot(Device* device, const std::vector<std::string>& args); Device::BuiltinAction StartFastboot(Device* device, const std::vector<std::string>& args);

View file

@ -16,7 +16,7 @@
#pragma once #pragma once
#include "device.h" #include "recovery_ui/device.h"
#include "ui.h" #include "recovery_ui/ui.h"
int ApplyFromSdcard(Device* device, bool* wipe_cache, RecoveryUI* ui); int ApplyFromSdcard(Device* device, bool* wipe_cache, RecoveryUI* ui);

View file

@ -53,8 +53,8 @@
#include "otautil/thermalutil.h" #include "otautil/thermalutil.h"
#include "package.h" #include "package.h"
#include "private/install.h" #include "private/install.h"
#include "recovery_ui/ui.h"
#include "roots.h" #include "roots.h"
#include "ui.h"
#include "verifier.h" #include "verifier.h"
using namespace std::chrono_literals; using namespace std::chrono_literals;

View file

@ -52,7 +52,6 @@
#include "adb_install.h" #include "adb_install.h"
#include "common.h" #include "common.h"
#include "device.h"
#include "fsck_unshare_blocks.h" #include "fsck_unshare_blocks.h"
#include "fuse_sdcard_install.h" #include "fuse_sdcard_install.h"
#include "install.h" #include "install.h"
@ -62,9 +61,9 @@
#include "otautil/paths.h" #include "otautil/paths.h"
#include "otautil/sysutil.h" #include "otautil/sysutil.h"
#include "package.h" #include "package.h"
#include "recovery_ui/screen_ui.h"
#include "recovery_ui/ui.h"
#include "roots.h" #include "roots.h"
#include "screen_ui.h"
#include "ui.h"
static constexpr const char* CACHE_LOG_DIR = "/cache/recovery"; static constexpr const char* CACHE_LOG_DIR = "/cache/recovery";
static constexpr const char* COMMAND_FILE = "/cache/recovery/command"; static constexpr const char* COMMAND_FILE = "/cache/recovery/command";

View file

@ -19,6 +19,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "device.h" #include "recovery_ui/device.h"
Device::BuiltinAction start_recovery(Device* device, const std::vector<std::string>& args); Device::BuiltinAction start_recovery(Device* device, const std::vector<std::string>& args);

View file

@ -49,16 +49,16 @@
#include <selinux/selinux.h> #include <selinux/selinux.h>
#include "common.h" #include "common.h"
#include "device.h"
#include "fastboot/fastboot.h" #include "fastboot/fastboot.h"
#include "logging.h" #include "logging.h"
#include "minadbd/minadbd.h" #include "minadbd/minadbd.h"
#include "otautil/paths.h" #include "otautil/paths.h"
#include "otautil/sysutil.h" #include "otautil/sysutil.h"
#include "recovery.h" #include "recovery.h"
#include "recovery_ui/device.h"
#include "recovery_ui/stub_ui.h"
#include "recovery_ui/ui.h"
#include "roots.h" #include "roots.h"
#include "stub_ui.h"
#include "ui.h"
static constexpr const char* COMMAND_FILE = "/cache/recovery/command"; static constexpr const char* COMMAND_FILE = "/cache/recovery/command";
static constexpr const char* LOCALE_FILE = "/cache/recovery/last_locale"; static constexpr const char* LOCALE_FILE = "/cache/recovery/last_locale";

91
recovery_ui/Android.bp Normal file
View file

@ -0,0 +1,91 @@
// Copyright (C) 2019 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
cc_library {
name: "librecovery_ui",
recovery_available: true,
defaults: [
"recovery_defaults",
],
srcs: [
"device.cpp",
"screen_ui.cpp",
"ui.cpp",
"vr_ui.cpp",
"wear_ui.cpp",
],
export_include_dirs: ["include"],
static_libs: [
"libminui",
"libotautil",
],
shared_libs: [
"libbase",
"libpng",
"libz",
],
}
// Generic device that uses ScreenRecoveryUI.
cc_library_static {
name: "librecovery_ui_default",
recovery_available: true,
defaults: [
"recovery_defaults",
],
srcs: [
"default_device.cpp",
],
export_include_dirs: ["include"],
}
// The default wear device that uses WearRecoveryUI.
cc_library_static {
name: "librecovery_ui_wear",
recovery_available: true,
defaults: [
"recovery_defaults",
],
srcs: [
"wear_device.cpp",
],
export_include_dirs: ["include"],
}
// The default VR device that uses VrRecoveryUI.
cc_library_static {
name: "librecovery_ui_vr",
recovery_available: true,
defaults: [
"recovery_defaults",
],
srcs: [
"vr_device.cpp",
],
export_include_dirs: ["include"],
}

View file

@ -14,8 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
#include "device.h" #include "recovery_ui/device.h"
#include "screen_ui.h" #include "recovery_ui/screen_ui.h"
Device* make_device() { Device* make_device() {
return new Device(new ScreenRecoveryUI); return new Device(new ScreenRecoveryUI);

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include "device.h" #include "recovery_ui/device.h"
#include <algorithm> #include <algorithm>
#include <string> #include <string>
@ -23,7 +23,7 @@
#include <android-base/logging.h> #include <android-base/logging.h>
#include "ui.h" #include "recovery_ui/ui.h"
static std::vector<std::pair<std::string, Device::BuiltinAction>> g_menu_actions{ static std::vector<std::pair<std::string, Device::BuiltinAction>> g_menu_actions{
{ "Reboot system now", Device::REBOOT }, { "Reboot system now", Device::REBOOT },

View file

@ -68,7 +68,7 @@ class Device {
// Called when recovery starts up (after the UI has been obtained and initialized and after the // Called when recovery starts up (after the UI has been obtained and initialized and after the
// arguments have been parsed, but before anything else). // arguments have been parsed, but before anything else).
virtual void StartRecovery() {}; virtual void StartRecovery() {}
// Called from the main thread when recovery is at the main menu and waiting for input, and a key // Called from the main thread when recovery is at the main menu and waiting for input, and a key
// is pressed. (Note that "at" the main menu does not necessarily mean the menu is visible; // is pressed. (Note that "at" the main menu does not necessarily mean the menu is visible;

View file

@ -35,20 +35,20 @@ class RecoveryUI {
INSTALLING_UPDATE, INSTALLING_UPDATE,
ERASING, ERASING,
NO_COMMAND, NO_COMMAND,
ERROR ERROR,
}; };
enum ProgressType { enum ProgressType {
EMPTY, EMPTY,
INDETERMINATE, INDETERMINATE,
DETERMINATE DETERMINATE,
}; };
enum KeyAction { enum KeyAction {
ENQUEUE, ENQUEUE,
TOGGLE, TOGGLE,
REBOOT, REBOOT,
IGNORE IGNORE,
}; };
enum class KeyError : int { enum class KeyError : int {
@ -60,8 +60,8 @@ class RecoveryUI {
virtual ~RecoveryUI(); virtual ~RecoveryUI();
// Initializes the object; called before anything else. UI texts will be initialized according to // Initializes the object; called before anything else. UI texts will be initialized according
// the given locale. Returns true on success. // to the given locale. Returns true on success.
virtual bool Init(const std::string& locale); virtual bool Init(const std::string& locale);
virtual std::string GetLocale() const = 0; virtual std::string GetLocale() const = 0;
@ -211,7 +211,7 @@ class RecoveryUI {
DISABLED, DISABLED,
NORMAL, NORMAL,
DIMMED, DIMMED,
OFF OFF,
}; };
// The sensitivity when detecting a swipe. // The sensitivity when detecting a swipe.

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include "screen_ui.h" #include "recovery_ui/screen_ui.h"
#include <dirent.h> #include <dirent.h>
#include <errno.h> #include <errno.h>
@ -42,10 +42,10 @@
#include <android-base/stringprintf.h> #include <android-base/stringprintf.h>
#include <android-base/strings.h> #include <android-base/strings.h>
#include "device.h"
#include "minui/minui.h" #include "minui/minui.h"
#include "otautil/paths.h" #include "otautil/paths.h"
#include "ui.h" #include "recovery_ui/device.h"
#include "recovery_ui/ui.h"
// Return the current time as a double (including fractions of a second). // Return the current time as a double (including fractions of a second).
static double now() { static double now() {
@ -388,10 +388,10 @@ int ScreenRecoveryUI::PixelsFromDp(int dp) const {
enum Layout { PORTRAIT = 0, PORTRAIT_LARGE = 1, LANDSCAPE = 2, LANDSCAPE_LARGE = 3, LAYOUT_MAX }; enum Layout { PORTRAIT = 0, PORTRAIT_LARGE = 1, LANDSCAPE = 2, LANDSCAPE_LARGE = 3, LAYOUT_MAX };
enum Dimension { TEXT = 0, ICON = 1, DIMENSION_MAX }; enum Dimension { TEXT = 0, ICON = 1, DIMENSION_MAX };
static constexpr int kLayouts[LAYOUT_MAX][DIMENSION_MAX] = { static constexpr int kLayouts[LAYOUT_MAX][DIMENSION_MAX] = {
{ 32, 68, }, // PORTRAIT { 32, 68 }, // PORTRAIT
{ 32, 68, }, // PORTRAIT_LARGE { 32, 68 }, // PORTRAIT_LARGE
{ 26, 56, }, // LANDSCAPE { 26, 56 }, // LANDSCAPE
{ 52, 112, }, // LANDSCAPE_LARGE { 52, 112 }, // LANDSCAPE_LARGE
}; };
int ScreenRecoveryUI::GetAnimationBaseline() const { int ScreenRecoveryUI::GetAnimationBaseline() const {
@ -1042,7 +1042,7 @@ void ScreenRecoveryUI::Print(const char* fmt, ...) {
va_end(ap); va_end(ap);
} }
void ScreenRecoveryUI::PrintOnScreenOnly(const char *fmt, ...) { void ScreenRecoveryUI::PrintOnScreenOnly(const char* fmt, ...) {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
PrintV(fmt, false, ap); PrintV(fmt, false, ap);

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include "ui.h" #include "recovery_ui/ui.h"
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
@ -39,7 +39,6 @@
#include "minui/minui.h" #include "minui/minui.h"
#include "otautil/sysutil.h" #include "otautil/sysutil.h"
#include "roots.h"
using namespace std::chrono_literals; using namespace std::chrono_literals;
@ -590,8 +589,7 @@ RecoveryUI::KeyAction RecoveryUI::CheckKey(int key, bool is_long_press) {
return (IsTextVisible() || screensaver_state_ == ScreensaverState::OFF) ? ENQUEUE : IGNORE; return (IsTextVisible() || screensaver_state_ == ScreensaverState::OFF) ? ENQUEUE : IGNORE;
} }
void RecoveryUI::KeyLongPress(int) { void RecoveryUI::KeyLongPress(int) {}
}
void RecoveryUI::SetEnableReboot(bool enabled) { void RecoveryUI::SetEnableReboot(bool enabled) {
std::lock_guard<std::mutex> lg(key_queue_mutex); std::lock_guard<std::mutex> lg(key_queue_mutex);

View file

@ -14,10 +14,9 @@
* limitations under the License. * limitations under the License.
*/ */
#include "device.h" #include "recovery_ui/device.h"
#include "vr_ui.h" #include "recovery_ui/vr_ui.h"
Device* make_device() { Device* make_device() {
return new Device(new VrRecoveryUI); return new Device(new VrRecoveryUI);
} }

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include "vr_ui.h" #include "recovery_ui/vr_ui.h"
#include <android-base/properties.h> #include <android-base/properties.h>

View file

@ -14,10 +14,9 @@
* limitations under the License. * limitations under the License.
*/ */
#include "device.h" #include "recovery_ui/device.h"
#include "wear_ui.h" #include "recovery_ui/wear_ui.h"
Device* make_device() { Device* make_device() {
return new Device(new WearRecoveryUI); return new Device(new WearRecoveryUI);
} }

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include "wear_ui.h" #include "recovery_ui/wear_ui.h"
#include <string.h> #include <string.h>

View file

@ -30,11 +30,11 @@
#include <gtest/gtest_prod.h> #include <gtest/gtest_prod.h>
#include "common/test_constants.h" #include "common/test_constants.h"
#include "device.h"
#include "minui/minui.h" #include "minui/minui.h"
#include "otautil/paths.h" #include "otautil/paths.h"
#include "private/resources.h" #include "private/resources.h"
#include "screen_ui.h" #include "recovery_ui/device.h"
#include "recovery_ui/screen_ui.h"
static const std::vector<std::string> HEADERS{ "header" }; static const std::vector<std::string> HEADERS{ "header" };
static const std::vector<std::string> ITEMS{ "item1", "item2", "item3", "item4", "1234567890" }; static const std::vector<std::string> ITEMS{ "item1", "item2", "item3", "item4", "1234567890" };