summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTianjie Xu <xunchang@google.com>2018-12-12 00:24:05 +0100
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-12-12 00:24:05 +0100
commitc456aab7e26ceaa8a322668122029c85a4eb4c31 (patch)
treeb4c41b378f11d46e64248a4157f087bb87e82d1e
parentMerge "tests: Temporarily disable ScreenRecoveryUITest tests." (diff)
parentShow wipe data confirmation text in recovery mode (diff)
downloadandroid_bootable_recovery-c456aab7e26ceaa8a322668122029c85a4eb4c31.tar
android_bootable_recovery-c456aab7e26ceaa8a322668122029c85a4eb4c31.tar.gz
android_bootable_recovery-c456aab7e26ceaa8a322668122029c85a4eb4c31.tar.bz2
android_bootable_recovery-c456aab7e26ceaa8a322668122029c85a4eb4c31.tar.lz
android_bootable_recovery-c456aab7e26ceaa8a322668122029c85a4eb4c31.tar.xz
android_bootable_recovery-c456aab7e26ceaa8a322668122029c85a4eb4c31.tar.zst
android_bootable_recovery-c456aab7e26ceaa8a322668122029c85a4eb4c31.zip
-rw-r--r--recovery.cpp10
-rw-r--r--screen_ui.cpp22
-rw-r--r--screen_ui.h11
-rw-r--r--stub_ui.h7
-rw-r--r--ui.h7
5 files changed, 51 insertions, 6 deletions
diff --git a/recovery.cpp b/recovery.cpp
index 7e1fa43a6..de916c633 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -369,7 +369,14 @@ static bool yes_no(Device* device, const char* question1, const char* question2)
}
static bool ask_to_wipe_data(Device* device) {
- return yes_no(device, "Wipe all user data?", " THIS CAN NOT BE UNDONE!");
+ std::vector<std::string> headers{ "Wipe all user data?", " THIS CAN NOT BE UNDONE!" };
+ std::vector<std::string> items{ " Cancel", " Factory data reset" };
+
+ size_t chosen_item = ui->ShowPromptWipeDataConfirmationMenu(
+ headers, items,
+ std::bind(&Device::HandleMenuKey, device, std::placeholders::_1, std::placeholders::_2));
+
+ return (chosen_item == 1);
}
// Return true on success.
@@ -420,7 +427,6 @@ static InstallResult prompt_and_wipe_data(Device* device) {
return INSTALL_SUCCESS; // Just reboot, no wipe; not a failure, user asked for it
}
- // TODO(xunchang) localize the confirmation texts also.
if (ask_to_wipe_data(device)) {
if (wipe_data(device)) {
return INSTALL_SUCCESS;
diff --git a/screen_ui.cpp b/screen_ui.cpp
index 765d2fe60..575605452 100644
--- a/screen_ui.cpp
+++ b/screen_ui.cpp
@@ -844,9 +844,13 @@ bool ScreenRecoveryUI::InitTextParams() {
return true;
}
-// TODO(xunchang) load localized text icons for the menu. (Init for screenRecoveryUI but
-// not wearRecoveryUI).
bool ScreenRecoveryUI::LoadWipeDataMenuText() {
+ // Ignores the errors since the member variables will stay as nullptr.
+ cancel_wipe_data_text_ = LoadLocalizedBitmap("cancel_wipe_data_text");
+ factory_data_reset_text_ = LoadLocalizedBitmap("factory_data_reset_text");
+ try_again_text_ = LoadLocalizedBitmap("try_again_text");
+ wipe_data_confirmation_text_ = LoadLocalizedBitmap("wipe_data_confirmation_text");
+ wipe_data_menu_header_text_ = LoadLocalizedBitmap("wipe_data_menu_header_text");
return true;
}
@@ -1250,6 +1254,20 @@ size_t ScreenRecoveryUI::ShowPromptWipeDataMenu(const std::vector<std::string>&
return ShowMenu(std::move(wipe_data_menu), true, key_handler);
}
+size_t ScreenRecoveryUI::ShowPromptWipeDataConfirmationMenu(
+ const std::vector<std::string>& backup_headers, const std::vector<std::string>& backup_items,
+ const std::function<int(int, bool)>& key_handler) {
+ auto confirmation_menu =
+ CreateMenu(wipe_data_confirmation_text_.get(),
+ { cancel_wipe_data_text_.get(), factory_data_reset_text_.get() }, backup_headers,
+ backup_items, 0);
+ if (confirmation_menu == nullptr) {
+ return 0;
+ }
+
+ return ShowMenu(std::move(confirmation_menu), true, key_handler);
+}
+
bool ScreenRecoveryUI::IsTextVisible() {
std::lock_guard<std::mutex> lg(updateMutex);
int visible = show_text;
diff --git a/screen_ui.h b/screen_ui.h
index ff245a2fb..acd44c819 100644
--- a/screen_ui.h
+++ b/screen_ui.h
@@ -240,6 +240,11 @@ class ScreenRecoveryUI : public RecoveryUI, public DrawInterface {
const std::vector<std::string>& backup_items,
const std::function<int(int, bool)>& key_handler) override;
+ // Displays the localized wipe data confirmation menu.
+ size_t ShowPromptWipeDataConfirmationMenu(
+ const std::vector<std::string>& backup_headers, const std::vector<std::string>& backup_items,
+ const std::function<int(int, bool)>& key_handler) override;
+
protected:
static constexpr int kMenuIndent = 4;
@@ -334,9 +339,11 @@ class ScreenRecoveryUI : public RecoveryUI, public DrawInterface {
std::unique_ptr<GRSurface> no_command_text_;
// Localized text images for the wipe data menu.
- std::unique_ptr<GRSurface> wipe_data_menu_header_text_;
- std::unique_ptr<GRSurface> try_again_text_;
+ std::unique_ptr<GRSurface> cancel_wipe_data_text_;
std::unique_ptr<GRSurface> factory_data_reset_text_;
+ std::unique_ptr<GRSurface> try_again_text_;
+ std::unique_ptr<GRSurface> wipe_data_confirmation_text_;
+ std::unique_ptr<GRSurface> wipe_data_menu_header_text_;
// current_icon_ points to one of the frames in intro_frames_ or loop_frames_, indexed by
// current_frame_, or error_icon_.
diff --git a/stub_ui.h b/stub_ui.h
index ca137dff3..fb1d8c7a6 100644
--- a/stub_ui.h
+++ b/stub_ui.h
@@ -74,6 +74,13 @@ class StubRecoveryUI : public RecoveryUI {
return 0;
}
+ size_t ShowPromptWipeDataConfirmationMenu(
+ const std::vector<std::string>& /* backup_headers */,
+ const std::vector<std::string>& /* backup_items */,
+ const std::function<int(int, bool)>& /* key_handle */) override {
+ return 0;
+ }
+
void SetTitle(const std::vector<std::string>& /* lines */) override {}
};
diff --git a/ui.h b/ui.h
index 1e6186a11..4924fec52 100644
--- a/ui.h
+++ b/ui.h
@@ -169,6 +169,13 @@ class RecoveryUI {
const std::vector<std::string>& backup_items,
const std::function<int(int, bool)>& key_handler) = 0;
+ // Displays the localized wipe data confirmation menu with pre-generated images. Falls back to
+ // the text strings upon failures. The initial selection is the 0th item, which returns to the
+ // upper level menu.
+ virtual size_t ShowPromptWipeDataConfirmationMenu(
+ const std::vector<std::string>& backup_headers, const std::vector<std::string>& backup_items,
+ const std::function<int(int, bool)>& key_handler) = 0;
+
// Resets the key interrupt status.
void ResetKeyInterruptStatus() {
key_interrupted_ = false;