android root: restore context for android system root

In this patchset we will store and reset the android system
root context after a wipe and restore to prevent issues
with no context labels in the file_contexts being applied.
This will prevent no boot issues in android with selinux
denials on the system root partition.

Change-Id: I87fd3a6060fbaa3e7bdfd7a4b1d09feeb4fa3f27
(cherry picked from commit 35d2bfda3c89ebd212a9bd2328bffd7464f95d47)
This commit is contained in:
bigbiff
2021-01-23 14:08:03 -05:00
parent e7c34e5715
commit 4a60bee82e
3 changed files with 15 additions and 0 deletions
+5
View File
@@ -1197,6 +1197,10 @@ int TWPartitionManager::Run_Restore(const string& Restore_Name) {
string Full_Filename = part_settings.Backup_Folder + "/" + part_settings.Part->Backup_FileName;
if (tw_get_default_metadata(Get_Android_Root_Path().c_str()) != 0) {
gui_msg(Msg(msg::kWarning, "restore_system_context=Unable to get default context for {1} -- Android may not boot.")(Get_Android_Root_Path()));
}
if (check_digest > 0 && !twrpDigestDriver::Check_Digest(Full_Filename))
return false;
part_settings.partition_count++;
@@ -1252,6 +1256,7 @@ int TWPartitionManager::Run_Restore(const string& Restore_Name) {
}
}
TWFunc::GUI_Operation_Text(TW_UPDATE_SYSTEM_DETAILS_TEXT, gui_parse_text("{@updating_system_details}"));
tw_set_default_metadata(Get_Android_Root_Path().c_str());
UnMount_By_Path(Get_Android_Root_Path(), false);
Update_System_Details();
UnMount_Main_Partitions();