Merge changes Iba026321,I31690e0b,If991c5b7

* changes:
  Make RescueParty not wipe if checkpointing
  Add Checkpoint's abortChanges
  Add needsCheckpoint
This commit is contained in:
Daniel Rosenberg
2019-03-25 21:17:09 +00:00
committed by Android (Google) Code Review
3 changed files with 46 additions and 0 deletions

View File

@@ -30,6 +30,7 @@ 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;
@@ -38,6 +39,8 @@ 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;
@@ -854,6 +857,21 @@ public class RecoverySystem {
/** {@hide} */
public static void rebootPromptAndWipeUserData(Context context, String reason)
throws IOException {
boolean checkpointing = false;
// 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;
} catch (RemoteException e) {
Log.i(TAG, "Failed to handle with checkpointing. Continuing with wipe.");
}
String reasonArg = null;
if (!TextUtils.isEmpty(reason)) {
reasonArg = "--reason=" + sanitizeArg(reason);

View File

@@ -193,4 +193,6 @@ interface IStorageManager {
void commitChanges() = 83;
boolean supportsCheckpoint() = 84;
void startCheckpoint(int numTries) = 85;
boolean needsCheckpoint() = 86;
void abortChanges(in String message, boolean retry) = 87;
}

View File

@@ -2881,6 +2881,32 @@ class StorageManagerService extends IStorageManager.Stub
mVold.commitChanges();
}
/**
* Check if we should be mounting with checkpointing or are checkpointing now
*/
@Override
public boolean needsCheckpoint() throws RemoteException {
// Only the system process is permitted to commit checkpoints
if (Binder.getCallingUid() != android.os.Process.SYSTEM_UID) {
throw new SecurityException("no permission to commit checkpoint changes");
}
return mVold.needsCheckpoint();
}
/**
* Abort the current set of changes and either try again, or abort entirely
*/
@Override
public void abortChanges(String message, boolean retry) throws RemoteException {
// Only the system process is permitted to abort checkpoints
if (Binder.getCallingUid() != android.os.Process.SYSTEM_UID) {
throw new SecurityException("no permission to commit checkpoint changes");
}
mVold.abortChanges(message, retry);
}
@Override
public String getPassword() throws RemoteException {
mContext.enforceCallingOrSelfPermission(Manifest.permission.CRYPT_KEEPER,