Merge "Switch to <android-base/properties.h>." am: cc02f9652f
am: be9a94fd17
Change-Id: Ib5e4fb8d20e04df7b592af96d898afbbc6846620
This commit is contained in:
@@ -26,13 +26,14 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
#include "cutils/properties.h"
|
|
||||||
#include "install.h"
|
#include "install.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "adb_install.h"
|
#include "adb_install.h"
|
||||||
#include "minadbd/fuse_adb_provider.h"
|
#include "minadbd/fuse_adb_provider.h"
|
||||||
#include "fuse_sideload.h"
|
#include "fuse_sideload.h"
|
||||||
|
|
||||||
|
#include <android-base/properties.h>
|
||||||
|
|
||||||
static void set_usb_driver(RecoveryUI* ui, bool enabled) {
|
static void set_usb_driver(RecoveryUI* ui, bool enabled) {
|
||||||
int fd = open("/sys/class/android_usb/android0/enable", O_WRONLY);
|
int fd = open("/sys/class/android_usb/android0/enable", O_WRONLY);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
@@ -49,7 +50,7 @@ static void set_usb_driver(RecoveryUI* ui, bool enabled) {
|
|||||||
|
|
||||||
static void stop_adbd(RecoveryUI* ui) {
|
static void stop_adbd(RecoveryUI* ui) {
|
||||||
ui->Print("Stopping adbd...\n");
|
ui->Print("Stopping adbd...\n");
|
||||||
property_set("ctl.stop", "adbd");
|
android::base::SetProperty("ctl.stop", "adbd");
|
||||||
set_usb_driver(ui, false);
|
set_usb_driver(ui, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +58,7 @@ static void maybe_restart_adbd(RecoveryUI* ui) {
|
|||||||
if (is_ro_debuggable()) {
|
if (is_ro_debuggable()) {
|
||||||
ui->Print("Restarting adbd...\n");
|
ui->Print("Restarting adbd...\n");
|
||||||
set_usb_driver(ui, true);
|
set_usb_driver(ui, true);
|
||||||
property_set("ctl.start", "adbd");
|
android::base::SetProperty("ctl.start", "adbd");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
20
recovery.cpp
20
recovery.cpp
@@ -43,11 +43,12 @@
|
|||||||
#include <android-base/file.h>
|
#include <android-base/file.h>
|
||||||
#include <android-base/logging.h>
|
#include <android-base/logging.h>
|
||||||
#include <android-base/parseint.h>
|
#include <android-base/parseint.h>
|
||||||
|
#include <android-base/properties.h>
|
||||||
#include <android-base/stringprintf.h>
|
#include <android-base/stringprintf.h>
|
||||||
#include <android-base/strings.h>
|
#include <android-base/strings.h>
|
||||||
#include <android-base/unique_fd.h>
|
#include <android-base/unique_fd.h>
|
||||||
#include <cutils/android_reboot.h>
|
#include <cutils/android_reboot.h>
|
||||||
#include <cutils/properties.h>
|
#include <cutils/properties.h> /* for property_list */
|
||||||
#include <healthd/BatteryMonitor.h>
|
#include <healthd/BatteryMonitor.h>
|
||||||
#include <private/android_logger.h> /* private pmsg functions */
|
#include <private/android_logger.h> /* private pmsg functions */
|
||||||
#include <selinux/label.h>
|
#include <selinux/label.h>
|
||||||
@@ -205,8 +206,7 @@ static void check_and_fclose(FILE *fp, const char *name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool is_ro_debuggable() {
|
bool is_ro_debuggable() {
|
||||||
char value[PROPERTY_VALUE_MAX+1];
|
return android::base::GetBoolProperty("ro.debuggable", false);
|
||||||
return (property_get("ro.debuggable", value, NULL) == 1 && value[0] == '1');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void redirect_stdio(const char* filename) {
|
static void redirect_stdio(const char* filename) {
|
||||||
@@ -1182,15 +1182,12 @@ prompt_and_wait(Device* device, int status) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Device::MOUNT_SYSTEM:
|
case Device::MOUNT_SYSTEM:
|
||||||
char system_root_image[PROPERTY_VALUE_MAX];
|
|
||||||
property_get("ro.build.system_root_image", system_root_image, "");
|
|
||||||
|
|
||||||
// For a system image built with the root directory (i.e.
|
// For a system image built with the root directory (i.e.
|
||||||
// system_root_image == "true"), we mount it to /system_root, and symlink /system
|
// system_root_image == "true"), we mount it to /system_root, and symlink /system
|
||||||
// to /system_root/system to make adb shell work (the symlink is created through
|
// to /system_root/system to make adb shell work (the symlink is created through
|
||||||
// the build system).
|
// the build system).
|
||||||
// Bug: 22855115
|
// Bug: 22855115
|
||||||
if (strcmp(system_root_image, "true") == 0) {
|
if (android::base::GetBoolProperty("ro.build.system_root_image", false)) {
|
||||||
if (ensure_path_mounted_at("/", "/system_root") != -1) {
|
if (ensure_path_mounted_at("/", "/system_root") != -1) {
|
||||||
ui->Print("Mounted /system.\n");
|
ui->Print("Mounted /system.\n");
|
||||||
}
|
}
|
||||||
@@ -1584,8 +1581,7 @@ int main(int argc, char **argv) {
|
|||||||
ui->Print("Retry attempt %d\n", retry_count);
|
ui->Print("Retry attempt %d\n", retry_count);
|
||||||
|
|
||||||
// Reboot and retry the update
|
// Reboot and retry the update
|
||||||
int ret = property_set(ANDROID_RB_PROPERTY, "reboot,recovery");
|
if (!android::base::SetProperty(ANDROID_RB_PROPERTY, "reboot,recovery")) {
|
||||||
if (ret < 0) {
|
|
||||||
ui->Print("Reboot failed\n");
|
ui->Print("Reboot failed\n");
|
||||||
} else {
|
} else {
|
||||||
while (true) {
|
while (true) {
|
||||||
@@ -1665,17 +1661,17 @@ int main(int argc, char **argv) {
|
|||||||
switch (after) {
|
switch (after) {
|
||||||
case Device::SHUTDOWN:
|
case Device::SHUTDOWN:
|
||||||
ui->Print("Shutting down...\n");
|
ui->Print("Shutting down...\n");
|
||||||
property_set(ANDROID_RB_PROPERTY, "shutdown,");
|
android::base::SetProperty(ANDROID_RB_PROPERTY, "shutdown,");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Device::REBOOT_BOOTLOADER:
|
case Device::REBOOT_BOOTLOADER:
|
||||||
ui->Print("Rebooting to bootloader...\n");
|
ui->Print("Rebooting to bootloader...\n");
|
||||||
property_set(ANDROID_RB_PROPERTY, "reboot,bootloader");
|
android::base::SetProperty(ANDROID_RB_PROPERTY, "reboot,bootloader");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ui->Print("Rebooting...\n");
|
ui->Print("Rebooting...\n");
|
||||||
property_set(ANDROID_RB_PROPERTY, "reboot,");
|
android::base::SetProperty(ANDROID_RB_PROPERTY, "reboot,");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|||||||
@@ -32,9 +32,9 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <android-base/logging.h>
|
#include <android-base/logging.h>
|
||||||
|
#include <android-base/properties.h>
|
||||||
#include <android-base/strings.h>
|
#include <android-base/strings.h>
|
||||||
#include <android-base/stringprintf.h>
|
#include <android-base/stringprintf.h>
|
||||||
#include <cutils/properties.h>
|
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
@@ -281,8 +281,8 @@ void ScreenRecoveryUI::draw_screen_locked() {
|
|||||||
|
|
||||||
int y = 0;
|
int y = 0;
|
||||||
if (show_menu) {
|
if (show_menu) {
|
||||||
char recovery_fingerprint[PROPERTY_VALUE_MAX];
|
std::string recovery_fingerprint =
|
||||||
property_get("ro.bootimage.build.fingerprint", recovery_fingerprint, "");
|
android::base::GetProperty("ro.bootimage.build.fingerprint", "");
|
||||||
|
|
||||||
SetColor(INFO);
|
SetColor(INFO);
|
||||||
DrawTextLine(TEXT_INDENT, &y, "Android Recovery", true);
|
DrawTextLine(TEXT_INDENT, &y, "Android Recovery", true);
|
||||||
@@ -439,7 +439,7 @@ void ScreenRecoveryUI::SetSystemUpdateText(bool security_update) {
|
|||||||
void ScreenRecoveryUI::Init() {
|
void ScreenRecoveryUI::Init() {
|
||||||
gr_init();
|
gr_init();
|
||||||
|
|
||||||
density_ = static_cast<float>(property_get_int32("ro.sf.lcd_density", 160)) / 160.f;
|
density_ = static_cast<float>(android::base::GetIntProperty("ro.sf.lcd_density", 160)) / 160.f;
|
||||||
is_large_ = gr_fb_height() > PixelsFromDp(800);
|
is_large_ = gr_fb_height() > PixelsFromDp(800);
|
||||||
|
|
||||||
gr_font_size(&char_width_, &char_height_);
|
gr_font_size(&char_width_, &char_height_);
|
||||||
|
|||||||
4
ui.cpp
4
ui.cpp
@@ -28,7 +28,7 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <cutils/properties.h>
|
#include <android-base/properties.h>
|
||||||
#include <cutils/android_reboot.h>
|
#include <cutils/android_reboot.h>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
@@ -175,7 +175,7 @@ void RecoveryUI::ProcessKey(int key_code, int updown) {
|
|||||||
|
|
||||||
case RecoveryUI::REBOOT:
|
case RecoveryUI::REBOOT:
|
||||||
if (reboot_enabled) {
|
if (reboot_enabled) {
|
||||||
property_set(ANDROID_RB_PROPERTY, "reboot,");
|
android::base::SetProperty(ANDROID_RB_PROPERTY, "reboot,");
|
||||||
while (true) { pause(); }
|
while (true) { pause(); }
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -17,12 +17,12 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/system_properties.h>
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <android-base/file.h>
|
#include <android-base/file.h>
|
||||||
|
#include <android-base/properties.h>
|
||||||
#include <android-base/stringprintf.h>
|
#include <android-base/stringprintf.h>
|
||||||
#include <android-base/unique_fd.h>
|
#include <android-base/unique_fd.h>
|
||||||
#include <fs_mgr.h>
|
#include <fs_mgr.h>
|
||||||
@@ -30,14 +30,13 @@
|
|||||||
#include "bootloader.h"
|
#include "bootloader.h"
|
||||||
|
|
||||||
static struct fstab* read_fstab(std::string* err) {
|
static struct fstab* read_fstab(std::string* err) {
|
||||||
// The fstab path is always "/fstab.${ro.hardware}".
|
std::string ro_hardware = android::base::GetProperty("ro.hardware", "");
|
||||||
std::string fstab_path = "/fstab.";
|
if (ro_hardware.empty()) {
|
||||||
char value[PROP_VALUE_MAX];
|
|
||||||
if (__system_property_get("ro.hardware", value) == 0) {
|
|
||||||
*err = "failed to get ro.hardware";
|
*err = "failed to get ro.hardware";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
fstab_path += value;
|
// The fstab path is always "/fstab.${ro.hardware}".
|
||||||
|
std::string fstab_path = "/fstab." + ro_hardware;
|
||||||
struct fstab* fstab = fs_mgr_read_fstab(fstab_path.c_str());
|
struct fstab* fstab = fs_mgr_read_fstab(fstab_path.c_str());
|
||||||
if (fstab == nullptr) {
|
if (fstab == nullptr) {
|
||||||
*err = "failed to read " + fstab_path;
|
*err = "failed to read " + fstab_path;
|
||||||
|
|||||||
@@ -107,12 +107,12 @@
|
|||||||
|
|
||||||
#include <android-base/file.h>
|
#include <android-base/file.h>
|
||||||
#include <android-base/logging.h>
|
#include <android-base/logging.h>
|
||||||
|
#include <android-base/properties.h>
|
||||||
#include <android-base/stringprintf.h>
|
#include <android-base/stringprintf.h>
|
||||||
#include <android-base/strings.h>
|
#include <android-base/strings.h>
|
||||||
#include <android-base/unique_fd.h>
|
#include <android-base/unique_fd.h>
|
||||||
#include <bootloader_message_writer.h>
|
#include <bootloader_message_writer.h>
|
||||||
#include <cutils/android_reboot.h>
|
#include <cutils/android_reboot.h>
|
||||||
#include <cutils/properties.h>
|
|
||||||
#include <cutils/sockets.h>
|
#include <cutils/sockets.h>
|
||||||
#include <fs_mgr.h>
|
#include <fs_mgr.h>
|
||||||
|
|
||||||
@@ -163,13 +163,15 @@ static struct fstab* read_fstab() {
|
|||||||
fstab = NULL;
|
fstab = NULL;
|
||||||
|
|
||||||
// The fstab path is always "/fstab.${ro.hardware}".
|
// The fstab path is always "/fstab.${ro.hardware}".
|
||||||
char fstab_path[PATH_MAX+1] = "/fstab.";
|
std::string ro_hardware = android::base::GetProperty("ro.hardware", "");
|
||||||
if (!property_get("ro.hardware", fstab_path+strlen(fstab_path), "")) {
|
if (ro_hardware.empty()) {
|
||||||
LOG(ERROR) << "failed to get ro.hardware";
|
LOG(ERROR) << "failed to get ro.hardware";
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
fstab = fs_mgr_read_fstab(fstab_path);
|
std::string fstab_path = "/fstab." + ro_hardware;
|
||||||
|
|
||||||
|
fstab = fs_mgr_read_fstab(fstab_path.c_str());
|
||||||
if (!fstab) {
|
if (!fstab) {
|
||||||
LOG(ERROR) << "failed to read " << fstab_path;
|
LOG(ERROR) << "failed to read " << fstab_path;
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -194,9 +196,7 @@ static const char* find_block_device(const char* path, bool* encryptable, bool*
|
|||||||
*encryptable = false;
|
*encryptable = false;
|
||||||
if (fs_mgr_is_encryptable(v) || fs_mgr_is_file_encrypted(v)) {
|
if (fs_mgr_is_encryptable(v) || fs_mgr_is_file_encrypted(v)) {
|
||||||
*encryptable = true;
|
*encryptable = true;
|
||||||
char buffer[PROPERTY_VALUE_MAX+1];
|
if (android::base::GetProperty("ro.crypto.state", "") == "encrypted") {
|
||||||
if (property_get("ro.crypto.state", buffer, "") &&
|
|
||||||
strcmp(buffer, "encrypted") == 0) {
|
|
||||||
*encrypted = true;
|
*encrypted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <android-base/parseint.h>
|
#include <android-base/parseint.h>
|
||||||
|
#include <android-base/properties.h>
|
||||||
#include <android-base/strings.h>
|
#include <android-base/strings.h>
|
||||||
#include <android-base/stringprintf.h>
|
#include <android-base/stringprintf.h>
|
||||||
#include <selinux/label.h>
|
#include <selinux/label.h>
|
||||||
@@ -46,7 +47,6 @@
|
|||||||
#include "applypatch/applypatch.h"
|
#include "applypatch/applypatch.h"
|
||||||
#include "cutils/android_reboot.h"
|
#include "cutils/android_reboot.h"
|
||||||
#include "cutils/misc.h"
|
#include "cutils/misc.h"
|
||||||
#include "cutils/properties.h"
|
|
||||||
#include "edify/expr.h"
|
#include "edify/expr.h"
|
||||||
#include "error_code.h"
|
#include "error_code.h"
|
||||||
#include "minzip/DirUtil.h"
|
#include "minzip/DirUtil.h"
|
||||||
@@ -906,11 +906,10 @@ Value* GetPropFn(const char* name, State* state, int argc, Expr* argv[]) {
|
|||||||
char* key = Evaluate(state, argv[0]);
|
char* key = Evaluate(state, argv[0]);
|
||||||
if (key == NULL) return NULL;
|
if (key == NULL) return NULL;
|
||||||
|
|
||||||
char value[PROPERTY_VALUE_MAX];
|
std::string value = android::base::GetProperty(key, "");
|
||||||
property_get(key, value, "");
|
|
||||||
free(key);
|
free(key);
|
||||||
|
|
||||||
return StringValue(strdup(value));
|
return StringValue(strdup(value.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1301,9 +1300,8 @@ Value* RebootNowFn(const char* name, State* state, int argc, Expr* argv[]) {
|
|||||||
char* property;
|
char* property;
|
||||||
if (ReadArgs(state, argv, 2, &filename, &property) < 0) return NULL;
|
if (ReadArgs(state, argv, 2, &filename, &property) < 0) return NULL;
|
||||||
|
|
||||||
char buffer[80];
|
|
||||||
|
|
||||||
// zero out the 'command' field of the bootloader message.
|
// zero out the 'command' field of the bootloader message.
|
||||||
|
char buffer[80];
|
||||||
memset(buffer, 0, sizeof(((struct bootloader_message*)0)->command));
|
memset(buffer, 0, sizeof(((struct bootloader_message*)0)->command));
|
||||||
FILE* f = ota_fopen(filename, "r+b");
|
FILE* f = ota_fopen(filename, "r+b");
|
||||||
fseek(f, offsetof(struct bootloader_message, command), SEEK_SET);
|
fseek(f, offsetof(struct bootloader_message, command), SEEK_SET);
|
||||||
@@ -1311,12 +1309,9 @@ Value* RebootNowFn(const char* name, State* state, int argc, Expr* argv[]) {
|
|||||||
ota_fclose(f);
|
ota_fclose(f);
|
||||||
free(filename);
|
free(filename);
|
||||||
|
|
||||||
strcpy(buffer, "reboot,");
|
std::string reboot_cmd = "reboot,";
|
||||||
if (property != NULL) {
|
if (property != nullptr) reboot_cmd += property;
|
||||||
strncat(buffer, property, sizeof(buffer)-10);
|
android::base::SetProperty(ANDROID_RB_PROPERTY, reboot_cmd);
|
||||||
}
|
|
||||||
|
|
||||||
property_set(ANDROID_RB_PROPERTY, buffer);
|
|
||||||
|
|
||||||
sleep(5);
|
sleep(5);
|
||||||
free(property);
|
free(property);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "wear_ui.h"
|
#include "wear_ui.h"
|
||||||
#include "cutils/properties.h"
|
#include "android-base/properties.h"
|
||||||
#include "android-base/strings.h"
|
#include "android-base/strings.h"
|
||||||
#include "android-base/stringprintf.h"
|
#include "android-base/stringprintf.h"
|
||||||
|
|
||||||
@@ -160,8 +160,8 @@ void WearRecoveryUI::draw_screen_locked()
|
|||||||
int y = outer_height;
|
int y = outer_height;
|
||||||
int x = outer_width;
|
int x = outer_width;
|
||||||
if (show_menu) {
|
if (show_menu) {
|
||||||
char recovery_fingerprint[PROPERTY_VALUE_MAX];
|
std::string recovery_fingerprint =
|
||||||
property_get("ro.bootimage.build.fingerprint", recovery_fingerprint, "");
|
android::base::GetProperty("ro.bootimage.build.fingerprint", "");
|
||||||
SetColor(HEADER);
|
SetColor(HEADER);
|
||||||
DrawTextLine(x + 4, &y, "Android Recovery", true);
|
DrawTextLine(x + 4, &y, "Android Recovery", true);
|
||||||
for (auto& chunk: android::base::Split(recovery_fingerprint, ":")) {
|
for (auto& chunk: android::base::Split(recovery_fingerprint, ":")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user