Commit 2673cec0 authored by Dees_Troy's avatar Dees_Troy
Browse files

Move all AOSP code out of recovery binary

Improves license compatibility between GPL and Apache

Change-Id: I2b165aa575bb6213af6b07936f99610c113443f0
parent a13d74fc
......@@ -16,25 +16,16 @@ LOCAL_PATH := $(call my-dir)
TARGET_RECOVERY_GUI := true
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
recovery.cpp \
twbootloader.cpp \
install.cpp \
roots.cpp \
ui.cpp \
screen_ui.cpp \
verifier.cpp \
twrp.cpp \
fixPermissions.cpp \
twrpTar.cpp \
twrpDigest.cpp \
adb_install.cpp
LOCAL_SRC_FILES += \
data.cpp \
partition.cpp \
partitionmanager.cpp \
mtdutils/mtdutils.c \
twinstall.cpp \
twrp-functions.cpp \
openrecoveryscript.cpp \
......@@ -64,10 +55,8 @@ LOCAL_C_INCLUDES += bionic external/stlport/stlport
LOCAL_STATIC_LIBRARIES :=
LOCAL_SHARED_LIBRARIES :=
LOCAL_STATIC_LIBRARIES += libmtdutils libcrecovery
LOCAL_STATIC_LIBRARIES += libminadbd libminzip libunz
LOCAL_STATIC_LIBRARIES += libminuitwrp libpixelflinger_static libpng libjpegtwrp libgui
LOCAL_SHARED_LIBRARIES += libz libc libstlport libcutils libstdc++ libmincrypt libext4_utils libtar libblkid
LOCAL_STATIC_LIBRARIES += libcrecovery libguitwrp
LOCAL_SHARED_LIBRARIES += libz libc libstlport libcutils libstdc++ libext4_utils libtar libblkid libminuitwrp libminadbd libmtdutils libminzip libaosprecovery
ifneq ($(wildcard system/core/libsparse/Android.mk),)
LOCAL_SHARED_LIBRARIES += libsparse
......@@ -80,9 +69,9 @@ ifeq ($(TARGET_USERIMAGES_USE_EXT4), true)
endif
ifeq ($(HAVE_SELINUX), true)
LOCAL_C_INCLUDES += external/libselinux/include
LOCAL_STATIC_LIBRARIES += libselinux
LOCAL_CFLAGS += -DHAVE_SELINUX -g
#LOCAL_C_INCLUDES += external/libselinux/include
#LOCAL_STATIC_LIBRARIES += libselinux
#LOCAL_CFLAGS += -DHAVE_SELINUX -g
endif # HAVE_SELINUX
# This binary is in the recovery ramdisk, which is otherwise a copy of root.
......@@ -217,17 +206,16 @@ ifeq ($(TW_INCLUDE_CRYPTO_SAMSUNG), true)
LOCAL_LDFLAGS += -ldl
LOCAL_STATIC_LIBRARIES += libcrypt_samsung
endif
LOCAL_SHARED_LIBRARIES += libcrypto
LOCAL_SRC_FILES += crypto/ics/cryptfs.c
LOCAL_C_INCLUDES += system/extras/ext4_utils external/openssl/include
LOCAL_SHARED_LIBRARIES += libcryptfsics
#LOCAL_SRC_FILES += crypto/ics/cryptfs.c
#LOCAL_C_INCLUDES += system/extras/ext4_utils external/openssl/include
endif
ifeq ($(TW_INCLUDE_JB_CRYPTO), true)
LOCAL_CFLAGS += -DTW_INCLUDE_CRYPTO
LOCAL_CFLAGS += -DTW_INCLUDE_JB_CRYPTO
LOCAL_SHARED_LIBRARIES += libcrypto
LOCAL_STATIC_LIBRARIES += libfs_mgrtwrp
LOCAL_SRC_FILES += crypto/jb/cryptfs.c
LOCAL_C_INCLUDES += system/extras/ext4_utils external/openssl/include
LOCAL_SHARED_LIBRARIES += libcryptfsjb
#LOCAL_SRC_FILES += crypto/jb/cryptfs.c
#LOCAL_C_INCLUDES += system/extras/ext4_utils external/openssl/include
endif
ifeq ($(TW_USE_MODEL_HARDWARE_ID_FOR_DEVICE_ID), true)
LOCAL_CFLAGS += -DTW_USE_MODEL_HARDWARE_ID_FOR_DEVICE_ID
......@@ -277,6 +265,18 @@ LOCAL_STATIC_LIBRARIES := \
libc
include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS)
LOCAL_MODULE := libaosprecovery
LOCAL_MODULE_TAGS := eng
LOCAL_MODULES_TAGS = optional
LOCAL_CFLAGS =
LOCAL_SRC_FILES = adb_install.cpp bootloader.cpp verifier.cpp
LOCAL_SHARED_LIBRARIES += libc liblog libcutils libmtdutils
LOCAL_STATIC_LIBRARIES += libmincrypt
include $(BUILD_SHARED_LIBRARY)
commands_recovery_local_path := $(LOCAL_PATH)
include $(LOCAL_PATH)/minui/Android.mk \
$(LOCAL_PATH)/minelf/Android.mk \
......@@ -291,7 +291,6 @@ include $(LOCAL_PATH)/minui/Android.mk \
include $(commands_recovery_local_path)/libjpegtwrp/Android.mk \
$(commands_recovery_local_path)/injecttwrp/Android.mk \
$(commands_recovery_local_path)/htcdumlock/Android.mk \
$(commands_recovery_local_path)/minuitwrp/Android.mk \
$(commands_recovery_local_path)/gui/Android.mk \
$(commands_recovery_local_path)/mmcutils/Android.mk \
$(commands_recovery_local_path)/bmlutils/Android.mk \
......@@ -305,13 +304,15 @@ include $(commands_recovery_local_path)/libjpegtwrp/Android.mk \
$(commands_recovery_local_path)/crypto/cryptfs/Android.mk \
$(commands_recovery_local_path)/libcrecovery/Android.mk \
$(commands_recovery_local_path)/twmincrypt/Android.mk \
$(commands_recovery_local_path)/libblkid/Android.mk
$(commands_recovery_local_path)/libblkid/Android.mk \
$(commands_recovery_local_path)/minuitwrp/Android.mk
ifeq ($(TW_INCLUDE_CRYPTO_SAMSUNG), true)
include $(commands_recovery_local_path)/crypto/libcrypt_samsung/Android.mk
endif
ifeq ($(TW_INCLUDE_JB_CRYPTO), true)
include $(commands_recovery_local_path)/crypto/jb/Android.mk
include $(commands_recovery_local_path)/crypto/fs_mgr/Android.mk
endif
ifeq ($(BUILD_ID), GINGERBREAD)
......@@ -323,5 +324,8 @@ ifneq ($(TW_NO_EXFAT), true)
$(commands_recovery_local_path)/fuse/Android.mk \
$(commands_recovery_local_path)/exfat/libexfat/Android.mk
endif
ifeq ($(TW_INCLUDE_CRYPTO), true)
include $(commands_recovery_local_path)/crypto/ics/Android.mk
endif
commands_recovery_local_path :=
......@@ -24,17 +24,13 @@
#include <sys/stat.h>
#include <signal.h>
#include <fcntl.h>
#include <stdio.h>
#include "ui.h"
#include "cutils/properties.h"
#include "install.h"
#include "common.h"
#include "adb_install.h"
extern "C" {
#include "minadbd/adb.h"
#include "twinstall.h"
#include "data.h"
int TWinstall_zip(const char* path, int* wipe_cache);
}
static RecoveryUI* ui = NULL;
......@@ -47,20 +43,20 @@ set_usb_driver(bool enabled) {
It's not a critical error so we're disabling the error messages.
ui->Print("failed to open driver control: %s\n", strerror(errno));
*/
LOGI("failed to open driver control: %s\n", strerror(errno));
printf("failed to open driver control: %s\n", strerror(errno));
return;
}
if (write(fd, enabled ? "1" : "0", 1) < 0) {
/*
ui->Print("failed to set driver control: %s\n", strerror(errno));
*/
LOGI("failed to set driver control: %s\n", strerror(errno));
printf("failed to set driver control: %s\n", strerror(errno));
}
if (close(fd) < 0) {
/*
ui->Print("failed to close driver control: %s\n", strerror(errno));
*/
LOGI("failed to close driver control: %s\n", strerror(errno));
printf("failed to close driver control: %s\n", strerror(errno));
}
}
......@@ -76,28 +72,29 @@ maybe_restart_adbd() {
char value[PROPERTY_VALUE_MAX+1];
int len = property_get("ro.debuggable", value, NULL);
if (len == 1 && value[0] == '1') {
ui->Print("Restarting adbd...\n");
printf("Restarting adbd...\n");
set_usb_driver(true);
property_set("ctl.start", "adbd");
}
}
int
apply_from_adb(RecoveryUI* ui_, int* wipe_cache, const char* install_file) {
ui = ui_;
apply_from_adb(const char* install_file) {
stop_adbd();
set_usb_driver(true);
/*
ui->Print("\n\nNow send the package you want to apply\n"
"to the device with \"adb sideload <filename>\"...\n");
*/
pid_t child;
if ((child = fork()) == 0) {
execl("/sbin/recovery", "recovery", "--adbd", install_file, NULL);
_exit(-1);
}
DataManager_SetIntValue("tw_child_pid", child);
char child_prop[PROPERTY_VALUE_MAX];
sprintf(child_prop, "%i", child);
property_set("tw_child_pid", child_prop);
int status;
// TODO(dougz): there should be a way to cancel waiting for a
// package (by pushing some button combo on the device). For now
......@@ -105,20 +102,19 @@ apply_from_adb(RecoveryUI* ui_, int* wipe_cache, const char* install_file) {
// package, like "/dev/null".
waitpid(child, &status, 0);
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
ui->Print("status %d\n", WEXITSTATUS(status));
printf("status %d\n", WEXITSTATUS(status));
}
DataManager_SetIntValue("tw_has_cancel", 0); // Remove cancel button from gui now that the zip install is going to start
set_usb_driver(false);
maybe_restart_adbd();
struct stat st;
if (stat(install_file, &st) != 0) {
if (errno == ENOENT) {
ui->Print("No package received.\n");
printf("No package received.\n");
} else {
ui->Print("Error reading package:\n %s\n", strerror(errno));
printf("Error reading package:\n %s\n", strerror(errno));
}
return INSTALL_ERROR;
return -1;
}
return TWinstall_zip(install_file, wipe_cache);
return 0;
}
......@@ -17,8 +17,8 @@
#ifndef _ADB_INSTALL_H
#define _ADB_INSTALL_H
class RecoveryUI;
//class RecoveryUI;
int apply_from_adb(RecoveryUI* h, int* wipe_cache, const char* install_file);
int apply_from_adb(const char* install_file);
#endif
......@@ -33,7 +33,7 @@ static int get_bootloader_message_block(struct bootloader_message *out, const Vo
static int set_bootloader_message_block(const struct bootloader_message *in, const Volume* v);
int get_bootloader_message(struct bootloader_message *out) {
Volume* v = volume_for_path("/misc");
Volume* v = NULL;//volume_for_path("/misc");
if (v == NULL) {
LOGE("Cannot load volume /misc!\n");
return -1;
......@@ -48,7 +48,7 @@ int get_bootloader_message(struct bootloader_message *out) {
}
int set_bootloader_message(const struct bootloader_message *in) {
Volume* v = volume_for_path("/misc");
Volume* v = NULL;//volume_for_path("/misc");
if (v == NULL) {
LOGE("Cannot load volume /misc!\n");
return -1;
......@@ -139,6 +139,49 @@ static int set_bootloader_message_mtd(const struct bootloader_message *in,
return 0;
}
int set_bootloader_message_mtd_name(const struct bootloader_message *in,
const char* mtd_name) {
size_t write_size;
mtd_scan_partitions();
const MtdPartition *part = mtd_find_partition_by_name(mtd_name);
if (part == NULL || mtd_partition_info(part, NULL, NULL, &write_size)) {
printf("Can't find %s\n", mtd_name);
return -1;
}
MtdReadContext *read = mtd_read_partition(part);
if (read == NULL) {
printf("Can't open %s\n(%s)\n", mtd_name, strerror(errno));
return -1;
}
ssize_t size = write_size * MISC_PAGES;
char data[size];
ssize_t r = mtd_read_data(read, data, size);
if (r != size) printf("Can't read %s\n(%s)\n", mtd_name, strerror(errno));
mtd_read_close(read);
if (r != size) return -1;
memcpy(&data[write_size * MISC_COMMAND_PAGE], in, sizeof(*in));
MtdWriteContext *write = mtd_write_partition(part);
if (write == NULL) {
printf("Can't open %s\n(%s)\n", mtd_name, strerror(errno));
return -1;
}
if (mtd_write_data(write, data, size) != size) {
printf("Can't write %s\n(%s)\n", mtd_name, strerror(errno));
mtd_write_close(write);
return -1;
}
if (mtd_write_close(write)) {
printf("Can't finish %s\n(%s)\n", mtd_name, strerror(errno));
return -1;
}
printf("Set boot command \"%s\"\n", in->command[0] != 255 ? in->command : "");
return 0;
}
// ------------------------------------
// for misc partitions on block devices
......@@ -202,3 +245,23 @@ static int set_bootloader_message_block(const struct bootloader_message *in,
}
return 0;
}
int set_bootloader_message_block_name(const struct bootloader_message *in,
const char* block_name) {
wait_for_device(block_name);
FILE* f = fopen(block_name, "wb");
if (f == NULL) {
printf("Can't open %s\n(%s)\n", block_name, strerror(errno));
return -1;
}
int count = fwrite(in, sizeof(*in), 1, f);
if (count != 1) {
printf("Failed writing %s\n(%s)\n", block_name, strerror(errno));
return -1;
}
if (fclose(f) != 0) {
printf("Failed closing %s\n(%s)\n", block_name, strerror(errno));
return -1;
}
return 0;
}
......@@ -51,6 +51,9 @@ struct bootloader_message {
int get_bootloader_message(struct bootloader_message *out);
int set_bootloader_message(const struct bootloader_message *in);
int set_bootloader_message_mtd_name(const struct bootloader_message *in, const char* mtd_name);
int set_bootloader_message_block_name(const struct bootloader_message *in, const char* block_name);
#ifdef __cplusplus
}
#endif
......
......@@ -25,12 +25,11 @@ extern "C" {
static long tmplog_offset = 0;
#define ui_print(...) gui_print(__VA_ARGS__)
#define ui_print_overwrite(...) gui_print_overwrite(__VA_ARGS__)
#define ui_print(...) printf(__VA_ARGS__)
#define ui_print_overwrite(...) printf(__VA_ARGS__)
#include "gui/gui.h"
// TODO: restore ui_print for LOGE
#define LOGE(...) gui_print("E:" __VA_ARGS__)
#define LOGE(...) printf("E:" __VA_ARGS__)
#define LOGW(...) fprintf(stdout, "W:" __VA_ARGS__)
#define LOGI(...) fprintf(stdout, "I:" __VA_ARGS__)
......
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libcryptfsics
LOCAL_MODULE_TAGS := eng
LOCAL_MODULES_TAGS = optional
LOCAL_CFLAGS =
LOCAL_SRC_FILES = cryptfs.c
LOCAL_C_INCLUDES += system/extras/ext4_utils external/openssl/include
LOCAL_SHARED_LIBRARIES += libc liblog libcutils libcrypto
include $(BUILD_SHARED_LIBRARY)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libcryptfsjb
LOCAL_MODULE_TAGS := eng
LOCAL_MODULES_TAGS = optional
LOCAL_CFLAGS =
LOCAL_SRC_FILES = cryptfs.c
LOCAL_C_INCLUDES += system/extras/ext4_utils external/openssl/include
LOCAL_SHARED_LIBRARIES += libc liblog libcutils libcrypto
LOCAL_STATIC_LIBRARIES += libfs_mgrtwrp
include $(BUILD_SHARED_LIBRARY)
\ No newline at end of file
......@@ -48,7 +48,7 @@
extern "C"
{
#include "common.h"
#include "twcommon.h"
#include "data.h"
#include "gui/pages.h"
......@@ -102,7 +102,7 @@ void DataManager::get_device_id(void) {
char model_id[PROPERTY_VALUE_MAX];
property_get("ro.product.model", model_id, "error");
if (strcmp(model_id,"error") != 0) {
LOGI("=> product model: '%s'\n", model_id);
LOGINFO("=> product model: '%s'\n", model_id);
// Replace spaces with underscores
for(int i = 0; i < strlen(model_id); i++) {
if(model_id[i] == ' ')
......@@ -115,7 +115,7 @@ void DataManager::get_device_id(void) {
}
sanitize_device_id((char *)device_id);
mConstValues.insert(make_pair("device_id", device_id));
LOGI("=> using device id: '%s'\n", device_id);
LOGINFO("=> using device id: '%s'\n", device_id);
return;
}
#endif
......@@ -166,7 +166,7 @@ void DataManager::get_device_id(void) {
} else {
strcpy(device_id, token);
}
LOGI("=> serial from cpuinfo: '%s'\n", device_id);
LOGINFO("=> serial from cpuinfo: '%s'\n", device_id);
fclose(fp);
sanitize_device_id((char *)device_id);
mConstValues.insert(make_pair("device_id", device_id));
......@@ -184,7 +184,7 @@ void DataManager::get_device_id(void) {
} else {
strcpy(hardware_id, token);
}
LOGI("=> hardware id from cpuinfo: '%s'\n", hardware_id);
LOGINFO("=> hardware id from cpuinfo: '%s'\n", hardware_id);
}
}
}
......@@ -192,7 +192,7 @@ void DataManager::get_device_id(void) {
}
if (hardware_id[0] != 0) {
LOGW("\nusing hardware id for device id: '%s'\n", hardware_id);
LOGINFO("\nusing hardware id for device id: '%s'\n", hardware_id);
strcpy(device_id, hardware_id);
sanitize_device_id((char *)device_id);
mConstValues.insert(make_pair("device_id", device_id));
......@@ -200,7 +200,7 @@ void DataManager::get_device_id(void) {
}
strcpy(device_id, "serialno");
LOGE("=> device id not found, using '%s'.", device_id);
LOGERR("=> device id not found, using '%s'.", device_id);
mConstValues.insert(make_pair("device_id", device_id));
return;
}
......@@ -227,10 +227,10 @@ int DataManager::LoadValues(const string filename)
// Read in the file, if possible
FILE* in = fopen(filename.c_str(), "rb");
if (!in) {
LOGI("Settings file '%s' not found.\n", filename.c_str());
LOGINFO("Settings file '%s' not found.\n", filename.c_str());
return 0;
} else {
LOGI("Loading settings from '%s'.\n", filename.c_str());
LOGINFO("Loading settings from '%s'.\n", filename.c_str());
}
int file_version;
......@@ -360,6 +360,17 @@ int DataManager::GetValue(const string varName, int& value)
return 0;
}
int DataManager::GetValue(const string varName, float& value)
{
string data;
if (GetValue(varName,data) != 0)
return -1;
value = atof(data.c_str());
return 0;
}
unsigned long long DataManager::GetValue(const string varName, unsigned long long& value)
{
string data;
......@@ -461,7 +472,7 @@ int DataManager::SetValue(const string varName, int value, int persist /* = 0 */
SetValue("tw_storage_path", str);
SetBackupFolder();
}
return SetValue(varName, valStr.str(), persist);;
return SetValue(varName, valStr.str(), persist);
}
int DataManager::SetValue(const string varName, float value, int persist /* = 0 */)
......@@ -478,13 +489,27 @@ int DataManager::SetValue(const string varName, unsigned long long value, int pe
return SetValue(varName, valStr.str(), persist);;
}
int DataManager::SetProgress(float Fraction) {
return SetValue("ui_progress", (float) (Fraction * 100.0));
}
int DataManager::ShowProgress(float Portion, float Seconds) {
float Starting_Portion;
GetValue("ui_progress_portion", Starting_Portion);
if (SetValue("ui_progress_portion", (float)(Portion * 100.0) + Starting_Portion) != 0)
return -1;
if (SetValue("ui_progress_frames", Seconds * 30) != 0)
return -1;
return 0;
}
void DataManager::DumpValues()
{
map<string, TStrIntPair>::iterator iter;
ui_print("Data Manager dump - Values with leading X are persisted.\n");
gui_print("Data Manager dump - Values with leading X are persisted.\n");
for (iter = mValues.begin(); iter != mValues.end(); ++iter)
{
ui_print("%c %s=%s\n", iter->second.second ? 'X' : ' ', iter->first.c_str(), iter->second.first.c_str());
gui_print("%c %s=%s\n", iter->second.second ? 'X' : ' ', iter->first.c_str(), iter->second.first.c_str());
}
}
......@@ -503,7 +528,7 @@ void DataManager::SetBackupFolder()
GetValue("device_id", dev_id);
str += dev_id;
LOGI("Backup folder set to '%s'\n", str.c_str());
LOGINFO("Backup folder set to '%s'\n", str.c_str());
SetValue(TW_BACKUPS_FOLDER_VAR, str, 0);
if (partition != NULL) {
SetValue("tw_storage_display_name", partition->Storage_Name);
......@@ -526,7 +551,7 @@ void DataManager::SetBackupFolder()
}
} else {
if (PartitionManager.Fstab_Processed() != 0)
LOGE("Storage partition '%s' not found\n", str.c_str());
LOGERR("Storage partition '%s' not found\n", str.c_str());
}
}
......@@ -563,7 +588,7 @@ void DataManager::SetDefaultValues()
#endif
#ifdef TW_INTERNAL_STORAGE_PATH
LOGI("Internal path defined: '%s'\n", EXPAND(TW_INTERNAL_STORAGE_PATH));
LOGINFO("Internal path defined: '%s'\n", EXPAND(TW_INTERNAL_STORAGE_PATH));
mValues.insert(make_pair(TW_USE_EXTERNAL_STORAGE, make_pair("0", 1)));
mConstValues.insert(make_pair(TW_HAS_INTERNAL, "1"));
mValues.insert(make_pair(TW_INTERNAL_PATH, make_pair(EXPAND(TW_INTERNAL_STORAGE_PATH), 0)));
......@@ -573,7 +598,7 @@ void DataManager::SetDefaultValues()
path += EXPAND(TW_INTERNAL_STORAGE_MOUNT_POINT);
mConstValues.insert(make_pair(TW_INTERNAL_MOUNT, path));
#ifdef TW_EXTERNAL_STORAGE_PATH
LOGI("External path defined: '%s'\n", EXPAND(TW_EXTERNAL_STORAGE_PATH));
LOGINFO("External path defined: '%s'\n", EXPAND(TW_EXTERNAL_STORAGE_PATH));
// Device has dual storage
mConstValues.insert(make_pair(TW_HAS_DUAL_STORAGE, "1"));
mConstValues.insert(make_pair(TW_HAS_EXTERNAL, "1"));
......@@ -590,7 +615,7 @@ void DataManager::SetDefaultValues()
mValues.insert(make_pair(TW_ZIP_INTERNAL_VAR, make_pair("/sdcard", 1)));
}
#else
LOGI("Just has internal storage.\n");
LOGINFO("Just has internal storage.\n");
// Just has internal storage
mValues.insert(make_pair(TW_ZIP_INTERNAL_VAR, make_pair("/sdcard", 1)));
mConstValues.insert(make_pair(TW_HAS_DUAL_STORAGE, "0"));
......@@ -602,22 +627,22 @@ void DataManager::SetDefaultValues()
#else
#ifdef RECOVERY_SDCARD_ON_DATA
#ifdef TW_EXTERNAL_STORAGE_PATH
LOGI("Has /data/media + external storage in '%s'\n", EXPAND(TW_EXTERNAL_STORAGE_PATH));
LOGINFO("Has /data/media + external storage in '%s'\n", EXPAND(TW_EXTERNAL_STORAGE_PATH));
// Device has /data/media + external storage
mConstValues.insert(make_pair(TW_HAS_DUAL_STORAGE, "1"));
#else
LOGI("Single storage only -- data/media.\n");
LOGINFO("Single storage only -- data/media.\n");
// Device just has external storage
mConstValues.insert(make_pair(TW_HAS_DUAL_STORAGE, "0"));
mConstValues.insert(make_pair(TW_HAS_EXTERNAL, "0"));
#endif
#else
LOGI("Single storage only.\n");
LOGINFO("Single storage only.\n");
// Device just has external storage
mConstValues.insert(make_pair(TW_HAS_DUAL_STORAGE, "0"));
#endif
#ifdef RECOVERY_SDCARD_ON_DATA
LOGI("Device has /data/media defined.\n");
LOGINFO("Device has /data/media defined.\n");
// Device has /data/media
mConstValues.insert(make_pair(TW_USE_EXTERNAL_STORAGE, "0"));
mConstValues.insert(make_pair(TW_HAS_INTERNAL, "1"));
......@@ -634,7 +659,7 @@ void DataManager::SetDefaultValues()
mValues.insert(make_pair(TW_ZIP_INTERNAL_VAR, make_pair("/sdcard", 1)));
#endif
#else
LOGI("No internal storage defined.\n");
LOGINFO("No internal storage defined.\n");
// Device has no internal storage
mConstValues.insert(make_pair(TW_USE_EXTERNAL_STORAGE, "1"));
mConstValues.insert(make_pair(TW_HAS_INTERNAL, "0"));
......@@ -643,7 +668,7 @@ void DataManager::SetDefaultValues()
mConstValues.insert(make_pair(TW_INTERNAL_LABEL, "0"));
#endif
#ifdef TW_EXTERNAL_STORAGE_PATH
LOGI("Only external path defined: '%s'\n", EXPAND(TW_EXTERNAL_STORAGE_PATH));
LOGINFO("Only external path defined: '%s'\n", EXPAND(TW_EXTERNAL_STORAGE_PATH));
// External has custom definition
mConstValues.insert(make_pair(TW_HAS_EXTERNAL, "1"));
mConstValues.insert(make_pair(TW_EXTERNAL_PATH, EXPAND(TW_EXTERNAL_STORAGE_PATH)));
......@@ -655,7 +680,7 @@ void DataManager::SetDefaultValues()
mConstValues.insert(make_pair(TW_EXTERNAL_MOUNT, path));
#else
#ifndef RECOVERY_SDCARD_ON_DATA
LOGI("No storage defined, defaulting to /sdcard.\n");
LOGINFO("No storage defined, defaulting to /sdcard.\n");
// Standard external definition
mConstValues.insert(make_pair(TW_HAS_EXTERNAL, "1"));
mConstValues.insert(make_pair(TW_EXTERNAL_PATH, "/sdcard"));
......@@ -779,10 +804,10 @@ void DataManager::SetDefaultValues()
Lun_File_str = lun_file;
}
if (!TWFunc::Path_Exists(Lun_File_str)) {
LOGI("Lun file '%s' does not exist, USB storage mode disabled\n", Lun_File_str.c_str());
LOGINFO("Lun file '%s' does not exist, USB storage mode disabled\n", Lun_File_str.c_str());
mConstValues.insert(make_pair(TW_HAS_USB_STORAGE, "0"));
} else {
LOGI("Lun file '%s'\n", Lun_File_str.c_str());
LOGINFO("Lun file '%s'\n", Lun_File_str.c_str());
mConstValues.insert(make_pair(TW_HAS_USB_STORAGE, "1"));
}
#endif
......@@ -886,7 +911,7 @@ void DataManager::SetDefaultValues()
mValues.insert(make_pair("tw_gui_done", make_pair("0", 0)));
#ifdef TW_MAX_BRIGHTNESS
if (strcmp(EXPAND(TW_BRIGHTNESS_PATH), "/nobrightness") != 0) {
LOGI("TW_BRIGHTNESS_PATH := %s\n", EXPAND(TW_BRIGHTNESS_PATH));
LOGINFO("TW_BRIGHTNESS_PATH := %s\n", EXPAND(TW_BRIGHTNESS_PATH));
mConstValues.insert(make_pair("tw_has_brightnesss_file", "1"));
mConstValues.insert(make_pair("tw_brightness_file", EXPAND(TW_BRIGHTNESS_PATH)));
ostringstream val100, val25, val50, val75;
......@@ -996,13 +1021,13 @@ void DataManager::Output_Version(void) {
char version[255];
if (!PartitionManager.Mount_By_Path("/cache", false)) {
LOGI("Unable to mount '%s' to write version number.\n", Path.c_str());
LOGINFO("Unable to mount '%s' to write version number.\n", Path.c_str());
return;
}
if (!TWFunc::Path_Exists("/cache/recovery/.")) {
LOGI("Recreating /cache/recovery folder.\n");
LOGINFO("Recreating /cache/recovery folder.\n");
if (mkdir("/cache/recovery", S_IRWXU | S_IRWXG | S_IWGRP | S_IXGRP) != 0) {
LOGE("DataManager::Output_Version -- Unable to make /cache/recovery\n");
LOGERR("DataManager::Output_Version -- Unable to make /cache/recovery\n");
return;
}
}
......@@ -1012,14 +1037,14 @@ void DataManager::Output_Version(void) {
}
FILE *fp = fopen(Path.c_str(), "w");
if (fp == NULL) {
LOGE("Unable to open '%s'.\n", Path.c_str());
LOGERR("Unable to open '%s'.\n", Path.c_str());
return;
}
strcpy(version, TW_VERSION_STR);
fwrite(version, sizeof(version[0]), strlen(version) / sizeof(version[0]), fp);
fclose(fp);
sync();
LOGI("Version number saved to '%s'\n", Path.c_str());
LOGINFO("Version number saved to '%s'\n", Path.c_str());
}
void DataManager::ReadSettingsFile(void)
......@@ -1031,7 +1056,7 @@ void DataManager::ReadSettingsFile(void)
GetValue(TW_IS_ENCRYPTED, is_enc);
GetValue(TW_HAS_DATA_MEDIA, has_data_media);
if (is_enc == 1 && has_data_media == 1) {
LOGI("Cannot load settings -- encrypted.\n");
LOGINFO("Cannot load settings -- encrypted.\n");
return;
}
......@@ -1044,12 +1069,12 @@ void DataManager::ReadSettingsFile(void)
{
usleep(500000);
if (!PartitionManager.Mount_Settings_Storage(false))
LOGE("Unable to mount %s when trying to read settings file.\n", settings_file);
LOGERR("Unable to mount %s when trying to read settings file.\n", settings_file);
}
mkdir(mkdir_path, 0777);
LOGI("Attempt to load settings from settings file...\n");
LOGINFO("Attempt to load settings from settings file...\n");
LoadValues(settings_file);
Output_Version();
GetValue(TW_HAS_DUAL_STORAGE, has_dual);
......@@ -1058,7 +1083,7 @@ void DataManager::ReadSettingsFile(void)
if (has_dual != 0 && use_ext == 1) {
// Attempt to switch to using external storage
if (!PartitionManager.Mount_Current_Storage(false)) {
LOGE("Failed to mount external storage, using internal storage.\n");
LOGERR("Failed to mount external storage, using internal storage.\n");
// Remount failed, default back to internal storage
SetValue(TW_USE_EXTERNAL_STORAGE, 0);
PartitionManager.Mount_Current_Storage(true);
......
......@@ -33,6 +33,7 @@ public:
// Core get routines
static int GetValue(const string varName, string& value);
static int GetValue(const string varName, int& value);
static int GetValue(const string varName, float& value);
static unsigned long long GetValue(const string varName, unsigned long long& value);
// This is a dangerous function. It will create the value if it doesn't exist so it has a valid c_str
......@@ -47,6 +48,8 @@ public:
static int SetValue(const string varName, int value, int persist = 0);
static int SetValue(const string varName, float value, int persist = 0);
static int SetValue(const string varName, unsigned long long value, int persist = 0);
static int SetProgress(float Fraction);
static int ShowProgress(float Portion, float Seconds);
static void DumpValues();
static void update_tz_environment_variables();
......
......@@ -29,7 +29,7 @@
#include "gui/rapidxml.hpp"
#include "fixPermissions.hpp"
#include "twrp-functions.hpp"
#include "common.h"
#include "twcommon.h"
using namespace std;
using namespace rapidxml;
......@@ -41,25 +41,25 @@ int fixPermissions::fixPerms(bool enable_debug, bool remove_data_for_missing_app
multi_user = TWFunc::Path_Exists("/data/user");
if (!(TWFunc::Path_Exists(packageFile))) {
ui_print("Can't check permissions\n");
ui_print("after Factory Reset.\n");
ui_print("Please boot rom and try\n");
ui_print("again after you reboot into\n");
ui_print("recovery.\n");
gui_print("Can't check permissions\n");
gui_print("after Factory Reset.\n");
gui_print("Please boot rom and try\n");
gui_print("again after you reboot into\n");
gui_print("recovery.\n");
return -1;
}
ui_print("Fixing permissions...\nLoading packages...\n");
gui_print("Fixing permissions...\nLoading packages...\n");
if ((getPackages()) != 0) {
return -1;
}
ui_print("Fixing /system/app permissions...\n");
gui_print("Fixing /system/app permissions...\n");
if ((fixSystemApps()) != 0) {
return -1;
}
ui_print("Fixing /data/app permisions...\n");
gui_print("Fixing /data/app permisions...\n");
if ((fixDataApps()) != 0) {
return -1;
}
......@@ -69,7 +69,7 @@ int fixPermissions::fixPerms(bool enable_debug, bool remove_data_for_missing_app
string new_path, user_id;
if (d == NULL) {
LOGE("Error opening '/data/user'\n");
LOGERR("Error opening '/data/user'\n");
return -1;
}
......@@ -102,7 +102,7 @@ int fixPermissions::fixPerms(bool enable_debug, bool remove_data_for_missing_app
// the uid and gid is stored for other users.
continue;
}
ui_print("Fixing %s permissions...\n", new_path.c_str());
gui_print("Fixing %s permissions...\n", new_path.c_str());
if ((fixDataData(new_path)) != 0) {
closedir(d);
return -1;
......@@ -111,19 +111,19 @@ int fixPermissions::fixPerms(bool enable_debug, bool remove_data_for_missing_app
closedir(d);
}
} else {
ui_print("Fixing /data/data permisions...\n");
gui_print("Fixing /data/data permisions...\n");
if ((fixDataData("/data/data/")) != 0) {
return -1;
}
}
ui_print("Done fixing permissions.\n");
gui_print("Done fixing permissions.\n");
return 0;
}
int fixPermissions::pchown(string fn, int puid, int pgid) {
LOGI("Fixing %s, uid: %d, gid: %d\n", fn.c_str(), puid, pgid);
LOGINFO("Fixing %s, uid: %d, gid: %d\n", fn.c_str(), puid, pgid);
if (chown(fn.c_str(), puid, pgid) != 0) {
LOGE("Unable to chown '%s' %i %i\n", fn.c_str(), puid, pgid);
LOGERR("Unable to chown '%s' %i %i\n", fn.c_str(), puid, pgid);
return -1;
}
return 0;
......@@ -131,7 +131,7 @@ int fixPermissions::pchown(string fn, int puid, int pgid) {
int fixPermissions::pchmod(string fn, string mode) {
long mask = 0;
LOGI("Fixing %s, mode: %s\n", fn.c_str(), mode.c_str());
LOGINFO("Fixing %s, mode: %s\n", fn.c_str(), mode.c_str());
for ( std::string::size_type n = 0; n < mode.length(); ++n) {
if (n == 0) {
if (mode[n] == '0')
......@@ -213,7 +213,7 @@ int fixPermissions::pchmod(string fn, string mode) {
}
if (chmod(fn.c_str(), mask) != 0) {
LOGE("Unable to chmod '%s' %l\n", fn.c_str(), mask);
LOGERR("Unable to chmod '%s' %l\n", fn.c_str(), mask);
return -1;
}
......@@ -226,10 +226,10 @@ int fixPermissions::fixSystemApps() {
if (TWFunc::Path_Exists(temp->codePath)) {
if (temp->appDir.compare("/system/app") == 0) {
if (debug) {
LOGI("Looking at '%s'\n", temp->codePath.c_str());
LOGI("Fixing permissions on '%s'\n", temp->pkgName.c_str());
LOGI("Directory: '%s'\n", temp->appDir.c_str());
LOGI("Original package owner: %d, group: %d\n", temp->uid, temp->gid);
LOGINFO("Looking at '%s'\n", temp->codePath.c_str());
LOGINFO("Fixing permissions on '%s'\n", temp->pkgName.c_str());
LOGINFO("Directory: '%s'\n", temp->appDir.c_str());
LOGINFO("Original package owner: %d, group: %d\n", temp->uid, temp->gid);
}
if (pchown(temp->codePath, 0, 0) != 0)
return -1;
......@@ -240,9 +240,9 @@ int fixPermissions::fixSystemApps() {
//Remove data directory since app isn't installed
if (remove_data && TWFunc::Path_Exists(temp->dDir) && temp->appDir.size() >= 9 && temp->appDir.substr(0, 9) != "/mnt/asec") {
if (debug)
LOGI("Looking at '%s', removing data dir: '%s', appDir: '%s'", temp->codePath.c_str(), temp->dDir.c_str(), temp->appDir.c_str());
LOGINFO("Looking at '%s', removing data dir: '%s', appDir: '%s'", temp->codePath.c_str(), temp->dDir.c_str(), temp->appDir.c_str());
if (TWFunc::removeDir(temp->dDir, false) != 0) {
LOGI("Unable to removeDir '%s'\n", temp->dDir.c_str());
LOGINFO("Unable to removeDir '%s'\n", temp->dDir.c_str());
return -1;
}
}
......@@ -272,10 +272,10 @@ int fixPermissions::fixDataApps() {
fix = false;
if (fix) {
if (debug) {
LOGI("Looking at '%s'\n", temp->codePath.c_str());
LOGI("Fixing permissions on '%s'\n", temp->pkgName.c_str());
LOGI("Directory: '%s'\n", temp->appDir.c_str());
LOGI("Original package owner: %d, group: %d\n", temp->uid, temp->gid);
LOGINFO("Looking at '%s'\n", temp->codePath.c_str());
LOGINFO("Fixing permissions on '%s'\n", temp->pkgName.c_str());
LOGINFO("Directory: '%s'\n", temp->appDir.c_str());
LOGINFO("Original package owner: %d, group: %d\n", temp->uid, temp->gid);
}
if (pchown(temp->codePath, 1000, new_gid) != 0)
return -1;
......@@ -286,9 +286,9 @@ int fixPermissions::fixDataApps() {
//Remove data directory since app isn't installed
if (remove_data && TWFunc::Path_Exists(temp->dDir) && temp->appDir.size() >= 9 && temp->appDir.substr(0, 9) != "/mnt/asec") {
if (debug)
LOGI("Looking at '%s', removing data dir: '%s', appDir: '%s'", temp->codePath.c_str(), temp->dDir.c_str(), temp->appDir.c_str());
LOGINFO("Looking at '%s', removing data dir: '%s', appDir: '%s'", temp->codePath.c_str(), temp->dDir.c_str(), temp->appDir.c_str());
if (TWFunc::removeDir(temp->dDir, false) != 0) {
LOGI("Unable to removeDir '%s'\n", temp->dDir.c_str());
LOGINFO("Unable to removeDir '%s'\n", temp->dDir.c_str());
return -1;
}
}
......@@ -307,7 +307,7 @@ int fixPermissions::fixAllFiles(string directory, int gid, int uid, string file_
file = directory + "/";
file.append(files.at(i));
if (debug)
LOGI("Looking at file '%s'\n", file.c_str());
LOGINFO("Looking at file '%s'\n", file.c_str());
if (pchmod(file, file_perms) != 0)
return -1;
if (pchown(file, uid, gid) != 0)
......@@ -328,7 +328,7 @@ int fixPermissions::fixDataData(string dataDir) {
directory = dir + "/";
directory.append(dataDataDirs.at(n));
if (debug)
LOGI("Looking at data directory: '%s'\n", directory.c_str());
LOGINFO("Looking at data directory: '%s'\n", directory.c_str());
if (dataDataDirs.at(n) == ".") {
if (pchmod(directory, "0755") != 0)
return -1;
......@@ -339,7 +339,7 @@ int fixPermissions::fixDataData(string dataDir) {
}
else if (dataDataDirs.at(n) == "..") {
if (debug)
LOGI("Skipping ..\n");
LOGINFO("Skipping ..\n");
continue;
}
else if (dataDataDirs.at(n) == "lib") {
......@@ -394,7 +394,7 @@ vector <string> fixPermissions::listAllDirectories(string path) {
vector <string> dirs;
if (dir == NULL) {
LOGE("Error opening '%s'\n", path.c_str());
LOGERR("Error opening '%s'\n", path.c_str());
return dirs;
}
struct dirent *entry = readdir(dir);
......@@ -412,7 +412,7 @@ vector <string> fixPermissions::listAllFiles(string path) {
vector <string> files;
if (dir == NULL) {
LOGE("Error opening '%s'\n", path.c_str());
LOGERR("Error opening '%s'\n", path.c_str());
return files;
}
struct dirent *entry = readdir(dir);
......@@ -449,7 +449,7 @@ int fixPermissions::getPackages() {
xml_node <> * next = pkgNode->first_node("package");
if (next == NULL) {
LOGE("No packages found to fix.\n");
LOGERR("No packages found to fix.\n");
return -1;
}
......@@ -465,7 +465,7 @@ int fixPermissions::getPackages() {
if (skiploop == true) {
if (debug)
LOGI("Skipping package %s\n", next->first_attribute("codePath")->value());
LOGINFO("Skipping package %s\n", next->first_attribute("codePath")->value());
free(temp);
next = next->next_sibling();
skiploop = false;
......@@ -474,9 +474,9 @@ int fixPermissions::getPackages() {
name.append((next->first_attribute("name")->value()));
temp->pkgName = next->first_attribute("name")->value();
if (debug)
LOGI("Loading pkg: %s\n", next->first_attribute("name")->value());
LOGINFO("Loading pkg: %s\n", next->first_attribute("name")->value());
if (next->first_attribute("codePath") == NULL) {
LOGI("Problem with codePath on %s\n", next->first_attribute("name")->value());
LOGINFO("Problem with codePath on %s\n", next->first_attribute("name")->value());
} else {
temp->codePath = next->first_attribute("codePath")->value();
temp->app = basename(next->first_attribute("codePath")->value());
......@@ -489,7 +489,7 @@ int fixPermissions::getPackages() {
}
else {
if (next->first_attribute("userId") == NULL) {
LOGI("Problem with userID on %s\n", next->first_attribute("name")->value());
LOGINFO("Problem with userID on %s\n", next->first_attribute("name")->value());
} else {
temp->uid = atoi(next->first_attribute("userId")->value());
temp->gid = atoi(next->first_attribute("userId")->value());
......@@ -516,7 +516,7 @@ int fixPermissions::getPackages() {
if (skiploop == true) {
if (debug)
LOGI("Skipping package %s\n", next->first_attribute("codePath")->value());
LOGINFO("Skipping package %s\n", next->first_attribute("codePath")->value());
free(temp);
next = next->next_sibling();
skiploop = false;
......@@ -525,9 +525,9 @@ int fixPermissions::getPackages() {
name.append((next->first_attribute("name")->value()));
temp->pkgName = next->first_attribute("name")->value();
if (debug)
LOGI("Loading pkg: %s\n", next->first_attribute("name")->value());
LOGINFO("Loading pkg: %s\n", next->first_attribute("name")->value());
if (next->first_attribute("codePath") == NULL) {
LOGI("Problem with codePath on %s\n", next->first_attribute("name")->value());
LOGINFO("Problem with codePath on %s\n", next->first_attribute("name")->value());
} else {
temp->codePath = next->first_attribute("codePath")->value();
temp->app = basename(next->first_attribute("codePath")->value());
......@@ -541,7 +541,7 @@ int fixPermissions::getPackages() {
}
else {
if (next->first_attribute("userId") == NULL) {
LOGI("Problem with userID on %s\n", next->first_attribute("name")->value());
LOGINFO("Problem with userID on %s\n", next->first_attribute("name")->value());
} else {
temp->uid = atoi(next->first_attribute("userId")->value());
temp->gid = atoi(next->first_attribute("userId")->value());
......
......@@ -30,7 +30,7 @@ else
LOCAL_SRC_FILES += hardwarekeyboard.cpp
endif
LOCAL_MODULE := libgui
LOCAL_MODULE := libguitwrp
# Use this flag to create a build that simulates threaded actions like installing zips, backups, restores, and wipes for theme testing
#TWRP_SIMULATE_ACTIONS := true
......
......@@ -38,17 +38,15 @@
#include "../twrp-functions.hpp"
#include "../openrecoveryscript.hpp"
#include "../ui.h"
#include "../adb_install.h"
#include "blanktimer.hpp"
extern "C" {
#include "../common.h"
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
#include "../recovery_ui.h"
#include "../variables.h"
#include "../twinstall.h"
#include "cutils/properties.h"
#include "../minadbd/adb.h"
int TWinstall_zip(const char* path, int* wipe_cache);
......@@ -60,7 +58,6 @@ int gui_start();
#include "rapidxml.hpp"
#include "objects.hpp"
extern RecoveryUI* ui;
extern blanktimer blankTimer;
void curtainClose(void);
......@@ -160,7 +157,7 @@ int GUIAction::NotifyVarChange(std::string varName, std::string value)
void GUIAction::simulate_progress_bar(void)
{
ui_print("Simulating actions...\n");
gui_print("Simulating actions...\n");
for (int i = 0; i < 5; i++)
{
usleep(500000);
......@@ -176,7 +173,7 @@ int GUIAction::flash_zip(std::string filename, std::string pageName, const int s
if (filename.empty())
{
LOGE("No file specified.\n");
LOGERR("No file specified.\n");
return -1;
}
......@@ -191,7 +188,7 @@ int GUIAction::flash_zip(std::string filename, std::string pageName, const int s
if (mzOpenZipArchive(filename.c_str(), &zip))
{
LOGE("Unable to open zip file.\n");
LOGERR("Unable to open zip file.\n");
return -1;
}
......@@ -231,10 +228,10 @@ int GUIAction::flash_zip(std::string filename, std::string pageName, const int s
{
DataManager::SetValue("tw_operation", "Configuring TWRP");
DataManager::SetValue("tw_partition", "");
ui_print("Configuring TWRP...\n");
gui_print("Configuring TWRP...\n");
if (TWFunc::Exec_Cmd("/sbin/installTwrp reinstall", result) < 0)
{
ui_print("Unable to configure TWRP with this kernel.\n");
gui_print("Unable to configure TWRP with this kernel.\n");
}
}
}
......@@ -256,33 +253,33 @@ int GUIAction::doActions()
pthread_attr_t tattr;
if (pthread_attr_init(&tattr)) {
LOGE("Unable to pthread_attr_init\n");
LOGERR("Unable to pthread_attr_init\n");
return -1;
}
if (pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_JOINABLE)) {
LOGE("Error setting pthread_attr_setdetachstate\n");
LOGERR("Error setting pthread_attr_setdetachstate\n");
return -1;
}
if (pthread_attr_setscope(&tattr, PTHREAD_SCOPE_SYSTEM)) {
LOGE("Error setting pthread_attr_setscope\n");
LOGERR("Error setting pthread_attr_setscope\n");
return -1;
}
/*if (pthread_attr_setstacksize(&tattr, 524288)) {
LOGE("Error setting pthread_attr_setstacksize\n");
LOGERR("Error setting pthread_attr_setstacksize\n");
return -1;
}
*/
int ret = pthread_create(&t, &tattr, thread_start, this);
if (ret) {
LOGE("Unable to create more threads for actions... continuing in same thread! %i\n", ret);
LOGERR("Unable to create more threads for actions... continuing in same thread! %i\n", ret);
thread_start(this);
} else {
if (pthread_join(t, NULL)) {
LOGE("Error joining threads\n");
LOGERR("Error joining threads\n");
}
}
if (pthread_attr_destroy(&tattr)) {
LOGE("Failed to pthread_attr_destroy\n");
LOGERR("Failed to pthread_attr_destroy\n");
return -1;
}
......@@ -392,7 +389,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
operation_start("Reload Theme");
theme_path = DataManager::GetSettingsStoragePath();
if (PartitionManager.Mount_By_Path(theme_path.c_str(), 1) < 0) {
LOGE("Unable to mount %s during reload function startup.\n", theme_path.c_str());
LOGERR("Unable to mount %s during reload function startup.\n", theme_path.c_str());
check = 1;
}
......@@ -400,10 +397,10 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
if (check != 0 || PageManager::ReloadPackage("TWRP", theme_path) != 0)
{
// Loading the custom theme failed - try loading the stock theme
LOGI("Attempting to reload stock theme...\n");
LOGINFO("Attempting to reload stock theme...\n");
if (PageManager::ReloadPackage("TWRP", "/res/ui.xml"))
{
LOGE("Failed to load base packages.\n");
LOGERR("Failed to load base packages.\n");
ret_val = 1;
}
}
......@@ -446,7 +443,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
if (!simulate)
PartitionManager.usb_storage_enable();
else
ui_print("Simulating actions...\n");
gui_print("Simulating actions...\n");
}
else if (!simulate)
{
......@@ -458,7 +455,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
else
PartitionManager.Mount_By_Path(arg, true);
} else
ui_print("Simulating actions...\n");
gui_print("Simulating actions...\n");
return 0;
}
......@@ -469,7 +466,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
if (!simulate)
PartitionManager.usb_storage_disable();
else
ui_print("Simulating actions...\n");
gui_print("Simulating actions...\n");
DataManager::SetValue(TW_ACTION_BUSY, 0);
}
else if (!simulate)
......@@ -482,7 +479,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
else
PartitionManager.UnMount_By_Path(arg, true);
} else
ui_print("Simulating actions...\n");
gui_print("Simulating actions...\n");
return 0;
}
......@@ -490,7 +487,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
{
operation_start("Restore Defaults");
if (simulate) // Simulated so that people don't accidently wipe out the "simulation is on" setting
ui_print("Simulating actions...\n");
gui_print("Simulating actions...\n");
else {
DataManager::ResetDefaults();
PartitionManager.Update_System_Details();
......@@ -509,7 +506,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
dst = DataManager::GetCurrentStoragePath() + "/recovery.log";
TWFunc::copy_file("/tmp/recovery.log", dst.c_str(), 0755);
sync();
ui_print("Copied recovery log to %s.\n", DataManager::GetCurrentStoragePath().c_str());
gui_print("Copied recovery log to %s.\n", DataManager::GetCurrentStoragePath().c_str());
} else
simulate_progress_bar();
operation_end(0, simulate);
......@@ -631,7 +628,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
if (function == "queuezip")
{
if (zip_queue_index >= 10) {
ui_print("Maximum zip queue reached!\n");
gui_print("Maximum zip queue reached!\n");
return 0;
}
DataManager::GetValue("tw_filename", zip_queue[zip_queue_index]);
......@@ -645,7 +642,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
if (function == "cancelzip")
{
if (zip_queue_index <= 0) {
ui_print("Minimum zip queue reached!\n");
gui_print("Minimum zip queue reached!\n");
return 0;
} else {
zip_queue_index--;
......@@ -694,7 +691,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
ret_val = flash_zip(zip_queue[i], arg, simulate, &wipe_cache);
if (ret_val != 0) {
ui_print("Error flashing zip '%s'\n", zip_queue[i].c_str());
gui_print("Error flashing zip '%s'\n", zip_queue[i].c_str());
i = 10; // Error flashing zip - exit queue
ret_val = 1;
}
......@@ -707,7 +704,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
string result;
if (DataManager::GetIntValue(TW_HAS_INJECTTWRP) == 1 && DataManager::GetIntValue(TW_INJECT_AFTER_ZIP) == 1) {
operation_start("ReinjectTWRP");
ui_print("Injecting TWRP into boot image...\n");
gui_print("Injecting TWRP into boot image...\n");
if (simulate) {
simulate_progress_bar();
} else {
......@@ -718,7 +715,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
string injectcmd = "injecttwrp --dump /tmp/backup_recovery_ramdisk.img /tmp/injected_boot.img --flash bd=" + Boot->Actual_Block_Device;
TWFunc::Exec_Cmd(injectcmd, result);
}
ui_print("TWRP injection complete.\n");
gui_print("TWRP injection complete.\n");
}
}
PartitionManager.Update_System_Details();
......@@ -768,15 +765,15 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
TWPartition* wipe_part = NULL;
DataManager::GetValue("tw_wipe_list", Wipe_List);
LOGI("wipe list '%s'\n", Wipe_List.c_str());
LOGINFO("wipe list '%s'\n", Wipe_List.c_str());
if (!Wipe_List.empty()) {
size_t start_pos = 0, end_pos = Wipe_List.find(";", start_pos);
while (end_pos != string::npos && start_pos < Wipe_List.size()) {
wipe_path = Wipe_List.substr(start_pos, end_pos - start_pos);
LOGI("wipe_path '%s'\n", wipe_path.c_str());
LOGINFO("wipe_path '%s'\n", wipe_path.c_str());
if (wipe_path == "/and-sec") {
if (!PartitionManager.Wipe_Android_Secure()) {
LOGE("Unable to wipe android secure\n");
LOGERR("Unable to wipe android secure\n");
ret_val = false;
break;
} else {
......@@ -784,7 +781,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
}
} else if (wipe_path == "DALVIK") {
if (!PartitionManager.Wipe_Dalvik_Cache()) {
LOGE("Failed to wipe dalvik\n");
LOGERR("Failed to wipe dalvik\n");
ret_val = false;
break;
} else {
......@@ -793,7 +790,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
}
if (!skip) {
if (!PartitionManager.Wipe_By_Path(wipe_path)) {
LOGE("Unable to wipe '%s'\n", wipe_path.c_str());
LOGERR("Unable to wipe '%s'\n", wipe_path.c_str());
ret_val = false;
break;
} else if (wipe_path == DataManager::GetSettingsStoragePath()) {
......@@ -814,12 +811,12 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
string Storage_Path = DataManager::GetSettingsStoragePath();
if (PartitionManager.Mount_By_Path(Storage_Path, true)) {
LOGI("Making TWRP folder and saving settings.\n");
LOGINFO("Making TWRP folder and saving settings.\n");
Storage_Path += "/TWRP";
mkdir(Storage_Path.c_str(), 0777);
DataManager::Flush();
} else {
LOGE("Unable to recreate TWRP folder and save settings.\n");
LOGERR("Unable to recreate TWRP folder and save settings.\n");
}
}
}
......@@ -879,7 +876,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
if (function == "fixpermissions")
{
operation_start("Fix Permissions");
LOGI("fix permissions started!\n");
LOGINFO("fix permissions started!\n");
if (simulate) {
simulate_progress_bar();
} else {
......@@ -915,7 +912,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
int allow_partition;
DataManager::GetValue(TW_ALLOW_PARTITION_SDCARD, allow_partition);
if (allow_partition == 0) {
ui_print("This device does not have a real SD Card!\nAborting!\n");
gui_print("This device does not have a real SD Card!\nAborting!\n");
} else {
if (!PartitionManager.Partition_SDCard())
ret_val = 1; // failed
......@@ -963,7 +960,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
string result;
operation_start("Command");
LOGI("Running command: '%s'\n", arg.c_str());
LOGINFO("Running command: '%s'\n", arg.c_str());
if (simulate) {
simulate_progress_bar();
} else {
......@@ -982,19 +979,19 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
DataManager::GetValue("tw_terminal_location", cmdpath);
operation_start("CommandOutput");
ui_print("%s # %s\n", cmdpath.c_str(), arg.c_str());
gui_print("%s # %s\n", cmdpath.c_str(), arg.c_str());
if (simulate) {
simulate_progress_bar();
operation_end(op_status, simulate);
} else {
command = "cd \"" + cmdpath + "\" && " + arg + " 2>&1";;
LOGI("Actual command is: '%s'\n", command.c_str());
LOGINFO("Actual command is: '%s'\n", command.c_str());
DataManager::SetValue("tw_terminal_command_thread", command);
DataManager::SetValue("tw_terminal_state", 1);
DataManager::SetValue("tw_background_thread_running", 1);
op_status = pthread_create(&terminal_command, NULL, command_thread, NULL);
if (op_status != 0) {
LOGE("Error starting terminal command thread, %i.\n", op_status);
LOGERR("Error starting terminal command thread, %i.\n", op_status);
DataManager::SetValue("tw_terminal_state", 0);
DataManager::SetValue("tw_background_thread_running", 0);
operation_end(1, simulate);
......@@ -1006,7 +1003,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
{
int op_status = 0;
LOGI("Sending kill command...\n");
LOGINFO("Sending kill command...\n");
operation_start("KillCommand");
DataManager::SetValue("tw_operation_status", 0);
DataManager::SetValue("tw_operation_state", 1);
......@@ -1020,12 +1017,12 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
int op_status = 0;
string result;
operation_start("ReinjectTWRP");
ui_print("Injecting TWRP into boot image...\n");
gui_print("Injecting TWRP into boot image...\n");
if (simulate) {
simulate_progress_bar();
} else {
TWFunc::Exec_Cmd("injecttwrp --dump /tmp/backup_recovery_ramdisk.img /tmp/injected_boot.img --flash", result);
ui_print("TWRP injection complete.\n");
gui_print("TWRP injection complete.\n");
}
operation_end(op_status, simulate);
......@@ -1077,7 +1074,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
theme_path = DataManager::GetSettingsStoragePath();
if (PartitionManager.Mount_By_Path(theme_path.c_str(), 1) < 0) {
LOGE("Unable to mount %s during reload function startup.\n", theme_path.c_str());
LOGERR("Unable to mount %s during reload function startup.\n", theme_path.c_str());
check = 1;
}
......@@ -1086,10 +1083,10 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
if (PageManager::ReloadPackage("TWRP", theme_path) != 0)
{
// Loading the custom theme failed - try loading the stock theme
LOGI("Attempting to reload stock theme...\n");
LOGINFO("Attempting to reload stock theme...\n");
if (PageManager::ReloadPackage("TWRP", "/res/ui.xml"))
{
LOGE("Failed to load base packages.\n");
LOGERR("Failed to load base packages.\n");
}
}
}
......@@ -1121,20 +1118,23 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
if (TWFunc::Path_Exists(Sideload_File)) {
unlink(Sideload_File.c_str());
}
ui_print("Starting ADB sideload feature...\n");
gui_print("Starting ADB sideload feature...\n");
DataManager::GetValue("tw_wipe_dalvik", wipe_dalvik);
ret = apply_from_adb(ui, &wipe_cache, Sideload_File.c_str());
ret = apply_from_adb(Sideload_File.c_str());
DataManager::SetValue("tw_has_cancel", 0); // Remove cancel button from gui now that the zip install is going to start
if (ret != 0) {
ret = 1; // failure
} else {
} else if (TWinstall_zip(Sideload_File.c_str(), &wipe_cache) == 0) {
if (wipe_cache || DataManager::GetIntValue("tw_wipe_cache"))
PartitionManager.Wipe_By_Path("/cache");
if (wipe_dalvik)
PartitionManager.Wipe_Dalvik_Cache();
} else {
ret = 1; // failure
}
if (DataManager::GetIntValue(TW_HAS_INJECTTWRP) == 1 && DataManager::GetIntValue(TW_INJECT_AFTER_ZIP) == 1) {
operation_start("ReinjectTWRP");
ui_print("Injecting TWRP into boot image...\n");
gui_print("Injecting TWRP into boot image...\n");
if (simulate) {
simulate_progress_bar();
} else {
......@@ -1145,7 +1145,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
string injectcmd = "injecttwrp --dump /tmp/backup_recovery_ramdisk.img /tmp/injected_boot.img --flash bd=" + Boot->Actual_Block_Device;
TWFunc::Exec_Cmd(injectcmd, result);
}
ui_print("TWRP injection complete.\n");
gui_print("TWRP injection complete.\n");
}
}
}
......@@ -1155,11 +1155,17 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
if (function == "adbsideloadcancel")
{
int child_pid;
char child_prop[PROPERTY_VALUE_MAX];
string Sideload_File;
Sideload_File = DataManager::GetCurrentStoragePath() + "/sideload.zip";
unlink(Sideload_File.c_str());
DataManager::GetValue("tw_child_pid", child_pid);
ui_print("Cancelling ADB sideload...\n");
property_get("tw_child_pid", child_prop, "error");
if (strcmp(child_prop, "error") == 0) {
LOGERR("Unable to get child ID from prop\n");
return 0;
}
child_pid = atoi(child_prop);
gui_print("Cancelling ADB sideload...\n");
kill(child_pid, SIGTERM);
DataManager::SetValue("tw_page_done", "1"); // For OpenRecoveryScript support
return 0;
......@@ -1174,14 +1180,14 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
// Run those first.
int reboot = 0;
if (TWFunc::Path_Exists(SCRIPT_FILE_TMP)) {
ui_print("Processing AOSP recovery commands...\n");
gui_print("Processing AOSP recovery commands...\n");
if (OpenRecoveryScript::run_script_file() == 0) {
reboot = 1;
}
}
// Check for the ORS file in /cache and attempt to run those commands.
if (OpenRecoveryScript::check_for_script_file()) {
ui_print("Processing OpenRecoveryScript file...\n");
gui_print("Processing OpenRecoveryScript file...\n");
if (OpenRecoveryScript::run_script_file() == 0) {
reboot = 1;
}
......@@ -1263,7 +1269,7 @@ void* GUIAction::command_thread(void *cookie)
DataManager::GetValue("tw_terminal_command_thread", command);
fp = popen(command.c_str(), "r");
if (fp == NULL) {
LOGE("Error opening command to run.\n");
LOGERR("Error opening command to run.\n");
} else {
int fd = fileno(fp), has_data = 0, check = 0, keep_going = -1, bytes_read = 0;
struct timeval timeout;
......@@ -1290,7 +1296,7 @@ void* GUIAction::command_thread(void *cookie)
memset(line, 0, sizeof(line));
bytes_read = read(fd, line, sizeof(line));
if (bytes_read > 0)
ui_print("%s", line); // Display output
gui_print("%s", line); // Display output
else
keep_going = 0; // Done executing
}
......
......@@ -18,9 +18,8 @@
#include <string>
extern "C" {
#include "../common.h"
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
#include "../recovery_ui.h"
}
#include "rapidxml.hpp"
......
......@@ -39,8 +39,7 @@ extern "C" {
#include "blanktimer.hpp"
#include "../data.hpp"
extern "C" {
#include "../common.h"
#include "../recovery_ui.h"
#include "../twcommon.h"
}
#include "../twrp-functions.hpp"
#include "../variables.h"
......@@ -140,7 +139,7 @@ void blanktimer::resetTimerAndUnblank(void) {
case 3:
#ifndef TW_NO_SCREEN_BLANK
if (gr_fb_blank(0) < 0) {
LOGI("blanktimer::resetTimerAndUnblank failed to gr_fb_blank(0)\n");
LOGINFO("blanktimer::resetTimerAndUnblank failed to gr_fb_blank(0)\n");
break;
}
#endif
......
......@@ -34,9 +34,8 @@
#include <string>
extern "C" {
#include "../common.h"
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
#include "../recovery_ui.h"
}
#include "rapidxml.hpp"
......@@ -87,7 +86,7 @@ GUIButton::GUIButton(xml_node<>* node)
}
}
if (!hasFill && mButtonImg == NULL) {
LOGE("No image resource or fill specified for button.\n");
LOGERR("No image resource or fill specified for button.\n");
}
// The icon is a special case
......
......@@ -18,9 +18,8 @@
#include <string>
extern "C" {
#include "../common.h"
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
#include "../recovery_ui.h"
}
#include "rapidxml.hpp"
......
......@@ -18,9 +18,8 @@
#include <string>
extern "C" {
#include "../common.h"
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
#include "../recovery_ui.h"
#include "../variables.h"
}
......
......@@ -18,9 +18,8 @@
#include <string>
extern "C" {
#include "../common.h"
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
#include "../recovery_ui.h"
}
#include "rapidxml.hpp"
......
......@@ -38,10 +38,8 @@
#include <algorithm>
extern "C" {
#include "../common.h"
#include "../roots.h"
#include "../twcommon.h"
#include "../minuitwrp/minui.h"
#include "../recovery_ui.h"
}
#include "rapidxml.hpp"
......@@ -945,7 +943,7 @@ int GUIFileSelector::GetFileList(const std::string folder)
d = opendir(folder.c_str());
if (d == NULL)
{
LOGI("Unable to open '%s'\n", folder.c_str());
LOGINFO("Unable to open '%s'\n", folder.c_str());
if (folder != "/" && (mShowNavFolders != 0 || mShowFiles != 0)) {
size_t found;
found = folder.find_last_of('/');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment