Merge "Move librecovery_ui to a sub-directory"
diff --git a/Android.bp b/Android.bp
index a6986bb..7b67f40 100644
--- a/Android.bp
+++ b/Android.bp
@@ -26,77 +26,6 @@
     ],
 }
 
-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 {
     name: "librecovery_fastboot",
     recovery_available: true,
@@ -113,6 +42,7 @@
         "libbootloader_message",
         "libcutils",
         "liblog",
+        "librecovery_ui",
     ],
 
     static_libs: [
@@ -180,6 +110,10 @@
         "roots.cpp",
     ],
 
+    shared_libs: [
+        "librecovery_ui",
+    ],
+
     include_dirs: [
         "system/vold",
     ],
diff --git a/adb_install.cpp b/adb_install.cpp
index 3f2843f..1d19fd3 100644
--- a/adb_install.cpp
+++ b/adb_install.cpp
@@ -32,7 +32,7 @@
 #include "common.h"
 #include "fuse_sideload.h"
 #include "install.h"
-#include "ui.h"
+#include "recovery_ui/ui.h"
 
 int apply_from_adb(bool* wipe_cache) {
   // Save the usb state to restore after the sideload operation.
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index 8458c99..14f5e4b 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -27,8 +27,7 @@
 #include <android-base/properties.h>
 #include <bootloader_message/bootloader_message.h>
 
-#include "device.h"
-#include "ui.h"
+#include "recovery_ui/ui.h"
 
 static const std::vector<std::pair<std::string, Device::BuiltinAction>> kFastbootMenuActions{
   { "Reboot system now", Device::REBOOT },
diff --git a/fastboot/fastboot.h b/fastboot/fastboot.h
index 53a2adc..1aa7de6 100644
--- a/fastboot/fastboot.h
+++ b/fastboot/fastboot.h
@@ -19,6 +19,6 @@
 #include <string>
 #include <vector>
 
-#include "device.h"
+#include "recovery_ui/device.h"
 
 Device::BuiltinAction StartFastboot(Device* device, const std::vector<std::string>& args);
diff --git a/fuse_sdcard_install.h b/fuse_sdcard_install.h
index 5f0d64a..345aea4 100644
--- a/fuse_sdcard_install.h
+++ b/fuse_sdcard_install.h
@@ -16,7 +16,7 @@
 
 #pragma once
 
-#include "device.h"
-#include "ui.h"
+#include "recovery_ui/device.h"
+#include "recovery_ui/ui.h"
 
 int ApplyFromSdcard(Device* device, bool* wipe_cache, RecoveryUI* ui);
diff --git a/install.cpp b/install.cpp
index dbc815d..b7fb788 100644
--- a/install.cpp
+++ b/install.cpp
@@ -53,8 +53,8 @@
 #include "otautil/thermalutil.h"
 #include "package.h"
 #include "private/install.h"
+#include "recovery_ui/ui.h"
 #include "roots.h"
-#include "ui.h"
 #include "verifier.h"
 
 using namespace std::chrono_literals;
diff --git a/recovery.cpp b/recovery.cpp
index 90ca3f0..d9c1f22 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -52,7 +52,6 @@
 
 #include "adb_install.h"
 #include "common.h"
-#include "device.h"
 #include "fsck_unshare_blocks.h"
 #include "fuse_sdcard_install.h"
 #include "install.h"
@@ -62,9 +61,9 @@
 #include "otautil/paths.h"
 #include "otautil/sysutil.h"
 #include "package.h"
+#include "recovery_ui/screen_ui.h"
+#include "recovery_ui/ui.h"
 #include "roots.h"
-#include "screen_ui.h"
-#include "ui.h"
 
 static constexpr const char* CACHE_LOG_DIR = "/cache/recovery";
 static constexpr const char* COMMAND_FILE = "/cache/recovery/command";
diff --git a/recovery.h b/recovery.h
index 00e22da..f050549 100644
--- a/recovery.h
+++ b/recovery.h
@@ -19,6 +19,6 @@
 #include <string>
 #include <vector>
 
-#include "device.h"
+#include "recovery_ui/device.h"
 
 Device::BuiltinAction start_recovery(Device* device, const std::vector<std::string>& args);
diff --git a/recovery_main.cpp b/recovery_main.cpp
index 935d698..2f5a184 100644
--- a/recovery_main.cpp
+++ b/recovery_main.cpp
@@ -49,16 +49,16 @@
 #include <selinux/selinux.h>
 
 #include "common.h"
-#include "device.h"
 #include "fastboot/fastboot.h"
 #include "logging.h"
 #include "minadbd/minadbd.h"
 #include "otautil/paths.h"
 #include "otautil/sysutil.h"
 #include "recovery.h"
+#include "recovery_ui/device.h"
+#include "recovery_ui/stub_ui.h"
+#include "recovery_ui/ui.h"
 #include "roots.h"
-#include "stub_ui.h"
-#include "ui.h"
 
 static constexpr const char* COMMAND_FILE = "/cache/recovery/command";
 static constexpr const char* LOCALE_FILE = "/cache/recovery/last_locale";
diff --git a/recovery_ui/Android.bp b/recovery_ui/Android.bp
new file mode 100644
index 0000000..ee3149d
--- /dev/null
+++ b/recovery_ui/Android.bp
@@ -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"],
+}
diff --git a/default_device.cpp b/recovery_ui/default_device.cpp
similarity index 90%
rename from default_device.cpp
rename to recovery_ui/default_device.cpp
index a971866..4db461a 100644
--- a/default_device.cpp
+++ b/recovery_ui/default_device.cpp
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#include "device.h"
-#include "screen_ui.h"
+#include "recovery_ui/device.h"
+#include "recovery_ui/screen_ui.h"
 
 Device* make_device() {
   return new Device(new ScreenRecoveryUI);
diff --git a/device.cpp b/recovery_ui/device.cpp
similarity index 97%
rename from device.cpp
rename to recovery_ui/device.cpp
index eec1932..ddb0118 100644
--- a/device.cpp
+++ b/recovery_ui/device.cpp
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "device.h"
+#include "recovery_ui/device.h"
 
 #include <algorithm>
 #include <string>
@@ -23,7 +23,7 @@
 
 #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{
   { "Reboot system now", Device::REBOOT },
diff --git a/device.h b/recovery_ui/include/recovery_ui/device.h
similarity index 98%
rename from device.h
rename to recovery_ui/include/recovery_ui/device.h
index 6a8daf8..cfa914e 100644
--- a/device.h
+++ b/recovery_ui/include/recovery_ui/device.h
@@ -68,7 +68,7 @@
 
   // Called when recovery starts up (after the UI has been obtained and initialized and after the
   // 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
   // is pressed. (Note that "at" the main menu does not necessarily mean the menu is visible;
diff --git a/screen_ui.h b/recovery_ui/include/recovery_ui/screen_ui.h
similarity index 100%
rename from screen_ui.h
rename to recovery_ui/include/recovery_ui/screen_ui.h
diff --git a/stub_ui.h b/recovery_ui/include/recovery_ui/stub_ui.h
similarity index 100%
rename from stub_ui.h
rename to recovery_ui/include/recovery_ui/stub_ui.h
diff --git a/ui.h b/recovery_ui/include/recovery_ui/ui.h
similarity index 98%
rename from ui.h
rename to recovery_ui/include/recovery_ui/ui.h
index b387ae3..d55322c 100644
--- a/ui.h
+++ b/recovery_ui/include/recovery_ui/ui.h
@@ -35,20 +35,20 @@
     INSTALLING_UPDATE,
     ERASING,
     NO_COMMAND,
-    ERROR
+    ERROR,
   };
 
   enum ProgressType {
     EMPTY,
     INDETERMINATE,
-    DETERMINATE
+    DETERMINATE,
   };
 
   enum KeyAction {
     ENQUEUE,
     TOGGLE,
     REBOOT,
-    IGNORE
+    IGNORE,
   };
 
   enum class KeyError : int {
@@ -60,8 +60,8 @@
 
   virtual ~RecoveryUI();
 
-  // Initializes the object; called before anything else. UI texts will be initialized according to
-  // the given locale. Returns true on success.
+  // Initializes the object; called before anything else. UI texts will be initialized according
+  // to the given locale. Returns true on success.
   virtual bool Init(const std::string& locale);
 
   virtual std::string GetLocale() const = 0;
@@ -211,7 +211,7 @@
     DISABLED,
     NORMAL,
     DIMMED,
-    OFF
+    OFF,
   };
 
   // The sensitivity when detecting a swipe.
diff --git a/vr_ui.h b/recovery_ui/include/recovery_ui/vr_ui.h
similarity index 100%
rename from vr_ui.h
rename to recovery_ui/include/recovery_ui/vr_ui.h
diff --git a/wear_ui.h b/recovery_ui/include/recovery_ui/wear_ui.h
similarity index 100%
rename from wear_ui.h
rename to recovery_ui/include/recovery_ui/wear_ui.h
diff --git a/screen_ui.cpp b/recovery_ui/screen_ui.cpp
similarity index 98%
rename from screen_ui.cpp
rename to recovery_ui/screen_ui.cpp
index 6f2b68b..870db62 100644
--- a/screen_ui.cpp
+++ b/recovery_ui/screen_ui.cpp
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "screen_ui.h"
+#include "recovery_ui/screen_ui.h"
 
 #include <dirent.h>
 #include <errno.h>
@@ -42,10 +42,10 @@
 #include <android-base/stringprintf.h>
 #include <android-base/strings.h>
 
-#include "device.h"
 #include "minui/minui.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).
 static double now() {
@@ -388,10 +388,10 @@
 enum Layout { PORTRAIT = 0, PORTRAIT_LARGE = 1, LANDSCAPE = 2, LANDSCAPE_LARGE = 3, LAYOUT_MAX };
 enum Dimension { TEXT = 0, ICON = 1, DIMENSION_MAX };
 static constexpr int kLayouts[LAYOUT_MAX][DIMENSION_MAX] = {
-  { 32,  68, },  // PORTRAIT
-  { 32,  68, },  // PORTRAIT_LARGE
-  { 26,  56, },  // LANDSCAPE
-  { 52, 112, },  // LANDSCAPE_LARGE
+  { 32, 68 },   // PORTRAIT
+  { 32, 68 },   // PORTRAIT_LARGE
+  { 26, 56 },   // LANDSCAPE
+  { 52, 112 },  // LANDSCAPE_LARGE
 };
 
 int ScreenRecoveryUI::GetAnimationBaseline() const {
@@ -1042,7 +1042,7 @@
   va_end(ap);
 }
 
-void ScreenRecoveryUI::PrintOnScreenOnly(const char *fmt, ...) {
+void ScreenRecoveryUI::PrintOnScreenOnly(const char* fmt, ...) {
   va_list ap;
   va_start(ap, fmt);
   PrintV(fmt, false, ap);
diff --git a/ui.cpp b/recovery_ui/ui.cpp
similarity index 99%
rename from ui.cpp
rename to recovery_ui/ui.cpp
index c12a11b..b7107ff 100644
--- a/ui.cpp
+++ b/recovery_ui/ui.cpp
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "ui.h"
+#include "recovery_ui/ui.h"
 
 #include <errno.h>
 #include <fcntl.h>
@@ -39,7 +39,6 @@
 
 #include "minui/minui.h"
 #include "otautil/sysutil.h"
-#include "roots.h"
 
 using namespace std::chrono_literals;
 
@@ -590,8 +589,7 @@
   return (IsTextVisible() || screensaver_state_ == ScreensaverState::OFF) ? ENQUEUE : IGNORE;
 }
 
-void RecoveryUI::KeyLongPress(int) {
-}
+void RecoveryUI::KeyLongPress(int) {}
 
 void RecoveryUI::SetEnableReboot(bool enabled) {
   std::lock_guard<std::mutex> lg(key_queue_mutex);
diff --git a/vr_device.cpp b/recovery_ui/vr_device.cpp
similarity index 86%
rename from vr_device.cpp
rename to recovery_ui/vr_device.cpp
index 61e15cb..fd76133 100644
--- a/vr_device.cpp
+++ b/recovery_ui/vr_device.cpp
@@ -14,10 +14,9 @@
  * limitations under the License.
  */
 
-#include "device.h"
-#include "vr_ui.h"
+#include "recovery_ui/device.h"
+#include "recovery_ui/vr_ui.h"
 
 Device* make_device() {
-    return new Device(new VrRecoveryUI);
+  return new Device(new VrRecoveryUI);
 }
-
diff --git a/vr_ui.cpp b/recovery_ui/vr_ui.cpp
similarity index 98%
rename from vr_ui.cpp
rename to recovery_ui/vr_ui.cpp
index 1f0292c..5b9b1b4 100644
--- a/vr_ui.cpp
+++ b/recovery_ui/vr_ui.cpp
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "vr_ui.h"
+#include "recovery_ui/vr_ui.h"
 
 #include <android-base/properties.h>
 
diff --git a/wear_device.cpp b/recovery_ui/wear_device.cpp
similarity index 90%
rename from wear_device.cpp
rename to recovery_ui/wear_device.cpp
index 3268130..bf21bc9 100644
--- a/wear_device.cpp
+++ b/recovery_ui/wear_device.cpp
@@ -14,10 +14,9 @@
  * limitations under the License.
  */
 
-#include "device.h"
-#include "wear_ui.h"
+#include "recovery_ui/device.h"
+#include "recovery_ui/wear_ui.h"
 
 Device* make_device() {
   return new Device(new WearRecoveryUI);
 }
-
diff --git a/wear_ui.cpp b/recovery_ui/wear_ui.cpp
similarity index 98%
rename from wear_ui.cpp
rename to recovery_ui/wear_ui.cpp
index 6da84c9..8d8108f 100644
--- a/wear_ui.cpp
+++ b/recovery_ui/wear_ui.cpp
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "wear_ui.h"
+#include "recovery_ui/wear_ui.h"
 
 #include <string.h>
 
diff --git a/tests/unit/screen_ui_test.cpp b/tests/unit/screen_ui_test.cpp
index 647c7b2..883dfbd 100644
--- a/tests/unit/screen_ui_test.cpp
+++ b/tests/unit/screen_ui_test.cpp
@@ -30,11 +30,11 @@
 #include <gtest/gtest_prod.h>
 
 #include "common/test_constants.h"
-#include "device.h"
 #include "minui/minui.h"
 #include "otautil/paths.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> ITEMS{ "item1", "item2", "item3", "item4", "1234567890" };