Move all AOSP code out of recovery binary
Improves license compatibility between GPL and Apache
Change-Id: I2b165aa575bb6213af6b07936f99610c113443f0
diff --git a/Android.mk b/Android.mk
index 0419e82..398eac7 100644
--- a/Android.mk
+++ b/Android.mk
@@ -16,25 +16,16 @@
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_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 @@
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 @@
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 @@
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 $(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 @@
$(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 @@
$(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 :=
diff --git a/adb_install.cpp b/adb_install.cpp
index f227bc0..c18126d 100644
--- a/adb_install.cpp
+++ b/adb_install.cpp
@@ -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 @@
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 @@
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 @@
// 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;
}
diff --git a/adb_install.h b/adb_install.h
index a18b712..a7cb336 100644
--- a/adb_install.h
+++ b/adb_install.h
@@ -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
diff --git a/bootloader.cpp b/bootloader.cpp
index 6f4f83a..6b42b94 100644
--- a/bootloader.cpp
+++ b/bootloader.cpp
@@ -33,7 +33,7 @@
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 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 @@
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 @@
}
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;
+}
diff --git a/bootloader.h b/bootloader.h
index 712aa1a..38bb19e 100644
--- a/bootloader.h
+++ b/bootloader.h
@@ -51,6 +51,9 @@
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
diff --git a/common.h b/common.h
index 7bd769a..4344298 100644
--- a/common.h
+++ b/common.h
@@ -25,12 +25,11 @@
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__)
diff --git a/crypto/ics/Android.mk b/crypto/ics/Android.mk
new file mode 100644
index 0000000..88f3b84
--- /dev/null
+++ b/crypto/ics/Android.mk
@@ -0,0 +1,13 @@
+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)
diff --git a/crypto/jb/Android.mk b/crypto/jb/Android.mk
new file mode 100644
index 0000000..87eb055
--- /dev/null
+++ b/crypto/jb/Android.mk
@@ -0,0 +1,14 @@
+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
diff --git a/data.cpp b/data.cpp
index c33fa89..9c60edd 100644
--- a/data.cpp
+++ b/data.cpp
@@ -48,7 +48,7 @@
extern "C"
{
- #include "common.h"
+ #include "twcommon.h"
#include "data.h"
#include "gui/pages.h"
@@ -102,7 +102,7 @@
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 @@
}
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 @@
} 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 @@
} 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 @@
}
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 @@
}
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 @@
// 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 @@
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 @@
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 @@
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 @@
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 @@
}
} 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 @@
#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 @@
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 @@
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 @@
#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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
}
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 @@
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 @@
{
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 @@
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);
diff --git a/data.hpp b/data.hpp
index b540675..ff50373 100644
--- a/data.hpp
+++ b/data.hpp
@@ -33,6 +33,7 @@
// 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 @@
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();
diff --git a/fixPermissions.cpp b/fixPermissions.cpp
index eae78e8..1d2c518 100644
--- a/fixPermissions.cpp
+++ b/fixPermissions.cpp
@@ -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 @@
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 @@
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 @@
// 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 @@
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::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 @@
}
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 @@
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 @@
//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 @@
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 @@
//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 @@
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 @@
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 @@
}
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> 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> 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 @@
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 @@
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 @@
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 @@
}
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 @@
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 @@
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 @@
}
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());
diff --git a/gui/Android.mk b/gui/Android.mk
index b3e9b09..748c5ec 100644
--- a/gui/Android.mk
+++ b/gui/Android.mk
@@ -30,7 +30,7 @@
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
diff --git a/gui/action.cpp b/gui/action.cpp
index 3456324..b35074c 100644
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -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 @@
#include "rapidxml.hpp"
#include "objects.hpp"
-extern RecoveryUI* ui;
extern blanktimer blankTimer;
void curtainClose(void);
@@ -160,7 +157,7 @@
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 @@
if (filename.empty())
{
- LOGE("No file specified.\n");
+ LOGERR("No file specified.\n");
return -1;
}
@@ -191,7 +188,7 @@
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 @@
{
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 @@
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 @@
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 @@
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 @@
if (!simulate)
PartitionManager.usb_storage_enable();
else
- ui_print("Simulating actions...\n");
+ gui_print("Simulating actions...\n");
}
else if (!simulate)
{
@@ -458,7 +455,7 @@
else
PartitionManager.Mount_By_Path(arg, true);
} else
- ui_print("Simulating actions...\n");
+ gui_print("Simulating actions...\n");
return 0;
}
@@ -469,7 +466,7 @@
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 @@
else
PartitionManager.UnMount_By_Path(arg, true);
} else
- ui_print("Simulating actions...\n");
+ gui_print("Simulating actions...\n");
return 0;
}
@@ -490,7 +487,7 @@
{
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
}
} 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 @@
}
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 @@
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 @@
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 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 @@
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 @@
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 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 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
// 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 @@
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 @@
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
}
diff --git a/gui/animation.cpp b/gui/animation.cpp
index 3021f46..77d7b54 100644
--- a/gui/animation.cpp
+++ b/gui/animation.cpp
@@ -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"
diff --git a/gui/blanktimer.cpp b/gui/blanktimer.cpp
index 17cc0b3..700a9ad 100644
--- a/gui/blanktimer.cpp
+++ b/gui/blanktimer.cpp
@@ -39,8 +39,7 @@
#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 @@
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
diff --git a/gui/button.cpp b/gui/button.cpp
index 5ba8182..af7d07b 100644
--- a/gui/button.cpp
+++ b/gui/button.cpp
@@ -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 @@
}
}
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
diff --git a/gui/checkbox.cpp b/gui/checkbox.cpp
index e52b589..077d5e2 100644
--- a/gui/checkbox.cpp
+++ b/gui/checkbox.cpp
@@ -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"
diff --git a/gui/conditional.cpp b/gui/conditional.cpp
index 4e8a492..b3aba2d 100644
--- a/gui/conditional.cpp
+++ b/gui/conditional.cpp
@@ -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"
}
diff --git a/gui/console.cpp b/gui/console.cpp
index 7631e43..8a7a85e 100644
--- a/gui/console.cpp
+++ b/gui/console.cpp
@@ -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"
diff --git a/gui/fileselector.cpp b/gui/fileselector.cpp
index d2be865..539bba0 100644
--- a/gui/fileselector.cpp
+++ b/gui/fileselector.cpp
@@ -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 @@
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('/');
diff --git a/gui/fill.cpp b/gui/fill.cpp
index 11b700f..901eee1 100644
--- a/gui/fill.cpp
+++ b/gui/fill.cpp
@@ -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"
@@ -36,7 +35,7 @@
attr = node->first_attribute("color");
if (!attr) {
- LOGE("No color specified for fill\n");
+ LOGERR("No color specified for fill\n");
return;
}
diff --git a/gui/gui.cpp b/gui/gui.cpp
index f08d68b..4c7bf5b 100644
--- a/gui/gui.cpp
+++ b/gui/gui.cpp
@@ -35,10 +35,8 @@
extern "C"
{
-#include "../common.h"
-#include "../roots.h"
+#include "../twcommon.h"
#include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
#include "../minzip/Zip.h"
#include <pixelflinger/pixelflinger.h>
}
@@ -217,7 +215,7 @@
touch_repeat = 1;
gettimeofday (&touchStart, NULL);
#ifdef _EVENT_LOGGING
- LOGE ("TOUCH_HOLD: %d,%d\n", x, y);
+ LOGERR("TOUCH_HOLD: %d,%d\n", x, y);
#endif
PageManager::NotifyTouch (TOUCH_HOLD, x, y);
blankTimer.resetTimerAndUnblank();
@@ -225,7 +223,7 @@
else if (touch_repeat && mtime > 100)
{
#ifdef _EVENT_LOGGING
- LOGE ("TOUCH_REPEAT: %d,%d\n", x, y);
+ LOGERR("TOUCH_REPEAT: %d,%d\n", x, y);
#endif
gettimeofday (&touchStart, NULL);
PageManager::NotifyTouch (TOUCH_REPEAT, x, y);
@@ -234,7 +232,7 @@
else if (key_repeat == 1 && mtime > 500)
{
#ifdef _EVENT_LOGGING
- LOGE ("KEY_HOLD: %d,%d\n", x, y);
+ LOGERR("KEY_HOLD: %d,%d\n", x, y);
#endif
gettimeofday (&touchStart, NULL);
key_repeat = 2;
@@ -244,7 +242,7 @@
else if (key_repeat == 2 && mtime > 100)
{
#ifdef _EVENT_LOGGING
- LOGE ("KEY_REPEAT: %d,%d\n", x, y);
+ LOGERR("KEY_REPEAT: %d,%d\n", x, y);
#endif
gettimeofday (&touchStart, NULL);
kb.KeyRepeat ();
@@ -262,7 +260,7 @@
if (state == 0)
{
#ifdef _EVENT_LOGGING
- LOGE ("TOUCH_RELEASE: %d,%d\n", x, y);
+ LOGERR("TOUCH_RELEASE: %d,%d\n", x, y);
#endif
PageManager::NotifyTouch (TOUCH_RELEASE, x, y);
blankTimer.resetTimerAndUnblank();
@@ -279,7 +277,7 @@
if (!drag)
{
#ifdef _EVENT_LOGGING
- LOGE ("TOUCH_START: %d,%d\n", x, y);
+ LOGERR("TOUCH_START: %d,%d\n", x, y);
#endif
if (PageManager::NotifyTouch (TOUCH_START, x, y) > 0)
state = 1;
@@ -295,7 +293,7 @@
if (state == 0)
{
#ifdef _EVENT_LOGGING
- LOGE ("TOUCH_DRAG: %d,%d\n", x, y);
+ LOGERR("TOUCH_DRAG: %d,%d\n", x, y);
#endif
if (PageManager::NotifyTouch (TOUCH_DRAG, x, y) > 0)
state = 1;
@@ -309,7 +307,7 @@
{
// Handle key-press here
#ifdef _EVENT_LOGGING
- LOGE ("TOUCH_KEY: %d\n", ev.code);
+ LOGERR("TOUCH_KEY: %d\n", ev.code);
#endif
if (ev.value != 0)
{
@@ -502,7 +500,7 @@
int
gui_changePage (std::string newPage)
{
- LOGI ("Set page: '%s'\n", newPage.c_str ());
+ LOGINFO("Set page: '%s'\n", newPage.c_str ());
PageManager::ChangePage (newPage);
pthread_mutex_lock(&gForceRendermutex);
gForceRender = 1;
@@ -600,41 +598,41 @@
{
if (PageManager::LoadPackage ("TWRP", "/res/ui.xml", "decrypt"))
{
- LOGE ("Failed to load base packages.\n");
+ LOGERR("Failed to load base packages.\n");
goto error;
}
else
check = 1;
}
if (check == 0
- && PageManager::LoadPackage ("TWRP", "/script/ui.xml", "main"))
+ && PageManager::LoadPackage("TWRP", "/script/ui.xml", "main"))
{
std::string theme_path;
theme_path = DataManager::GetSettingsStoragePath ();
- if (!PartitionManager.Mount_Settings_Storage (false))
+ if (!PartitionManager.Mount_Settings_Storage(false))
{
int retry_count = 5;
while (retry_count > 0
- && !PartitionManager.Mount_Settings_Storage (false))
+ && !PartitionManager.Mount_Settings_Storage(false))
{
usleep (500000);
retry_count--;
}
- if (!PartitionManager.Mount_Settings_Storage (false))
+ if (!PartitionManager.Mount_Settings_Storage(false))
{
- LOGE ("Unable to mount %s during GUI startup.\n",
+ LOGERR("Unable to mount %s during GUI startup.\n",
theme_path.c_str ());
check = 1;
}
}
theme_path += "/TWRP/theme/ui.zip";
- if (check || PageManager::LoadPackage ("TWRP", theme_path, "main"))
+ if (check || PageManager::LoadPackage("TWRP", theme_path, "main"))
{
- if (PageManager::LoadPackage ("TWRP", "/res/ui.xml", "main"))
+ if (PageManager::LoadPackage("TWRP", "/res/ui.xml", "main"))
{
- LOGE ("Failed to load base packages.\n");
+ LOGERR("Failed to load base packages.\n");
goto error;
}
}
@@ -647,7 +645,7 @@
return 0;
error:
- LOGE ("An internal error has occurred.\n");
+ LOGERR("An internal error has occurred.\n");
gGuiInitialized = 0;
return -1;
}
@@ -687,7 +685,7 @@
loopTimer ();
// Set the default package
- PageManager::SelectPackage ("TWRP");
+ PageManager::SelectPackage("TWRP");
if (!gGuiInputRunning)
{
@@ -697,7 +695,7 @@
gGuiInputRunning = 1;
}
- DataManager::SetValue ("tw_page_done", 0);
+ DataManager::SetValue("tw_page_done", 0);
return runPage (page_name);
}
@@ -722,7 +720,7 @@
flip ();
if (ret < 0)
- LOGE ("An update request has failed.\n");
+ LOGERR("An update request has failed.\n");
}
else
{
diff --git a/gui/hardwarekeyboard.cpp b/gui/hardwarekeyboard.cpp
index 39b02cc..96958d5 100644
--- a/gui/hardwarekeyboard.cpp
+++ b/gui/hardwarekeyboard.cpp
@@ -19,9 +19,8 @@
#include <string>
extern "C" {
-#include "../common.h"
+#include "../twcommon.h"
#include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
}
#include "rapidxml.hpp"
@@ -37,7 +36,7 @@
int HardwareKeyboard::KeyDown(int key_code) {
#ifdef _EVENT_LOGGING
- LOGE("HardwareKeyboard::KeyDown %i\n", key_code);
+ LOGERR("HardwareKeyboard::KeyDown %i\n", key_code);
#endif
PageManager::NotifyKey(key_code);
return 0; // 0 = no key repeat anything else turns on key repeat
@@ -45,14 +44,14 @@
int HardwareKeyboard::KeyUp(int key_code) {
#ifdef _EVENT_LOGGING
- LOGE("HardwareKeyboard::KeyUp %i\n", key_code);
+ LOGERR("HardwareKeyboard::KeyUp %i\n", key_code);
#endif
return 0;
}
int HardwareKeyboard::KeyRepeat(void) {
#ifdef _EVENT_LOGGING
- LOGE("HardwareKeyboard::KeyRepeat\n");
+ LOGERR("HardwareKeyboard::KeyRepeat\n");
#endif
return 0;
}
diff --git a/gui/image.cpp b/gui/image.cpp
index 05e5178..c684d1b 100644
--- a/gui/image.cpp
+++ b/gui/image.cpp
@@ -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"
diff --git a/gui/input.cpp b/gui/input.cpp
index 2418c4c..e016724 100644
--- a/gui/input.cpp
+++ b/gui/input.cpp
@@ -20,9 +20,8 @@
#include <string>
extern "C" {
-#include "../common.h"
+#include "../twcommon.h"
#include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
}
#include "rapidxml.hpp"
@@ -300,7 +299,7 @@
}
}
} else
- LOGI("GUIInput::HandleTextLocation -> We really shouldn't ever get here...\n");
+ LOGINFO("GUIInput::HandleTextLocation -> We really shouldn't ever get here...\n");
} else if (x > lastX) {
// Dragging to right, scrolling left
while (-1) {
diff --git a/gui/keyboard.cpp b/gui/keyboard.cpp
index b74ff56..7b6d006 100644
--- a/gui/keyboard.cpp
+++ b/gui/keyboard.cpp
@@ -38,9 +38,8 @@
#include <string>
extern "C" {
-#include "../common.h"
+#include "../twcommon.h"
#include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
}
#include "rapidxml.hpp"
@@ -116,7 +115,7 @@
while (keylayout)
{
if (layoutindex > MAX_KEYBOARD_LAYOUTS) {
- LOGE("Too many layouts defined in keyboard.\n");
+ LOGERR("Too many layouts defined in keyboard.\n");
return;
}
@@ -141,7 +140,7 @@
while (keyrow)
{
if (rowindex > MAX_KEYBOARD_ROWS) {
- LOGE("Too many rows defined in keyboard.\n");
+ LOGERR("Too many rows defined in keyboard.\n");
return;
}
@@ -158,20 +157,20 @@
char keyinfo[255];
if (keyindex > MAX_KEYBOARD_KEYS) {
- LOGE("Too many keys defined in a keyboard row.\n");
+ LOGERR("Too many keys defined in a keyboard row.\n");
return;
}
stratt = attr->value();
if (strlen(stratt.c_str()) >= 255) {
- LOGE("Key info on layout%i, row%i, key%dd is too long.\n", layoutindex, rowindex, keyindex);
+ LOGERR("Key info on layout%i, row%i, key%dd is too long.\n", layoutindex, rowindex, keyindex);
return;
}
strcpy(keyinfo, stratt.c_str());
if (strlen(keyinfo) == 0) {
- LOGE("No key info on layout%i, row%i, key%dd.\n", layoutindex, rowindex, keyindex);
+ LOGERR("No key info on layout%i, row%i, key%dd.\n", layoutindex, rowindex, keyindex);
return;
}
@@ -220,7 +219,7 @@
// This is an action
keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1].key = KEYBOARD_ACTION;
} else
- LOGE("Invalid key info on layout%i, row%i, key%02i.\n", layoutindex, rowindex, keyindex);
+ LOGERR("Invalid key info on layout%i, row%i, key%02i.\n", layoutindex, rowindex, keyindex);
}
// PROCESS LONG PRESS INFO IF EXISTS
@@ -229,14 +228,14 @@
if (attr) {
stratt = attr->value();
if (strlen(stratt.c_str()) >= 255) {
- LOGE("Key info on layout%i, row%i, key%dd is too long.\n", layoutindex, rowindex, keyindex);
+ LOGERR("Key info on layout%i, row%i, key%dd is too long.\n", layoutindex, rowindex, keyindex);
return;
}
strcpy(keyinfo, stratt.c_str());
if (strlen(keyinfo) == 0) {
- LOGE("No long press info on layout%i, row%i, long%dd.\n", layoutindex, rowindex, keyindex);
+ LOGERR("No long press info on layout%i, row%i, long%dd.\n", layoutindex, rowindex, keyindex);
return;
}
@@ -282,7 +281,7 @@
// This is an action
keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1].longpresskey = KEYBOARD_ACTION;
} else
- LOGE("Invalid long press key info on layout%i, row%i, long%02i.\n", layoutindex, rowindex, keyindex);
+ LOGERR("Invalid long press key info on layout%i, row%i, long%02i.\n", layoutindex, rowindex, keyindex);
}
}
keyindex++;
diff --git a/gui/listbox.cpp b/gui/listbox.cpp
index 910a6a3..3af40ed 100644
--- a/gui/listbox.cpp
+++ b/gui/listbox.cpp
@@ -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"
diff --git a/gui/pages.cpp b/gui/pages.cpp
index 40de44f..bf44b38 100644
--- a/gui/pages.cpp
+++ b/gui/pages.cpp
@@ -35,9 +35,8 @@
#include <string>
extern "C" {
-#include "../common.h"
+#include "../twcommon.h"
#include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
}
#include "rapidxml.hpp"
@@ -171,11 +170,11 @@
mName = page->first_attribute("name")->value();
else
{
- LOGE("No page name attribute found!\n");
+ LOGERR("No page name attribute found!\n");
return;
}
- LOGI("Loading page %s\n", mName.c_str());
+ LOGINFO("Loading page %s\n", mName.c_str());
// This is a recursive routine for template handling
ProcessNode(page, templates);
@@ -187,7 +186,7 @@
{
if (depth == 10)
{
- LOGE("Page processing depth has exceeded 10. Failing out. This is likely a recursive template.\n");
+ LOGERR("Page processing depth has exceeded 10. Failing out. This is likely a recursive template.\n");
return false;
}
@@ -303,7 +302,7 @@
{
if (!templates || !child->first_attribute("name"))
{
- LOGE("Invalid template request.\n");
+ LOGERR("Invalid template request.\n");
}
else
{
@@ -331,7 +330,7 @@
}
else
{
- LOGE("Unknown object type.\n");
+ LOGERR("Unknown object type.\n");
}
child = child->next_sibling("object");
}
@@ -349,7 +348,7 @@
for (iter = mRenders.begin(); iter != mRenders.end(); iter++)
{
if ((*iter)->Render())
- LOGE("A render request has failed.\n");
+ LOGERR("A render request has failed.\n");
}
return 0;
}
@@ -363,7 +362,7 @@
{
int ret = (*iter)->Update();
if (ret < 0)
- LOGE("An update request has failed.\n");
+ LOGERR("An update request has failed.\n");
else if (ret > retCode)
retCode = ret;
}
@@ -421,7 +420,7 @@
if (ret == 0)
return 0;
else if (ret < 0)
- LOGE("An action handler has returned an error");
+ LOGERR("An action handler has returned an error");
}
return 1;
}
@@ -440,7 +439,7 @@
if (ret == 0)
return 0;
else if (ret < 0)
- LOGE("A keyboard handler has returned an error");
+ LOGERR("A keyboard handler has returned an error");
}
return 1;
}
@@ -459,7 +458,7 @@
if (ret == 0)
return 0;
else if (ret < 0)
- LOGE("An input focus handler has returned an error");
+ LOGERR("An input focus handler has returned an error");
}
return 1;
}
@@ -485,7 +484,7 @@
for (iter = mActions.begin(); iter != mActions.end(); ++iter)
{
if ((*iter)->NotifyVarChange(varName, value))
- LOGE("An action handler errored on NotifyVarChange.\n");
+ LOGERR("An action handler errored on NotifyVarChange.\n");
}
return 0;
}
@@ -520,17 +519,17 @@
parent = mDoc.first_node("install");
// Now, let's parse the XML
- LOGI("Loading resources...\n");
+ LOGINFO("Loading resources...\n");
child = parent->first_node("resources");
if (child)
mResources = new ResourceManager(child, package);
- LOGI("Loading variables...\n");
+ LOGINFO("Loading variables...\n");
child = parent->first_node("variables");
if (child)
LoadVariables(child);
- LOGI("Loading pages...\n");
+ LOGINFO("Loading pages...\n");
// This may be NULL if no templates are present
templates = parent->first_node("templates");
@@ -554,7 +553,7 @@
}
else
{
- LOGE("Unable to locate page (%s)\n", page.c_str());
+ LOGERR("Unable to locate page (%s)\n", page.c_str());
}
return -1;
}
@@ -618,7 +617,7 @@
Page* page = new Page(child, templates);
if (page->GetName().empty())
{
- LOGE("Unable to process load page\n");
+ LOGERR("Unable to process load page\n");
delete page;
}
else
@@ -697,7 +696,7 @@
int ret;
// Open the XML file
- LOGI("Loading package: %s (%s)\n", name.c_str(), package.c_str());
+ LOGINFO("Loading package: %s (%s)\n", name.c_str(), package.c_str());
if (mzOpenZipArchive(package.c_str(), &zip))
{
// We can try to load the XML directly...
@@ -721,7 +720,7 @@
const ZipEntry* ui_xml = mzFindZipEntry(&zip, "ui.xml");
if (ui_xml == NULL)
{
- LOGE("Unable to locate ui.xml in zip file\n");
+ LOGERR("Unable to locate ui.xml in zip file\n");
goto error;
}
@@ -732,7 +731,7 @@
if (!mzExtractZipEntryToBuffer(&zip, ui_xml, (unsigned char*) xmlFile))
{
- LOGE("Unable to extract ui.xml\n");
+ LOGERR("Unable to extract ui.xml\n");
goto error;
}
}
@@ -752,7 +751,7 @@
}
else
{
- LOGE("Package %s failed to load.\n", name.c_str());
+ LOGERR("Package %s failed to load.\n", name.c_str());
}
// The first successful package we loaded is the base
@@ -765,7 +764,7 @@
return ret;
error:
- LOGE("An internal error has occurred.\n");
+ LOGERR("An internal error has occurred.\n");
if (pZip) mzCloseZipArchive(pZip);
if (xmlFile) free(xmlFile);
return -1;
@@ -780,20 +779,20 @@
{
return (*iter).second;
}
- LOGE("Unable to locate package %s\n", name.c_str());
+ LOGERR("Unable to locate package %s\n", name.c_str());
return NULL;
}
PageSet* PageManager::SelectPackage(std::string name)
{
- LOGI("Switching packages (%s)\n", name.c_str());
+ LOGINFO("Switching packages (%s)\n", name.c_str());
PageSet* tmp;
tmp = FindPackage(name);
if (tmp)
mCurrentSet = tmp;
else
- LOGE("Unable to find package.\n");
+ LOGERR("Unable to find package.\n");
return mCurrentSet;
}
@@ -811,7 +810,7 @@
if (LoadPackage(name, package, "main") != 0)
{
- LOGE("Failed to load package.\n");
+ LOGERR("Failed to load package.\n");
mPageSets.insert(std::pair<std::string, PageSet*>(name, set));
return -1;
}
diff --git a/gui/partitionlist.cpp b/gui/partitionlist.cpp
index 9f9321c..36d5c16 100644
--- a/gui/partitionlist.cpp
+++ b/gui/partitionlist.cpp
@@ -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"
@@ -330,12 +328,12 @@
PartitionManager.Get_Partition_List(ListType, &mList);
} else {
mList.clear();
- LOGE("No partition listtype name specified for partitionlist GUI element\n");
+ LOGERR("No partition listtype name specified for partitionlist GUI element\n");
return;
}
} else {
mList.clear();
- LOGE("No partition listtype specified for partitionlist GUI element\n");
+ LOGERR("No partition listtype specified for partitionlist GUI element\n");
return;
}
}
@@ -755,7 +753,7 @@
bool update_size = false;
TWPartition* Part = PartitionManager.Find_Partition_By_Path(str);
if (Part == NULL) {
- LOGE("Unable to locate partition for '%s'\n", str.c_str());
+ LOGERR("Unable to locate partition for '%s'\n", str.c_str());
return 0;
}
if (!Part->Is_Mounted() && Part->Removable)
diff --git a/gui/progressbar.cpp b/gui/progressbar.cpp
index e0e9c51..dce4315 100644
--- a/gui/progressbar.cpp
+++ b/gui/progressbar.cpp
@@ -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,7 +38,7 @@
if (!node)
{
- LOGE("GUIProgressBar created without XML node\n");
+ LOGERR("GUIProgressBar created without XML node\n");
return;
}
diff --git a/gui/resources.cpp b/gui/resources.cpp
index 2f2ea95..aaa1533 100644
--- a/gui/resources.cpp
+++ b/gui/resources.cpp
@@ -21,9 +21,8 @@
#include <iomanip>
extern "C" {
-#include "../common.h"
+#include "../twcommon.h"
#include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
}
#include "rapidxml.hpp"
@@ -207,9 +206,9 @@
if (!attr_name) {
std::string res_name = attr_name->value();
- LOGE("Resource (%s)-(%s) failed to load\n", type.c_str(), res_name.c_str());
+ LOGERR("Resource (%s)-(%s) failed to load\n", type.c_str(), res_name.c_str());
} else
- LOGE("Resource type (%s) failed to load\n", type.c_str());
+ LOGERR("Resource type (%s) failed to load\n", type.c_str());
delete res;
}
@@ -227,9 +226,9 @@
if (!attr_name) {
std::string res_name = attr_name->value();
- LOGE("Resource (%s)-(%s) failed to load\n", type.c_str(), res_name.c_str());
+ LOGERR("Resource (%s)-(%s) failed to load\n", type.c_str(), res_name.c_str());
} else
- LOGE("Resource type (%s) failed to load\n", type.c_str());
+ LOGERR("Resource type (%s) failed to load\n", type.c_str());
delete res;
}
@@ -247,9 +246,9 @@
if (!attr_name) {
std::string res_name = attr_name->value();
- LOGE("Resource (%s)-(%s) failed to load\n", type.c_str(), res_name.c_str());
+ LOGERR("Resource (%s)-(%s) failed to load\n", type.c_str(), res_name.c_str());
} else
- LOGE("Resource type (%s) failed to load\n", type.c_str());
+ LOGERR("Resource type (%s) failed to load\n", type.c_str());
delete res;
}
@@ -260,7 +259,7 @@
}
else
{
- LOGE("Resource type (%s) not supported.\n", type.c_str());
+ LOGERR("Resource type (%s) not supported.\n", type.c_str());
}
child = child->next_sibling("resource");
diff --git a/gui/slider.cpp b/gui/slider.cpp
index 95962c0..4542d60 100644
--- a/gui/slider.cpp
+++ b/gui/slider.cpp
@@ -19,9 +19,8 @@
#include <string>
extern "C" {
-#include "../common.h"
+#include "../twcommon.h"
#include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
}
#include "rapidxml.hpp"
@@ -40,7 +39,7 @@
if (!node)
{
- LOGE("GUISlider created without XML node\n");
+ LOGERR("GUISlider created without XML node\n");
return;
}
@@ -74,7 +73,7 @@
sTouchH = gr_get_height(sTouch->GetResource()); // Height of the "touch image" that follows the touch (arrow)
}
- //LOGI("mRenderW: %i mTouchW: %i\n", mRenderW, mTouchW);
+ //LOGINFO("mRenderW: %i mTouchW: %i\n", mRenderW, mTouchW);
mActionX = mRenderX;
mActionY = mRenderY;
mActionW = mRenderW;
diff --git a/gui/text.cpp b/gui/text.cpp
index 1eceab1..46a6622 100644
--- a/gui/text.cpp
+++ b/gui/text.cpp
@@ -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"
diff --git a/install.cpp b/install.cpp
index 4d73aa9..92388e8 100644
--- a/install.cpp
+++ b/install.cpp
@@ -188,7 +188,7 @@
// commas. The last key must not be followed by a comma.
//
// Returns NULL if the file failed to parse, or if it contain zero keys.
-static RSAPublicKey*
+RSAPublicKey*
load_keys(const char* filename, int* numKeys) {
RSAPublicKey* out = NULL;
*numKeys = 0;
diff --git a/install.h b/install.h
index 1943f02..5829c65 100644
--- a/install.h
+++ b/install.h
@@ -18,6 +18,7 @@
#define RECOVERY_INSTALL_H_
#include "common.h"
+#include "mincrypt/rsa.h"
#ifdef __cplusplus
extern "C" {
@@ -29,6 +30,7 @@
// cache partition.
int install_package(const char *root_path, int* wipe_cache,
const char* install_file);
+RSAPublicKey* load_keys(const char* filename, int* numKeys);
#ifdef __cplusplus
}
diff --git a/libjpegtwrp/Android.mk b/libjpegtwrp/Android.mk
index de852cb..98b2539 100755
--- a/libjpegtwrp/Android.mk
+++ b/libjpegtwrp/Android.mk
@@ -69,11 +69,9 @@
LOCAL_CFLAGS+= \
$(foreach f,$(asm_flags),-Wa,"$(f)")
endif
-
+LOCAL_MODULE_TAGS := eng
+LOCAL_SHARED_LIBRARIES += libcutils
LOCAL_MODULE:= libjpegtwrp
-LOCAL_SHARED_LIBRARIES := \
- libcutils
-
include $(BUILD_STATIC_LIBRARY)
diff --git a/minadbd/Android.mk b/minadbd/Android.mk
index 5a4de68..c08fd46 100644
--- a/minadbd/Android.mk
+++ b/minadbd/Android.mk
@@ -18,15 +18,16 @@
sockets.c \
services.c \
usb_linux_client.c \
- utils.c
+ utils.c \
+ ../../../system/core/adb/transport_local.c
LOCAL_CFLAGS := -O2 -g -DADB_HOST=0 -Wall -Wno-unused-parameter
LOCAL_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE
-
+LOCAL_MODULE_TAGS := eng
LOCAL_MODULE := libminadbd
-LOCAL_STATIC_LIBRARIES := libcutils libc
-include $(BUILD_STATIC_LIBRARY)
+LOCAL_SHARED_LIBRARIES := libcutils libc
+include $(BUILD_SHARED_LIBRARY)
diff --git a/minuitwrp/Android.mk b/minuitwrp/Android.mk
index f0c7089..59ca2cc 100644
--- a/minuitwrp/Android.mk
+++ b/minuitwrp/Android.mk
@@ -1,7 +1,9 @@
LOCAL_PATH := $(call my-dir)
+
include $(CLEAR_VARS)
LOCAL_SRC_FILES := events.c resources.c
+#LOCAL_SRC_FILES := $(TARGET_OUT_SHARED_LIBRARIES)/libjpegtwrp.so $(TARGET_OUT_SHARED_LIBRARIES)/libpng.so $(TARGET_OUT_SHARED_LIBRARIES)/libpixelflinger.so
ifneq ($(TW_BOARD_CUSTOM_GRAPHICS),)
LOCAL_SRC_FILES += $(TW_BOARD_CUSTOM_GRAPHICS)
@@ -9,11 +11,13 @@
LOCAL_SRC_FILES += graphics.c
endif
-LOCAL_C_INCLUDES +=\
- external/libpng\
- external/zlib\
- external/jpeg
+LOCAL_C_INCLUDES += \
+ external/libpng \
+ external/zlib \
+ system/core/include
+LOCAL_C_INCLUDES += \
+ bootable/recovery/libjpegtwrp
ifeq ($(RECOVERY_TOUCHSCREEN_SWAP_XY), true)
LOCAL_CFLAGS += -DRECOVERY_TOUCHSCREEN_SWAP_XY
@@ -54,7 +58,9 @@
ifneq ($(BOARD_USE_CUSTOM_RECOVERY_FONT),)
LOCAL_CFLAGS += -DBOARD_USE_CUSTOM_RECOVERY_FONT=$(BOARD_USE_CUSTOM_RECOVERY_FONT)
endif
-LOCAL_STATIC_LIBRARY := libpng
+LOCAL_SHARED_LIBRARIES += libz libpixelflinger libc libcutils
+LOCAL_STATIC_LIBRARIES += libpng libjpegtwrp
+LOCAL_MODULE_TAGS := eng
LOCAL_MODULE := libminuitwrp
-include $(BUILD_STATIC_LIBRARY)
+include $(BUILD_SHARED_LIBRARY)
\ No newline at end of file
diff --git a/minuitwrp/events.c b/minuitwrp/events.c
index 285b5b6..73c4066 100644
--- a/minuitwrp/events.c
+++ b/minuitwrp/events.c
@@ -152,11 +152,11 @@
len = ioctl(e->fd->fd, EVIOCGNAME(sizeof(e->deviceName)), e->deviceName);
if (len <= 0)
{
- LOGE("Unable to query event object.\n");
+ printf("Unable to query event object.\n");
return -1;
}
#ifdef _EVENT_LOGGING
- LOGI("Event object: %s\n", e->deviceName);
+ printf("Event object: %s\n", e->deviceName);
#endif
// Blacklist these "input" devices
@@ -188,7 +188,7 @@
}
if (e->vk_count % 6) {
- LOGW("minui: %s is %d %% 6\n", vk_path, e->vk_count % 6);
+ printf("minui: %s is %d %% 6\n", vk_path, e->vk_count % 6);
}
e->vk_count /= 6;
if (e->vk_count <= 0)
@@ -201,14 +201,14 @@
ioctl(e->fd->fd, EVIOCGABS(ABS_Y), &e->p.yi);
e->p.synced = 0;
#ifdef _EVENT_LOGGING
- LOGI("EV: ST minX: %d maxX: %d minY: %d maxY: %d\n", e->p.xi.minimum, e->p.xi.maximum, e->p.yi.minimum, e->p.yi.maximum);
+ printf("EV: ST minX: %d maxX: %d minY: %d maxY: %d\n", e->p.xi.minimum, e->p.xi.maximum, e->p.yi.minimum, e->p.yi.maximum);
#endif
ioctl(e->fd->fd, EVIOCGABS(ABS_MT_POSITION_X), &e->mt_p.xi);
ioctl(e->fd->fd, EVIOCGABS(ABS_MT_POSITION_Y), &e->mt_p.yi);
e->mt_p.synced = 0;
#ifdef _EVENT_LOGGING
- LOGI("EV: MT minX: %d maxX: %d minY: %d maxY: %d\n", e->mt_p.xi.minimum, e->mt_p.xi.maximum, e->mt_p.yi.minimum, e->mt_p.yi.maximum);
+ printf("EV: MT minX: %d maxX: %d minY: %d maxY: %d\n", e->mt_p.xi.minimum, e->mt_p.xi.maximum, e->mt_p.yi.minimum, e->mt_p.yi.maximum);
#endif
e->vks = malloc(sizeof(*e->vks) * e->vk_count);
@@ -223,7 +223,7 @@
if (strcmp(token[0], "0x01") != 0) {
/* Java does string compare, so we do too. */
- LOGW("minui: %s: ignoring unknown virtual key type %s\n", vk_path, token[0]);
+ printf("minui: %s: ignoring unknown virtual key type %s\n", vk_path, token[0]);
continue;
}
@@ -299,7 +299,7 @@
}
#ifdef _EVENT_LOGGING
- LOGI("EV: p->x=%d x-range=%d,%d fb-width=%d\n", p->x, p->xi.minimum, p->xi.maximum, gr_fb_width());
+ printf("EV: p->x=%d x-range=%d,%d fb-width=%d\n", p->x, p->xi.minimum, p->xi.maximum, gr_fb_width());
#endif
#ifndef RECOVERY_TOUCHSCREEN_SWAP_XY
@@ -341,14 +341,14 @@
{
// This appears to be an accelerometer or another strange input device. It's not the touchscreen.
#ifdef _EVENT_LOGGING
- LOGI("EV: Device disabled due to non-touchscreen messages.\n");
+ printf("EV: Device disabled due to non-touchscreen messages.\n");
#endif
e->ignored = 1;
return 1;
}
#ifdef _EVENT_LOGGING
- LOGI("EV: %s => type: %x code: %x value: %d\n", e->deviceName, ev->type, ev->code, ev->value);
+ printf("EV: %s => type: %x code: %x value: %d\n", e->deviceName, ev->type, ev->code, ev->value);
#endif
// Handle keyboard events, value of 1 indicates key down, 0 indicates key up
@@ -363,7 +363,7 @@
e->p.synced |= 0x01;
e->p.x = ev->value;
#ifdef _EVENT_LOGGING
- LOGI("EV: %s => EV_ABS ABS_X %d\n", e->deviceName, ev->value);
+ printf("EV: %s => EV_ABS ABS_X %d\n", e->deviceName, ev->value);
#endif
break;
@@ -371,7 +371,7 @@
e->p.synced |= 0x02;
e->p.y = ev->value;
#ifdef _EVENT_LOGGING
- LOGI("EV: %s => EV_ABS ABS_Y %d\n", e->deviceName, ev->value);
+ printf("EV: %s => EV_ABS ABS_Y %d\n", e->deviceName, ev->value);
#endif
break;
@@ -400,7 +400,7 @@
touchReleaseOnNextSynReport = 1;
}
#ifdef _EVENT_LOGGING
- LOGI("EV: %s => EV_ABS ABS_MT_TOUCH_MAJOR %d\n", e->deviceName, ev->value);
+ printf("EV: %s => EV_ABS ABS_MT_TOUCH_MAJOR %d\n", e->deviceName, ev->value);
#endif
break;
@@ -413,7 +413,7 @@
touchReleaseOnNextSynReport = 1;
}
#ifdef _EVENT_LOGGING
- LOGI("EV: %s => EV_ABS ABS_MT_PRESSURE %d\n", e->deviceName, ev->value);
+ printf("EV: %s => EV_ABS ABS_MT_PRESSURE %d\n", e->deviceName, ev->value);
#endif
break;
@@ -421,7 +421,7 @@
e->mt_p.synced |= 0x01;
e->mt_p.x = ev->value;
#ifdef _EVENT_LOGGING
- LOGI("EV: %s => EV_ABS ABS_MT_POSITION_X %d\n", e->deviceName, ev->value);
+ printf("EV: %s => EV_ABS ABS_MT_POSITION_X %d\n", e->deviceName, ev->value);
#endif
break;
@@ -429,29 +429,29 @@
e->mt_p.synced |= 0x02;
e->mt_p.y = ev->value;
#ifdef _EVENT_LOGGING
- LOGI("EV: %s => EV_ABS ABS_MT_POSITION_Y %d\n", e->deviceName, ev->value);
+ printf("EV: %s => EV_ABS ABS_MT_POSITION_Y %d\n", e->deviceName, ev->value);
#endif
break;
#ifdef _EVENT_LOGGING
// All of these items are strictly for logging purposes only. Return 1 because they don't need to be handled.
case ABS_MT_TOUCH_MINOR: //31
- LOGI("EV: %s => EV_ABS ABS_MT_TOUCH_MINOR %d\n", e->deviceName, ev->value);
+ printf("EV: %s => EV_ABS ABS_MT_TOUCH_MINOR %d\n", e->deviceName, ev->value);
return 1;
break;
case ABS_MT_WIDTH_MAJOR: //32
- LOGI("EV: %s => EV_ABS ABS_MT_WIDTH_MAJOR %d\n", e->deviceName, ev->value);
+ printf("EV: %s => EV_ABS ABS_MT_WIDTH_MAJOR %d\n", e->deviceName, ev->value);
return 1;
break;
case ABS_MT_WIDTH_MINOR: //33
- LOGI("EV: %s => EV_ABS ABS_MT_WIDTH_MINOR %d\n", e->deviceName, ev->value);
+ printf("EV: %s => EV_ABS ABS_MT_WIDTH_MINOR %d\n", e->deviceName, ev->value);
return 1;
break;
case ABS_MT_ORIENTATION: //34
- LOGI("EV: %s => EV_ABS ABS_MT_ORIENTATION %d\n", e->deviceName, ev->value);
+ printf("EV: %s => EV_ABS ABS_MT_ORIENTATION %d\n", e->deviceName, ev->value);
return 1;
break;
@@ -461,17 +461,17 @@
break;
case ABS_MT_BLOB_ID: //38
- LOGI("EV: %s => EV_ABS ABS_MT_BLOB_ID %d\n", e->deviceName, ev->value);
+ printf("EV: %s => EV_ABS ABS_MT_BLOB_ID %d\n", e->deviceName, ev->value);
return 1;
break;
case ABS_MT_TRACKING_ID: //39
- LOGI("EV: %s => EV_ABS ABS_MT_TRACKING_ID %d\n", e->deviceName, ev->value);
+ printf("EV: %s => EV_ABS ABS_MT_TRACKING_ID %d\n", e->deviceName, ev->value);
return 1;
break;
case ABS_MT_DISTANCE: //3b
- LOGI("EV: %s => EV_ABS ABS_MT_DISTANCE %d\n", e->deviceName, ev->value);
+ printf("EV: %s => EV_ABS ABS_MT_DISTANCE %d\n", e->deviceName, ev->value);
return 1;
break;
#endif
@@ -496,8 +496,8 @@
}
#ifdef _EVENT_LOGGING
- if (ev->type == EV_SYN && ev->code == SYN_REPORT) LOGI("EV: %s => EV_SYN SYN_REPORT\n", e->deviceName);
- if (ev->type == EV_SYN && ev->code == SYN_MT_REPORT) LOGI("EV: %s => EV_SYN SYN_MT_REPORT\n", e->deviceName);
+ if (ev->type == EV_SYN && ev->code == SYN_REPORT) printf("EV: %s => EV_SYN SYN_REPORT\n", e->deviceName);
+ if (ev->type == EV_SYN && ev->code == SYN_MT_REPORT) printf("EV: %s => EV_SYN SYN_MT_REPORT\n", e->deviceName);
#endif
// Discard the MT versions
@@ -555,7 +555,7 @@
#endif
#ifdef _EVENT_LOGGING
- LOGI("EV: x: %d y: %d\n", x, y);
+ printf("EV: x: %d y: %d\n", x, y);
#endif
// Clear the current sync states
diff --git a/minuitwrp/graphics.c b/minuitwrp/graphics.c
index 61a98c3..627e343 100644
--- a/minuitwrp/graphics.c
+++ b/minuitwrp/graphics.c
@@ -79,14 +79,14 @@
#ifdef PRINT_SCREENINFO
static void print_fb_var_screeninfo()
{
- LOGI("vi.xres: %d\n", vi.xres);
- LOGI("vi.yres: %d\n", vi.yres);
- LOGI("vi.xres_virtual: %d\n", vi.xres_virtual);
- LOGI("vi.yres_virtual: %d\n", vi.yres_virtual);
- LOGI("vi.xoffset: %d\n", vi.xoffset);
- LOGI("vi.yoffset: %d\n", vi.yoffset);
- LOGI("vi.bits_per_pixel: %d\n", vi.bits_per_pixel);
- LOGI("vi.grayscale: %d\n", vi.grayscale);
+ printf("vi.xres: %d\n", vi.xres);
+ printf("vi.yres: %d\n", vi.yres);
+ printf("vi.xres_virtual: %d\n", vi.xres_virtual);
+ printf("vi.yres_virtual: %d\n", vi.yres_virtual);
+ printf("vi.xoffset: %d\n", vi.xoffset);
+ printf("vi.yoffset: %d\n", vi.yoffset);
+ printf("vi.bits_per_pixel: %d\n", vi.bits_per_pixel);
+ printf("vi.grayscale: %d\n", vi.grayscale);
}
#endif
@@ -191,7 +191,7 @@
fb->width = vi.xres;
fb->height = vi.yres;
#ifdef BOARD_HAS_JANKY_BACKBUFFER
- LOGI("setting JANKY BACKBUFFER\n");
+ printf("setting JANKY BACKBUFFER\n");
fb->stride = fi.line_length/2;
#else
fb->stride = vi.xres_virtual;
diff --git a/minuitwrp/resources.c b/minuitwrp/resources.c
index ea6a447..4c8d8a9 100644
--- a/minuitwrp/resources.c
+++ b/minuitwrp/resources.c
@@ -30,7 +30,7 @@
#include <pixelflinger/pixelflinger.h>
#include <png.h>
-#include <jpeglib.h>
+#include "../libjpegtwrp/jpeglib.h"
#include "minui.h"
diff --git a/minzip/Android.mk b/minzip/Android.mk
index 6c1d096..73407b7 100644
--- a/minzip/Android.mk
+++ b/minzip/Android.mk
@@ -21,5 +21,6 @@
LOCAL_MODULE := libminzip
LOCAL_CFLAGS += -Wall
+LOCAL_SHARED_LIBRARIES := libz
-include $(BUILD_STATIC_LIBRARY)
+include $(BUILD_SHARED_LIBRARY)
diff --git a/mtdutils/Android.mk b/mtdutils/Android.mk
index 438b393..8e1bdca 100644
--- a/mtdutils/Android.mk
+++ b/mtdutils/Android.mk
@@ -17,6 +17,21 @@
include $(BUILD_STATIC_LIBRARY)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ mtdutils.c \
+ mounts.c
+
+ifeq ($(TARGET_BOARD_PLATFORM),rk30xx)
+LOCAL_SRC_FILES += rk30hack.c
+endif
+
+LOCAL_MODULE := libmtdutils
+LOCAL_STATIC_LIBRARIES := libcutils libc
+
+include $(BUILD_SHARED_LIBRARY)
+
ifeq ($(BOARD_USES_BML_OVER_MTD),true)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := bml_over_mtd.c
diff --git a/openrecoveryscript.cpp b/openrecoveryscript.cpp
index 5a23c1d..a842d33 100644
--- a/openrecoveryscript.cpp
+++ b/openrecoveryscript.cpp
@@ -35,7 +35,7 @@
#include "twrp-functions.hpp"
#include "partitions.hpp"
-#include "common.h"
+#include "twcommon.h"
#include "openrecoveryscript.hpp"
#include "variables.h"
#include "adb_install.h"
@@ -46,16 +46,15 @@
int TWinstall_zip(const char* path, int* wipe_cache);
}
-extern RecoveryUI* ui;
#define SCRIPT_COMMAND_SIZE 512
int OpenRecoveryScript::check_for_script_file(void) {
if (!PartitionManager.Mount_By_Path(SCRIPT_FILE_CACHE, false)) {
- LOGE("Unable to mount /cache for OpenRecoveryScript support.\n");
+ LOGERR("Unable to mount /cache for OpenRecoveryScript support.\n");
return 0;
}
if (TWFunc::Path_Exists(SCRIPT_FILE_CACHE)) {
- LOGI("Script file found: '%s'\n", SCRIPT_FILE_CACHE);
+ LOGINFO("Script file found: '%s'\n", SCRIPT_FILE_CACHE);
// Copy script file to /tmp
TWFunc::copy_file(SCRIPT_FILE_CACHE, SCRIPT_FILE_TMP, 0755);
// Delete the file from /cache
@@ -81,7 +80,7 @@
line_len = strlen(script_line);
if (line_len < 2)
continue; // there's a blank line or line is too short to contain a command
- //ui_print("script line: '%s'\n", script_line);
+ //gui_print("script line: '%s'\n", script_line);
for (i=0; i<line_len; i++) {
if ((int)script_line[i] == 32) {
cindex = i;
@@ -96,14 +95,14 @@
remove_nl = 1;
if (cindex != 0) {
strncpy(command, script_line, cindex);
- LOGI("command is: '%s' and ", command);
+ LOGINFO("command is: '%s' and ", command);
val_start = script_line;
val_start += cindex + 1;
strncpy(value, val_start, line_len - cindex - remove_nl);
- LOGI("value is: '%s'\n", value);
+ LOGINFO("value is: '%s'\n", value);
} else {
strncpy(command, script_line, line_len - remove_nl + 1);
- ui_print("command is: '%s' and there is no value\n", command);
+ gui_print("command is: '%s' and there is no value\n", command);
}
if (strcmp(command, "install") == 0) {
// Install Zip
@@ -114,19 +113,19 @@
} else if (strcmp(command, "wipe") == 0) {
// Wipe
if (strcmp(value, "cache") == 0 || strcmp(value, "/cache") == 0) {
- ui_print("-- Wiping Cache Partition...\n");
+ gui_print("-- Wiping Cache Partition...\n");
PartitionManager.Wipe_By_Path("/cache");
- ui_print("-- Cache Partition Wipe Complete!\n");
+ gui_print("-- Cache Partition Wipe Complete!\n");
} else if (strcmp(value, "dalvik") == 0 || strcmp(value, "dalvick") == 0 || strcmp(value, "dalvikcache") == 0 || strcmp(value, "dalvickcache") == 0) {
- ui_print("-- Wiping Dalvik Cache...\n");
+ gui_print("-- Wiping Dalvik Cache...\n");
PartitionManager.Wipe_Dalvik_Cache();
- ui_print("-- Dalvik Cache Wipe Complete!\n");
+ gui_print("-- Dalvik Cache Wipe Complete!\n");
} else if (strcmp(value, "data") == 0 || strcmp(value, "/data") == 0 || strcmp(value, "factory") == 0 || strcmp(value, "factoryreset") == 0) {
- ui_print("-- Wiping Data Partition...\n");
+ gui_print("-- Wiping Data Partition...\n");
PartitionManager.Factory_Reset();
- ui_print("-- Data Partition Wipe Complete!\n");
+ gui_print("-- Data Partition Wipe Complete!\n");
} else {
- LOGE("Error with wipe command value: '%s'\n", value);
+ LOGERR("Error with wipe command value: '%s'\n", value);
ret_val = 1;
}
} else if (strcmp(command, "backup") == 0) {
@@ -148,7 +147,7 @@
remove_nl = 0;
strncpy(value2, tok, line_len - remove_nl);
DataManager::SetValue(TW_BACKUP_NAME, value2);
- ui_print("Backup folder set to '%s'\n", value2);
+ gui_print("Backup folder set to '%s'\n", value2);
if (PartitionManager.Check_Backup_Name(true) != 0) {
ret_val = 1;
continue;
@@ -177,27 +176,27 @@
strcpy(partitions, restore_partitions.c_str());
}
strcpy(folder_path, restore_folder.c_str());
- LOGI("Restore folder is: '%s' and partitions: '%s'\n", folder_path, partitions);
- ui_print("Restoring '%s'\n", folder_path);
+ LOGINFO("Restore folder is: '%s' and partitions: '%s'\n", folder_path, partitions);
+ gui_print("Restoring '%s'\n", folder_path);
if (folder_path[0] != '/') {
char backup_folder[512];
string folder_var;
DataManager::GetValue(TW_BACKUPS_FOLDER_VAR, folder_var);
sprintf(backup_folder, "%s/%s", folder_var.c_str(), folder_path);
- LOGI("Restoring relative path: '%s'\n", backup_folder);
+ LOGINFO("Restoring relative path: '%s'\n", backup_folder);
if (!TWFunc::Path_Exists(backup_folder)) {
if (DataManager::GetIntValue(TW_HAS_DUAL_STORAGE)) {
if (DataManager::GetIntValue(TW_USE_EXTERNAL_STORAGE)) {
- LOGI("Backup folder '%s' not found on external storage, trying internal...\n", folder_path);
+ LOGINFO("Backup folder '%s' not found on external storage, trying internal...\n", folder_path);
DataManager::SetValue(TW_USE_EXTERNAL_STORAGE, 0);
} else {
- LOGI("Backup folder '%s' not found on internal storage, trying external...\n", folder_path);
+ LOGINFO("Backup folder '%s' not found on internal storage, trying external...\n", folder_path);
DataManager::SetValue(TW_USE_EXTERNAL_STORAGE, 1);
}
DataManager::GetValue(TW_BACKUPS_FOLDER_VAR, folder_var);
sprintf(backup_folder, "%s/%s", folder_var.c_str(), folder_path);
- LOGI("2Restoring relative path: '%s'\n", backup_folder);
+ LOGINFO("2Restoring relative path: '%s'\n", backup_folder);
}
}
strcpy(folder_path, backup_folder);
@@ -208,7 +207,7 @@
strcat(folder_path, "/.");
}
if (!TWFunc::Path_Exists(folder_path)) {
- ui_print("Unable to locate backup '%s'\n", folder_path);
+ gui_print("Unable to locate backup '%s'\n", folder_path);
ret_val = 1;
continue;
}
@@ -222,38 +221,38 @@
memset(value2, 0, sizeof(value2));
strcpy(value2, partitions);
- ui_print("Setting restore options: '%s':\n", value2);
+ gui_print("Setting restore options: '%s':\n", value2);
line_len = strlen(value2);
for (i=0; i<line_len; i++) {
if ((value2[i] == 'S' || value2[i] == 's') && Partition_List.find("/system;") != string::npos) {
Restore_List += "/system;";
- ui_print("System\n");
+ gui_print("System\n");
} else if ((value2[i] == 'D' || value2[i] == 'd') && Partition_List.find("/data;") != string::npos) {
Restore_List += "/data;";
- ui_print("Data\n");
+ gui_print("Data\n");
} else if ((value2[i] == 'C' || value2[i] == 'c') && Partition_List.find("/cache;") != string::npos) {
Restore_List += "/cache;";
- ui_print("Cache\n");
+ gui_print("Cache\n");
} else if ((value2[i] == 'R' || value2[i] == 'r') && Partition_List.find("/recovery;") != string::npos) {
- ui_print("Recovery -- Not allowed to restore recovery\n");
+ gui_print("Recovery -- Not allowed to restore recovery\n");
} else if (value2[i] == '1' && DataManager::GetIntValue(TW_RESTORE_SP1_VAR) > 0) {
- ui_print("%s\n", "Special1 -- No Longer Supported...");
+ gui_print("%s\n", "Special1 -- No Longer Supported...");
} else if (value2[i] == '2' && DataManager::GetIntValue(TW_RESTORE_SP2_VAR) > 0) {
- ui_print("%s\n", "Special2 -- No Longer Supported...");
+ gui_print("%s\n", "Special2 -- No Longer Supported...");
} else if (value2[i] == '3' && DataManager::GetIntValue(TW_RESTORE_SP3_VAR) > 0) {
- ui_print("%s\n", "Special3 -- No Longer Supported...");
+ gui_print("%s\n", "Special3 -- No Longer Supported...");
} else if ((value2[i] == 'B' || value2[i] == 'b') && Partition_List.find("/boot;") != string::npos) {
Restore_List += "/boot;";
- ui_print("Boot\n");
+ gui_print("Boot\n");
} else if ((value2[i] == 'A' || value2[i] == 'a') && Partition_List.find("/and-sec;") != string::npos) {
Restore_List += "/and-sec;";
- ui_print("Android Secure\n");
+ gui_print("Android Secure\n");
} else if ((value2[i] == 'E' || value2[i] == 'e') && Partition_List.find("/sd-ext;") != string::npos) {
Restore_List += "/sd-ext;";
- ui_print("SD-Ext\n");
+ gui_print("SD-Ext\n");
} else if (value2[i] == 'M' || value2[i] == 'm') {
DataManager::SetValue(TW_SKIP_MD5_CHECK_VAR, 1);
- ui_print("MD5 check skip is on\n");
+ gui_print("MD5 check skip is on\n");
}
}
@@ -264,7 +263,7 @@
if (!PartitionManager.Run_Restore(folder_path))
ret_val = 1;
else
- ui_print("Restore complete!\n");
+ gui_print("Restore complete!\n");
} else if (strcmp(command, "mount") == 0) {
// Mount
DataManager::SetValue("tw_action_text2", "Mounting");
@@ -274,7 +273,7 @@
} else
strcpy(mount, value);
if (PartitionManager.Mount_By_Path(mount, true))
- ui_print("Mounted '%s'\n", mount);
+ gui_print("Mounted '%s'\n", mount);
} else if (strcmp(command, "unmount") == 0 || strcmp(command, "umount") == 0) {
// Unmount
DataManager::SetValue("tw_action_text2", "Unmounting");
@@ -284,21 +283,21 @@
} else
strcpy(mount, value);
if (PartitionManager.UnMount_By_Path(mount, true))
- ui_print("Unmounted '%s'\n", mount);
+ gui_print("Unmounted '%s'\n", mount);
} else if (strcmp(command, "set") == 0) {
// Set value
tok = strtok(value, " ");
strcpy(value1, tok);
tok = strtok(NULL, " ");
strcpy(value2, tok);
- ui_print("Setting '%s' to '%s'\n", value1, value2);
+ gui_print("Setting '%s' to '%s'\n", value1, value2);
DataManager::SetValue(value1, value2);
} else if (strcmp(command, "mkdir") == 0) {
// Make directory (recursive)
DataManager::SetValue("tw_action_text2", "Making Directory");
- ui_print("Making directory (recursive): '%s'\n", value);
+ gui_print("Making directory (recursive): '%s'\n", value);
if (TWFunc::Recursive_Mkdir(value)) {
- LOGE("Unable to create folder: '%s'\n", value);
+ LOGERR("Unable to create folder: '%s'\n", value);
ret_val = 1;
}
} else if (strcmp(command, "reboot") == 0) {
@@ -309,10 +308,10 @@
string status;
TWFunc::Exec_Cmd(value, status);
} else {
- LOGE("No value given for cmd\n");
+ LOGERR("No value given for cmd\n");
}
} else if (strcmp(command, "print") == 0) {
- ui_print("%s\n", value);
+ gui_print("%s\n", value);
} else if (strcmp(command, "sideload") == 0) {
// ADB Sideload
DataManager::SetValue("tw_action_text2", "ADB Sideload");
@@ -328,32 +327,36 @@
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::SetValue("tw_has_cancel", 1);
DataManager::SetValue("tw_cancel_action", "adbsideloadcancel");
- ret_val = apply_from_adb(ui, &wipe_cache, Sideload_File.c_str());
+ ret_val = apply_from_adb(Sideload_File.c_str());
DataManager::SetValue("tw_has_cancel", 0);
if (ret_val != 0)
ret_val = 1; // failure
- else if (wipe_cache)
- PartitionManager.Wipe_By_Path("/cache");
+ else if (TWinstall_zip(Sideload_File.c_str(), &wipe_cache) == 0) {
+ if (wipe_cache)
+ PartitionManager.Wipe_By_Path("/cache");
+ } else {
+ ret_val = 1; // failure
+ }
sideload = 1; // Causes device to go to the home screen afterwards
- ui_print("Sideload finished.\n");
+ gui_print("Sideload finished.\n");
}
} else {
- LOGE("Unrecognized script command: '%s'\n", command);
+ LOGERR("Unrecognized script command: '%s'\n", command);
ret_val = 1;
}
}
fclose(fp);
- ui_print("Done processing script file\n");
+ gui_print("Done processing script file\n");
} else {
- LOGE("Error opening script file '%s'\n", SCRIPT_FILE_TMP);
+ LOGERR("Error opening script file '%s'\n", SCRIPT_FILE_TMP);
return 1;
}
if (install_cmd && DataManager::GetIntValue(TW_HAS_INJECTTWRP) == 1 && DataManager::GetIntValue(TW_INJECT_AFTER_ZIP) == 1) {
string status;
- ui_print("Injecting TWRP into boot image...\n");
+ gui_print("Injecting TWRP into boot image...\n");
TWPartition* Boot = PartitionManager.Find_Partition_By_Path("/boot");
if (Boot == NULL || Boot->Current_File_System != "emmc")
TWFunc::Exec_Cmd("injecttwrp --dump /tmp/backup_recovery_ramdisk.img /tmp/injected_boot.img --flash", status);
@@ -361,7 +364,7 @@
string injectcmd = "injecttwrp --dump /tmp/backup_recovery_ramdisk.img /tmp/injected_boot.img --flash bd=" + Boot->Actual_Block_Device;
TWFunc::Exec_Cmd(injectcmd.c_str(), status);
}
- ui_print("TWRP injection complete.\n");
+ gui_print("TWRP injection complete.\n");
}
if (sideload)
ret_val = 1; // Forces booting to the home page after sideload
@@ -373,12 +376,12 @@
if (ORSfile.is_open()) {
//if (Command.substr(Command.size() - 1, 1) != "\n")
// Command += "\n";
- LOGI("Inserting '%s'\n", Command.c_str());
+ LOGINFO("Inserting '%s'\n", Command.c_str());
ORSfile << Command.c_str();
ORSfile.close();
return 1;
}
- LOGE("Unable to append '%s' to '%s'\n", Command.c_str(), SCRIPT_FILE_TMP);
+ LOGERR("Unable to append '%s' to '%s'\n", Command.c_str(), SCRIPT_FILE_TMP);
return 0;
}
@@ -394,22 +397,22 @@
Full_Path = DataManager::GetCurrentStoragePath();
Full_Path += "/" + Zip;
- LOGI("Full zip path: '%s'\n", Full_Path.c_str());
+ LOGINFO("Full zip path: '%s'\n", Full_Path.c_str());
if (!TWFunc::Path_Exists(Full_Path)) {
ret_string = Locate_Zip_File(Full_Path, DataManager::GetCurrentStoragePath());
if (!ret_string.empty()) {
Full_Path = ret_string;
} else if (DataManager::GetIntValue(TW_HAS_DUAL_STORAGE)) {
if (DataManager::GetIntValue(TW_USE_EXTERNAL_STORAGE)) {
- LOGI("Zip file not found on external storage, trying internal...\n");
+ LOGINFO("Zip file not found on external storage, trying internal...\n");
DataManager::SetValue(TW_USE_EXTERNAL_STORAGE, 0);
} else {
- LOGI("Zip file not found on internal storage, trying external...\n");
+ LOGINFO("Zip file not found on internal storage, trying external...\n");
DataManager::SetValue(TW_USE_EXTERNAL_STORAGE, 1);
}
Full_Path = DataManager::GetCurrentStoragePath();
Full_Path += "/" + Zip;
- LOGI("Full zip path: '%s'\n", Full_Path.c_str());
+ LOGINFO("Full zip path: '%s'\n", Full_Path.c_str());
ret_string = Locate_Zip_File(Full_Path, DataManager::GetCurrentStoragePath());
if (!ret_string.empty())
Full_Path = ret_string;
@@ -427,14 +430,14 @@
if (!TWFunc::Path_Exists(Zip)) {
// zip file doesn't exist
- ui_print("Unable to locate zip file '%s'.\n", Zip.c_str());
+ gui_print("Unable to locate zip file '%s'.\n", Zip.c_str());
ret_val = 1;
} else {
- ui_print("Installing zip file '%s'\n", Zip.c_str());
+ gui_print("Installing zip file '%s'\n", Zip.c_str());
ret_val = TWinstall_zip(Zip.c_str(), &wipe_cache);
}
if (ret_val != 0) {
- LOGE("Error installing zip file '%s'\n", Zip.c_str());
+ LOGERR("Error installing zip file '%s'\n", Zip.c_str());
ret_val = 1;
} else if (wipe_cache)
PartitionManager.Wipe_By_Path("/cache");
@@ -474,50 +477,50 @@
DataManager::SetValue(TW_USE_COMPRESSION_VAR, 0);
DataManager::SetValue(TW_SKIP_MD5_GENERATE_VAR, 0);
- ui_print("Setting backup options:\n");
+ gui_print("Setting backup options:\n");
line_len = Options.size();
for (i=0; i<line_len; i++) {
if (Options.substr(i, 1) == "S" || Options.substr(i, 1) == "s") {
Backup_List += "/system;";
- ui_print("System\n");
+ gui_print("System\n");
} else if (Options.substr(i, 1) == "D" || Options.substr(i, 1) == "d") {
Backup_List += "/data;";
- ui_print("Data\n");
+ gui_print("Data\n");
} else if (Options.substr(i, 1) == "C" || Options.substr(i, 1) == "c") {
Backup_List += "/cache;";
- ui_print("Cache\n");
+ gui_print("Cache\n");
} else if (Options.substr(i, 1) == "R" || Options.substr(i, 1) == "r") {
Backup_List += "/recovery;";
- ui_print("Recovery\n");
+ gui_print("Recovery\n");
} else if (Options.substr(i, 1) == "1") {
- ui_print("%s\n", "Special1 -- No Longer Supported...");
+ gui_print("%s\n", "Special1 -- No Longer Supported...");
} else if (Options.substr(i, 1) == "2") {
- ui_print("%s\n", "Special2 -- No Longer Supported...");
+ gui_print("%s\n", "Special2 -- No Longer Supported...");
} else if (Options.substr(i, 1) == "3") {
- ui_print("%s\n", "Special3 -- No Longer Supported...");
+ gui_print("%s\n", "Special3 -- No Longer Supported...");
} else if (Options.substr(i, 1) == "B" || Options.substr(i, 1) == "b") {
Backup_List += "/boot;";
- ui_print("Boot\n");
+ gui_print("Boot\n");
} else if (Options.substr(i, 1) == "A" || Options.substr(i, 1) == "a") {
Backup_List += "/and-sec;";
- ui_print("Android Secure\n");
+ gui_print("Android Secure\n");
} else if (Options.substr(i, 1) == "E" || Options.substr(i, 1) == "e") {
Backup_List += "/sd-ext;";
- ui_print("SD-Ext\n");
+ gui_print("SD-Ext\n");
} else if (Options.substr(i, 1) == "O" || Options.substr(i, 1) == "o") {
DataManager::SetValue(TW_USE_COMPRESSION_VAR, 1);
- ui_print("Compression is on\n");
+ gui_print("Compression is on\n");
} else if (Options.substr(i, 1) == "M" || Options.substr(i, 1) == "m") {
DataManager::SetValue(TW_SKIP_MD5_GENERATE_VAR, 1);
- ui_print("MD5 Generation is off\n");
+ gui_print("MD5 Generation is off\n");
}
}
DataManager::SetValue("tw_backup_list", Backup_List);
if (!PartitionManager.Run_Backup()) {
- LOGE("Backup failed!\n");
+ LOGERR("Backup failed!\n");
return 1;
}
- ui_print("Backup complete!\n");
+ gui_print("Backup complete!\n");
return 0;
}
@@ -533,6 +536,6 @@
DataManager::SetValue("tw_has_cancel", 0);
DataManager::SetValue("tw_show_reboot", 0);
if (gui_startPage("action_page") != 0) {
- LOGE("Failed to load OpenRecoveryScript GUI page.\n");
+ LOGERR("Failed to load OpenRecoveryScript GUI page.\n");
}
}
diff --git a/partition.cpp b/partition.cpp
index 426faa5..7eb2ae5 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -37,7 +37,7 @@
#include "libblkid/blkid.h"
#include "variables.h"
-#include "common.h"
+#include "twcommon.h"
#include "partitions.hpp"
#include "data.hpp"
#include "twrp-functions.hpp"
@@ -121,7 +121,7 @@
full_line[index] = '\0';
}
Mount_Point = full_line;
- LOGI("Processing '%s'\n", Mount_Point.c_str());
+ LOGINFO("Processing '%s'\n", Mount_Point.c_str());
Backup_Path = Mount_Point;
Storage_Path = Mount_Point;
index = Mount_Point.size();
@@ -148,12 +148,12 @@
MTD_Name = "recovery";
Primary_Block_Device = ptr;
if (*ptr != '/')
- LOGE("Until we get better BML support, you will have to find and provide the full block device path to the BML devices e.g. /dev/block/bml9 instead of the partition name\n");
+ LOGERR("Until we get better BML support, you will have to find and provide the full block device path to the BML devices e.g. /dev/block/bml9 instead of the partition name\n");
} else if (*ptr != '/') {
if (Display_Error)
- LOGE("Invalid block device on '%s', '%s', %i\n", Line.c_str(), ptr, index);
+ LOGERR("Invalid block device on '%s', '%s', %i\n", Line.c_str(), ptr, index);
else
- LOGI("Invalid block device on '%s', '%s', %i\n", Line.c_str(), ptr, index);
+ LOGINFO("Invalid block device on '%s', '%s', %i\n", Line.c_str(), ptr, index);
return 0;
} else {
Primary_Block_Device = ptr;
@@ -178,7 +178,7 @@
// Do nothing
} else {
// Unhandled data
- LOGI("Unhandled fstab information: '%s', %i, line: '%s'\n", ptr, index, Line.c_str());
+ LOGINFO("Unhandled fstab information: '%s', %i, line: '%s'\n", ptr, index, Line.c_str());
}
}
while (index < line_len && full_line[index] != '\0')
@@ -187,9 +187,9 @@
if (!Is_File_System(Fstab_File_System) && !Is_Image(Fstab_File_System)) {
if (Display_Error)
- LOGE("Unknown File System: '%s'\n", Fstab_File_System.c_str());
+ LOGERR("Unknown File System: '%s'\n", Fstab_File_System.c_str());
else
- LOGI("Unknown File System: '%s'\n", Fstab_File_System.c_str());
+ LOGINFO("Unknown File System: '%s'\n", Fstab_File_System.c_str());
return 0;
} else if (Is_File_System(Fstab_File_System)) {
Find_Actual_Block_Device();
@@ -238,7 +238,7 @@
Is_Encrypted = true;
Is_Decrypted = true;
Decrypted_Block_Device = crypto_blkdev;
- LOGI("Data already decrypted, new block device: '%s'\n", crypto_blkdev);
+ LOGINFO("Data already decrypted, new block device: '%s'\n", crypto_blkdev);
} else if (!Mount(false)) {
Is_Encrypted = true;
Is_Decrypted = false;
@@ -271,7 +271,7 @@
Wipe_During_Factory_Reset = true;
Can_Be_Backed_Up = true;
if (Mount(false) && !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)
return -1;
}
@@ -446,9 +446,9 @@
Length = atoi(ptr);
} else {
if (Display_Error)
- LOGE("Unhandled flag: '%s'\n", ptr);
+ LOGERR("Unhandled flag: '%s'\n", ptr);
else
- LOGI("Unhandled flag: '%s'\n", ptr);
+ LOGINFO("Unhandled flag: '%s'\n", ptr);
}
while (index < flags_len && flags[index] != '\0')
index++;
@@ -489,12 +489,12 @@
if (!TWFunc::Path_Exists(Path)) {
if (mkdir(Path.c_str(), 0777) == -1) {
if (Display_Error)
- LOGE("Can not create '%s' folder.\n", Path.c_str());
+ LOGERR("Can not create '%s' folder.\n", Path.c_str());
else
- LOGI("Can not create '%s' folder.\n", Path.c_str());
+ LOGINFO("Can not create '%s' folder.\n", Path.c_str());
return false;
} else {
- LOGI("Created '%s' folder.\n", Path.c_str());
+ LOGINFO("Created '%s' folder.\n", Path.c_str());
return true;
}
}
@@ -522,15 +522,15 @@
else if (Current_File_System == "mtd" || Current_File_System == "bml")
Backup_Method = FLASH_UTILS;
else
- LOGI("Unhandled file system '%s' on image '%s'\n", Current_File_System.c_str(), Display_Name.c_str());
+ LOGINFO("Unhandled file system '%s' on image '%s'\n", Current_File_System.c_str(), Display_Name.c_str());
if (Find_Partition_Size()) {
Used = Size;
Backup_Size = Size;
} else {
if (Display_Error)
- LOGE("Unable to find parition size for '%s'\n", Mount_Point.c_str());
+ LOGERR("Unable to find parition size for '%s'\n", Mount_Point.c_str());
else
- LOGI("Unable to find parition size for '%s'\n", Mount_Point.c_str());
+ LOGINFO("Unable to find parition size for '%s'\n", Mount_Point.c_str());
}
}
@@ -559,9 +559,9 @@
if (device[0] != '/') {
if (Display_Error)
- LOGE("Invalid symlink path '%s' found on block device '%s'\n", device, Block.c_str());
+ LOGERR("Invalid symlink path '%s' found on block device '%s'\n", device, Block.c_str());
else
- LOGI("Invalid symlink path '%s' found on block device '%s'\n", device, Block.c_str());
+ LOGINFO("Invalid symlink path '%s' found on block device '%s'\n", device, Block.c_str());
return;
} else {
Block = device;
@@ -587,7 +587,7 @@
fp = fopen("/proc/mtd", "rt");
if (fp == NULL) {
- LOGE("Device does not support /proc/mtd\n");
+ LOGERR("Device does not support /proc/mtd\n");
return false;
}
@@ -632,9 +632,9 @@
if (statfs(Local_Path.c_str(), &st) != 0) {
if (!Removable) {
if (Display_Error)
- LOGE("Unable to statfs '%s'\n", Local_Path.c_str());
+ LOGERR("Unable to statfs '%s'\n", Local_Path.c_str());
else
- LOGI("Unable to statfs '%s'\n", Local_Path.c_str());
+ LOGINFO("Unable to statfs '%s'\n", Local_Path.c_str());
}
return false;
}
@@ -660,7 +660,7 @@
TWFunc::Exec_Cmd(command, result);
fp = fopen("/tmp/dfoutput.txt", "rt");
if (fp == NULL) {
- LOGI("Unable to open /tmp/dfoutput.txt.\n");
+ LOGINFO("Unable to open /tmp/dfoutput.txt.\n");
return false;
}
@@ -788,10 +788,10 @@
Check_FS_Type();
if (Current_File_System == "exfat" && TWFunc::Path_Exists("/sbin/exfat-fuse")) {
string cmd = "/sbin/exfat-fuse -o big_writes,max_read=131072,max_write=131072 " + Actual_Block_Device + " " + Mount_Point;
- LOGI("cmd: %s\n", cmd.c_str());
+ LOGINFO("cmd: %s\n", cmd.c_str());
string result;
if (TWFunc::Exec_Cmd(cmd, result) != 0) {
- LOGI("exfat-fuse failed to mount with result '%s', trying vfat\n", result.c_str());
+ LOGINFO("exfat-fuse failed to mount with result '%s', trying vfat\n", result.c_str());
Current_File_System = "vfat";
} else {
#ifdef TW_NO_EXFAT_FUSE
@@ -809,37 +809,37 @@
const MtdPartition* partition;
partition = mtd_find_partition_by_name(MTD_Name.c_str());
if (partition == NULL) {
- LOGE("Failed to find '%s' partition to mount at '%s'\n",
+ LOGERR("Failed to find '%s' partition to mount at '%s'\n",
MTD_Name.c_str(), Mount_Point.c_str());
return false;
}
if (mtd_mount_partition(partition, Mount_Point.c_str(), Fstab_File_System.c_str(), 0)) {
if (Display_Error)
- LOGE("Failed to mount '%s' (MTD)\n", Mount_Point.c_str());
+ LOGERR("Failed to mount '%s' (MTD)\n", Mount_Point.c_str());
else
- LOGI("Failed to mount '%s' (MTD)\n", Mount_Point.c_str());
+ LOGINFO("Failed to mount '%s' (MTD)\n", Mount_Point.c_str());
return false;
} else
return true;
} else if (!exfat_mounted && mount(Actual_Block_Device.c_str(), Mount_Point.c_str(), Current_File_System.c_str(), 0, NULL) != 0) {
#ifdef TW_NO_EXFAT_FUSE
if (Current_File_System == "exfat") {
- LOGI("Mounting exfat failed, trying vfat...\n");
+ LOGINFO("Mounting exfat failed, trying vfat...\n");
if (mount(Actual_Block_Device.c_str(), Mount_Point.c_str(), "vfat", 0, NULL) != 0) {
if (Display_Error)
- LOGE("Unable to mount '%s'\n", Mount_Point.c_str());
+ LOGERR("Unable to mount '%s'\n", Mount_Point.c_str());
else
- LOGI("Unable to mount '%s'\n", Mount_Point.c_str());
- LOGI("Actual block device: '%s', current file system: '%s'\n", Actual_Block_Device.c_str(), Current_File_System.c_str());
+ LOGINFO("Unable to mount '%s'\n", Mount_Point.c_str());
+ LOGINFO("Actual block device: '%s', current file system: '%s'\n", Actual_Block_Device.c_str(), Current_File_System.c_str());
return false;
}
} else {
#endif
if (Display_Error)
- LOGE("Unable to mount '%s'\n", Mount_Point.c_str());
+ LOGERR("Unable to mount '%s'\n", Mount_Point.c_str());
else
- LOGI("Unable to mount '%s'\n", Mount_Point.c_str());
- LOGI("Actual block device: '%s', current file system: '%s'\n", Actual_Block_Device.c_str(), Current_File_System.c_str());
+ LOGINFO("Unable to mount '%s'\n", Mount_Point.c_str());
+ LOGINFO("Actual block device: '%s', current file system: '%s'\n", Actual_Block_Device.c_str(), Current_File_System.c_str());
return false;
#ifdef TW_NO_EXFAT_FUSE
}
@@ -851,11 +851,11 @@
if (EcryptFS_Password.size() > 0 && PartitionManager.Mount_By_Path("/data", false) && TWFunc::Path_Exists(MetaEcfsFile)) {
if (mount_ecryptfs_drive(EcryptFS_Password.c_str(), Mount_Point.c_str(), Mount_Point.c_str(), 0) != 0) {
if (Display_Error)
- LOGE("Unable to mount ecryptfs for '%s'\n", Mount_Point.c_str());
+ LOGERR("Unable to mount ecryptfs for '%s'\n", Mount_Point.c_str());
else
- LOGI("Unable to mount ecryptfs for '%s'\n", Mount_Point.c_str());
+ LOGINFO("Unable to mount ecryptfs for '%s'\n", Mount_Point.c_str());
} else {
- LOGI("Successfully mounted ecryptfs for '%s'\n", Mount_Point.c_str());
+ LOGINFO("Successfully mounted ecryptfs for '%s'\n", Mount_Point.c_str());
Is_Decrypted = true;
}
} else {
@@ -885,11 +885,11 @@
if (EcryptFS_Password.size() > 0) {
if (unmount_ecryptfs_drive(Mount_Point.c_str()) != 0) {
if (Display_Error)
- LOGE("Unable to unmount ecryptfs for '%s'\n", Mount_Point.c_str());
+ LOGERR("Unable to unmount ecryptfs for '%s'\n", Mount_Point.c_str());
else
- LOGI("Unable to unmount ecryptfs for '%s'\n", Mount_Point.c_str());
+ LOGINFO("Unable to unmount ecryptfs for '%s'\n", Mount_Point.c_str());
} else {
- LOGI("Successfully unmounted ecryptfs for '%s'\n", Mount_Point.c_str());
+ LOGINFO("Successfully unmounted ecryptfs for '%s'\n", Mount_Point.c_str());
}
}
#endif
@@ -900,9 +900,9 @@
umount(Mount_Point.c_str());
if (Is_Mounted()) {
if (Display_Error)
- LOGE("Unable to unmount '%s'\n", Mount_Point.c_str());
+ LOGERR("Unable to unmount '%s'\n", Mount_Point.c_str());
else
- LOGI("Unable to unmount '%s'\n", Mount_Point.c_str());
+ LOGINFO("Unable to unmount '%s'\n", Mount_Point.c_str());
return false;
} else
return true;
@@ -917,12 +917,12 @@
string Layout_Filename = Mount_Point + "/.layout_version";
if (!Can_Be_Wiped) {
- LOGE("Partition '%s' cannot be wiped.\n", Mount_Point.c_str());
+ LOGERR("Partition '%s' cannot be wiped.\n", Mount_Point.c_str());
return false;
}
if (Mount_Point == "/cache")
- tmplog_offset = 0;
+ Log_Offset = 0;
#ifdef TW_INCLUDE_CRYPTO_SAMSUNG
if (Mount_Point == "/data" && Mount(false)) {
@@ -955,7 +955,7 @@
else if (New_File_System == "yaffs2")
wiped = Wipe_MTD();
else {
- LOGE("Unable to wipe '%s' -- unknown file system '%s'\n", Mount_Point.c_str(), New_File_System.c_str());
+ LOGERR("Unable to wipe '%s' -- unknown file system '%s'\n", Mount_Point.c_str(), New_File_System.c_str());
unlink("/.layout_version");
return false;
}
@@ -1009,7 +1009,7 @@
if (!Mount(true))
return false;
- ui_print("Wiping %s\n", Backup_Display_Name.c_str());
+ gui_print("Wiping %s\n", Backup_Display_Name.c_str());
TWFunc::removeDir(Mount_Point + "/.android_secure/", true);
return true;
}
@@ -1021,7 +1021,7 @@
return Backup_DD(backup_folder);
else if (Backup_Method == FLASH_UTILS)
return Backup_Dump_Image(backup_folder);
- LOGE("Unknown backup method for '%s'\n", Mount_Point.c_str());
+ LOGERR("Unknown backup method for '%s'\n", Mount_Point.c_str());
return false;
}
@@ -1036,18 +1036,18 @@
if (!TWFunc::Path_Exists(Full_Filename)) {
// This is a split archive, we presume
sprintf(split_filename, "%s%03i", Full_Filename.c_str(), index);
- LOGI("split_filename: %s\n", split_filename);
+ LOGINFO("split_filename: %s\n", split_filename);
md5file = split_filename;
md5file += ".md5";
if (!TWFunc::Path_Exists(md5file)) {
- LOGE("No md5 file found for '%s'.\n", split_filename);
- LOGE("Please unselect Enable MD5 verification to restore.\n");
+ LOGERR("No md5 file found for '%s'.\n", split_filename);
+ LOGERR("Please unselect Enable MD5 verification to restore.\n");
return false;
}
md5sum.setfn(split_filename);
while (index < 1000 && TWFunc::Path_Exists(split_filename)) {
if (md5sum.verify_md5digest() != 0) {
- LOGE("MD5 failed to match on '%s'.\n", split_filename);
+ LOGERR("MD5 failed to match on '%s'.\n", split_filename);
return false;
}
index++;
@@ -1059,13 +1059,13 @@
// Single file archive
md5file = Full_Filename + ".md5";
if (!TWFunc::Path_Exists(md5file)) {
- LOGE("No md5 file found for '%s'.\n", Full_Filename.c_str());
- LOGE("Please unselect Enable MD5 verification to restore.\n");
+ LOGERR("No md5 file found for '%s'.\n", Full_Filename.c_str());
+ LOGERR("Please unselect Enable MD5 verification to restore.\n");
return false;
}
md5sum.setfn(Full_Filename);
if (md5sum.verify_md5digest() != 0) {
- LOGE("MD5 failed to match on '%s'.\n", Full_Filename.c_str());
+ LOGERR("MD5 failed to match on '%s'.\n", Full_Filename.c_str());
return false;
} else
return true;
@@ -1078,22 +1078,22 @@
string Restore_File_System;
TWFunc::GUI_Operation_Text(TW_RESTORE_TEXT, Display_Name, "Restoring");
- LOGI("Restore filename is: %s\n", Backup_FileName.c_str());
+ LOGINFO("Restore filename is: %s\n", Backup_FileName.c_str());
// Parse backup filename to extract the file system before wiping
first_period = Backup_FileName.find(".");
if (first_period == string::npos) {
- LOGE("Unable to find file system (first period).\n");
+ LOGERR("Unable to find file system (first period).\n");
return false;
}
Restore_File_System = Backup_FileName.substr(first_period + 1, Backup_FileName.size() - first_period - 1);
second_period = Restore_File_System.find(".");
if (second_period == string::npos) {
- LOGE("Unable to find file system (second period).\n");
+ LOGERR("Unable to find file system (second period).\n");
return false;
}
Restore_File_System.resize(second_period);
- LOGI("Restore file system is: '%s'.\n", Restore_File_System.c_str());
+ LOGINFO("Restore file system is: '%s'.\n", Restore_File_System.c_str());
if (Is_File_System(Restore_File_System))
return Restore_Tar(restore_folder, Restore_File_System);
@@ -1104,7 +1104,7 @@
return Restore_Flash_Image(restore_folder);
}
- LOGE("Unknown restore method for '%s'\n", Mount_Point.c_str());
+ LOGERR("Unknown restore method for '%s'\n", Mount_Point.c_str());
return false;
}
@@ -1123,7 +1123,7 @@
}
bool TWPartition::Decrypt(string Password) {
- LOGI("STUB TWPartition::Decrypt, password: '%s'\n", Password.c_str());
+ LOGINFO("STUB TWPartition::Decrypt, password: '%s'\n", Password.c_str());
// Is this needed?
return 1;
}
@@ -1140,11 +1140,11 @@
if (Has_Data_Media && !Symlink_Mount_Point.empty()) {
Recreate_Media_Folder();
}
- ui_print("You may need to reboot recovery to be able to use /data again.\n");
+ gui_print("You may need to reboot recovery to be able to use /data again.\n");
return true;
} else {
Has_Data_Media = Save_Data_Media;
- LOGE("Unable to format to remove encryption.\n");
+ LOGERR("Unable to format to remove encryption.\n");
return false;
}
return false;
@@ -1164,12 +1164,12 @@
pr = blkid_new_probe_from_filename(Actual_Block_Device.c_str());
if (blkid_do_fullprobe(pr)) {
blkid_free_probe(pr);
- LOGI("Can't probe device %s\n", Actual_Block_Device.c_str());
+ LOGINFO("Can't probe device %s\n", Actual_Block_Device.c_str());
return;
}
if (blkid_probe_lookup_value(pr, "TYPE", &type, NULL) < 0) {
blkid_free_probe(pr);
- LOGI("can't find filesystem on device %s\n", Actual_Block_Device.c_str());
+ LOGINFO("can't find filesystem on device %s\n", Actual_Block_Device.c_str());
return;
}
Current_File_System = type;
@@ -1183,17 +1183,17 @@
if (TWFunc::Path_Exists("/sbin/mke2fs")) {
string command, result;
- ui_print("Formatting %s using mke2fs...\n", Display_Name.c_str());
+ gui_print("Formatting %s using mke2fs...\n", Display_Name.c_str());
Find_Actual_Block_Device();
command = "mke2fs -t " + File_System + " -m 0 " + Actual_Block_Device;
- LOGI("mke2fs command: %s\n", command.c_str());
+ LOGINFO("mke2fs command: %s\n", command.c_str());
if (TWFunc::Exec_Cmd(command, result) == 0) {
Current_File_System = File_System;
Recreate_AndSec_Folder();
- ui_print("Done.\n");
+ gui_print("Done.\n");
return true;
} else {
- LOGE("Unable to wipe '%s'.\n", Mount_Point.c_str());
+ LOGERR("Unable to wipe '%s'.\n", Mount_Point.c_str());
return false;
}
} else
@@ -1209,7 +1209,7 @@
if (TWFunc::Path_Exists("/sbin/make_ext4fs")) {
string Command, result;
- ui_print("Formatting %s using make_ext4fs...\n", Display_Name.c_str());
+ gui_print("Formatting %s using make_ext4fs...\n", Display_Name.c_str());
Find_Actual_Block_Device();
Command = "make_ext4fs";
if (!Is_Decrypted && Length != 0) {
@@ -1220,14 +1220,14 @@
Command += len;
}
Command += " " + Actual_Block_Device;
- LOGI("make_ext4fs command: %s\n", Command.c_str());
+ LOGINFO("make_ext4fs command: %s\n", Command.c_str());
if (TWFunc::Exec_Cmd(Command, result) == 0) {
Current_File_System = "ext4";
Recreate_AndSec_Folder();
- ui_print("Done.\n");
+ gui_print("Done.\n");
return true;
} else {
- LOGE("Unable to wipe '%s'.\n", Mount_Point.c_str());
+ LOGERR("Unable to wipe '%s'.\n", Mount_Point.c_str());
return false;
}
} else
@@ -1243,16 +1243,16 @@
if (!UnMount(true))
return false;
- ui_print("Formatting %s using mkdosfs...\n", Display_Name.c_str());
+ gui_print("Formatting %s using mkdosfs...\n", Display_Name.c_str());
Find_Actual_Block_Device();
command = "mkdosfs " + Actual_Block_Device;
if (TWFunc::Exec_Cmd(command, result) == 0) {
Current_File_System = "vfat";
Recreate_AndSec_Folder();
- ui_print("Done.\n");
+ gui_print("Done.\n");
return true;
} else {
- LOGE("Unable to wipe '%s'.\n", Mount_Point.c_str());
+ LOGERR("Unable to wipe '%s'.\n", Mount_Point.c_str());
return false;
}
return true;
@@ -1270,15 +1270,15 @@
if (!UnMount(true))
return false;
- ui_print("Formatting %s using mkexfatfs...\n", Display_Name.c_str());
+ gui_print("Formatting %s using mkexfatfs...\n", Display_Name.c_str());
Find_Actual_Block_Device();
command = "mkexfatfs " + Actual_Block_Device;
if (TWFunc::Exec_Cmd(command, result) == 0) {
Recreate_AndSec_Folder();
- ui_print("Done.\n");
+ gui_print("Done.\n");
return true;
} else {
- LOGE("Unable to wipe '%s'.\n", Mount_Point.c_str());
+ LOGERR("Unable to wipe '%s'.\n", Mount_Point.c_str());
return false;
}
return true;
@@ -1290,32 +1290,32 @@
if (!UnMount(true))
return false;
- ui_print("MTD Formatting \"%s\"\n", MTD_Name.c_str());
+ gui_print("MTD Formatting \"%s\"\n", MTD_Name.c_str());
mtd_scan_partitions();
const MtdPartition* mtd = mtd_find_partition_by_name(MTD_Name.c_str());
if (mtd == NULL) {
- LOGE("No mtd partition named '%s'", MTD_Name.c_str());
+ LOGERR("No mtd partition named '%s'", MTD_Name.c_str());
return false;
}
MtdWriteContext* ctx = mtd_write_partition(mtd);
if (ctx == NULL) {
- LOGE("Can't write '%s', failed to format.", MTD_Name.c_str());
+ LOGERR("Can't write '%s', failed to format.", MTD_Name.c_str());
return false;
}
if (mtd_erase_blocks(ctx, -1) == -1) {
mtd_write_close(ctx);
- LOGE("Failed to format '%s'", MTD_Name.c_str());
+ LOGERR("Failed to format '%s'", MTD_Name.c_str());
return false;
}
if (mtd_write_close(ctx) != 0) {
- LOGE("Failed to close '%s'", MTD_Name.c_str());
+ LOGERR("Failed to close '%s'", MTD_Name.c_str());
return false;
}
Current_File_System = "yaffs2";
Recreate_AndSec_Folder();
- ui_print("Done.\n");
+ gui_print("Done.\n");
return true;
}
@@ -1323,7 +1323,7 @@
if (!Mount(true))
return false;
- ui_print("Removing all files under '%s'\n", Mount_Point.c_str());
+ gui_print("Removing all files under '%s'\n", Mount_Point.c_str());
TWFunc::removeDir(Mount_Point, true);
Recreate_AndSec_Folder();
return true;
@@ -1336,7 +1336,7 @@
if (!Mount(true))
return false;
- ui_print("Wiping data without wiping /data/media ...\n");
+ gui_print("Wiping data without wiping /data/media ...\n");
DIR* d;
d = opendir("/data");
@@ -1355,14 +1355,14 @@
TWFunc::removeDir(dir, false);
} else if (de->d_type == DT_REG || de->d_type == DT_LNK || de->d_type == DT_FIFO || de->d_type == DT_SOCK) {
if (!unlink(dir.c_str()))
- LOGI("Unable to unlink '%s'\n", dir.c_str());
+ LOGINFO("Unable to unlink '%s'\n", dir.c_str());
}
}
closedir(d);
- ui_print("Done.\n");
+ gui_print("Done.\n");
return true;
}
- ui_print("Dirent failed to open /data, error!\n");
+ gui_print("Dirent failed to open /data, error!\n");
return false;
}
@@ -1379,7 +1379,7 @@
return false;
TWFunc::GUI_Operation_Text(TW_BACKUP_TEXT, Backup_Display_Name, "Backing Up");
- ui_print("Backing up %s...\n", Backup_Display_Name.c_str());
+ gui_print("Backing up %s...\n", Backup_Display_Name.c_str());
DataManager::GetValue(TW_USE_COMPRESSION_VAR, use_compression);
@@ -1388,13 +1388,13 @@
Full_FileName = backup_folder + "/" + Backup_FileName;
if (Backup_Size > MAX_ARCHIVE_SIZE) {
// This backup needs to be split into multiple archives
- ui_print("Breaking backup file into multiple archives...\n");
+ gui_print("Breaking backup file into multiple archives...\n");
sprintf(back_name, "%s", Backup_Path.c_str());
tar.setdir(back_name);
tar.setfn(Full_FileName);
backup_count = tar.splitArchiveFork();
if (backup_count == -1) {
- LOGE("Error tarring split files!\n");
+ LOGERR("Error tarring split files!\n");
return false;
}
return true;
@@ -1415,7 +1415,7 @@
return -1;
}
if (TWFunc::Get_File_Size(Full_FileName) == 0) {
- LOGE("Backup file size for '%s' is 0 bytes.\n", Full_FileName.c_str());
+ LOGERR("Backup file size for '%s' is 0 bytes.\n", Full_FileName.c_str());
return false;
}
}
@@ -1431,7 +1431,7 @@
DD_BS = backup_size;
TWFunc::GUI_Operation_Text(TW_BACKUP_TEXT, Display_Name, "Backing Up");
- ui_print("Backing up %s...\n", Display_Name.c_str());
+ gui_print("Backing up %s...\n", Display_Name.c_str());
sprintf(back_name, "%s.%s.win", Backup_Name.c_str(), Current_File_System.c_str());
Backup_FileName = back_name;
@@ -1439,10 +1439,10 @@
Full_FileName = backup_folder + "/" + Backup_FileName;
Command = "dd if=" + Actual_Block_Device + " of='" + Full_FileName + "'" + " bs=" + DD_BS + "c count=1";
- LOGI("Backup command: '%s'\n", Command.c_str());
+ LOGINFO("Backup command: '%s'\n", Command.c_str());
TWFunc::Exec_Cmd(Command, result);
if (TWFunc::Get_File_Size(Full_FileName) == 0) {
- LOGE("Backup file size for '%s' is 0 bytes.\n", Full_FileName.c_str());
+ LOGERR("Backup file size for '%s' is 0 bytes.\n", Full_FileName.c_str());
return false;
}
return true;
@@ -1454,7 +1454,7 @@
int use_compression;
TWFunc::GUI_Operation_Text(TW_BACKUP_TEXT, Display_Name, "Backing Up");
- ui_print("Backing up %s...\n", Display_Name.c_str());
+ gui_print("Backing up %s...\n", Display_Name.c_str());
sprintf(back_name, "%s.%s.win", Backup_Name.c_str(), Current_File_System.c_str());
Backup_FileName = back_name;
@@ -1462,11 +1462,11 @@
Full_FileName = backup_folder + "/" + Backup_FileName;
Command = "dump_image " + MTD_Name + " '" + Full_FileName + "'";
- LOGI("Backup command: '%s'\n", Command.c_str());
+ LOGINFO("Backup command: '%s'\n", Command.c_str());
TWFunc::Exec_Cmd(Command, result);
if (TWFunc::Get_File_Size(Full_FileName) == 0) {
// Actual size may not match backup size due to bad blocks on MTD devices so just check for 0 bytes
- LOGE("Backup file size for '%s' is 0 bytes.\n", Full_FileName.c_str());
+ LOGERR("Backup file size for '%s' is 0 bytes.\n", Full_FileName.c_str());
return false;
}
return true;
@@ -1481,12 +1481,12 @@
if (!Wipe_AndSec())
return false;
} else {
- ui_print("Wiping %s...\n", Display_Name.c_str());
+ gui_print("Wiping %s...\n", Display_Name.c_str());
if (!Wipe(Restore_File_System))
return false;
}
TWFunc::GUI_Operation_Text(TW_RESTORE_TEXT, Backup_Display_Name, "Restoring");
- ui_print("Restoring %s...\n", Backup_Display_Name.c_str());
+ gui_print("Restoring %s...\n", Backup_Display_Name.c_str());
if (!Mount(true))
return false;
@@ -1495,13 +1495,13 @@
if (!TWFunc::Path_Exists(Full_FileName)) {
if (!TWFunc::Path_Exists(Full_FileName)) {
// Backup is multiple archives
- LOGI("Backup is multiple archives.\n");
+ LOGINFO("Backup is multiple archives.\n");
sprintf(split_index, "%03i", index);
Full_FileName = restore_folder + "/" + Backup_FileName + split_index;
while (TWFunc::Path_Exists(Full_FileName)) {
index++;
- ui_print("Restoring archive %i...\n", index);
- LOGI("Restoring '%s'...\n", Full_FileName.c_str());
+ gui_print("Restoring archive %i...\n", index);
+ LOGINFO("Restoring '%s'...\n", Full_FileName.c_str());
twrpTar tar;
tar.setdir("/");
tar.setfn(Full_FileName);
@@ -1511,7 +1511,7 @@
Full_FileName = restore_folder + "/" + Backup_FileName + split_index;
}
if (index == 0) {
- LOGE("Error locating restore file: '%s'\n", Full_FileName.c_str());
+ LOGERR("Error locating restore file: '%s'\n", Full_FileName.c_str());
return false;
}
}
@@ -1532,20 +1532,20 @@
Full_FileName = restore_folder + "/" + Backup_FileName;
if (!Find_Partition_Size()) {
- LOGE("Unable to find partition size for '%s'\n", Mount_Point.c_str());
+ LOGERR("Unable to find partition size for '%s'\n", Mount_Point.c_str());
return false;
}
unsigned long long backup_size = TWFunc::Get_File_Size(Full_FileName);
if (backup_size > Size) {
- LOGE("Size (%iMB) of backup '%s' is larger than target device '%s' (%iMB)\n",
+ LOGERR("Size (%iMB) of backup '%s' is larger than target device '%s' (%iMB)\n",
(int)(backup_size / 1048576LLU), Full_FileName.c_str(),
Actual_Block_Device.c_str(), (int)(Size / 1048576LLU));
return false;
}
- ui_print("Restoring %s...\n", Display_Name.c_str());
+ gui_print("Restoring %s...\n", Display_Name.c_str());
Command = "dd bs=4096 if='" + Full_FileName + "' of=" + Actual_Block_Device;
- LOGI("Restore command: '%s'\n", Command.c_str());
+ LOGINFO("Restore command: '%s'\n", Command.c_str());
TWFunc::Exec_Cmd(Command, result);
return true;
}
@@ -1553,14 +1553,14 @@
bool TWPartition::Restore_Flash_Image(string restore_folder) {
string Full_FileName, Command, result;
- ui_print("Restoring %s...\n", Display_Name.c_str());
+ gui_print("Restoring %s...\n", Display_Name.c_str());
Full_FileName = restore_folder + "/" + Backup_FileName;
// Sometimes flash image doesn't like to flash due to the first 2KB matching, so we erase first to ensure that it flashes
Command = "erase_image " + MTD_Name;
- LOGI("Erase command: '%s'\n", Command.c_str());
+ LOGINFO("Erase command: '%s'\n", Command.c_str());
TWFunc::Exec_Cmd(Command, result);
Command = "flash_image " + MTD_Name + " '" + Full_FileName + "'";
- LOGI("Restore command: '%s'\n", Command.c_str());
+ LOGINFO("Restore command: '%s'\n", Command.c_str());
TWFunc::Exec_Cmd(Command, result);
return true;
}
@@ -1599,7 +1599,7 @@
int us = (int)(Used / 1048576LLU);
int fre = (int)(Free / 1048576LLU);
int datmed = (int)(data_media_used / 1048576LLU);
- LOGI("Data backup size is %iMB, size: %iMB, used: %iMB, free: %iMB, in data/media: %iMB.\n", bak, total, us, fre, datmed);
+ LOGINFO("Data backup size is %iMB, size: %iMB, used: %iMB, free: %iMB, in data/media: %iMB.\n", bak, total, us, fre, datmed);
} else {
if (!Was_Already_Mounted)
UnMount(false);
@@ -1642,10 +1642,10 @@
string Command;
if (!Mount(true)) {
- LOGE("Unable to recreate /data/media folder.\n");
+ LOGERR("Unable to recreate /data/media folder.\n");
} else if (!TWFunc::Path_Exists("/data/media")) {
PartitionManager.Mount_By_Path(Symlink_Mount_Point, true);
- LOGI("Recreating /data/media folder.\n");
+ LOGINFO("Recreating /data/media folder.\n");
mkdir("/data/media", S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
PartitionManager.UnMount_By_Path(Symlink_Mount_Point, true);
}
@@ -1654,11 +1654,11 @@
void TWPartition::Recreate_AndSec_Folder(void) {
if (!Has_Android_Secure)
return;
- LOGI("Creating %s: %s\n", Backup_Display_Name.c_str(), Symlink_Path.c_str());
+ LOGINFO("Creating %s: %s\n", Backup_Display_Name.c_str(), Symlink_Path.c_str());
if (!Mount(true)) {
- LOGE("Unable to recreate %s folder.\n", Backup_Name.c_str());
+ LOGERR("Unable to recreate %s folder.\n", Backup_Name.c_str());
} else if (!TWFunc::Path_Exists(Symlink_Path)) {
- LOGI("Recreating %s folder.\n", Backup_Name.c_str());
+ LOGINFO("Recreating %s folder.\n", Backup_Name.c_str());
PartitionManager.Mount_By_Path(Symlink_Mount_Point, true);
mkdir(Symlink_Path.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
PartitionManager.UnMount_By_Path(Symlink_Mount_Point, true);
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index f40b35e..69812c8 100644
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -34,8 +34,7 @@
#include <iostream>
#include <iomanip>
#include "variables.h"
-#include "common.h"
-#include "ui.h"
+#include "twcommon.h"
#include "partitions.hpp"
#include "data.hpp"
#include "twrp-functions.hpp"
@@ -51,8 +50,6 @@
#include "cutils/properties.h"
#endif
-extern RecoveryUI* ui;
-
int TWPartitionManager::Process_Fstab(string Fstab_Filename, bool Display_Error) {
FILE *fstabFile;
char fstab_line[MAX_FSTAB_LINE_LENGTH];
@@ -60,7 +57,7 @@
fstabFile = fopen(Fstab_Filename.c_str(), "rt");
if (fstabFile == NULL) {
- LOGE("Critical Error: Unable to open fstab at '%s'.\n", Fstab_Filename.c_str());
+ LOGERR("Critical Error: Unable to open fstab at '%s'.\n", Fstab_Filename.c_str());
return false;
}
@@ -81,7 +78,7 @@
Partitions.push_back(partition);
DataManager::SetValue("tw_settings_path", partition->Storage_Path);
DataManager::SetValue("tw_storage_path", partition->Storage_Path);
- LOGI("Settings storage is '%s'\n", partition->Storage_Path.c_str());
+ LOGINFO("Settings storage is '%s'\n", partition->Storage_Path.c_str());
} else {
partition->Is_Settings_Storage = false;
Partitions.push_back(partition);
@@ -99,18 +96,18 @@
Found_Settings_Storage = true;
DataManager::SetValue("tw_settings_path", (*iter)->Storage_Path);
DataManager::SetValue("tw_storage_path", (*iter)->Storage_Path);
- LOGI("Settings storage is '%s'\n", (*iter)->Storage_Path.c_str());
+ LOGINFO("Settings storage is '%s'\n", (*iter)->Storage_Path.c_str());
break;
}
}
if (!Found_Settings_Storage)
- LOGE("Unable to locate storage partition for storing settings file.\n");
+ LOGERR("Unable to locate storage partition for storing settings file.\n");
}
if (!Write_Fstab()) {
if (Display_Error)
- LOGE("Error creating fstab\n");
+ LOGERR("Error creating fstab\n");
else
- LOGI("Error creating fstab\n");
+ LOGINFO("Error creating fstab\n");
}
Update_System_Details();
UnMount_Main_Partitions();
@@ -124,7 +121,7 @@
fp = fopen("/etc/fstab", "w");
if (fp == NULL) {
- LOGI("Can not open /etc/fstab.\n");
+ LOGINFO("Can not open /etc/fstab.\n");
return false;
}
for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
@@ -137,7 +134,7 @@
if (ParentPartition)
ParentPartition->Has_SubPartition = true;
else
- LOGE("Unable to locate parent partition '%s' of '%s'\n", (*iter)->SubPartition_Of.c_str(), (*iter)->Mount_Point.c_str());
+ LOGERR("Unable to locate parent partition '%s' of '%s'\n", (*iter)->SubPartition_Of.c_str(), (*iter)->Mount_Point.c_str());
}
}
}
@@ -259,9 +256,9 @@
if (found) {
return ret;
} else if (Display_Error) {
- LOGE("Mount: Unable to find partition for path '%s'\n", Local_Path.c_str());
+ LOGERR("Mount: Unable to find partition for path '%s'\n", Local_Path.c_str());
} else {
- LOGI("Mount: Unable to find partition for path '%s'\n", Local_Path.c_str());
+ LOGINFO("Mount: Unable to find partition for path '%s'\n", Local_Path.c_str());
}
return false;
}
@@ -282,9 +279,9 @@
return Part->Mount(Display_Error);
}
if (Display_Error)
- LOGE("Mount: Unable to find partition for block '%s'\n", Block.c_str());
+ LOGERR("Mount: Unable to find partition for block '%s'\n", Block.c_str());
else
- LOGI("Mount: Unable to find partition for block '%s'\n", Block.c_str());
+ LOGINFO("Mount: Unable to find partition for block '%s'\n", Block.c_str());
return false;
}
@@ -304,9 +301,9 @@
return Part->Mount(Display_Error);
}
if (Display_Error)
- LOGE("Mount: Unable to find partition for name '%s'\n", Name.c_str());
+ LOGERR("Mount: Unable to find partition for name '%s'\n", Name.c_str());
else
- LOGI("Mount: Unable to find partition for name '%s'\n", Name.c_str());
+ LOGINFO("Mount: Unable to find partition for name '%s'\n", Name.c_str());
return false;
}
@@ -328,9 +325,9 @@
if (found) {
return ret;
} else if (Display_Error) {
- LOGE("UnMount: Unable to find partition for path '%s'\n", Local_Path.c_str());
+ LOGERR("UnMount: Unable to find partition for path '%s'\n", Local_Path.c_str());
} else {
- LOGI("UnMount: Unable to find partition for path '%s'\n", Local_Path.c_str());
+ LOGINFO("UnMount: Unable to find partition for path '%s'\n", Local_Path.c_str());
}
return false;
}
@@ -351,9 +348,9 @@
return Part->UnMount(Display_Error);
}
if (Display_Error)
- LOGE("UnMount: Unable to find partition for block '%s'\n", Block.c_str());
+ LOGERR("UnMount: Unable to find partition for block '%s'\n", Block.c_str());
else
- LOGI("UnMount: Unable to find partition for block '%s'\n", Block.c_str());
+ LOGINFO("UnMount: Unable to find partition for block '%s'\n", Block.c_str());
return false;
}
@@ -373,9 +370,9 @@
return Part->UnMount(Display_Error);
}
if (Display_Error)
- LOGE("UnMount: Unable to find partition for name '%s'\n", Name.c_str());
+ LOGERR("UnMount: Unable to find partition for name '%s'\n", Name.c_str());
else
- LOGI("UnMount: Unable to find partition for name '%s'\n", Name.c_str());
+ LOGINFO("UnMount: Unable to find partition for name '%s'\n", Name.c_str());
return false;
}
@@ -385,7 +382,7 @@
if (Part)
return Part->Is_Mounted();
else
- LOGI("Is_Mounted: Unable to find partition for path '%s'\n", Path.c_str());
+ LOGINFO("Is_Mounted: Unable to find partition for path '%s'\n", Path.c_str());
return false;
}
@@ -395,7 +392,7 @@
if (Part)
return Part->Is_Mounted();
else
- LOGI("Is_Mounted: Unable to find partition for block '%s'\n", Block.c_str());
+ LOGINFO("Is_Mounted: Unable to find partition for block '%s'\n", Block.c_str());
return false;
}
@@ -405,7 +402,7 @@
if (Part)
return Part->Is_Mounted();
else
- LOGI("Is_Mounted: Unable to find partition for name '%s'\n", Name.c_str());
+ LOGINFO("Is_Mounted: Unable to find partition for name '%s'\n", Name.c_str());
return false;
}
@@ -470,7 +467,7 @@
// Check size
if (copy_size > MAX_BACKUP_NAME_LEN) {
if (Display_Error)
- LOGE("Backup name is too long.\n");
+ LOGERR("Backup name is too long.\n");
return -2;
}
@@ -489,7 +486,7 @@
// and -_.{}[]
} else {
if (Display_Error)
- LOGE("Backup name '%s' contains invalid character: '%c'\n", backup_name, (char)cur_char);
+ LOGERR("Backup name '%s' contains invalid character: '%c'\n", backup_name, (char)cur_char);
return -3;
}
}
@@ -500,7 +497,7 @@
sprintf(tw_image_dir,"%s/%s", backup_loc, Backup_Name.c_str());
if (TWFunc::Path_Exists(tw_image_dir)) {
if (Display_Error)
- LOGE("A backup with this name already exists.\n");
+ LOGERR("A backup with this name already exists.\n");
return -4;
}
// No problems found, return 0
@@ -518,17 +515,17 @@
return true;
TWFunc::GUI_Operation_Text(TW_GENERATE_MD5_TEXT, "Generating MD5");
- ui_print(" * Generating md5...\n");
+ gui_print(" * Generating md5...\n");
if (TWFunc::Path_Exists(Full_File)) {
md5sum.setfn(Backup_Folder + Backup_Filename);
if (md5sum.computeMD5() == 0)
if (md5sum.write_md5digest() == 0)
- ui_print(" * MD5 Created.\n");
+ gui_print(" * MD5 Created.\n");
else
return -1;
else
- ui_print(" * MD5 Error!\n");
+ gui_print(" * MD5 Error!\n");
} else {
char filename[512];
int index = 0;
@@ -540,7 +537,7 @@
if (md5sum.computeMD5() == 0) {
if (md5sum.write_md5digest() != 0)
{
- ui_print(" * MD5 Error.\n");
+ gui_print(" * MD5 Error.\n");
return false;
}
}
@@ -552,10 +549,10 @@
strfn = filename;
}
if (index == 0) {
- LOGE("Backup file: '%s' not found!\n", filename);
+ LOGERR("Backup file: '%s' not found!\n", filename);
return false;
}
- ui_print(" * MD5 Created.\n");
+ gui_print(" * MD5 Created.\n");
}
return true;
}
@@ -584,9 +581,9 @@
remain_time = (*img_bytes_remaining / (unsigned long)img_bps) + (*file_bytes_remaining / (unsigned long)file_bps);
pos = (total_time - remain_time) / (float) total_time;
- ui->SetProgress(pos);
+ DataManager::SetProgress(pos);
- LOGI("Estimated Total time: %lu Estimated remaining time: %lu\n", total_time, remain_time);
+ LOGINFO("Estimated Total time: %lu Estimated remaining time: %lu\n", total_time, remain_time);
// And get the time
if (Part->Backup_Method == 1)
@@ -596,7 +593,7 @@
// Set the position
pos = section_time / (float) total_time;
- ui->ShowProgress(pos, section_time);
+ DataManager::ShowProgress(pos, section_time);
time(&start);
@@ -620,7 +617,7 @@
}
time(&stop);
backup_time = (int) difftime(stop, start);
- LOGI("Partition Backup time: %d\n", backup_time);
+ LOGINFO("Partition Backup time: %d\n", backup_time);
if (Part->Backup_Method == 1) {
*file_bytes_remaining -= Part->Backup_Size;
*file_time += backup_time;
@@ -668,11 +665,11 @@
sprintf(timestamp,"%04d-%02d-%02d--%02d-%02d-%02d",t->tm_year+1900,t->tm_mon+1,t->tm_mday,t->tm_hour,t->tm_min,t->tm_sec);
Backup_Name = timestamp;
}
- LOGI("Backup Name is: '%s'\n", Backup_Name.c_str());
+ LOGINFO("Backup Name is: '%s'\n", Backup_Name.c_str());
Full_Backup_Path = Backup_Folder + "/" + Backup_Name + "/";
- LOGI("Full_Backup_Path is: '%s'\n", Full_Backup_Path.c_str());
+ LOGINFO("Full_Backup_Path is: '%s'\n", Full_Backup_Path.c_str());
- LOGI("Calculating backup details...\n");
+ LOGINFO("Calculating backup details...\n");
DataManager::GetValue("tw_backup_list", Backup_List);
if (!Backup_List.empty()) {
end_pos = Backup_List.find(";", start_pos);
@@ -699,7 +696,7 @@
}
}
} else {
- LOGE("Unable to locate '%s' partition for backup calculations.\n", backup_path.c_str());
+ LOGERR("Unable to locate '%s' partition for backup calculations.\n", backup_path.c_str());
}
start_pos = end_pos + 1;
end_pos = Backup_List.find(";", start_pos);
@@ -707,36 +704,36 @@
}
if (partition_count == 0) {
- ui_print("No partitions selected for backup.\n");
+ gui_print("No partitions selected for backup.\n");
return false;
}
total_bytes = file_bytes + img_bytes;
- ui_print(" * Total number of partitions to back up: %d\n", partition_count);
- ui_print(" * Total size of all data: %lluMB\n", total_bytes / 1024 / 1024);
+ gui_print(" * Total number of partitions to back up: %d\n", partition_count);
+ gui_print(" * Total size of all data: %lluMB\n", total_bytes / 1024 / 1024);
storage = Find_Partition_By_Path(DataManager::GetCurrentStoragePath());
if (storage != NULL) {
free_space = storage->Free;
- ui_print(" * Available space: %lluMB\n", free_space / 1024 / 1024);
+ gui_print(" * Available space: %lluMB\n", free_space / 1024 / 1024);
} else {
- LOGE("Unable to locate storage device.\n");
+ LOGERR("Unable to locate storage device.\n");
return false;
}
if (free_space - (32 * 1024 * 1024) < total_bytes) {
// We require an extra 32MB just in case
- LOGE("Not enough free space on storage.\n");
+ LOGERR("Not enough free space on storage.\n");
return false;
}
img_bytes_remaining = img_bytes;
file_bytes_remaining = file_bytes;
- ui_print("\n[BACKUP STARTED]\n");
- ui_print(" * Backup Folder: %s\n", Full_Backup_Path.c_str());
+ gui_print("\n[BACKUP STARTED]\n");
+ gui_print(" * Backup Folder: %s\n", Full_Backup_Path.c_str());
if (!TWFunc::Recursive_Mkdir(Full_Backup_Path)) {
- LOGE("Failed to make backup folder.\n");
+ LOGERR("Failed to make backup folder.\n");
return false;
}
- ui->SetProgress(0.0);
+ DataManager::SetProgress(0.0);
start_pos = 0;
end_pos = Backup_List.find(";", start_pos);
@@ -747,7 +744,7 @@
if (!Backup_Partition(backup_part, Full_Backup_Path, do_md5, &img_bytes_remaining, &file_bytes_remaining, &img_time, &file_time, &img_bytes, &file_bytes))
return false;
} else {
- LOGE("Unable to locate '%s' partition for backup process.\n", backup_path.c_str());
+ LOGERR("Unable to locate '%s' partition for backup process.\n", backup_path.c_str());
}
start_pos = end_pos + 1;
end_pos = Backup_List.find(";", start_pos);
@@ -761,8 +758,8 @@
int img_bps = (int)img_bytes / (int)img_time;
unsigned long long file_bps = file_bytes / (int)file_time;
- ui_print("Average backup rate for file systems: %llu MB/sec\n", (file_bps / (1024 * 1024)));
- ui_print("Average backup rate for imaged drives: %lu MB/sec\n", (img_bps / (1024 * 1024)));
+ gui_print("Average backup rate for file systems: %llu MB/sec\n", (file_bps / (1024 * 1024)));
+ gui_print("Average backup rate for imaged drives: %lu MB/sec\n", (img_bps / (1024 * 1024)));
time(&total_stop);
int total_time = (int) difftime(total_stop, total_start);
@@ -789,10 +786,10 @@
else
DataManager::SetValue(TW_BACKUP_AVG_FILE_RATE, file_bps);
- ui_print("[%llu MB TOTAL BACKED UP]\n", actual_backup_size);
+ gui_print("[%llu MB TOTAL BACKED UP]\n", actual_backup_size);
Update_System_Details();
UnMount_Main_Partitions();
- ui_print("[BACKUP COMPLETED IN %d SECONDS]\n\n", total_time); // the end
+ gui_print("[BACKUP COMPLETED IN %d SECONDS]\n\n", total_time); // the end
string backup_log = Full_Backup_Path + "recovery.log";
TWFunc::copy_file("/tmp/recovery.log", backup_log, 0644);
return true;
@@ -801,7 +798,7 @@
bool TWPartitionManager::Restore_Partition(TWPartition* Part, string Restore_Name, int partition_count) {
time_t Start, Stop;
time(&Start);
- ui->ShowProgress(1.0 / (float)partition_count, 150);
+ DataManager::ShowProgress(1.0 / (float)partition_count, 150);
if (!Part->Restore(Restore_Name))
return false;
if (Part->Has_SubPartition) {
@@ -815,7 +812,7 @@
}
}
time(&Stop);
- ui_print("[%s done (%d seconds)]\n\n", Part->Backup_Display_Name.c_str(), (int)difftime(Stop, Start));
+ gui_print("[%s done (%d seconds)]\n\n", Part->Backup_Display_Name.c_str(), (int)difftime(Stop, Start));
return true;
}
@@ -827,8 +824,8 @@
string Restore_List, restore_path;
size_t start_pos = 0, end_pos;
- ui_print("\n[RESTORE STARTED]\n\n");
- ui_print("Restore folder: '%s'\n", Restore_Name.c_str());
+ gui_print("\n[RESTORE STARTED]\n\n");
+ gui_print("Restore folder: '%s'\n", Restore_Name.c_str());
if (!Mount_Current_Storage(true))
return false;
@@ -837,9 +834,9 @@
if (check_md5 > 0) {
// Check MD5 files first before restoring to ensure that all of them match before starting a restore
TWFunc::GUI_Operation_Text(TW_VERIFY_MD5_TEXT, "Verifying MD5");
- ui_print("Verifying MD5...\n");
+ gui_print("Verifying MD5...\n");
} else {
- ui_print("Skipping MD5 check based on user setting.\n");
+ gui_print("Skipping MD5 check based on user setting.\n");
}
DataManager::GetValue("tw_restore_selected", Restore_List);
if (!Restore_List.empty()) {
@@ -862,7 +859,7 @@
}
}
} else {
- LOGE("Unable to locate '%s' partition for restoring.\n", restore_path.c_str());
+ LOGERR("Unable to locate '%s' partition for restoring.\n", restore_path.c_str());
}
start_pos = end_pos + 1;
end_pos = Restore_List.find(";", start_pos);
@@ -870,12 +867,12 @@
}
if (partition_count == 0) {
- LOGE("No partitions selected for restore.\n");
+ LOGERR("No partitions selected for restore.\n");
return false;
}
- ui_print("Restoring %i partitions...\n", partition_count);
- ui->SetProgress(0.0);
+ gui_print("Restoring %i partitions...\n", partition_count);
+ DataManager::SetProgress(0.0);
start_pos = 0;
if (!Restore_List.empty()) {
end_pos = Restore_List.find(";", start_pos);
@@ -887,7 +884,7 @@
if (!Restore_Partition(restore_part, Restore_Name, partition_count))
return false;
} else {
- LOGE("Unable to locate '%s' partition for restoring.\n", restore_path.c_str());
+ LOGERR("Unable to locate '%s' partition for restoring.\n", restore_path.c_str());
}
start_pos = end_pos + 1;
end_pos = Restore_List.find(";", start_pos);
@@ -898,7 +895,7 @@
Update_System_Details();
UnMount_Main_Partitions();
time(&rStop);
- ui_print("[RESTORE COMPLETED IN %d SECONDS]\n\n",(int)difftime(rStop,rStart));
+ gui_print("[RESTORE COMPLETED IN %d SECONDS]\n\n",(int)difftime(rStop,rStart));
return true;
}
@@ -911,7 +908,7 @@
d = opendir(Restore_Name.c_str());
if (d == NULL)
{
- LOGE("Error opening %s\n", Restore_Name.c_str());
+ LOGERR("Error opening %s\n", Restore_Name.c_str());
return;
}
@@ -968,7 +965,7 @@
TWPartition* Part = Find_Partition_By_Path(label);
if (Part == NULL)
{
- LOGE(" Unable to locate partition by backup name: '%s'\n", label);
+ LOGERR(" Unable to locate partition by backup name: '%s'\n", label);
continue;
}
@@ -1008,7 +1005,7 @@
if (found) {
return ret;
} else
- LOGE("Wipe: Unable to find partition for path '%s'\n", Local_Path.c_str());
+ LOGERR("Wipe: Unable to find partition for path '%s'\n", Local_Path.c_str());
return false;
}
@@ -1027,7 +1024,7 @@
} else
return Part->Wipe();
}
- LOGE("Wipe: Unable to find partition for block '%s'\n", Block.c_str());
+ LOGERR("Wipe: Unable to find partition for block '%s'\n", Block.c_str());
return false;
}
@@ -1046,7 +1043,7 @@
} else
return Part->Wipe();
}
- LOGE("Wipe: Unable to find partition for name '%s'\n", Name.c_str());
+ LOGERR("Wipe: Unable to find partition for name '%s'\n", Name.c_str());
return false;
}
@@ -1079,11 +1076,11 @@
dir.push_back("/data/dalvik-cache");
dir.push_back("/cache/dalvik-cache");
dir.push_back("/cache/dc");
- ui_print("\nWiping Dalvik Cache Directories...\n");
+ gui_print("\nWiping Dalvik Cache Directories...\n");
for (unsigned i = 0; i < dir.size(); ++i) {
if (stat(dir.at(i).c_str(), &st) == 0) {
TWFunc::removeDir(dir.at(i), false);
- ui_print("Cleaned: %s...\n", dir.at(i).c_str());
+ gui_print("Cleaned: %s...\n", dir.at(i).c_str());
}
}
TWPartition* sdext = Find_Partition_By_Path("/sd-ext");
@@ -1091,11 +1088,11 @@
if (sdext->Is_Present && sdext->Mount(false)) {
if (stat("/sd-ext/dalvik-cache", &st) == 0) {
TWFunc::removeDir("/sd-ext/dalvik-cache", false);
- ui_print("Cleaned: /sd-ext/dalvik-cache...\n");
+ gui_print("Cleaned: /sd-ext/dalvik-cache...\n");
}
}
}
- ui_print("-- Dalvik Cache Directories Wipe Complete!\n\n");
+ gui_print("-- Dalvik Cache Directories Wipe Complete!\n\n");
return true;
}
@@ -1105,7 +1102,7 @@
unlink("/data/misc/akmd*");
unlink("/data/misc/rild*");
- ui_print("Rotation data wiped.\n");
+ gui_print("Rotation data wiped.\n");
return true;
}
@@ -1116,10 +1113,10 @@
return false;
if (0 != stat("/data/system/batterystats.bin", &st)) {
- ui_print("No Battery Stats Found. No Need To Wipe.\n");
+ gui_print("No Battery Stats Found. No Need To Wipe.\n");
} else {
remove("/data/system/batterystats.bin");
- ui_print("Cleared battery stats.\n");
+ gui_print("Cleared battery stats.\n");
}
return true;
}
@@ -1139,7 +1136,7 @@
if (found) {
return ret;
} else {
- LOGE("No android secure partitions found.\n");
+ LOGERR("No android secure partitions found.\n");
}
return false;
}
@@ -1153,7 +1150,7 @@
return dat->Wipe_Encryption();
} else {
- LOGE("Unable to locate /data.\n");
+ LOGERR("Unable to locate /data.\n");
return false;
}
return false;
@@ -1164,13 +1161,13 @@
if (dat != NULL) {
if (!dat->Has_Data_Media) {
- LOGE("This device does not have /data/media\n");
+ LOGERR("This device does not have /data/media\n");
return false;
}
if (!dat->Mount(true))
return false;
- ui_print("Wiping internal storage -- /data/media...\n");
+ gui_print("Wiping internal storage -- /data/media...\n");
TWFunc::removeDir("/data/media", false);
if (mkdir("/data/media", S_IRWXU | S_IRWXG | S_IWGRP | S_IXGRP) != 0)
return -1;
@@ -1179,7 +1176,7 @@
}
return true;
} else {
- LOGE("Unable to locate /data.\n");
+ LOGERR("Unable to locate /data.\n");
return false;
}
return false;
@@ -1194,7 +1191,7 @@
std::vector<TWPartition*>::iterator iter;
int data_size = 0;
- ui_print("Updating partition details...\n");
+ gui_print("Updating partition details...\n");
for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
if ((*iter)->Can_Be_Mounted) {
(*iter)->Update_Size(true);
@@ -1304,7 +1301,7 @@
if (current_storage_path == DataManager::GetSettingsStoragePath()) {
if (!FreeStorage->Is_Encrypted) {
// Not able to use internal, so error!
- LOGE("Unable to mount internal storage.\n");
+ LOGERR("Unable to mount internal storage.\n");
}
DataManager::SetValue(TW_STORAGE_FREE_SIZE, 0);
} else {
@@ -1315,23 +1312,23 @@
if (FreeStorage != NULL) {
DataManager::SetValue(TW_STORAGE_FREE_SIZE, (int)(FreeStorage->Free / 1048576LLU));
} else {
- LOGE("Unable to locate internal storage partition.\n");
+ LOGERR("Unable to locate internal storage partition.\n");
DataManager::SetValue(TW_STORAGE_FREE_SIZE, 0);
}
}
} else {
// No dual storage and unable to mount storage, error!
- LOGE("Unable to mount storage.\n");
+ LOGERR("Unable to mount storage.\n");
DataManager::SetValue(TW_STORAGE_FREE_SIZE, 0);
}
} else {
DataManager::SetValue(TW_STORAGE_FREE_SIZE, (int)(FreeStorage->Free / 1048576LLU));
}
} else {
- LOGI("Unable to find storage partition '%s'.\n", current_storage_path.c_str());
+ LOGINFO("Unable to find storage partition '%s'.\n", current_storage_path.c_str());
}
if (!Write_Fstab())
- LOGE("Error creating fstab\n");
+ LOGERR("Error creating fstab\n");
return;
}
@@ -1384,7 +1381,7 @@
int pwret = cryptfs_check_passwd(cPassword);
if (pwret != 0) {
- LOGE("Failed to decrypt data.\n");
+ LOGERR("Failed to decrypt data.\n");
return -1;
}
@@ -1393,7 +1390,7 @@
property_get("ro.crypto.fs_crypto_blkdev", crypto_blkdev, "error");
if (strcmp(crypto_blkdev, "error") == 0) {
- LOGE("Error retrieving decrypted data block device.\n");
+ LOGERR("Error retrieving decrypted data block device.\n");
} else {
TWPartition* dat = Find_Partition_By_Path("/data");
if (dat != NULL) {
@@ -1402,18 +1399,18 @@
dat->Is_Decrypted = true;
dat->Decrypted_Block_Device = crypto_blkdev;
dat->Setup_File_System(false);
- ui_print("Data successfully decrypted, new block device: '%s'\n", crypto_blkdev);
+ gui_print("Data successfully decrypted, new block device: '%s'\n", crypto_blkdev);
#ifdef CRYPTO_SD_FS_TYPE
char crypto_blkdev_sd[255];
property_get("ro.crypto.sd_fs_crypto_blkdev", crypto_blkdev_sd, "error");
if (strcmp(crypto_blkdev_sd, "error") == 0) {
- LOGE("Error retrieving decrypted data block device.\n");
+ LOGERR("Error retrieving decrypted data block device.\n");
} else if(TWPartition* emmc = Find_Partition_By_Path(EXPAND(TW_INTERNAL_STORAGE_PATH))){
emmc->Is_Decrypted = true;
emmc->Decrypted_Block_Device = crypto_blkdev_sd;
emmc->Setup_File_System(false);
- ui_print("Internal SD successfully decrypted, new block device: '%s'\n", crypto_blkdev_sd);
+ gui_print("Internal SD successfully decrypted, new block device: '%s'\n", crypto_blkdev_sd);
}
#endif //ifdef CRYPTO_SD_FS_TYPE
#ifdef TW_EXTERNAL_STORAGE_PATH
@@ -1453,11 +1450,11 @@
Update_System_Details();
UnMount_Main_Partitions();
} else
- LOGE("Unable to locate data partition.\n");
+ LOGERR("Unable to locate data partition.\n");
}
return 0;
#else
- LOGE("No crypto support was compiled into this build.\n");
+ LOGERR("No crypto support was compiled into this build.\n");
return -1;
#endif
return 1;
@@ -1476,33 +1473,24 @@
fixPermissions perms;
result = perms.fixPerms(true, false);
UnMount_Main_Partitions();
- ui_print("Done.\n\n");
+ gui_print("Done.\n\n");
return result;
}
-//partial kangbang from system/vold
int TWPartitionManager::Open_Lun_File(string Partition_Path, string Lun_File) {
- int fd;
TWPartition* Part = Find_Partition_By_Path(Partition_Path);
if (Part == NULL) {
- LOGE("Unable to locate volume information for USB storage mode.");
+ LOGERR("Unable to locate volume information for USB storage mode.");
return false;
}
if (!Part->UnMount(true))
return false;
- if ((fd = open(Lun_File.c_str(), O_WRONLY)) < 0) {
- LOGE("Unable to open ums lunfile '%s': (%s)\n", Lun_File.c_str(), strerror(errno));
+ if (TWFunc::write_file(Lun_File, Part->Actual_Block_Device)) {
+ LOGERR("Unable to write to ums lunfile '%s': (%s)\n", Lun_File.c_str(), strerror(errno));
return false;
}
-
- if (write(fd, Part->Actual_Block_Device.c_str(), Part->Actual_Block_Device.size()) < 0) {
- LOGE("Unable to write to ums lunfile '%s': (%s)\n", Lun_File.c_str(), strerror(errno));
- close(fd);
- return false;
- }
- close(fd);
return true;
}
@@ -1547,39 +1535,28 @@
}
int TWPartitionManager::usb_storage_disable(void) {
- int fd, index;
- char lun_file[255];
+ int index, ret;
+ char lun_file[255], ch[2] = {0, 0};
+ string str = ch;
for (index=0; index<2; index++) {
sprintf(lun_file, CUSTOM_LUN_FILE, index);
-
- if ((fd = open(lun_file, O_WRONLY)) < 0) {
- Mount_All_Storage();
- Update_System_Details();
- if (index == 0) {
- LOGE("Unable to open ums lunfile '%s': (%s)", lun_file, strerror(errno));
- return false;
- } else
- return true;
+ ret = TWFunc::write_file(lun_file, str);
+ Mount_All_Storage();
+ Update_System_Details();
+ if (ret < 0) {
+ break;
}
-
- char ch = 0;
- if (write(fd, &ch, 1) < 0) {
- close(fd);
- Mount_All_Storage();
- Update_System_Details();
- if (index == 0) {
- LOGE("Unable to write to ums lunfile '%s': (%s)", lun_file, strerror(errno));
- return false;
- } else
- return true;
- }
-
- close(fd);
}
Mount_All_Storage();
Update_System_Details();
UnMount_Main_Partitions();
+ if (ret < 0 && index == 0) {
+ LOGERR("Unable to write to ums lunfile '%s'.", lun_file);
+ return false;
+ } else {
+ return true;
+ }
return true;
}
@@ -1595,7 +1572,7 @@
void TWPartitionManager::UnMount_Main_Partitions(void) {
// Unmounts system and data if data is not data/media
// Also unmounts boot if boot is mountable
- LOGI("Unmounting main partitions...\n");
+ LOGINFO("Unmounting main partitions...\n");
TWPartition* Boot_Partition = Find_Partition_By_Path("/boot");
@@ -1613,14 +1590,14 @@
int ext, swap, total_size = 0, fat_size;
FILE* fp;
- ui_print("Partitioning SD Card...\n");
+ gui_print("Partitioning SD Card...\n");
#ifdef TW_EXTERNAL_STORAGE_PATH
TWPartition* SDCard = Find_Partition_By_Path(EXPAND(TW_EXTERNAL_STORAGE_PATH));
#else
TWPartition* SDCard = Find_Partition_By_Path("/sdcard");
#endif
if (SDCard == NULL) {
- LOGE("Unable to locate device to partition.\n");
+ LOGERR("Unable to locate device to partition.\n");
return false;
}
if (!SDCard->UnMount(true))
@@ -1639,7 +1616,7 @@
// Find the size of the block device:
fp = fopen("/proc/partitions", "rt");
if (fp == NULL) {
- LOGE("Unable to open /proc/partitions\n");
+ LOGERR("Unable to open /proc/partitions\n");
return false;
}
@@ -1666,7 +1643,7 @@
DataManager::GetValue("tw_swap_size", swap);
DataManager::GetValue("tw_sdpart_file_system", ext_format);
fat_size = total_size - ext - swap;
- LOGI("sd card block device is '%s', sdcard size is: %iMB, fat size: %iMB, ext size: %iMB, ext system: '%s', swap size: %iMB\n", Device.c_str(), total_size, fat_size, ext, ext_format.c_str(), swap);
+ LOGINFO("sd card block device is '%s', sdcard size is: %iMB, fat size: %iMB, ext size: %iMB, ext system: '%s', swap size: %iMB\n", Device.c_str(), total_size, fat_size, ext, ext_format.c_str(), swap);
memset(temp, 0, sizeof(temp));
sprintf(temp, "%i", fat_size);
fat_str = temp;
@@ -1677,40 +1654,40 @@
sprintf(temp, "%i", fat_size + ext + swap);
swap_str = temp;
if (ext + swap > total_size) {
- LOGE("EXT + Swap size is larger than sdcard size.\n");
+ LOGERR("EXT + Swap size is larger than sdcard size.\n");
return false;
}
- ui_print("Removing partition table...\n");
+ gui_print("Removing partition table...\n");
Command = "parted -s " + Device + " mklabel msdos";
- LOGI("Command is: '%s'\n", Command.c_str());
+ LOGINFO("Command is: '%s'\n", Command.c_str());
if (TWFunc::Exec_Cmd(Command, result) != 0) {
- LOGE("Unable to remove partition table.\n");
+ LOGERR("Unable to remove partition table.\n");
Update_System_Details();
return false;
}
- ui_print("Creating FAT32 partition...\n");
+ gui_print("Creating FAT32 partition...\n");
Command = "parted " + Device + " mkpartfs primary fat32 0 " + fat_str + "MB";
- LOGI("Command is: '%s'\n", Command.c_str());
+ LOGINFO("Command is: '%s'\n", Command.c_str());
if (TWFunc::Exec_Cmd(Command, result) != 0) {
- LOGE("Unable to create FAT32 partition.\n");
+ LOGERR("Unable to create FAT32 partition.\n");
return false;
}
if (ext > 0) {
- ui_print("Creating EXT partition...\n");
+ gui_print("Creating EXT partition...\n");
Command = "parted " + Device + " mkpartfs primary ext2 " + fat_str + "MB " + ext_str + "MB";
- LOGI("Command is: '%s'\n", Command.c_str());
+ LOGINFO("Command is: '%s'\n", Command.c_str());
if (TWFunc::Exec_Cmd(Command, result) != 0) {
- LOGE("Unable to create EXT partition.\n");
+ LOGERR("Unable to create EXT partition.\n");
Update_System_Details();
return false;
}
}
if (swap > 0) {
- ui_print("Creating swap partition...\n");
+ gui_print("Creating swap partition...\n");
Command = "parted " + Device + " mkpartfs primary linux-swap " + ext_str + "MB " + swap_str + "MB";
- LOGI("Command is: '%s'\n", Command.c_str());
+ LOGINFO("Command is: '%s'\n", Command.c_str());
if (TWFunc::Exec_Cmd(Command, result) != 0) {
- LOGE("Unable to create swap partition.\n");
+ LOGERR("Unable to create swap partition.\n");
Update_System_Details();
return false;
}
@@ -1738,17 +1715,17 @@
#endif
if (ext > 0) {
if (SDext == NULL) {
- LOGE("Unable to locate sd-ext partition.\n");
+ LOGERR("Unable to locate sd-ext partition.\n");
return false;
}
Command = "mke2fs -t " + ext_format + " -m 0 " + SDext->Actual_Block_Device;
- ui_print("Formatting sd-ext as %s...\n", ext_format.c_str());
- LOGI("Formatting sd-ext after partitioning, command: '%s'\n", Command.c_str());
+ gui_print("Formatting sd-ext as %s...\n", ext_format.c_str());
+ LOGINFO("Formatting sd-ext after partitioning, command: '%s'\n", Command.c_str());
TWFunc::Exec_Cmd(Command, result);
}
Update_System_Details();
- ui_print("Partitioning complete.\n");
+ gui_print("Partitioning complete.\n");
return true;
}
@@ -1816,7 +1793,7 @@
Partition_List->push_back(part);
}
} else {
- LOGE("Unable to locate '%s' partition for restore.\n", restore_path.c_str());
+ LOGERR("Unable to locate '%s' partition for restore.\n", restore_path.c_str());
}
start_pos = end_pos + 1;
end_pos = Restore_List.find(";", start_pos);
@@ -1845,7 +1822,7 @@
}
}
} else {
- LOGE("Unknown list type '%s' requested for TWPartitionManager::Get_Partition_List\n", ListType.c_str());
+ LOGERR("Unknown list type '%s' requested for TWPartitionManager::Get_Partition_List\n", ListType.c_str());
}
}
diff --git a/prebuilt/Android.mk b/prebuilt/Android.mk
index dec000f..d28d289 100644
--- a/prebuilt/Android.mk
+++ b/prebuilt/Android.mk
@@ -35,8 +35,16 @@
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libm.so
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libstdc++.so
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libz.so
-#RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libjpeg.so
-#RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libmtdutils.so
+#RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libjpegtwrp.so
+#RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libpng.so
+RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libhardware_legacy.so
+RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libwpa_client.so
+RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libnetutils.so
+RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libpixelflinger.so
+RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libminuitwrp.so
+RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libminadbd.so
+RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libminzip.so
+RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libmtdutils.so
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libtar.so
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libblkid.so
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libmmcutils.so
@@ -45,6 +53,7 @@
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libstlport.so
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libmincrypt.so
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext4_utils.so
+RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libaosprecovery.so
ifeq ($(BUILD_ID), GINGERBREAD)
TW_NO_EXFAT := true
endif
@@ -63,9 +72,11 @@
RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/htcdumlock
endif
ifeq ($(TW_INCLUDE_CRYPTO), true)
+ RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libcryptfsics.so
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libcrypto.so
endif
ifeq ($(TW_INCLUDE_JB_CRYPTO), true)
+ RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libcryptfsjb.so
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libcrypto.so
endif
ifeq ($(TARGET_USERIMAGES_USE_EXT4), true)
diff --git a/tarWrite.c b/tarWrite.c
index 0f9a4a4..f5af449 100644
--- a/tarWrite.c
+++ b/tarWrite.c
@@ -23,7 +23,7 @@
#include <fcntl.h>
#include "libtar/libtar.h"
-#include "common.h"
+#include "twcommon.h"
int flush = 0, eot_count = -1;
unsigned char *write_buffer;
@@ -73,7 +73,7 @@
return 0;
}
if (write(fd, write_buffer, buffer_loc) != buffer_loc) {
- LOGE("Error writing tar file!\n");
+ LOGERR("Error writing tar file!\n");
buffer_loc = 0;
return -1;
} else {
diff --git a/twcommon.h b/twcommon.h
new file mode 100644
index 0000000..2c96d04
--- /dev/null
+++ b/twcommon.h
@@ -0,0 +1,19 @@
+#ifndef TWCOMMON_HPP
+#define TWCOMMON_HPP
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "gui/gui.h"
+#define LOGERR(...) gui_print("E:" __VA_ARGS__)
+#define LOGINFO(...) fprintf(stdout, "I:" __VA_ARGS__)
+
+#define STRINGIFY(x) #x
+#define EXPAND(x) STRINGIFY(x)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // TWCOMMON_HPP
diff --git a/twinstall.cpp b/twinstall.cpp
index e1133c0..e7d23ec 100644
--- a/twinstall.cpp
+++ b/twinstall.cpp
@@ -1,18 +1,3 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
#include <ctype.h>
#include <errno.h>
@@ -25,7 +10,7 @@
#include <string.h>
#include <stdio.h>
-#include "common.h"
+#include "twcommon.h"
#include "mincrypt/rsa.h"
#include "mincrypt/sha.h"
#include "minui/minui.h"
@@ -33,290 +18,150 @@
#include "minzip/Zip.h"
#include "mtdutils/mounts.h"
#include "mtdutils/mtdutils.h"
-#include "roots.h"
#include "verifier.h"
-#include "ui.h"
#include "variables.h"
#include "data.hpp"
#include "partitions.hpp"
#include "twrpDigest.hpp"
#include "twrp-functions.hpp"
+extern "C" {
+ #include "gui/gui.h"
+}
-extern RecoveryUI* ui;
+static int Run_Update_Binary(const char *path, ZipArchive *Zip, int* wipe_cache) {
+ const ZipEntry* binary_location = mzFindZipEntry(Zip, ASSUMED_UPDATE_BINARY_NAME);
+ string Temp_Binary = "/tmp/updater";
+ int binary_fd, ret_val, pipe_fd[2], status, zip_verify;
+ char buffer[1024];
+ const char** args = (const char**)malloc(sizeof(char*) * 5);
+ FILE* child_data;
-#define ASSUMED_UPDATE_BINARY_NAME "META-INF/com/google/android/update-binary"
-#define PUBLIC_KEYS_FILE "/res/keys"
+ if (binary_location == NULL) {
+ mzCloseZipArchive(Zip);
+ return INSTALL_CORRUPT;
+ }
-// Default allocation of progress bar segments to operations
-static const int VERIFICATION_PROGRESS_TIME = 60;
-static const float VERIFICATION_PROGRESS_FRACTION = 0.25;
-static const float DEFAULT_FILES_PROGRESS_FRACTION = 0.4;
-static const float DEFAULT_IMAGE_PROGRESS_FRACTION = 0.1;
+ // Delete any existing updater
+ if (TWFunc::Path_Exists(Temp_Binary) && unlink(Temp_Binary.c_str()) != 0) {
+ LOGINFO("Unable to unlink '%s'\n", Temp_Binary.c_str());
+ }
-enum { INSTALL_SUCCESS, INSTALL_ERROR, INSTALL_CORRUPT };
+ binary_fd = creat(Temp_Binary.c_str(), 0755);
+ if (binary_fd < 0) {
+ mzCloseZipArchive(Zip);
+ LOGERR("Could not create file for updater extract in '%s'\n", Temp_Binary.c_str());
+ return INSTALL_ERROR;
+ }
-// If the package contains an update binary, extract it and run it.
-static int
-try_update_binary(const char *path, ZipArchive *zip, int* wipe_cache) {
- const ZipEntry* binary_entry =
- mzFindZipEntry(zip, ASSUMED_UPDATE_BINARY_NAME);
- if (binary_entry == NULL) {
- mzCloseZipArchive(zip);
- return INSTALL_CORRUPT;
- }
+ ret_val = mzExtractZipEntryToFile(Zip, binary_location, binary_fd);
+ close(binary_fd);
+ mzCloseZipArchive(Zip);
- const char* binary = "/tmp/update_binary";
- unlink(binary);
- int fd = creat(binary, 0755);
- if (fd < 0) {
- mzCloseZipArchive(zip);
- LOGE("Can't make %s\n", binary);
- return INSTALL_ERROR;
- }
- bool ok = mzExtractZipEntryToFile(zip, binary_entry, fd);
- close(fd);
- mzCloseZipArchive(zip);
+ if (!ret_val) {
+ LOGERR("Could not extract '%s'\n", ASSUMED_UPDATE_BINARY_NAME);
+ return INSTALL_ERROR;
+ }
- if (!ok) {
- LOGE("Can't copy %s\n", ASSUMED_UPDATE_BINARY_NAME);
- return INSTALL_ERROR;
- }
+ pipe(pipe_fd);
- int pipefd[2];
- pipe(pipefd);
+ args[0] = Temp_Binary.c_str();
+ args[1] = EXPAND(RECOVERY_API_VERSION);
+ char* temp = (char*)malloc(10);
+ sprintf(temp, "%d", pipe_fd[1]);
+ args[2] = temp;
+ args[3] = (char*)path;
+ args[4] = NULL;
- // When executing the update binary contained in the package, the
- // arguments passed are:
- //
- // - the version number for this interface
- //
- // - an fd to which the program can write in order to update the
- // progress bar. The program can write single-line commands:
- //
- // progress <frac> <secs>
- // fill up the next <frac> part of of the progress bar
- // over <secs> seconds. If <secs> is zero, use
- // set_progress commands to manually control the
- // progress of this segment of the bar
- //
- // set_progress <frac>
- // <frac> should be between 0.0 and 1.0; sets the
- // progress bar within the segment defined by the most
- // recent progress command.
- //
- // firmware <"hboot"|"radio"> <filename>
- // arrange to install the contents of <filename> in the
- // given partition on reboot.
- //
- // (API v2: <filename> may start with "PACKAGE:" to
- // indicate taking a file from the OTA package.)
- //
- // (API v3: this command no longer exists.)
- //
- // ui_print <string>
- // display <string> on the screen.
- //
- // - the name of the package zip file.
- //
+ pid_t pid = fork();
+ if (pid == 0) {
+ close(pipe_fd[0]);
+ execv(Temp_Binary.c_str(), (char* const*)args);
+ printf("E:Can't execute '%s'\n", Temp_Binary.c_str());
+ _exit(-1);
+ }
+ close(pipe_fd[1]);
- const char** args = (const char**)malloc(sizeof(char*) * 5);
- args[0] = binary;
- args[1] = EXPAND(RECOVERY_API_VERSION); // defined in Android.mk
- char* temp = (char*)malloc(10);
- sprintf(temp, "%d", pipefd[1]);
- args[2] = temp;
- args[3] = (char*)path;
- args[4] = NULL;
+ *wipe_cache = 0;
- pid_t pid = fork();
- if (pid == 0) {
- close(pipefd[0]);
- execv(binary, (char* const*)args);
- fprintf(stdout, "E:Can't run %s (%s)\n", binary, strerror(errno));
- _exit(-1);
- }
- close(pipefd[1]);
-
- *wipe_cache = 0;
-
- char buffer[1024];
- FILE* from_child = fdopen(pipefd[0], "r");
- while (fgets(buffer, sizeof(buffer), from_child) != NULL) {
- char* command = strtok(buffer, " \n");
+ DataManager::GetValue(TW_SIGNED_ZIP_VERIFY_VAR, zip_verify);
+ child_data = fdopen(pipe_fd[0], "r");
+ while (fgets(buffer, sizeof(buffer), child_data) != NULL) {
+ char* command = strtok(buffer, " \n");
if (command == NULL) {
continue;
} else if (strcmp(command, "progress") == 0) {
- char* fraction_s = strtok(NULL, " \n");
- char* seconds_s = strtok(NULL, " \n");
+ char* fraction_char = strtok(NULL, " \n");
+ char* seconds_char = strtok(NULL, " \n");
- float fraction = strtof(fraction_s, NULL);
- int seconds = strtol(seconds_s, NULL, 10);
+ float fraction_float = strtof(fraction_char, NULL);
+ int seconds_float = strtol(seconds_char, NULL, 10);
- ui->ShowProgress(fraction * (1-VERIFICATION_PROGRESS_FRACTION), seconds);
+ if (zip_verify)
+ DataManager::ShowProgress(fraction_float * (1 - VERIFICATION_PROGRESS_FRACTION), seconds_float);
+ else
+ DataManager::ShowProgress(fraction_float, seconds_float);
} else if (strcmp(command, "set_progress") == 0) {
- char* fraction_s = strtok(NULL, " \n");
- float fraction = strtof(fraction_s, NULL);
- ui->SetProgress(fraction);
+ char* fraction_char = strtok(NULL, " \n");
+ float fraction_float = strtof(fraction_char, NULL);
+ DataManager::SetProgress(fraction_float);
} else if (strcmp(command, "ui_print") == 0) {
- char* str = strtok(NULL, "\n");
- if (str) {
- ui->Print("%s", str);
+ char* display_value = strtok(NULL, "\n");
+ if (display_value) {
+ gui_print("%s", display_value);
} else {
- ui->Print("\n");
+ gui_print("\n");
}
} else if (strcmp(command, "wipe_cache") == 0) {
*wipe_cache = 1;
} else if (strcmp(command, "clear_display") == 0) {
- //ui->SetBackground(RecoveryUI::NONE);
+ // Do nothing, not supported by TWRP
} else {
- LOGE("unknown command [%s]\n", command);
+ LOGERR("unknown command [%s]\n", command);
}
- }
- fclose(from_child);
+ }
+ fclose(child_data);
- int status;
- waitpid(pid, &status, 0);
- if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
- LOGE("Error in %s\n(Status %d)\n", path, WEXITSTATUS(status));
- return INSTALL_ERROR;
- }
+ waitpid(pid, &status, 0);
+ if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
+ LOGERR("Error executing updater binary in zip '%s'\n", path);
+ return INSTALL_ERROR;
+ }
- return INSTALL_SUCCESS;
-}
-
-// Reads a file containing one or more public keys as produced by
-// DumpPublicKey: this is an RSAPublicKey struct as it would appear
-// as a C source literal, eg:
-//
-// "{64,0xc926ad21,{1795090719,...,-695002876},{-857949815,...,1175080310}}"
-//
-// (Note that the braces and commas in this example are actual
-// characters the parser expects to find in the file; the ellipses
-// indicate more numbers omitted from this example.)
-//
-// The file may contain multiple keys in this format, separated by
-// commas. The last key must not be followed by a comma.
-//
-// Returns NULL if the file failed to parse, or if it contain zero keys.
-static RSAPublicKey*
-load_keys(const char* filename, int* numKeys) {
- RSAPublicKey* out = NULL;
- *numKeys = 0;
-
- FILE* f = fopen(filename, "r");
- if (f == NULL) {
- LOGE("opening %s: %s\n", filename, strerror(errno));
- goto exit;
- }
-
- {
- int i;
- bool done = false;
- while (!done) {
- ++*numKeys;
- out = (RSAPublicKey*)realloc(out, *numKeys * sizeof(RSAPublicKey));
- RSAPublicKey* key = out + (*numKeys - 1);
- if (fscanf(f, " { %i , 0x%x , { %u",
- &(key->len), &(key->n0inv), &(key->n[0])) != 3) {
- goto exit;
- }
- if (key->len != RSANUMWORDS) {
- LOGE("key length (%d) does not match expected size\n", key->len);
- goto exit;
- }
- for (i = 1; i < key->len; ++i) {
- if (fscanf(f, " , %u", &(key->n[i])) != 1) goto exit;
- }
- if (fscanf(f, " } , { %u", &(key->rr[0])) != 1) goto exit;
- for (i = 1; i < key->len; ++i) {
- if (fscanf(f, " , %u", &(key->rr[i])) != 1) goto exit;
- }
- fscanf(f, " } } ");
-
- // if the line ends in a comma, this file has more keys.
- switch (fgetc(f)) {
- case ',':
- // more keys to come.
- break;
-
- case EOF:
- done = true;
- break;
-
- default:
- LOGE("unexpected character between keys\n");
- goto exit;
- }
- }
- }
-
- fclose(f);
- return out;
-
-exit:
- if (f) fclose(f);
- free(out);
- *numKeys = 0;
- return NULL;
+ return INSTALL_SUCCESS;
}
extern "C" int TWinstall_zip(const char* path, int* wipe_cache) {
- int err, zip_verify, md5_return;
+ int ret_val, zip_verify, md5_return, key_count;
twrpDigest md5sum;
string strpath = path;
- ui_print("Installing '%s'...\n", path);
+ ZipArchive Zip;
- if (!PartitionManager.Mount_By_Path(path, 0)) {
- LOGE("Failed to mount '%s'\n", path);
- return -1;
- }
-
- ui_print("Checking for MD5 file...\n");
+ gui_print("Installing '%s'...\nChecking for MD5 file...\n", path);
md5sum.setfn(strpath);
md5_return = md5sum.verify_md5digest();
if (md5_return == -2) {
// MD5 did not match.
- LOGE("Zip MD5 does not match.\nUnable to install zip.\n");
+ LOGERR("Zip MD5 does not match.\nUnable to install zip.\n");
return INSTALL_CORRUPT;
} else if (md5_return == -1) {
- ui_print("Skipping MD5 check: no MD5 file found.\n");
+ gui_print("Skipping MD5 check: no MD5 file found.\n");
} else if (md5_return == 0)
- ui_print("Zip MD5 matched.\n"); // MD5 found and matched.
+ gui_print("Zip MD5 matched.\n"); // MD5 found and matched.
DataManager::GetValue(TW_SIGNED_ZIP_VERIFY_VAR, zip_verify);
+ DataManager::SetProgress(0);
if (zip_verify) {
- ui_print("Verifying zip signature...\n");
- int numKeys;
- RSAPublicKey* loadedKeys = load_keys(PUBLIC_KEYS_FILE, &numKeys);
- if (loadedKeys == NULL) {
- LOGE("Failed to load keys\n");
- return -1;
- }
- LOGI("%d key(s) loaded from %s\n", numKeys, PUBLIC_KEYS_FILE);
-
- // Give verification half the progress bar...
- ui->Print("Verifying update package...\n");
- ui->SetProgressType(RecoveryUI::DETERMINATE);
- ui->ShowProgress(VERIFICATION_PROGRESS_FRACTION, VERIFICATION_PROGRESS_TIME);
-
- err = verify_file(path, loadedKeys, numKeys);
- free(loadedKeys);
- LOGI("verify_file returned %d\n", err);
- if (err != VERIFY_SUCCESS) {
- LOGE("signature verification failed\n");
+ gui_print("Verifying zip signature...\n");
+ ret_val = verify_file(path);
+ if (ret_val != VERIFY_SUCCESS) {
+ LOGERR("Zip signature verification failed: %i\n", ret_val);
return -1;
}
}
- /* Try to open the package.
- */
- ZipArchive zip;
- err = mzOpenZipArchive(path, &zip);
- if (err != 0) {
- LOGE("Can't open %s\n(%s)\n", path, err != -1 ? strerror(err) : "bad");
- return INSTALL_CORRUPT;
- }
-
- /* Verify and install the contents of the package.
- */
- return try_update_binary(path, &zip, wipe_cache);
+ ret_val = mzOpenZipArchive(path, &Zip);
+ if (ret_val != 0) {
+ LOGERR("Zip file is corrupt!\n", path);
+ return INSTALL_CORRUPT;
+ }
+ return Run_Update_Binary(path, &Zip, wipe_cache);
}
diff --git a/twinstall.h b/twinstall.h
index 8fd940e..ea467a2 100644
--- a/twinstall.h
+++ b/twinstall.h
@@ -1,23 +1,5 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef RECOVERY_INSTALL_H_
-#define RECOVERY_INSTALL_H_
-
-#include "common.h"
+#ifndef RECOVERY_TWINSTALL_H_
+#define RECOVERY_TWINSTALL_H_
#ifdef __cplusplus
extern "C" {
@@ -29,4 +11,4 @@
}
#endif
-#endif // RECOVERY_INSTALL_H_
+#endif // RECOVERY_TWINSTALL_H_
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index 76ee93a..a0194b3 100644
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -19,18 +19,16 @@
#include <fstream>
#include "twrp-functions.hpp"
#include "partitions.hpp"
-#include "common.h"
+#include "twcommon.h"
#include "data.hpp"
-#include "bootloader.h"
#include "variables.h"
+#include "bootloader.h"
extern "C" {
#include "libcrecovery/common.h"
}
-
/* Execute a command */
-
int TWFunc::Exec_Cmd(string cmd, string &result) {
FILE* exec;
char buffer[130];
@@ -96,33 +94,33 @@
if (!PartitionManager.Mount_By_Path("/data", true))
return;
- ui_print("Installing HTC Dumlock to system...\n");
+ gui_print("Installing HTC Dumlock to system...\n");
copy_file("/res/htcd/htcdumlocksys", "/system/bin/htcdumlock", 0755);
if (!Path_Exists("/system/bin/flash_image")) {
- ui_print("Installing flash_image...\n");
+ gui_print("Installing flash_image...\n");
copy_file("/res/htcd/flash_imagesys", "/system/bin/flash_image", 0755);
need_libs = 1;
} else
- ui_print("flash_image is already installed, skipping...\n");
+ gui_print("flash_image is already installed, skipping...\n");
if (!Path_Exists("/system/bin/dump_image")) {
- ui_print("Installing dump_image...\n");
+ gui_print("Installing dump_image...\n");
copy_file("/res/htcd/dump_imagesys", "/system/bin/dump_image", 0755);
need_libs = 1;
} else
- ui_print("dump_image is already installed, skipping...\n");
+ gui_print("dump_image is already installed, skipping...\n");
if (need_libs) {
- ui_print("Installing libs needed for flash_image and dump_image...\n");
+ gui_print("Installing libs needed for flash_image and dump_image...\n");
copy_file("/res/htcd/libbmlutils.so", "/system/lib/libbmlutils.so", 0755);
copy_file("/res/htcd/libflashutils.so", "/system/lib/libflashutils.so", 0755);
copy_file("/res/htcd/libmmcutils.so", "/system/lib/libmmcutils.so", 0755);
copy_file("/res/htcd/libmtdutils.so", "/system/lib/libmtdutils.so", 0755);
}
- ui_print("Installing HTC Dumlock app...\n");
+ gui_print("Installing HTC Dumlock app...\n");
mkdir("/data/app", 0777);
unlink("/data/app/com.teamwin.htcdumlock*");
copy_file("/res/htcd/HTCDumlock.apk", "/data/app/com.teamwin.htcdumlock.apk", 0777);
sync();
- ui_print("HTC Dumlock is installed.\n");
+ gui_print("HTC Dumlock is installed.\n");
}
void TWFunc::htc_dumlock_restore_original_boot(void) {
@@ -130,18 +128,18 @@
if (!PartitionManager.Mount_By_Path("/sdcard", true))
return;
- ui_print("Restoring original boot...\n");
+ gui_print("Restoring original boot...\n");
Exec_Cmd("htcdumlock restore", status);
- ui_print("Original boot restored.\n");
+ gui_print("Original boot restored.\n");
}
void TWFunc::htc_dumlock_reflash_recovery_to_boot(void) {
string status;
if (!PartitionManager.Mount_By_Path("/sdcard", true))
return;
- ui_print("Reflashing recovery to boot...\n");
+ gui_print("Reflashing recovery to boot...\n");
Exec_Cmd("htcdumlock recovery noreboot", status);
- ui_print("Recovery is flashed to boot.\n");
+ gui_print("Recovery is flashed to boot.\n");
}
int TWFunc::Recursive_Mkdir(string Path) {
@@ -153,7 +151,7 @@
{
wholePath = pathCpy.substr(0, pos);
if (mkdir(wholePath.c_str(), 0777) && errno != EEXIST) {
- LOGE("Unable to create folder: %s (errno=%d)\n", wholePath.c_str(), errno);
+ LOGERR("Unable to create folder: %s (errno=%d)\n", wholePath.c_str(), errno);
return false;
}
@@ -174,8 +172,8 @@
d = opendir(Path.c_str());
if (d == NULL)
{
- LOGE("error opening '%s'\n", Path.c_str());
- LOGE("error: %s\n", strerror(errno));
+ LOGERR("error opening '%s'\n", Path.c_str());
+ LOGERR("error: %s\n", strerror(errno));
return 0;
}
@@ -236,81 +234,62 @@
return st.st_size;
}
-static const char *COMMAND_FILE = "/cache/recovery/command";
-static const char *INTENT_FILE = "/cache/recovery/intent";
-static const char *LOG_FILE = "/cache/recovery/log";
-static const char *LAST_LOG_FILE = "/cache/recovery/last_log";
-static const char *LAST_INSTALL_FILE = "/cache/recovery/last_install";
-static const char *CACHE_ROOT = "/cache";
-static const char *SDCARD_ROOT = "/sdcard";
-static const char *TEMPORARY_LOG_FILE = "/tmp/recovery.log";
-static const char *TEMPORARY_INSTALL_FILE = "/tmp/last_install";
-
-// close a file, log an error if the error indicator is set
-void TWFunc::check_and_fclose(FILE *fp, const char *name) {
- fflush(fp);
- if (ferror(fp)) LOGE("Error in %s\n(%s)\n", name, strerror(errno));
- fclose(fp);
-}
-
-void TWFunc::copy_log_file(const char* source, const char* destination, int append) {
- FILE *log = fopen_path(destination, append ? "a" : "w");
- if (log == NULL) {
- LOGE("Can't open %s\n", destination);
+void TWFunc::Copy_Log(string Source, string Destination) {
+ FILE *destination_log = fopen(Destination.c_str(), "a");
+ if (destination_log == NULL) {
+ LOGERR("TWFunc::Copy_Log -- Can't open destination log file: '%s'\n", Destination.c_str());
} else {
- FILE *tmplog = fopen(source, "r");
- if (tmplog != NULL) {
- if (append) {
- fseek(tmplog, tmplog_offset, SEEK_SET); // Since last write
- }
- char buf[4096];
- while (fgets(buf, sizeof(buf), tmplog)) fputs(buf, log);
- if (append) {
- tmplog_offset = ftell(tmplog);
- }
- check_and_fclose(tmplog, source);
+ FILE *source_log = fopen(Source.c_str(), "r");
+ if (source_log != NULL) {
+ fseek(source_log, Log_Offset, SEEK_SET);
+ char buffer[4096];
+ while (fgets(buffer, sizeof(buffer), source_log))
+ fputs(buffer, destination_log); // Buffered write of log file
+ Log_Offset = ftell(source_log);
+ fflush(source_log);
+ fclose(source_log);
}
- check_and_fclose(log, destination);
+ fflush(destination_log);
+ fclose(destination_log);
}
}
-// clear the recovery command and prepare to boot a (hopefully working) system,
-// copy our log file to cache as well (for the system to read), and
-// record any intent we were asked to communicate back to the system.
-// this function is idempotent: call it as many times as you like.
-void TWFunc::twfinish_recovery(const char *send_intent) {
- // By this point, we're ready to return to the main system...
- if (send_intent != NULL) {
- FILE *fp = fopen_path(INTENT_FILE, "w");
- if (fp == NULL) {
- LOGE("Can't open %s\n", INTENT_FILE);
- } else {
- fputs(send_intent, fp);
- check_and_fclose(fp, INTENT_FILE);
- }
- }
-
+void TWFunc::Update_Log_File(void) {
// Copy logs to cache so the system can find out what happened.
- copy_log_file(TEMPORARY_LOG_FILE, LOG_FILE, true);
- copy_log_file(TEMPORARY_LOG_FILE, LAST_LOG_FILE, false);
- copy_log_file(TEMPORARY_INSTALL_FILE, LAST_INSTALL_FILE, false);
- chmod(LOG_FILE, 0600);
- chown(LOG_FILE, 1000, 1000); // system user
- chmod(LAST_LOG_FILE, 0640);
- chmod(LAST_INSTALL_FILE, 0644);
+ Copy_Log(TMP_LOG_FILE, "/cache/recovery/log");
+ copy_file("/cache/recovery/log", "/cache/recovery/last_log", 600);
+ chown("/cache/recovery/log", 1000, 1000);
+ chmod("/cache/recovery/log", 0600);
+ chmod("/cache/recovery/last_log", 0640);
- // Reset to normal system boot so recovery won't cycle indefinitely.
- struct bootloader_message boot;
- memset(&boot, 0, sizeof(boot));
- set_bootloader_message(&boot);
+ // Reset bootloader message
+ TWPartition* Part = PartitionManager.Find_Partition_By_Path("/misc");
+ if (Part != NULL) {
+ struct bootloader_message boot;
+ memset(&boot, 0, sizeof(boot));
+ if (Part->Current_File_System == "mtd") {
+ if (set_bootloader_message_mtd_name(&boot, Part->MTD_Name.c_str()) != 0)
+ LOGERR("Unable to set MTD bootloader message.\n");
+ } else if (Part->Current_File_System == "emmc") {
+ if (set_bootloader_message_block_name(&boot, Part->Actual_Block_Device.c_str()) != 0)
+ LOGERR("Unable to set emmc bootloader message.\n");
+ } else {
+ LOGERR("Unknown file system for /misc: '%s'\n", Part->Current_File_System.c_str());
+ }
+ }
- // Remove the command file, so recovery won't repeat indefinitely.
- if (!PartitionManager.Mount_By_Path("/system", true) || (unlink(COMMAND_FILE) && errno != ENOENT)) {
- LOGW("Can't unlink %s\n", COMMAND_FILE);
+ if (!PartitionManager.Mount_By_Path("/cache", true) || (unlink("/cache/recovery/command") && errno != ENOENT)) {
+ LOGINFO("Can't unlink %s\n", "/cache/recovery/command");
}
PartitionManager.UnMount_By_Path("/cache", true);
- sync(); // For good measure.
+ sync();
+}
+
+void TWFunc::Update_Intent_File(string Intent) {
+ if (PartitionManager.Mount_By_Path("/cache", false) && !Intent.empty()) {
+ TWFunc::write_file("/cache/recovery/intent", Intent);
+ }
}
// reboot: Reboot the system. Return -1 on error, no return on success
@@ -319,32 +298,31 @@
// Always force a sync before we reboot
sync();
- switch (command)
- {
- case rb_current:
- case rb_system:
- twfinish_recovery("s");
- sync();
- check_and_run_script("/sbin/rebootsystem.sh", "reboot system");
- return reboot(RB_AUTOBOOT);
- case rb_recovery:
- check_and_run_script("/sbin/rebootrecovery.sh", "reboot recovery");
- return __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, (void*) "recovery");
- case rb_bootloader:
- check_and_run_script("/sbin/rebootbootloader.sh", "reboot bootloader");
- return __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, (void*) "bootloader");
- case rb_poweroff:
- check_and_run_script("/sbin/poweroff.sh", "power off");
+ switch (command) {
+ case rb_current:
+ case rb_system:
+ Update_Log_File();
+ Update_Intent_File("s");
+ sync();
+ check_and_run_script("/sbin/rebootsystem.sh", "reboot system");
+ return reboot(RB_AUTOBOOT);
+ case rb_recovery:
+ check_and_run_script("/sbin/rebootrecovery.sh", "reboot recovery");
+ return __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, (void*) "recovery");
+ case rb_bootloader:
+ check_and_run_script("/sbin/rebootbootloader.sh", "reboot bootloader");
+ return __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, (void*) "bootloader");
+ case rb_poweroff:
+ check_and_run_script("/sbin/poweroff.sh", "power off");
#ifdef ANDROID_RB_POWEROFF
- android_reboot(ANDROID_RB_POWEROFF, 0, 0);
+ android_reboot(ANDROID_RB_POWEROFF, 0, 0);
#endif
- return reboot(RB_POWER_OFF);
- case rb_download:
- check_and_run_script("/sbin/rebootdownload.sh", "reboot download");
- return __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, (void*) "download");
- return 1;
- default:
- return -1;
+ return reboot(RB_POWER_OFF);
+ case rb_download:
+ check_and_run_script("/sbin/rebootdownload.sh", "reboot download");
+ return __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, (void*) "download");
+ default:
+ return -1;
}
return -1;
}
@@ -355,10 +333,10 @@
struct stat st;
string result;
if (stat(script_file, &st) == 0) {
- ui_print("Running %s script...\n", display_name);
+ gui_print("Running %s script...\n", display_name);
chmod(script_file, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
TWFunc::Exec_Cmd(script_file, result);
- ui_print("\nFinished running %s script.\n", display_name);
+ gui_print("\nFinished running %s script.\n", display_name);
}
}
@@ -368,7 +346,7 @@
string new_path;
if (d == NULL) {
- LOGE("Error opening '%s'\n", path.c_str());
+ LOGERR("Error opening '%s'\n", path.c_str());
return -1;
}
@@ -385,12 +363,12 @@
if (p->d_type == DT_DIR)
r = rmdir(new_path.c_str());
else
- LOGI("Unable to removeDir '%s': %s\n", new_path.c_str(), strerror(errno));
+ LOGINFO("Unable to removeDir '%s': %s\n", new_path.c_str(), strerror(errno));
}
} else if (p->d_type == DT_REG || p->d_type == DT_LNK || p->d_type == DT_FIFO || p->d_type == DT_SOCK) {
r = unlink(new_path.c_str());
if (r != 0) {
- LOGI("Unable to unlink '%s: %s'\n", new_path.c_str(), strerror(errno));
+ LOGINFO("Unable to unlink '%s: %s'\n", new_path.c_str(), strerror(errno));
}
}
}
@@ -407,7 +385,7 @@
}
int TWFunc::copy_file(string src, string dst, int mode) {
- LOGI("Copying file %s to %s\n", src.c_str(), dst.c_str());
+ LOGINFO("Copying file %s to %s\n", src.c_str(), dst.c_str());
ifstream srcfile(src.c_str(), ios::binary);
ofstream dstfile(dst.c_str(), ios::binary);
dstfile << srcfile.rdbuf();
@@ -447,7 +425,7 @@
file.close();
return 0;
}
- LOGI("Cannot find file %s\n", fn.c_str());
+ LOGINFO("Cannot find file %s\n", fn.c_str());
return -1;
}
@@ -461,7 +439,7 @@
file.close();
return 0;
}
- LOGI("Cannot find file %s\n", fn.c_str());
+ LOGINFO("Cannot find file %s\n", fn.c_str());
return -1;
}
@@ -473,7 +451,7 @@
fclose(file);
return 0;
}
- LOGI("Cannot find file %s\n", fn.c_str());
+ LOGINFO("Cannot find file %s\n", fn.c_str());
return -1;
}
@@ -531,44 +509,44 @@
string file = "/system/bin/su";
if (TWFunc::Path_Exists(file)) {
if (chown(file.c_str(), 0, 0) != 0) {
- LOGE("Failed to chown '%s'\n", file.c_str());
+ LOGERR("Failed to chown '%s'\n", file.c_str());
return false;
}
if (tw_chmod(file, "6755") != 0) {
- LOGE("Failed to chmod '%s'\n", file.c_str());
+ LOGERR("Failed to chmod '%s'\n", file.c_str());
return false;
}
}
file = "/system/xbin/su";
if (TWFunc::Path_Exists(file)) {
if (chown(file.c_str(), 0, 0) != 0) {
- LOGE("Failed to chown '%s'\n", file.c_str());
+ LOGERR("Failed to chown '%s'\n", file.c_str());
return false;
}
if (tw_chmod(file, "6755") != 0) {
- LOGE("Failed to chmod '%s'\n", file.c_str());
+ LOGERR("Failed to chmod '%s'\n", file.c_str());
return false;
}
}
file = "/system/bin/.ext/.su";
if (TWFunc::Path_Exists(file)) {
if (chown(file.c_str(), 0, 0) != 0) {
- LOGE("Failed to chown '%s'\n", file.c_str());
+ LOGERR("Failed to chown '%s'\n", file.c_str());
return false;
}
if (tw_chmod(file, "6755") != 0) {
- LOGE("Failed to chmod '%s'\n", file.c_str());
+ LOGERR("Failed to chmod '%s'\n", file.c_str());
return false;
}
}
file = "/system/app/Superuser.apk";
if (TWFunc::Path_Exists(file)) {
if (chown(file.c_str(), 0, 0) != 0) {
- LOGE("Failed to chown '%s'\n", file.c_str());
+ LOGERR("Failed to chown '%s'\n", file.c_str());
return false;
}
if (tw_chmod(file, "0644") != 0) {
- LOGE("Failed to chmod '%s'\n", file.c_str());
+ LOGERR("Failed to chmod '%s'\n", file.c_str());
return false;
}
}
@@ -677,7 +655,7 @@
}
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;
}
@@ -689,11 +667,11 @@
return false;
if (copy_file("/supersu/su", "/system/xbin/su", 0755) != 0) {
- LOGE("Failed to copy su binary to /system/bin\n");
+ LOGERR("Failed to copy su binary to /system/bin\n");
return false;
}
if (copy_file("/supersu/Superuser.apk", "/system/app/Superuser.apk", 0644) != 0) {
- LOGE("Failed to copy Superuser app to /system/app\n");
+ LOGERR("Failed to copy Superuser app to /system/app\n");
return false;
}
if (!Fix_su_Perms())
diff --git a/twrp-functions.hpp b/twrp-functions.hpp
index 042c567..8e31e42 100644
--- a/twrp-functions.hpp
+++ b/twrp-functions.hpp
@@ -2,6 +2,7 @@
#define _TWRPFUNCTIONS_HPP
#include <string>
+#include <vector>
using namespace std;
@@ -32,7 +33,8 @@
static void GUI_Operation_Text(string Read_Value, string Default_Text); // Updates text for display in the GUI, e.g. Backing up %partition name%
static void GUI_Operation_Text(string Read_Value, string Partition_Name, string Default_Text); // Same as above but includes partition name
static unsigned long Get_File_Size(string Path); // Returns the size of a file
- static void twfinish_recovery(const char *send_intent); // Writes the log to last_log
+ static void Update_Log_File(void); // Writes the log to last_log
+ static void Update_Intent_File(string Intent); // Updates intent file
static int tw_reboot(RebootCommand command); // Prepares the device for rebooting
static void check_and_run_script(const char* script_file, const char* display_name); // checks for the existence of a script, chmods it to 755, then runs it
static int Exec_Cmd(string cmd, string &result); //execute a command and return the result as a string by reference
@@ -50,9 +52,10 @@
static bool Install_SuperSU(void); // Installs su binary and apk and sets proper permissions
private:
- static void check_and_fclose(FILE *fp, const char *name);
- static void copy_log_file(const char* source, const char* destination, int append);
+ static void Copy_Log(string Source, string Destination);
};
+extern int Log_Offset;
+
#endif // _TWRPFUNCTIONS_HPP
diff --git a/twrp.cpp b/twrp.cpp
new file mode 100644
index 0000000..938a07a
--- /dev/null
+++ b/twrp.cpp
@@ -0,0 +1,241 @@
+/*
+ Copyright 2013 bigbiff/Dees_Troy TeamWin
+ This file is part of TWRP/TeamWin Recovery Project.
+
+ TWRP is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ TWRP is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with TWRP. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <time.h>
+#include <unistd.h>
+
+#include "cutils/properties.h"
+extern "C" {
+#include "minadbd/adb.h"
+}
+
+#ifdef ANDROID_RB_RESTART
+#include "cutils/android_reboot.h"
+#else
+#include <sys/reboot.h>
+#endif
+
+extern "C" {
+#include "gui/gui.h"
+}
+#include "twcommon.h"
+#include "twrp-functions.hpp"
+#include "data.hpp"
+#include "partitions.hpp"
+#include "openrecoveryscript.hpp"
+#include "variables.h"
+
+TWPartitionManager PartitionManager;
+int Log_Offset;
+
+static void Print_Prop(const char *key, const char *name, void *cookie) {
+ printf("%s=%s\n", key, name);
+}
+
+int main(int argc, char **argv) {
+ // Recovery needs to install world-readable files, so clear umask
+ // set by init
+ umask(0);
+
+ Log_Offset = 0;
+
+ // Set up temporary log file (/tmp/recovery.log)
+ freopen(TMP_LOG_FILE, "a", stdout);
+ setbuf(stdout, NULL);
+ freopen(TMP_LOG_FILE, "a", stderr);
+ setbuf(stderr, NULL);
+
+ // Handle ADB sideload
+ if (argc == 3 && strcmp(argv[1], "--adbd") == 0) {
+ adb_main(argv[2]);
+ return 0;
+ }
+
+ time_t StartupTime = time(NULL);
+ printf("Starting TWRP %s on %s", TW_VERSION_STR, ctime(&StartupTime));
+
+ // Load default values to set DataManager constants and handle ifdefs
+ DataManager::SetDefaultValues();
+ printf("Starting the UI...");
+ gui_init();
+ printf("=> Linking mtab\n");
+ symlink("/proc/mounts", "/etc/mtab");
+ printf("=> Processing recovery.fstab\n");
+ if (!PartitionManager.Process_Fstab("/etc/recovery.fstab", 1)) {
+ LOGERR("Failing out of recovery due to problem with recovery.fstab.\n");
+ return -1;
+ }
+ PartitionManager.Output_Partition_Logging();
+ // Load up all the resources
+ gui_loadResources();
+
+ PartitionManager.Mount_By_Path("/cache", true);
+
+ string Zip_File, Reboot_Value;
+ bool Cache_Wipe = false, Factory_Reset = false, Perform_Backup = false;
+
+ int index, index2;
+ char* ptr;
+ printf("Startup Commands: ");
+ for (index = 1; index < argc; index++) {
+ printf(" '%s'", argv[index]);
+ if (*argv[index] == 'u') {
+ ptr = argv[index];
+ index2 = 0;
+ while (*ptr != '=' && *ptr != '\n')
+ ptr++;
+ if (*ptr) {
+ Zip_File = ptr;
+ } else
+ LOGERR("argument error specifying zip file\n");
+ } else if (*argv[index] == 'c') {
+ Cache_Wipe = true;
+ } else if (*argv[index] == 'w') {
+ Factory_Reset = true;
+ } else if (*argv[index] == 'n') {
+ Perform_Backup = true;
+ } else if (*argv[index] == 's') {
+ ptr = argv[index];
+ index2 = 0;
+ while (*ptr != '=' && *ptr != '\n')
+ ptr++;
+ if (*ptr) {
+ Reboot_Value = *ptr;
+ }
+ }
+ }
+
+ char twrp_booted[PROPERTY_VALUE_MAX];
+ property_get("ro.twrp.boot", twrp_booted, "0");
+ if (strcmp(twrp_booted, "0") != 0) {
+ property_list(Print_Prop, NULL);
+ printf("\n");
+ property_set("ro.twrp.boot", "1");
+ }
+
+ // Check for and run startup script if script exists
+ TWFunc::check_and_run_script("/sbin/runatboot.sh", "boot");
+ TWFunc::check_and_run_script("/sbin/postrecoveryboot.sh", "boot");
+
+#ifdef TW_INCLUDE_INJECTTWRP
+ // Back up TWRP Ramdisk if needed:
+ TWPartition* Boot = PartitionManager.Find_Partition_By_Path("/boot");
+ string result;
+ LOGINFO("Backing up TWRP ramdisk...\n");
+ if (Boot == NULL || Boot->Current_File_System != "emmc")
+ TWFunc::Exec_Cmd("injecttwrp --backup /tmp/backup_recovery_ramdisk.img", result);
+ else {
+ string injectcmd = "injecttwrp --backup /tmp/backup_recovery_ramdisk.img bd=" + Boot->Actual_Block_Device;
+ TWFunc::Exec_Cmd(injectcmd, result);
+ }
+ LOGINFO("Backup of TWRP ramdisk done.\n");
+#endif
+
+ bool Keep_Going = true;
+ if (Perform_Backup) {
+ DataManager::SetValue(TW_BACKUP_NAME, "(Current Date)");
+ if (!OpenRecoveryScript::Insert_ORS_Command("backup BSDCAE\n"))
+ Keep_Going = false;
+ }
+ if (Keep_Going && !Zip_File.empty()) {
+ string ORSCommand = "install " + Zip_File;
+
+ if (!OpenRecoveryScript::Insert_ORS_Command(ORSCommand))
+ Keep_Going = false;
+ }
+ if (Keep_Going) {
+ if (Factory_Reset) {
+ if (!OpenRecoveryScript::Insert_ORS_Command("wipe data\n"))
+ Keep_Going = false;
+ } else if (Cache_Wipe) {
+ if (!OpenRecoveryScript::Insert_ORS_Command("wipe cache\n"))
+ Keep_Going = false;
+ }
+ }
+
+ TWFunc::Update_Log_File();
+ // Offer to decrypt if the device is encrypted
+ if (DataManager::GetIntValue(TW_IS_ENCRYPTED) != 0) {
+ LOGINFO("Is encrypted, do decrypt page first\n");
+ if (gui_startPage("decrypt") != 0) {
+ LOGERR("Failed to start decrypt GUI page.\n");
+ }
+ }
+
+ // Read the settings file
+ DataManager::ReadSettingsFile();
+ // Run any outstanding OpenRecoveryScript
+ if (DataManager::GetIntValue(TW_IS_ENCRYPTED) == 0 && (TWFunc::Path_Exists(SCRIPT_FILE_TMP) || TWFunc::Path_Exists(SCRIPT_FILE_CACHE))) {
+ OpenRecoveryScript::Run_OpenRecoveryScript();
+ }
+ // Launch the main GUI
+ gui_start();
+
+ // Check for su to see if the device is rooted or not
+ if (PartitionManager.Mount_By_Path("/system", false)) {
+ // Disable flashing of stock recovery
+ if (TWFunc::Path_Exists("/system/recovery-from-boot.p")) {
+ rename("/system/recovery-from-boot.p", "/system/recovery-from-boot.bak");
+ gui_print("Renamed stock recovery file in /system to prevent\nthe stock ROM from replacing TWRP.\n");
+ }
+ if (TWFunc::Path_Exists("/supersu/su") && !TWFunc::Path_Exists("/system/bin/su") && !TWFunc::Path_Exists("/system/xbin/su") && !TWFunc::Path_Exists("/system/bin/.ext/.su")) {
+ // Device doesn't have su installed
+ DataManager::SetValue("tw_busy", 1);
+ if (gui_startPage("installsu") != 0) {
+ LOGERR("Failed to start decrypt GUI page.\n");
+ }
+ } else if (TWFunc::Check_su_Perms() > 0) {
+ // su perms are set incorrectly
+ DataManager::SetValue("tw_busy", 1);
+ if (gui_startPage("fixsu") != 0) {
+ LOGERR("Failed to start decrypt GUI page.\n");
+ }
+ }
+ sync();
+ PartitionManager.UnMount_By_Path("/system", false);
+ }
+
+ // Reboot
+ TWFunc::Update_Intent_File(Reboot_Value);
+ TWFunc::Update_Log_File();
+ gui_print("Rebooting...\n");
+ string Reboot_Arg;
+ DataManager::GetValue("tw_reboot_arg", Reboot_Arg);
+ if (Reboot_Arg == "recovery")
+ TWFunc::tw_reboot(rb_recovery);
+ else if (Reboot_Arg == "poweroff")
+ TWFunc::tw_reboot(rb_poweroff);
+ else if (Reboot_Arg == "bootloader")
+ TWFunc::tw_reboot(rb_bootloader);
+ else if (Reboot_Arg == "download")
+ TWFunc::tw_reboot(rb_download);
+ else
+ TWFunc::tw_reboot(rb_system);
+
+#ifdef ANDROID_RB_RESTART
+ android_reboot(ANDROID_RB_RESTART, 0, 0);
+#else
+ reboot(RB_AUTOBOOT);
+#endif
+ return 0;
+}
diff --git a/twrpDigest.cpp b/twrpDigest.cpp
index add498c..663d085 100644
--- a/twrpDigest.cpp
+++ b/twrpDigest.cpp
@@ -36,7 +36,7 @@
#include <sstream>
#include <dirent.h>
#include <sys/mman.h>
-#include "common.h"
+#include "twcommon.h"
#include "data.hpp"
#include "variables.h"
#include "twrp-functions.hpp"
@@ -61,6 +61,7 @@
while ((len = fread(buf, 1, sizeof(buf), file)) > 0) {
MD5Update(&md5c, buf, len);
}
+ fclose(file);
MD5Final(md5sum ,&md5c);
return 0;
}
diff --git a/twrpTar.cpp b/twrpTar.cpp
index 1ab1ab7..2dbfd15 100644
--- a/twrpTar.cpp
+++ b/twrpTar.cpp
@@ -35,7 +35,7 @@
#include <dirent.h>
#include <sys/mman.h>
#include "twrpTar.hpp"
-#include "common.h"
+#include "twcommon.h"
#include "data.hpp"
#include "variables.h"
#include "twrp-functions.hpp"
@@ -54,7 +54,7 @@
int status;
pid_t pid;
if ((pid = fork()) == -1) {
- LOGI("create tar failed to fork.\n");
+ LOGINFO("create tar failed to fork.\n");
return -1;
}
if (pid == 0) {
@@ -65,18 +65,18 @@
}
else {
if ((pid = wait(&status)) == -1) {
- LOGI("Tar creation failed\n");
+ LOGINFO("Tar creation failed\n");
return -1;
}
else {
if (WIFSIGNALED(status) != 0) {
- LOGI("Child process ended with signal: %d\n", WTERMSIG(status));
+ LOGINFO("Child process ended with signal: %d\n", WTERMSIG(status));
return -1;
}
else if (WIFEXITED(status) != 0)
- LOGI("Tar creation successful\n");
+ LOGINFO("Tar creation successful\n");
else {
- LOGI("Tar creation failed\n");
+ LOGINFO("Tar creation failed\n");
return -1;
}
}
@@ -88,7 +88,7 @@
int status;
pid_t pid;
if ((pid = fork()) == -1) {
- LOGI("create tar failed to fork.\n");
+ LOGINFO("create tar failed to fork.\n");
return -1;
}
if (pid == 0) {
@@ -99,18 +99,18 @@
}
else {
if ((pid = wait(&status)) == -1) {
- LOGI("Tar creation failed\n");
+ LOGINFO("Tar creation failed\n");
return -1;
}
else {
if (WIFSIGNALED(status) != 0) {
- LOGI("Child process ended with signal: %d\n", WTERMSIG(status));
+ LOGINFO("Child process ended with signal: %d\n", WTERMSIG(status));
return -1;
}
else if (WEXITSTATUS(status) == 0)
- LOGI("Tar creation successful\n");
+ LOGINFO("Tar creation successful\n");
else {
- LOGI("Tar creation failed\n");
+ LOGINFO("Tar creation failed\n");
return -1;
}
}
@@ -122,7 +122,7 @@
int status;
pid_t pid;
if ((pid = fork()) == -1) {
- LOGI("extract tar failed to fork.\n");
+ LOGINFO("extract tar failed to fork.\n");
return -1;
}
if (pid == 0) {
@@ -133,18 +133,18 @@
}
else {
if ((pid = wait(&status)) == -1) {
- LOGI("Tar extraction failed\n");
+ LOGINFO("Tar extraction failed\n");
return -1;
}
else {
if (WIFSIGNALED(status) != 0) {
- LOGI("Child process ended with signal: %d\n", WTERMSIG(status));
+ LOGINFO("Child process ended with signal: %d\n", WTERMSIG(status));
return -1;
}
else if (WEXITSTATUS(status) == 0)
- LOGI("Tar extraction successful\n");
+ LOGINFO("Tar extraction successful\n");
else {
- LOGI("Tar extraction failed\n");
+ LOGINFO("Tar extraction failed\n");
return -1;
}
}
@@ -156,7 +156,7 @@
int status;
pid_t pid;
if ((pid = fork()) == -1) {
- LOGI("create tar failed to fork.\n");
+ LOGINFO("create tar failed to fork.\n");
return -1;
}
if (pid == 0) {
@@ -167,18 +167,18 @@
}
else {
if ((pid = wait(&status)) == -1) {
- LOGI("Tar creation failed\n");
+ LOGINFO("Tar creation failed\n");
return -1;
}
else {
if (WIFSIGNALED(status) != 0) {
- LOGI("Child process ended with signal: %d\n", WTERMSIG(status));
+ LOGINFO("Child process ended with signal: %d\n", WTERMSIG(status));
return -1;
}
else if (WIFEXITED(status) != 0)
- LOGI("Tar creation successful\n");
+ LOGINFO("Tar creation successful\n");
else {
- LOGI("Tar creation failed\n");
+ LOGINFO("Tar creation failed\n");
return -1;
}
}
@@ -195,12 +195,12 @@
if (has_data_media == 1 && Path.size() >= 11 && strncmp(Path.c_str(), "/data/media", 11) == 0)
return 0; // Skip /data/media
- LOGI("Path: '%s', archive filename: '%s'\n", Path.c_str(), tarfn.c_str());
+ LOGINFO("Path: '%s', archive filename: '%s'\n", Path.c_str(), tarfn.c_str());
d = opendir(Path.c_str());
if (d == NULL)
{
- LOGE("error opening '%s' -- error: %s\n", Path.c_str(), strerror(errno));
+ LOGERR("error opening '%s' -- error: %s\n", Path.c_str(), strerror(errno));
closedir(d);
return -1;
}
@@ -216,12 +216,12 @@
{
unsigned long long folder_size = TWFunc::Get_Folder_Size(FileName, false);
if (Archive_Current_Size + folder_size > MAX_ARCHIVE_SIZE) {
- LOGI("Calling Generate_Multiple_Archives\n");
+ LOGINFO("Calling Generate_Multiple_Archives\n");
if (Generate_Multiple_Archives(FileName) < 0)
return -1;
} else {
//FileName += "/";
- LOGI("Adding folder '%s'\n", FileName.c_str());
+ LOGINFO("Adding folder '%s'\n", FileName.c_str());
tardir = FileName;
if (tarDirs(true) < 0)
return -1;
@@ -233,34 +233,34 @@
stat(FileName.c_str(), &st);
if (Archive_Current_Size != 0 && Archive_Current_Size + st.st_size > MAX_ARCHIVE_SIZE) {
- LOGI("Closing tar '%s', ", tarfn.c_str());
+ LOGINFO("Closing tar '%s', ", tarfn.c_str());
closeTar(false);
reinit_libtar_buffer();
if (TWFunc::Get_File_Size(tarfn) == 0) {
- LOGE("Backup file size for '%s' is 0 bytes.\n", tarfn.c_str());
+ LOGERR("Backup file size for '%s' is 0 bytes.\n", tarfn.c_str());
return -1;
}
Archive_File_Count++;
if (Archive_File_Count > 999) {
- LOGE("Archive count is too large!\n");
+ LOGERR("Archive count is too large!\n");
return -1;
}
string temp = basefn + "%03i";
sprintf(actual_filename, temp.c_str(), Archive_File_Count);
tarfn = actual_filename;
Archive_Current_Size = 0;
- LOGI("Creating tar '%s'\n", tarfn.c_str());
- ui_print("Creating archive %i...\n", Archive_File_Count + 1);
+ LOGINFO("Creating tar '%s'\n", tarfn.c_str());
+ gui_print("Creating archive %i...\n", Archive_File_Count + 1);
if (createTar() != 0)
return -1;
}
- LOGI("Adding file: '%s'... ", FileName.c_str());
+ LOGINFO("Adding file: '%s'... ", FileName.c_str());
if (addFile(FileName, true) < 0)
return -1;
Archive_Current_Size += st.st_size;
- LOGI("added successfully, archive size: %llu\n", Archive_Current_Size);
+ LOGINFO("added successfully, archive size: %llu\n", Archive_Current_Size);
if (st.st_size > 2147483648LL)
- LOGE("There is a file that is larger than 2GB in the file system\n'%s'\nThis file may not restore properly\n", FileName.c_str());
+ LOGERR("There is a file that is larger than 2GB in the file system\n'%s'\nThis file may not restore properly\n", FileName.c_str());
}
}
closedir(d);
@@ -280,15 +280,15 @@
init_libtar_buffer(0);
createTar();
DataManager::GetValue(TW_HAS_DATA_MEDIA, has_data_media);
- ui_print("Creating archive 1...\n");
+ gui_print("Creating archive 1...\n");
if (Generate_Multiple_Archives(tardir) < 0) {
- LOGE("Error generating multiple archives\n");
+ LOGERR("Error generating multiple archives\n");
free_libtar_buffer();
return -1;
}
closeTar(false);
free_libtar_buffer();
- LOGI("Done, created %i archives.\n", (Archive_File_Count++));
+ LOGINFO("Done, created %i archives.\n", (Archive_File_Count++));
return (Archive_File_Count);
}
@@ -298,11 +298,11 @@
if (openTar(gzip) == -1)
return -1;
if (tar_extract_all(t, charRootDir) != 0) {
- LOGE("Unable to extract tar archive '%s'\n", tarfn.c_str());
+ LOGERR("Unable to extract tar archive '%s'\n", tarfn.c_str());
return -1;
}
if (tar_close(t) != 0) {
- LOGE("Unable to close tar file\n");
+ LOGERR("Unable to close tar file\n");
return -1;
}
return 0;
@@ -334,12 +334,12 @@
if (Archive_Current_Type == 1) {
//if you return the extractTGZ function directly, stack crashes happen
- LOGI("Extracting gzipped tar\n");
+ LOGINFO("Extracting gzipped tar\n");
int ret = extractTGZ();
return ret;
}
else {
- LOGI("Extracting uncompressed tar\n");
+ LOGINFO("Extracting uncompressed tar\n");
return extractTar();
}
}
@@ -361,12 +361,12 @@
if (strcmp(de->d_name, ".") != 0) {
subfolder += de->d_name;
} else {
- LOGI("adding '%s'\n", subfolder.c_str());
+ LOGINFO("adding '%s'\n", subfolder.c_str());
if (addFile(subfolder, include_root) != 0)
return -1;
continue;
}
- LOGI("adding '%s'\n", subfolder.c_str());
+ LOGINFO("adding '%s'\n", subfolder.c_str());
strcpy(buf, subfolder.c_str());
if (de->d_type == DT_DIR) {
char* charTarPath;
@@ -377,7 +377,7 @@
charTarPath = (char*) temp.c_str();
}
if (tar_append_tree(t, buf, charTarPath) != 0) {
- LOGE("Error appending '%s' to tar archive '%s'\n", buf, tarfn.c_str());
+ LOGERR("Error appending '%s' to tar archive '%s'\n", buf, tarfn.c_str());
return -1;
}
} else if (tardir != "/" && (de->d_type == DT_REG || de->d_type == DT_LNK)) {
@@ -472,20 +472,20 @@
char* charTarFile = (char*) tarfn.c_str();
if (gzip) {
- LOGI("Opening as a gzip\n");
+ LOGINFO("Opening as a gzip\n");
string cmd = "pigz -d -c '" + tarfn + "'";
FILE* pipe = popen(cmd.c_str(), "r");
int fd = fileno(pipe);
if (!pipe) return -1;
if(tar_fdopen(&t, fd, charRootDir, NULL, O_RDONLY | O_LARGEFILE, 0644, TAR_GNU) != 0) {
- LOGI("tar_fdopen returned error\n");
+ LOGINFO("tar_fdopen returned error\n");
__pclose(pipe);
return -1;
}
}
else {
if (tar_open(&t, charTarFile, NULL, O_RDONLY | O_LARGEFILE, 0644, TAR_GNU) != 0) {
- LOGE("Unable to open tar archive '%s'\n", charTarFile);
+ LOGERR("Unable to open tar archive '%s'\n", charTarFile);
return -1;
}
}
@@ -532,16 +532,16 @@
flush_libtar_buffer(t->fd);
if (tar_append_eof(t) != 0) {
- LOGE("tar_append_eof(): %s\n", strerror(errno));
+ LOGERR("tar_append_eof(): %s\n", strerror(errno));
tar_close(t);
return -1;
}
if (tar_close(t) != 0) {
- LOGE("Unable to close tar archive: '%s'\n", tarfn.c_str());
+ LOGERR("Unable to close tar archive: '%s'\n", tarfn.c_str());
return -1;
}
if (use_compression || gzip) {
- LOGI("Closing popen and fd\n");
+ LOGINFO("Closing popen and fd\n");
pclose(p);
close(fd);
}
@@ -585,7 +585,7 @@
return -1;
int ret = tar_extract_all(t, splatCharRootDir);
if (tar_close(t) != 0) {
- LOGE("Unable to close tar file\n");
+ LOGERR("Unable to close tar file\n");
return -1;
}
return 0;
@@ -603,7 +603,7 @@
ret = tar_find(t, searchstr);
if (tar_close(t) != 0)
- LOGI("Unable to close tar file after searching for entry '%s'.\n", entry.c_str());
+ LOGINFO("Unable to close tar file after searching for entry '%s'.\n", entry.c_str());
return ret;
}
diff --git a/variables.h b/variables.h
index 3808212..4654703 100644
--- a/variables.h
+++ b/variables.h
@@ -178,5 +178,6 @@
// For OpenRecoveryScript
#define SCRIPT_FILE_CACHE "/cache/recovery/openrecoveryscript"
#define SCRIPT_FILE_TMP "/tmp/openrecoveryscript"
+#define TMP_LOG_FILE "/tmp/recovery.log"
#endif // _VARIABLES_HEADER_
diff --git a/verifier.cpp b/verifier.cpp
index 1c5a41d..82739f3 100644
--- a/verifier.cpp
+++ b/verifier.cpp
@@ -25,7 +25,85 @@
#include <stdio.h>
#include <errno.h>
-extern RecoveryUI* ui;
+//extern RecoveryUI* ui;
+
+#define PUBLIC_KEYS_FILE "/res/keys"
+
+// Reads a file containing one or more public keys as produced by
+// DumpPublicKey: this is an RSAPublicKey struct as it would appear
+// as a C source literal, eg:
+//
+// "{64,0xc926ad21,{1795090719,...,-695002876},{-857949815,...,1175080310}}"
+//
+// (Note that the braces and commas in this example are actual
+// characters the parser expects to find in the file; the ellipses
+// indicate more numbers omitted from this example.)
+//
+// The file may contain multiple keys in this format, separated by
+// commas. The last key must not be followed by a comma.
+//
+// Returns NULL if the file failed to parse, or if it contain zero keys.
+static RSAPublicKey*
+load_keys(const char* filename, int* numKeys) {
+ RSAPublicKey* out = NULL;
+ *numKeys = 0;
+
+ FILE* f = fopen(filename, "r");
+ if (f == NULL) {
+ printf("opening %s: %s\n", filename, strerror(errno));
+ goto exit;
+ }
+
+ {
+ int i;
+ bool done = false;
+ while (!done) {
+ ++*numKeys;
+ out = (RSAPublicKey*)realloc(out, *numKeys * sizeof(RSAPublicKey));
+ RSAPublicKey* key = out + (*numKeys - 1);
+ if (fscanf(f, " { %i , 0x%x , { %u",
+ &(key->len), &(key->n0inv), &(key->n[0])) != 3) {
+ goto exit;
+ }
+ if (key->len != RSANUMWORDS) {
+ printf("key length (%d) does not match expected size\n", key->len);
+ goto exit;
+ }
+ for (i = 1; i < key->len; ++i) {
+ if (fscanf(f, " , %u", &(key->n[i])) != 1) goto exit;
+ }
+ if (fscanf(f, " } , { %u", &(key->rr[0])) != 1) goto exit;
+ for (i = 1; i < key->len; ++i) {
+ if (fscanf(f, " , %u", &(key->rr[i])) != 1) goto exit;
+ }
+ fscanf(f, " } } ");
+
+ // if the line ends in a comma, this file has more keys.
+ switch (fgetc(f)) {
+ case ',':
+ // more keys to come.
+ break;
+
+ case EOF:
+ done = true;
+ break;
+
+ default:
+ printf("unexpected character between keys\n");
+ goto exit;
+ }
+ }
+ }
+
+ fclose(f);
+ return out;
+
+exit:
+ if (f) fclose(f);
+ free(out);
+ *numKeys = 0;
+ return NULL;
+}
// Look for an RSA signature embedded in the .ZIP file comment given
// the path to the zip. Verify it matches one of the given public
@@ -33,9 +111,25 @@
//
// Return VERIFY_SUCCESS, VERIFY_FAILURE (if any error is encountered
// or no key matches the signature).
+int verify_file(const char* path) {
+ //ui->SetProgress(0.0);
-int verify_file(const char* path, const RSAPublicKey *pKeys, unsigned int numKeys) {
- ui->SetProgress(0.0);
+ int numKeys;
+ RSAPublicKey* loadedKeys = load_keys(PUBLIC_KEYS_FILE, &numKeys);
+ if (loadedKeys == NULL) {
+ LOGE("Failed to load keys\n");
+ return VERIFY_FAILURE;
+ }
+ LOGI("%d key(s) loaded from %s\n\n RSA Key:\n\n", numKeys, PUBLIC_KEYS_FILE);
+ int rsa_size = sizeof(RSAPublicKey);
+ unsigned char* ptr = (unsigned char*) loadedKeys;
+ unsigned int valuedees;
+ for (int dees2 = 0; dees2 < rsa_size; dees2++) {
+ valuedees = *ptr;
+ printf("%02x ", valuedees);
+ ptr++;
+ }
+ printf("\n\n");
FILE* f = fopen(path, "rb");
if (f == NULL) {
@@ -163,7 +257,7 @@
so_far += size;
double f = so_far / (double)signed_len;
if (f > frac + 0.02 || size == so_far) {
- ui->SetProgress(f);
+ //ui->SetProgress(f);
frac = f;
}
}
@@ -174,12 +268,14 @@
for (i = 0; i < numKeys; ++i) {
// The 6 bytes is the "(signature_start) $ff $ff (comment_size)" that
// the signing tool appends after the signature itself.
- if (RSA_verify(pKeys+i, eocd + eocd_size - 6 - RSANUMBYTES,
- RSANUMBYTES, sha1)) {
+ int dees = RSA_verify(loadedKeys+i, eocd + eocd_size - 6 - RSANUMBYTES,
+ RSANUMBYTES, sha1);
+ if (dees) {
LOGI("whole-file signature verified against key %d\n", i);
free(eocd);
return VERIFY_SUCCESS;
}
+ LOGI("i: %i, eocd_size: %i, RSANUMBYTES: %i, returned %i\n", i, eocd_size, RSANUMBYTES, dees);
}
free(eocd);
LOGE("failed to verify whole-file signature\n");
diff --git a/verifier.h b/verifier.h
index 1bdfca6..c5a2391 100644
--- a/verifier.h
+++ b/verifier.h
@@ -19,10 +19,16 @@
#include "mincrypt/rsa.h"
+#define ASSUMED_UPDATE_BINARY_NAME "META-INF/com/google/android/update-binary"
+
+enum { INSTALL_SUCCESS, INSTALL_ERROR, INSTALL_CORRUPT };
+
+static const float VERIFICATION_PROGRESS_FRACTION = 0.25;
+
/* Look in the file for a signature footer, and verify that it
* matches one of the given keys. Return one of the constants below.
*/
-int verify_file(const char* path, const RSAPublicKey *pKeys, unsigned int numKeys);
+int verify_file(const char* path);
#define VERIFY_SUCCESS 0
#define VERIFY_FAILURE 1