From d078d8b15c785db4984f9f032617742e32d18036 Mon Sep 17 00:00:00 2001 From: Daniel Rosenberg Date: Thu, 20 Jun 2019 15:15:58 -0700 Subject: [PATCH] Make RescueParty call vold directly This changes RescueParty to call vold over binder directly for Checkpointing related calls. It turns out that if the system is in a bad enough state, the other method would not work, as some of the services required would not be running. Bug: 135558798 Test: setprop persist.sys.enable_rescue 1 setprop debug.crash_system 1 or setprop debug.crash_sysui 1 vdc checkpoint startCheckpoint 3 stop start Device should go through the rescueparty flow, and reboot. Repeat without checkpoint. Device should prompt reboot. Change-Id: I8b11d68075cc291e9557d524bc87b54d17b370e4 --- core/java/android/os/RecoverySystem.java | 32 ++++++++++++++++-------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/core/java/android/os/RecoverySystem.java b/core/java/android/os/RecoverySystem.java index 1b41694e7d485..53298d8d8aed8 100644 --- a/core/java/android/os/RecoverySystem.java +++ b/core/java/android/os/RecoverySystem.java @@ -30,7 +30,6 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; -import android.os.storage.IStorageManager; import android.provider.Settings; import android.telephony.euicc.EuiccManager; import android.text.TextUtils; @@ -39,8 +38,6 @@ import android.util.Log; import android.view.Display; import android.view.WindowManager; -import com.android.internal.content.PackageHelper; - import libcore.io.Streams; import java.io.ByteArrayInputStream; @@ -858,18 +855,31 @@ public class RecoverySystem { public static void rebootPromptAndWipeUserData(Context context, String reason) throws IOException { boolean checkpointing = false; + boolean needReboot = false; + IVold vold = null; + try { + vold = IVold.Stub.asInterface(ServiceManager.checkService("vold")); + if (vold != null) { + checkpointing = vold.needsCheckpoint(); + } else { + Log.w(TAG, "Failed to get vold"); + } + } catch (Exception e) { + Log.w(TAG, "Failed to check for checkpointing"); + } // If we are running in checkpointing mode, we should not prompt a wipe. // Checkpointing may save us. If it doesn't, we will wind up here again. - try { - IStorageManager storageManager = PackageHelper.getStorageManager(); - if (storageManager.needsCheckpoint()) { - Log.i(TAG, "Rescue Party requested wipe. Aborting update instead."); - storageManager.abortChanges("rescueparty", false); - return; + if (checkpointing) { + try { + vold.abortChanges("rescueparty", false); + Log.i(TAG, "Rescue Party requested wipe. Aborting update"); + } catch (Exception e) { + Log.i(TAG, "Rescue Party requested wipe. Rebooting instead."); + PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); + pm.reboot("rescueparty"); } - } catch (RemoteException e) { - Log.i(TAG, "Failed to handle with checkpointing. Continuing with wipe."); + return; } String reasonArg = null;