Skip to content

Commit e8d12e4

Browse files
Revert "Implement autodetection for SAR, based on the installed system"
This reverts commit d6b7de5. Signed-off-by: Mohd Faraz <[email protected]>
1 parent 1d1043f commit e8d12e4

File tree

4 files changed

+16
-82
lines changed

4 files changed

+16
-82
lines changed

partition.cpp

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ TWPartition::~TWPartition(void) {
291291
// Do nothing
292292
}
293293

294-
bool TWPartition::Process_Fstab_Line(const char *fstab_line, bool Display_Error, std::map<string, Flags_Map> *twrp_flags, bool Sar_Detect) {
294+
bool TWPartition::Process_Fstab_Line(const char *fstab_line, bool Display_Error, std::map<string, Flags_Map> *twrp_flags) {
295295
char full_line[MAX_FSTAB_LINE_LENGTH];
296296
char twflags[MAX_FSTAB_LINE_LENGTH] = "";
297297
char* ptr;
@@ -339,12 +339,11 @@ bool TWPartition::Process_Fstab_Line(const char *fstab_line, bool Display_Error,
339339
Mount_Point = ptr;
340340
if (fstab_version == 2 && Is_Super == false) {
341341
additional_entry = PartitionManager.Find_Partition_By_Path(Mount_Point);
342-
if (!Sar_Detect && additional_entry) {
342+
if (additional_entry) {
343343
LOGINFO("Found an additional entry for '%s'\n", Mount_Point.c_str());
344344
}
345345
}
346-
if(!Sar_Detect)
347-
LOGINFO("Processing '%s'\n", Mount_Point.c_str());
346+
LOGINFO("Processing '%s'\n", Mount_Point.c_str());
348347
Backup_Path = Mount_Point;
349348
Storage_Path = Mount_Point;
350349
Display_Name = ptr + 1;
@@ -436,12 +435,7 @@ bool TWPartition::Process_Fstab_Line(const char *fstab_line, bool Display_Error,
436435
if (Primary_Block_Device.find("*") != string::npos)
437436
Wildcard_Block_Device = true;
438437

439-
if (Sar_Detect) {
440-
if(Is_File_System(Fstab_File_System) && (Mount_Point == "/" || Mount_Point == "/system" || Mount_Point == "/system_root"))
441-
Find_Actual_Block_Device();
442-
else
443-
return true;
444-
} else if (Mount_Point == "auto") {
438+
if (Mount_Point == "auto") {
445439
Mount_Point = "/auto";
446440
char autoi[5];
447441
sprintf(autoi, "%i", auto_index);
@@ -470,6 +464,9 @@ bool TWPartition::Process_Fstab_Line(const char *fstab_line, bool Display_Error,
470464
Setup_File_System(Display_Error);
471465
Backup_Name = Display_Name = Mount_Point.substr(1, Mount_Point.size() - 1);
472466
if (Mount_Point == "/" || Mount_Point == "/system" || Mount_Point == "/system_root") {
467+
Mount_Point = PartitionManager.Get_Android_Root_Path();
468+
Backup_Path = Mount_Point;
469+
Storage_Path = Mount_Point;
473470
Display_Name = "System";
474471
Backup_Name = "system";
475472
Backup_Display_Name = Display_Name;
@@ -646,24 +643,6 @@ bool TWPartition::Process_Fstab_Line(const char *fstab_line, bool Display_Error,
646643
}
647644
}
648645

649-
if (Is_File_System(Fstab_File_System) && (Mount_Point == "/" || Mount_Point == "/system" || Mount_Point == "/system_root")) {
650-
if (Sar_Detect) {
651-
Mount_Point = "/s";
652-
Mount_Read_Only = true;
653-
Can_Be_Mounted = true;
654-
} else {
655-
Mount_Point = PartitionManager.Get_Android_Root_Path();
656-
Backup_Path = Mount_Point;
657-
Storage_Path = Mount_Point;
658-
Make_Dir(Mount_Point, Display_Error);
659-
}
660-
if (Is_Super) {
661-
Can_Be_Backed_Up = false;
662-
Can_Be_Wiped = false;
663-
Wipe_Available_in_GUI = false;
664-
}
665-
}
666-
667646
return true;
668647
}
669648

@@ -3101,7 +3080,7 @@ bool TWPartition::Find_Wildcard_Block_Devices(const string& Device) {
31013080
TWPartition *part = new TWPartition;
31023081
char buffer[MAX_FSTAB_LINE_LENGTH];
31033082
sprintf(buffer, "%s %s-%i auto defaults defaults", item.c_str(), Mount_Point.c_str(), ++mount_point_index);
3104-
part->Process_Fstab_Line(buffer, false, NULL, false);
3083+
part->Process_Fstab_Line(buffer, false, NULL);
31053084
char display[MAX_FSTAB_LINE_LENGTH];
31063085
sprintf(display, "%s %i", Storage_Name.c_str(), mount_point_index);
31073086
part->Storage_Name = display;

partitionmanager.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,7 @@ int TWPartitionManager::Set_Crypto_Type(const char* crypto_type) {
162162
return 0;
163163
}
164164

165-
int TWPartitionManager::Process_Fstab(string Fstab_Filename, bool Display_Error, bool recovery_mode,
166-
bool Sar_Detect) {
165+
int TWPartitionManager::Process_Fstab(string Fstab_Filename, bool Display_Error, bool recovery_mode) {
167166
FILE* fstabFile;
168167
char fstab_line[MAX_FSTAB_LINE_LENGTH];
169168
std::map<string, Flags_Map> twrp_flags;
@@ -239,7 +238,7 @@ int TWPartitionManager::Process_Fstab(string Fstab_Filename, bool Display_Error,
239238
if (fstab_line[line_size - 1] != '\n') fstab_line[line_size] = '\n';
240239

241240
TWPartition* partition = new TWPartition();
242-
if (partition->Process_Fstab_Line(fstab_line, Display_Error, &twrp_flags, Sar_Detect))
241+
if (partition->Process_Fstab_Line(fstab_line, Display_Error, &twrp_flags))
243242
Partitions.push_back(partition);
244243
else
245244
delete partition;
@@ -255,8 +254,7 @@ int TWPartitionManager::Process_Fstab(string Fstab_Filename, bool Display_Error,
255254
mapit != twrp_flags.end(); mapit++) {
256255
if (Find_Partition_By_Path(mapit->first) == NULL) {
257256
TWPartition* partition = new TWPartition();
258-
if (partition->Process_Fstab_Line(mapit->second.fstab_line, Display_Error, NULL,
259-
Sar_Detect))
257+
if (partition->Process_Fstab_Line(mapit->second.fstab_line, Display_Error, NULL))
260258
Partitions.push_back(partition);
261259
else
262260
delete partition;
@@ -3363,8 +3361,7 @@ string TWPartitionManager::Get_Active_Slot_Display() {
33633361
}
33643362

33653363
string TWPartitionManager::Get_Android_Root_Path() {
3366-
if (property_get_bool("ro.twrp.sar", false)) return "/system_root";
3367-
return "/system";
3364+
return "/system_root";
33683365
}
33693366

33703367
void TWPartitionManager::Remove_Uevent_Devices(const string& Mount_Point) {

partitions.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class TWPartition
181181
void Set_Block_Device(std::string block_device); // Allow super partition setup to change block device
182182

183183
private:
184-
bool Process_Fstab_Line(const char *fstab_line, bool Display_Error, std::map<string, Flags_Map> *twrp_flags, bool Sar_Detect); // Processes a fstab line
184+
bool Process_Fstab_Line(const char *fstab_line, bool Display_Error, std::map<string, Flags_Map> *twrp_flags); // Processes a fstab line
185185
void Setup_Data_Partition(bool Display_Error); // Setup data partition after fstab processed
186186
void Set_FBE_Status(); // Set FBE status of partition
187187
void Setup_Cache_Partition(bool Display_Error); // Setup cache partition after fstab processed
@@ -317,7 +317,7 @@ class TWPartitionManager
317317
~TWPartitionManager() {}
318318

319319
public:
320-
int Process_Fstab(string Fstab_Filename, bool Display_Error, bool recovery_mode, bool Sar_Detect); // Parses the fstab files
320+
int Process_Fstab(string Fstab_Filename, bool Display_Error, bool recovery_mode); // Parses the fstab files
321321
void Setup_Fstab_Partitions(bool Display_Error); // Populates the partitions
322322
int Write_Fstab(); // Creates /etc/fstab file that's used by the command line for mount commands
323323
void Decrypt_Data(); // Decrypt Data if enabled

twrp.cpp

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -148,51 +148,9 @@ static void process_recovery_mode(twrpAdbBuFifo* adb_bu_fifo, bool skip_decrypti
148148
if (!TWFunc::Path_Exists(fstab_filename))
149149
fstab_filename = "/etc/recovery.fstab";
150150
}
151-
152-
// Begin SAR detection
153-
{
154-
TWPartitionManager SarPartitionManager;
155-
printf("=> Processing %s for SAR-detection\n", fstab_filename.c_str());
156-
if (!SarPartitionManager.Process_Fstab(fstab_filename, 1, 1, 1)) {
157-
LOGERR("Failing out of recovery due to problem with fstab.\n");
158-
return;
159-
}
160-
161-
mkdir("/s", 0755);
162-
163-
#if defined(AB_OTA_UPDATER) || defined(__ANDROID_API_Q__)
164-
bool fallback_sar = true;
165-
#else
166-
bool fallback_sar = property_get_bool("ro.build.system_root_image", false);
167-
#endif
168-
169-
if(SarPartitionManager.Mount_By_Path("/s", false)) {
170-
if (TWFunc::Path_Exists("/s/build.prop")) {
171-
LOGINFO("SAR-DETECT: Non-SAR System detected\n");
172-
property_set("ro.twrp.sar", "0");
173-
rmdir("/system_root");
174-
} else if (TWFunc::Path_Exists("/s/system/build.prop")) {
175-
LOGINFO("SAR-DETECT: SAR System detected\n");
176-
property_set("ro.twrp.sar", "1");
177-
} else {
178-
LOGINFO("SAR-DETECT: No build.prop found, falling back to %s\n", fallback_sar ? "SAR" : "Non-SAR");
179-
property_set("ro.twrp.sar", fallback_sar ? "1" : "0");
180-
}
181-
182-
SarPartitionManager.UnMount_By_Path("/s", false);
183-
} else {
184-
LOGINFO("SAR-DETECT: Could not mount system partition, falling back to %s\n", fallback_sar ? "SAR":"Non-SAR");
185-
property_set("ro.twrp.sar", fallback_sar ? "1" : "0");
186-
}
187-
188-
rmdir("/s");
189-
190-
TWFunc::check_and_run_script("/system/bin/sarsetup.sh", "boot");
191-
}
192-
// End SAR detection
193-
151+
property_set("ro.twrp.sar", "1");
194152
printf("=> Processing %s\n", fstab_filename.c_str());
195-
if (!PartitionManager.Process_Fstab(fstab_filename, 1, true, false)) {
153+
if (!PartitionManager.Process_Fstab(fstab_filename, 1, true)) {
196154
LOGERR("Failing out of recovery due to problem with fstab.\n");
197155
return;
198156
}

0 commit comments

Comments
 (0)