Merge changes Ibbe7084e,If584fc8a
am: bb8f0fff17
Change-Id: I1df188d9a668dffc2f81000c30ae1d6fd2f4bb1c
This commit is contained in:
11
common.h
11
common.h
@@ -14,11 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef RECOVERY_COMMON_H
|
#pragma once
|
||||||
#define RECOVERY_COMMON_H
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -39,9 +35,4 @@ extern std::string stage;
|
|||||||
// The reason argument provided in "--reason=".
|
// The reason argument provided in "--reason=".
|
||||||
extern const char* reason;
|
extern const char* reason;
|
||||||
|
|
||||||
void ui_print(const char* format, ...) __printflike(1, 2);
|
|
||||||
|
|
||||||
bool is_ro_debuggable();
|
bool is_ro_debuggable();
|
||||||
|
|
||||||
bool SetUsbConfig(const std::string& state);
|
|
||||||
#endif // RECOVERY_COMMON_H
|
|
||||||
|
|||||||
21
recovery.cpp
21
recovery.cpp
@@ -24,7 +24,6 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <linux/fs.h>
|
#include <linux/fs.h>
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -272,12 +271,6 @@ static bool erase_volume(const char* volume) {
|
|||||||
return (result == 0);
|
return (result == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets the usb config to 'state'
|
|
||||||
bool SetUsbConfig(const std::string& state) {
|
|
||||||
android::base::SetProperty("sys.usb.config", state);
|
|
||||||
return android::base::WaitForProperty("sys.usb.state", state);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool yes_no(Device* device, const char* question1, const char* question2) {
|
static bool yes_no(Device* device, const char* question1, const char* question2) {
|
||||||
std::vector<std::string> headers{ question1, question2 };
|
std::vector<std::string> headers{ question1, question2 };
|
||||||
std::vector<std::string> items{ " No", " Yes" };
|
std::vector<std::string> items{ " No", " Yes" };
|
||||||
@@ -746,20 +739,6 @@ static void print_property(const char* key, const char* name, void* /* cookie */
|
|||||||
printf("%s=%s\n", key, name);
|
printf("%s=%s\n", key, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_print(const char* format, ...) {
|
|
||||||
std::string buffer;
|
|
||||||
va_list ap;
|
|
||||||
va_start(ap, format);
|
|
||||||
android::base::StringAppendV(&buffer, format, ap);
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
if (ui != nullptr) {
|
|
||||||
ui->Print("%s", buffer.c_str());
|
|
||||||
} else {
|
|
||||||
fputs(buffer.c_str(), stdout);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool is_battery_ok(int* required_battery_level) {
|
static bool is_battery_ok(int* required_battery_level) {
|
||||||
using android::hardware::health::V1_0::BatteryStatus;
|
using android::hardware::health::V1_0::BatteryStatus;
|
||||||
using android::hardware::health::V2_0::get_health_service;
|
using android::hardware::health::V2_0::get_health_service;
|
||||||
|
|||||||
@@ -178,6 +178,12 @@ static std::string load_locale_from_cache() {
|
|||||||
return android::base::Trim(content);
|
return android::base::Trim(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sets the usb config to 'state'.
|
||||||
|
static bool SetUsbConfig(const std::string& state) {
|
||||||
|
android::base::SetProperty("sys.usb.config", state);
|
||||||
|
return android::base::WaitForProperty("sys.usb.state", state);
|
||||||
|
}
|
||||||
|
|
||||||
static void ListenRecoverySocket(RecoveryUI* ui, std::atomic<Device::BuiltinAction>& action) {
|
static void ListenRecoverySocket(RecoveryUI* ui, std::atomic<Device::BuiltinAction>& action) {
|
||||||
android::base::unique_fd sock_fd(android_get_control_socket("recovery"));
|
android::base::unique_fd sock_fd(android_get_control_socket("recovery"));
|
||||||
if (sock_fd < 0) {
|
if (sock_fd < 0) {
|
||||||
|
|||||||
@@ -93,8 +93,8 @@ class Device {
|
|||||||
|
|
||||||
// Performs a recovery action selected from the menu. 'menu_position' will be the index of the
|
// Performs a recovery action selected from the menu. 'menu_position' will be the index of the
|
||||||
// selected menu item, or a non-negative value returned from HandleMenuKey(). The menu will be
|
// selected menu item, or a non-negative value returned from HandleMenuKey(). The menu will be
|
||||||
// hidden when this is called; implementations can call ui_print() to print information to the
|
// hidden when this is called; implementations can call GetUI()->Print() to print information to
|
||||||
// screen. If the menu position is one of the builtin actions, you can just return the
|
// the screen. If the menu position is one of the builtin actions, you can just return the
|
||||||
// corresponding enum value. If it is an action specific to your device, you actually perform it
|
// corresponding enum value. If it is an action specific to your device, you actually perform it
|
||||||
// here and return NO_ACTION.
|
// here and return NO_ACTION.
|
||||||
virtual BuiltinAction InvokeMenuItem(size_t menu_position);
|
virtual BuiltinAction InvokeMenuItem(size_t menu_position);
|
||||||
|
|||||||
Reference in New Issue
Block a user