Merge "Retrieve a monitor for backup Tasks when it's missing"

This commit is contained in:
Sarp Misoglu
2022-10-25 16:05:17 +00:00
committed by Android (Google) Code Review
3 changed files with 31 additions and 1 deletions

View File

@@ -376,6 +376,16 @@ public class PerformFullTransportBackupTask extends FullBackupTask implements Ba
return;
}
// In some cases there may not be a monitor passed in when creating this task. So, if we
// don't have one already we ask the transport for a monitor.
if (mMonitor == null) {
try {
mMonitor = transport.getBackupManagerMonitor();
} catch (RemoteException e) {
Slog.i(TAG, "Failed to retrieve monitor from transport");
}
}
// Set up to send data to the transport
final int N = mPackages.size();
final byte[] buffer = new byte[8192];

View File

@@ -21,6 +21,7 @@ import static com.android.server.backup.BackupManagerService.MORE_DEBUG;
import static com.android.server.backup.BackupManagerService.TAG;
import android.app.backup.BackupManager.OperationType;
import android.app.backup.IBackupManagerMonitor;
import android.app.backup.RestoreSet;
import android.os.Handler;
import android.os.HandlerThread;
@@ -203,6 +204,14 @@ public class BackupHandler extends Handler {
}
}
// Ask the transport for a monitor that will be used to relay log events back to it.
IBackupManagerMonitor monitor = null;
try {
monitor = transport.getBackupManagerMonitor();
} catch (RemoteException e) {
Slog.i(TAG, "Failed to retrieve monitor from transport");
}
// At this point, we have started a new journal file, and the old
// file identity is being passed to the backup processing task.
// When it completes successfully, that old journal file will be
@@ -225,7 +234,7 @@ public class BackupHandler extends Handler {
queue,
oldJournal,
/* observer */ null,
/* monitor */ null,
monitor,
listener,
Collections.emptyList(),
/* userInitiated */ false,

View File

@@ -18,10 +18,12 @@ package com.android.server.backup.transport;
import android.annotation.Nullable;
import android.app.backup.BackupTransport;
import android.app.backup.IBackupManagerMonitor;
import android.app.backup.RestoreDescription;
import android.app.backup.RestoreSet;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.os.IBinder;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.util.Slog;
@@ -362,6 +364,15 @@ public class BackupTransportClient {
return result == null ? BackupTransport.TRANSPORT_ERROR : result;
}
/**
* See {@link IBackupTransport#getBackupManagerMonitor()}
*/
public IBackupManagerMonitor getBackupManagerMonitor() throws RemoteException {
AndroidFuture<IBackupManagerMonitor> resultFuture = mTransportFutures.newFuture();
mTransportBinder.getBackupManagerMonitor(resultFuture);
return IBackupManagerMonitor.Stub.asInterface((IBinder) getFutureResult(resultFuture));
}
/**
* Allows the {@link TransportConnection} to notify this client
* if the underlying transport has become unusable. If that happens