aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlessandro Astone <ales.astone@gmail.com>2019-03-29 21:49:20 +0100
committerMichael Bestas <mkbestas@lineageos.org>2019-04-05 02:12:01 +0300
commite5004ac43465fa8d9c8118373cbd660a58ccee56 (patch)
tree247816dc67be5caef7eeb2b96211e1d679eba5d3
parentb3552c5447961bee673472ca65155325a940f906 (diff)
downloadandroid_bootable_recovery-e5004ac43465fa8d9c8118373cbd660a58ccee56.tar.gz
android_bootable_recovery-e5004ac43465fa8d9c8118373cbd660a58ccee56.tar.bz2
android_bootable_recovery-e5004ac43465fa8d9c8118373cbd660a58ccee56.zip
recovery: ignore refresh events while on browsing menus
* Also avoid generating a refresh event when mounting a storage volume to browse it, it would end up being ignored anyways. Thanks to @tdm Change-Id: Idabce4e90b484f34f83d310abdb345778cfc3bf0
-rw-r--r--recovery.cpp15
-rw-r--r--ui.h3
2 files changed, 11 insertions, 7 deletions
diff --git a/recovery.cpp b/recovery.cpp
index 29dd39dc..2bb60521 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -731,7 +731,7 @@ static bool erase_volume(const char* volume) {
// (non-negative) chosen item number, or -1 if timed out waiting for input.
int get_menu_selection(bool menu_is_main, menu_type_t menu_type, const char* const* headers,
const MenuItemVector& menu_items, bool menu_only, int initial_selection,
- Device* device) {
+ Device* device, bool refreshable = false) {
// Throw away keys pressed previously, so user doesn't accidentally trigger menu items.
ui->FlushKeys();
@@ -794,7 +794,9 @@ int get_menu_selection(bool menu_is_main, menu_type_t menu_type, const char* con
chosen_item = Device::kGoHome;
break;
case Device::kRefresh:
- chosen_item = Device::kRefresh;
+ if (refreshable) {
+ chosen_item = Device::kRefresh;
+ }
break;
}
} else if (!menu_only) {
@@ -861,7 +863,7 @@ static std::string browse_directory(const std::string& path, Device* device) {
return "";
}
if (chosen_item == Device::kRefresh) {
- return "@refresh";
+ continue;
}
const std::string& item = zips[chosen_item];
@@ -1212,6 +1214,7 @@ static int apply_from_storage(Device* device, VolumeInfo& vi, bool* wipe_cache)
if (!VolumeManager::Instance()->volumeMount(vi.mId)) {
return INSTALL_ERROR;
}
+ ui->VolumesChanged();
std::string path;
do {
@@ -1270,7 +1273,8 @@ refresh:
int status = INSTALL_ERROR;
- int chosen = get_menu_selection(false, MT_LIST, headers, items, false, 0, device);
+ int chosen =
+ get_menu_selection(false, MT_LIST, headers, items, false, 0, device, true /*refreshable*/);
if (chosen == Device::kRefresh) {
goto refresh;
}
@@ -1282,7 +1286,8 @@ refresh:
static const MenuItemVector s_items = { MenuItem("Cancel sideload") };
sideload_start();
- int item = get_menu_selection(false, MT_LIST, s_headers, s_items, false, 0, device);
+ int item = get_menu_selection(false, MT_LIST, s_headers, s_items, false, 0, device,
+ true /*refreshable*/);
if (item == Device::kRefresh) {
sideload_wait(false);
status = sideload_install(wipe_cache, TEMPORARY_INSTALL_FILE, true);
diff --git a/ui.h b/ui.h
index 018ad3c9..c7f2f915 100644
--- a/ui.h
+++ b/ui.h
@@ -258,6 +258,7 @@ class RecoveryUI {
void onVolumeChanged() {
volumes_changed_ = 1;
}
+ bool VolumesChanged();
virtual bool MenuShowing() const = 0;
virtual bool MenuScrollable() const = 0;
@@ -310,8 +311,6 @@ class RecoveryUI {
bool IsUsbConnected();
- bool VolumesChanged();
-
static void* time_key_helper(void* cookie);
void time_key(int key_code, int count);