Allow building of an OEM friendly TWRP

Disable theming
Disable creating the TWRP folder for the settings file
Change factory reset on data/media devices to a full wipe

Change-Id: I3104282b5dd3f55dfff7c8cf39c72750af08563d
This commit is contained in:
Ethan Yonker
2014-04-04 10:59:28 -05:00
parent 26774a02f9
commit 83e82578af
6 changed files with 24 additions and 4 deletions
+3
View File
@@ -278,6 +278,9 @@ endif
ifneq ($(wildcard bionic/libc/include/sys/capability.h),)
LOCAL_CFLAGS += -DHAVE_CAPABILITIES
endif
ifeq ($(TW_OEM_BUILD),true)
LOCAL_CFLAGS += -DTW_OEM_BUILD
endif
include $(BUILD_EXECUTABLE)
+4
View File
@@ -294,6 +294,7 @@ int DataManager::Flush()
int DataManager::SaveValues()
{
#ifndef TW_OEM_BUILD
if (mBackingFile.empty())
return -1;
@@ -322,6 +323,7 @@ int DataManager::SaveValues()
}
}
fclose(out);
#endif // ifdef TW_OEM_BUILD
return 0;
}
@@ -1078,6 +1080,7 @@ void DataManager::Output_Version(void)
void DataManager::ReadSettingsFile(void)
{
#ifndef TW_OEM_BUILD
// Load up the values for TWRP - Sleep to let the card be ready
char mkdir_path[255], settings_file[255];
int is_enc, has_dual, use_ext, has_data_media, has_ext;
@@ -1127,6 +1130,7 @@ void DataManager::ReadSettingsFile(void)
GetValue(TW_EXTERNAL_PATH, ext_path);
PartitionManager.Mount_By_Path(ext_path, 0);
}
#endif // ifdef TW_OEM_BUILD
update_tz_environment_variables();
#ifdef TW_MAX_BRIGHTNESS
if (strcmp(EXPAND(TW_BRIGHTNESS_PATH), "/nobrightness") != 0) {
+3
View File
@@ -68,6 +68,9 @@ endif
ifeq ($(HAVE_SELINUX), true)
LOCAL_CFLAGS += -DHAVE_SELINUX
endif
ifeq ($(TW_OEM_BUILD),true)
LOCAL_CFLAGS += -DTW_OEM_BUILD
endif
ifeq ($(DEVICE_RESOLUTION),)
$(warning ********************************************************************************)
+2 -1
View File
@@ -800,7 +800,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
}
} else
ret_val = PartitionManager.Wipe_By_Path(arg);
#ifdef TW_OEM_BUILD
if (arg == DataManager::GetSettingsStoragePath()) {
// If we wiped the settings storage path, recreate the TWRP folder and dump the settings
string Storage_Path = DataManager::GetSettingsStoragePath();
@@ -814,6 +814,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
LOGERR("Unable to recreate TWRP folder and save settings.\n");
}
}
#endif
}
PartitionManager.Update_System_Details();
if (ret_val)
+5 -3
View File
@@ -692,7 +692,7 @@ extern "C" int gui_loadResources(void)
// unlink("/sdcard/video.last");
// rename("/sdcard/video.bin", "/sdcard/video.last");
// gRecorder = open("/sdcard/video.bin", O_CREAT | O_WRONLY);
#ifndef TW_OEM_BUILD
int check = 0;
DataManager::GetValue(TW_IS_ENCRYPTED, check);
if (check)
@@ -731,14 +731,16 @@ extern "C" int gui_loadResources(void)
theme_path += "/TWRP/theme/ui.zip";
if (check || PageManager::LoadPackage("TWRP", theme_path, "main"))
{
#endif // ifndef TW_OEM_BUILD
if (PageManager::LoadPackage("TWRP", "/res/ui.xml", "main"))
{
LOGERR("Failed to load base packages.\n");
goto error;
}
#ifndef TW_OEM_BUILD
}
}
#endif // ifndef TW_OEM_BUILD
// Set the default package
PageManager::SelectPackage("TWRP");
@@ -746,7 +748,7 @@ extern "C" int gui_loadResources(void)
return 0;
error:
LOGERR("An internal error has occurred.\n");
LOGERR("An internal error has occurred: unable to load theme.\n");
gGuiInitialized = 0;
return -1;
}
+7
View File
@@ -1312,7 +1312,9 @@ bool TWPartition::Wipe_Encryption() {
if (Has_Data_Media && !Symlink_Mount_Point.empty()) {
Recreate_Media_Folder();
}
#ifndef TW_OEM_BUILD
gui_print("You may need to reboot recovery to be able to use /data again.\n");
#endif
return true;
} else {
Has_Data_Media = Save_Data_Media;
@@ -1556,6 +1558,10 @@ bool TWPartition::Wipe_F2FS() {
}
bool TWPartition::Wipe_Data_Without_Wiping_Media() {
#ifdef TW_OEM_BUILD
// In an OEM Build we want to do a full format
return Wipe_Encryption();
#else
string dir;
#ifdef HAVE_SELINUX
fixPermissions perms;
@@ -1599,6 +1605,7 @@ bool TWPartition::Wipe_Data_Without_Wiping_Media() {
}
gui_print("Dirent failed to open /data, error!\n");
return false;
#endif // ifdef TW_OEM_BUILD
}
bool TWPartition::Backup_Tar(string backup_folder) {