TeamWin / android_bootable_recovery

1.33k stars 415 forks source link

/cache/recovery/command is not processed #144

Open sjevtic opened 3 years ago

sjevtic commented 3 years ago

Device codename: samsung_y2s TWRP version: 3.5.2_10-0

WHAT STEPS WILL REPRODUCE THE PROBLEM?

  1. echo "--wipe_cache" > /cache/recovery/command
  2. reboot recovery

WHAT IS THE EXPECTED RESULT?

TWRP wipes cache and reboots into system.

WHAT HAPPENS INSTEAD?

Nothing. TWRP sits on the main menu indefinitely.

ADDITIONAL INFORMATION

This is core functionality since a system image should be able to expect to perform tasks like a factory reset using the /cache/recovery/command interface.

The breaking change appears to be introduced as part of commit df8436b51ae92449c5b45141d344b14b439bc42b (2020/10/21: fastboot: implement fastbootd in twrp).

Of note, in args::get_args() (bootable/recovery/install/get_args.cpp):

  1. bool has_cache must be true as a precondition for reading /cache/recovery/command, It appears that this variable is initialized to false and never otherwise set.
  2. /cache must also be mounted; ensure_path_mounted(COMMAND_FILE) returns -1.

In main() (bootable/recovery/twrp.cpp):

startupArgs::parse(), the caller of args::get_args(), is called before process_recovery_mode(), which which fstab handling/filesystem mounting is performed. The predecessor to args::get_args() (get_args()) was called much later, after filesystem mounting is complete.

On a related housekeeping note, code that is now unreachable as a consequence of this refactor (e.g., get_args()) remains in the project.

bigbiff commented 3 years ago

Does your device have a dedicated cache partition? I haven't seen that on a device in a while.

Pierre2324 commented 3 years ago

Does your device have a dedicated cache partition? I haven't seen that on a device in a while.

Same happens on poco f1 when using any a10 or up recoveries. Works fine on a9 recovery. Sadly cant use any a9 recovery on poco x3 pro so scripts in there do not work.