updater: boot the installed slot via a configurable reboot reason

Replace the config_use_tryboot boolean with a config_abRebootReason string
passed straight to PowerManager.reboot() (empty = normal reboot). RPi
overrides it to "2" so the candidate slot boots via a one-shot reboot,2
(partition 2 = boot_b); tryboot is now reserved for recovery entry. No
behavior change on devices that leave the reason empty.
This commit is contained in:
oxmc
2026-07-15 21:37:54 -07:00
parent d253b57d1d
commit 2fb8e31cfd
4 changed files with 16 additions and 5 deletions
@@ -78,7 +78,7 @@ public class UpdaterReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
if (ACTION_INSTALL_REBOOT.equals(intent.getAction())) {
PowerManager pm = context.getSystemService(PowerManager.class);
pm.reboot(Utils.usesTryboot(context) ? "tryboot" : null);
pm.reboot(Utils.getAbRebootReason(context));
} else if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
pref.edit().remove(Constants.PREF_NEEDS_REBOOT_ID).apply();
@@ -412,7 +412,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
button.setEnabled(enabled);
clickListener = enabled ? view -> {
PowerManager pm = mActivity.getSystemService(PowerManager.class);
pm.reboot(Utils.usesTryboot(mActivity) ? "tryboot" : null);
pm.reboot(Utils.getAbRebootReason(mActivity));
} : null;
}
break;
@@ -420,7 +420,14 @@ public class Utils {
return new File(Constants.UPDATE_RECOVERY_EXEC).exists();
}
public static boolean usesTryboot(Context context) {
return context.getResources().getBoolean(R.bool.config_use_tryboot);
/**
* Reason to pass to {@link android.os.PowerManager#reboot} when booting the
* freshly-installed slot, or {@code null} for a normal reboot. Devices whose
* firmware needs an explicit slot boot set config_abRebootReason (e.g. RPi
* uses "2" to one-shot boot partition 2 = boot_b).
*/
public static String getAbRebootReason(Context context) {
String reason = context.getResources().getString(R.string.config_abRebootReason);
return (reason == null || reason.isEmpty()) ? null : reason;
}
}
+5 -1
View File
@@ -5,5 +5,9 @@
-->
<resources>
<bool name="config_hideRecoveryUpdate">false</bool>
<bool name="config_use_tryboot">false</bool>
<!-- Reason passed to PowerManager.reboot() to boot the freshly-installed
slot. Empty = normal reboot. Devices whose firmware needs an explicit
slot boot override this (e.g. RPi sets "2" to one-shot boot partition 2
= boot_b); see the device vendor.prop / config.txt. -->
<string name="config_abRebootReason" translatable="false"></string>
</resources>