Merge "Rename TransportClient to TransportConnection"
This commit is contained in:
committed by
Android (Google) Code Review
commit
fecb63e7d0
@@ -40,8 +40,8 @@ import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.backup.IBackupTransport;
|
||||
import com.android.internal.util.Preconditions;
|
||||
import com.android.server.backup.transport.OnTransportRegisteredListener;
|
||||
import com.android.server.backup.transport.TransportClient;
|
||||
import com.android.server.backup.transport.TransportClientManager;
|
||||
import com.android.server.backup.transport.TransportConnection;
|
||||
import com.android.server.backup.transport.TransportConnectionManager;
|
||||
import com.android.server.backup.transport.TransportConnectionListener;
|
||||
import com.android.server.backup.transport.TransportNotAvailableException;
|
||||
import com.android.server.backup.transport.TransportNotRegisteredException;
|
||||
@@ -65,7 +65,7 @@ public class TransportManager {
|
||||
private final @UserIdInt int mUserId;
|
||||
private final PackageManager mPackageManager;
|
||||
private final Set<ComponentName> mTransportWhitelist;
|
||||
private final TransportClientManager mTransportClientManager;
|
||||
private final TransportConnectionManager mTransportConnectionManager;
|
||||
private final TransportStats mTransportStats;
|
||||
private OnTransportRegisteredListener mOnTransportRegisteredListener = (c, n) -> {};
|
||||
|
||||
@@ -73,8 +73,8 @@ public class TransportManager {
|
||||
* Lock for registered transports and currently selected transport.
|
||||
*
|
||||
* <p><b>Warning:</b> No calls to {@link IBackupTransport} or calls that result in transport
|
||||
* code being executed such as {@link TransportClient#connect(String)}} and its variants should
|
||||
* be made with this lock held, risk of deadlock.
|
||||
* code being executed such as {@link TransportConnection#connect(String)}} and its variants
|
||||
* should be made with this lock held, risk of deadlock.
|
||||
*/
|
||||
private final Object mTransportLock = new Object();
|
||||
|
||||
@@ -94,7 +94,8 @@ public class TransportManager {
|
||||
mTransportWhitelist = Preconditions.checkNotNull(whitelist);
|
||||
mCurrentTransportName = selectedTransport;
|
||||
mTransportStats = new TransportStats();
|
||||
mTransportClientManager = new TransportClientManager(mUserId, context, mTransportStats);
|
||||
mTransportConnectionManager = new TransportConnectionManager(mUserId, context,
|
||||
mTransportStats);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -103,13 +104,13 @@ public class TransportManager {
|
||||
Context context,
|
||||
Set<ComponentName> whitelist,
|
||||
String selectedTransport,
|
||||
TransportClientManager transportClientManager) {
|
||||
TransportConnectionManager transportConnectionManager) {
|
||||
mUserId = userId;
|
||||
mPackageManager = context.getPackageManager();
|
||||
mTransportWhitelist = Preconditions.checkNotNull(whitelist);
|
||||
mCurrentTransportName = selectedTransport;
|
||||
mTransportStats = new TransportStats();
|
||||
mTransportClientManager = transportClientManager;
|
||||
mTransportConnectionManager = transportConnectionManager;
|
||||
}
|
||||
|
||||
/* Sets a listener to be called whenever a transport is registered. */
|
||||
@@ -307,7 +308,7 @@ public class TransportManager {
|
||||
* transportConsumer}.
|
||||
*
|
||||
* <p><b>Warning:</b> Do NOT make any calls to {@link IBackupTransport} or call any variants of
|
||||
* {@link TransportClient#connect(String)} here, otherwise you risk deadlock.
|
||||
* {@link TransportConnection#connect(String)} here, otherwise you risk deadlock.
|
||||
*/
|
||||
public void forEachRegisteredTransport(Consumer<String> transportConsumer) {
|
||||
synchronized (mTransportLock) {
|
||||
@@ -407,17 +408,17 @@ public class TransportManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link TransportClient} for {@code transportName} or {@code null} if not
|
||||
* Returns a {@link TransportConnection} for {@code transportName} or {@code null} if not
|
||||
* registered.
|
||||
*
|
||||
* @param transportName The name of the transport.
|
||||
* @param caller A {@link String} identifying the caller for logging/debugging purposes. Check
|
||||
* {@link TransportClient#connectAsync(TransportConnectionListener, String)} for more
|
||||
* {@link TransportConnection#connectAsync(TransportConnectionListener, String)} for more
|
||||
* details.
|
||||
* @return A {@link TransportClient} or null if not registered.
|
||||
* @return A {@link TransportConnection} or null if not registered.
|
||||
*/
|
||||
@Nullable
|
||||
public TransportClient getTransportClient(String transportName, String caller) {
|
||||
public TransportConnection getTransportClient(String transportName, String caller) {
|
||||
try {
|
||||
return getTransportClientOrThrow(transportName, caller);
|
||||
} catch (TransportNotRegisteredException e) {
|
||||
@@ -427,38 +428,38 @@ public class TransportManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link TransportClient} for {@code transportName} or throws if not registered.
|
||||
* Returns a {@link TransportConnection} for {@code transportName} or throws if not registered.
|
||||
*
|
||||
* @param transportName The name of the transport.
|
||||
* @param caller A {@link String} identifying the caller for logging/debugging purposes. Check
|
||||
* {@link TransportClient#connectAsync(TransportConnectionListener, String)} for more
|
||||
* {@link TransportConnection#connectAsync(TransportConnectionListener, String)} for more
|
||||
* details.
|
||||
* @return A {@link TransportClient}.
|
||||
* @return A {@link TransportConnection}.
|
||||
* @throws TransportNotRegisteredException if the transport is not registered.
|
||||
*/
|
||||
public TransportClient getTransportClientOrThrow(String transportName, String caller)
|
||||
public TransportConnection getTransportClientOrThrow(String transportName, String caller)
|
||||
throws TransportNotRegisteredException {
|
||||
synchronized (mTransportLock) {
|
||||
ComponentName component = getRegisteredTransportComponentLocked(transportName);
|
||||
if (component == null) {
|
||||
throw new TransportNotRegisteredException(transportName);
|
||||
}
|
||||
return mTransportClientManager.getTransportClient(component, caller);
|
||||
return mTransportConnectionManager.getTransportClient(component, caller);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link TransportClient} for the current transport or {@code null} if not
|
||||
* Returns a {@link TransportConnection} for the current transport or {@code null} if not
|
||||
* registered.
|
||||
*
|
||||
* @param caller A {@link String} identifying the caller for logging/debugging purposes. Check
|
||||
* {@link TransportClient#connectAsync(TransportConnectionListener, String)} for more
|
||||
* {@link TransportConnection#connectAsync(TransportConnectionListener, String)} for more
|
||||
* details.
|
||||
* @return A {@link TransportClient} or null if not registered.
|
||||
* @return A {@link TransportConnection} or null if not registered.
|
||||
* @throws IllegalStateException if no transport is selected.
|
||||
*/
|
||||
@Nullable
|
||||
public TransportClient getCurrentTransportClient(String caller) {
|
||||
public TransportConnection getCurrentTransportClient(String caller) {
|
||||
if (mCurrentTransportName == null) {
|
||||
throw new IllegalStateException("No transport selected");
|
||||
}
|
||||
@@ -468,16 +469,16 @@ public class TransportManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link TransportClient} for the current transport or throws if not registered.
|
||||
* Returns a {@link TransportConnection} for the current transport or throws if not registered.
|
||||
*
|
||||
* @param caller A {@link String} identifying the caller for logging/debugging purposes. Check
|
||||
* {@link TransportClient#connectAsync(TransportConnectionListener, String)} for more
|
||||
* {@link TransportConnection#connectAsync(TransportConnectionListener, String)} for more
|
||||
* details.
|
||||
* @return A {@link TransportClient}.
|
||||
* @return A {@link TransportConnection}.
|
||||
* @throws TransportNotRegisteredException if the transport is not registered.
|
||||
* @throws IllegalStateException if no transport is selected.
|
||||
*/
|
||||
public TransportClient getCurrentTransportClientOrThrow(String caller)
|
||||
public TransportConnection getCurrentTransportClientOrThrow(String caller)
|
||||
throws TransportNotRegisteredException {
|
||||
if (mCurrentTransportName == null) {
|
||||
throw new IllegalStateException("No transport selected");
|
||||
@@ -488,15 +489,15 @@ public class TransportManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Disposes of the {@link TransportClient}.
|
||||
* Disposes of the {@link TransportConnection}.
|
||||
*
|
||||
* @param transportClient The {@link TransportClient} to be disposed of.
|
||||
* @param transportConnection The {@link TransportConnection} to be disposed of.
|
||||
* @param caller A {@link String} identifying the caller for logging/debugging purposes. Check
|
||||
* {@link TransportClient#connectAsync(TransportConnectionListener, String)} for more
|
||||
* {@link TransportConnection#connectAsync(TransportConnectionListener, String)} for more
|
||||
* details.
|
||||
*/
|
||||
public void disposeOfTransportClient(TransportClient transportClient, String caller) {
|
||||
mTransportClientManager.disposeOfTransportClient(transportClient, caller);
|
||||
public void disposeOfTransportClient(TransportConnection transportConnection, String caller) {
|
||||
mTransportConnectionManager.disposeOfTransportClient(transportConnection, caller);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -637,15 +638,16 @@ public class TransportManager {
|
||||
Bundle extras = new Bundle();
|
||||
extras.putBoolean(BackupTransport.EXTRA_TRANSPORT_REGISTRATION, true);
|
||||
|
||||
TransportClient transportClient =
|
||||
mTransportClientManager.getTransportClient(
|
||||
TransportConnection transportConnection =
|
||||
mTransportConnectionManager.getTransportClient(
|
||||
transportComponent, extras, callerLogString);
|
||||
final IBackupTransport transport;
|
||||
try {
|
||||
transport = transportClient.connectOrThrow(callerLogString);
|
||||
transport = transportConnection.connectOrThrow(callerLogString);
|
||||
} catch (TransportNotAvailableException e) {
|
||||
Slog.e(TAG, "Couldn't connect to transport " + transportString + " for registration");
|
||||
mTransportClientManager.disposeOfTransportClient(transportClient, callerLogString);
|
||||
mTransportConnectionManager.disposeOfTransportClient(transportConnection,
|
||||
callerLogString);
|
||||
return BackupManager.ERROR_TRANSPORT_UNAVAILABLE;
|
||||
}
|
||||
|
||||
@@ -667,7 +669,7 @@ public class TransportManager {
|
||||
result = BackupManager.ERROR_TRANSPORT_UNAVAILABLE;
|
||||
}
|
||||
|
||||
mTransportClientManager.disposeOfTransportClient(transportClient, callerLogString);
|
||||
mTransportConnectionManager.disposeOfTransportClient(transportConnection, callerLogString);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -695,7 +697,7 @@ public class TransportManager {
|
||||
}
|
||||
|
||||
public void dumpTransportClients(PrintWriter pw) {
|
||||
mTransportClientManager.dump(pw);
|
||||
mTransportConnectionManager.dump(pw);
|
||||
}
|
||||
|
||||
public void dumpTransportStats(PrintWriter pw) {
|
||||
|
||||
@@ -59,16 +59,17 @@ import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
/**
|
||||
* A {@link TransportClient} manages the connection to an {@link IBackupTransport} service, obtained
|
||||
* via the {@param bindIntent} parameter provided in the constructor. A {@link TransportClient} is
|
||||
* responsible for only one connection to the transport service, not more.
|
||||
* A {@link TransportConnection} manages the connection to an {@link IBackupTransport} service,
|
||||
* obtained via the {@param bindIntent} parameter provided in the constructor. A
|
||||
* {@link TransportConnection} is responsible for only one connection to the transport service,
|
||||
* not more.
|
||||
*
|
||||
* <p>After retrieved using {@link TransportManager#getTransportClient(String, String)}, you can
|
||||
* call either {@link #connect(String)}, if you can block your thread, or {@link
|
||||
* #connectAsync(TransportConnectionListener, String)}, otherwise, to obtain a {@link
|
||||
* IBackupTransport} instance. It's meant to be passed around as a token to a connected transport.
|
||||
* When the connection is not needed anymore you should call {@link #unbind(String)} or indirectly
|
||||
* via {@link TransportManager#disposeOfTransportClient(TransportClient, String)}.
|
||||
* via {@link TransportManager#disposeOfTransportClient(TransportConnection, String)}.
|
||||
*
|
||||
* <p>DO NOT forget to unbind otherwise there will be dangling connections floating around.
|
||||
*
|
||||
@@ -76,8 +77,8 @@ import java.util.concurrent.ExecutionException;
|
||||
*
|
||||
* @see TransportManager
|
||||
*/
|
||||
public class TransportClient {
|
||||
@VisibleForTesting static final String TAG = "TransportClient";
|
||||
public class TransportConnection {
|
||||
@VisibleForTesting static final String TAG = "TransportConnection";
|
||||
private static final int LOG_BUFFER_SIZE = 5;
|
||||
|
||||
private final @UserIdInt int mUserId;
|
||||
@@ -107,7 +108,7 @@ public class TransportClient {
|
||||
@GuardedBy("mStateLock")
|
||||
private volatile IBackupTransport mTransport;
|
||||
|
||||
TransportClient(
|
||||
TransportConnection(
|
||||
@UserIdInt int userId,
|
||||
Context context,
|
||||
TransportStats transportStats,
|
||||
@@ -127,7 +128,7 @@ public class TransportClient {
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
TransportClient(
|
||||
TransportConnection(
|
||||
@UserIdInt int userId,
|
||||
Context context,
|
||||
TransportStats transportStats,
|
||||
@@ -144,7 +145,7 @@ public class TransportClient {
|
||||
mIdentifier = identifier;
|
||||
mCreatorLogString = caller;
|
||||
mListenerHandler = listenerHandler;
|
||||
mConnection = new TransportConnection(context, this);
|
||||
mConnection = new TransportConnectionMonitor(context, this);
|
||||
|
||||
// For logging
|
||||
String classNameForLog = mTransportComponent.getShortClassName().replaceFirst(".*\\.", "");
|
||||
@@ -192,7 +193,7 @@ public class TransportClient {
|
||||
* For unusable transport binders check {@link DeadObjectException}.
|
||||
*
|
||||
* @param listener The listener that will be called with the (possibly null or unusable) {@link
|
||||
* IBackupTransport} instance and this {@link TransportClient} object.
|
||||
* IBackupTransport} instance and this {@link TransportConnection} object.
|
||||
* @param caller A {@link String} identifying the caller for logging/debugging purposes. This
|
||||
* should be a human-readable short string that is easily identifiable in the logs. Ideally
|
||||
* TAG.methodName(), where TAG is the one used in logcat. In cases where this is is not very
|
||||
@@ -373,8 +374,8 @@ public class TransportClient {
|
||||
}
|
||||
|
||||
/**
|
||||
* If the {@link TransportClient} is already connected to the transport, returns the transport,
|
||||
* otherwise throws {@link TransportNotAvailableException}.
|
||||
* If the {@link TransportConnection} is already connected to the transport, returns the
|
||||
* transport, otherwise throws {@link TransportNotAvailableException}.
|
||||
*
|
||||
* @param caller A {@link String} identifying the caller for logging/debugging purposes. Check
|
||||
* {@link #connectAsync(TransportConnectionListener, String)} for more details.
|
||||
@@ -647,19 +648,20 @@ public class TransportClient {
|
||||
* This class is a proxy to TransportClient methods that doesn't hold a strong reference to the
|
||||
* TransportClient, allowing it to be GC'ed. If the reference was lost it logs a message.
|
||||
*/
|
||||
private static class TransportConnection implements ServiceConnection {
|
||||
private static class TransportConnectionMonitor implements ServiceConnection {
|
||||
private final Context mContext;
|
||||
private final WeakReference<TransportClient> mTransportClientRef;
|
||||
private final WeakReference<TransportConnection> mTransportClientRef;
|
||||
|
||||
private TransportConnection(Context context, TransportClient transportClient) {
|
||||
private TransportConnectionMonitor(Context context,
|
||||
TransportConnection transportConnection) {
|
||||
mContext = context;
|
||||
mTransportClientRef = new WeakReference<>(transportClient);
|
||||
mTransportClientRef = new WeakReference<>(transportConnection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName transportComponent, IBinder binder) {
|
||||
TransportClient transportClient = mTransportClientRef.get();
|
||||
if (transportClient == null) {
|
||||
TransportConnection transportConnection = mTransportClientRef.get();
|
||||
if (transportConnection == null) {
|
||||
referenceLost("TransportConnection.onServiceConnected()");
|
||||
return;
|
||||
}
|
||||
@@ -667,30 +669,30 @@ public class TransportClient {
|
||||
// In short-term, blocking calls are OK as the transports come from the allowlist at
|
||||
// {@link SystemConfig#getBackupTransportWhitelist()}
|
||||
Binder.allowBlocking(binder);
|
||||
transportClient.onServiceConnected(binder);
|
||||
transportConnection.onServiceConnected(binder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName transportComponent) {
|
||||
TransportClient transportClient = mTransportClientRef.get();
|
||||
if (transportClient == null) {
|
||||
TransportConnection transportConnection = mTransportClientRef.get();
|
||||
if (transportConnection == null) {
|
||||
referenceLost("TransportConnection.onServiceDisconnected()");
|
||||
return;
|
||||
}
|
||||
transportClient.onServiceDisconnected();
|
||||
transportConnection.onServiceDisconnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindingDied(ComponentName transportComponent) {
|
||||
TransportClient transportClient = mTransportClientRef.get();
|
||||
if (transportClient == null) {
|
||||
TransportConnection transportConnection = mTransportClientRef.get();
|
||||
if (transportConnection == null) {
|
||||
referenceLost("TransportConnection.onBindingDied()");
|
||||
return;
|
||||
}
|
||||
transportClient.onBindingDied();
|
||||
transportConnection.onBindingDied();
|
||||
}
|
||||
|
||||
/** @see TransportClient#finalize() */
|
||||
/** @see TransportConnection#finalize() */
|
||||
private void referenceLost(String caller) {
|
||||
mContext.unbindService(this);
|
||||
TransportUtils.log(
|
||||
@@ -21,17 +21,18 @@ import android.annotation.Nullable;
|
||||
import com.android.internal.backup.IBackupTransport;
|
||||
|
||||
/**
|
||||
* Listener to be called by {@link TransportClient#connectAsync(TransportConnectionListener,
|
||||
* Listener to be called by {@link TransportConnection#connectAsync(TransportConnectionListener,
|
||||
* String)}.
|
||||
*/
|
||||
public interface TransportConnectionListener {
|
||||
/**
|
||||
* Called when {@link TransportClient} has a transport binder available or that it decided it
|
||||
* couldn't obtain one, in which case {@param transport} is null.
|
||||
* Called when {@link TransportConnection} has a transport binder available or that it decided
|
||||
* it couldn't obtain one, in which case {@param transport} is null.
|
||||
*
|
||||
* @param transport A {@link IBackupTransport} transport binder or null.
|
||||
* @param transportClient The {@link TransportClient} used to retrieve this transport binder.
|
||||
* @param transportConnection The {@link TransportConnection} used to retrieve this transport
|
||||
* binder.
|
||||
*/
|
||||
void onTransportConnectionResult(
|
||||
@Nullable IBackupTransport transport, TransportClient transportClient);
|
||||
@Nullable IBackupTransport transport, TransportConnection transportConnection);
|
||||
}
|
||||
|
||||
@@ -36,18 +36,18 @@ import java.util.WeakHashMap;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Manages the creation and disposal of {@link TransportClient}s. The only class that should use
|
||||
* Manages the creation and disposal of {@link TransportConnection}s. The only class that should use
|
||||
* this is {@link TransportManager}, all the other usages should go to {@link TransportManager}.
|
||||
*/
|
||||
public class TransportClientManager {
|
||||
private static final String TAG = "TransportClientManager";
|
||||
public class TransportConnectionManager {
|
||||
private static final String TAG = "TransportConnectionManager";
|
||||
|
||||
private final @UserIdInt int mUserId;
|
||||
private final Context mContext;
|
||||
private final TransportStats mTransportStats;
|
||||
private final Object mTransportClientsLock = new Object();
|
||||
private int mTransportClientsCreated = 0;
|
||||
private Map<TransportClient, String> mTransportClientsCallerMap = new WeakHashMap<>();
|
||||
private Map<TransportConnection, String> mTransportClientsCallerMap = new WeakHashMap<>();
|
||||
private final Function<ComponentName, Intent> mIntentFunction;
|
||||
|
||||
/**
|
||||
@@ -58,12 +58,12 @@ public class TransportClientManager {
|
||||
return new Intent(SERVICE_ACTION_TRANSPORT_HOST).setComponent(transportComponent);
|
||||
}
|
||||
|
||||
public TransportClientManager(@UserIdInt int userId, Context context,
|
||||
public TransportConnectionManager(@UserIdInt int userId, Context context,
|
||||
TransportStats transportStats) {
|
||||
this(userId, context, transportStats, TransportClientManager::getRealTransportIntent);
|
||||
this(userId, context, transportStats, TransportConnectionManager::getRealTransportIntent);
|
||||
}
|
||||
|
||||
private TransportClientManager(@UserIdInt int userId, Context context,
|
||||
private TransportConnectionManager(@UserIdInt int userId, Context context,
|
||||
TransportStats transportStats, Function<ComponentName, Intent> intentFunction) {
|
||||
mUserId = userId;
|
||||
mContext = context;
|
||||
@@ -72,31 +72,31 @@ public class TransportClientManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a {@link TransportClient} for the transport identified by {@param
|
||||
* Retrieves a {@link TransportConnection} for the transport identified by {@param
|
||||
* transportComponent}.
|
||||
*
|
||||
* @param transportComponent The {@link ComponentName} of the transport.
|
||||
* @param caller A {@link String} identifying the caller for logging/debugging purposes. Check
|
||||
* {@link TransportClient#connectAsync(TransportConnectionListener, String)} for more
|
||||
* {@link TransportConnection#connectAsync(TransportConnectionListener, String)} for more
|
||||
* details.
|
||||
* @return A {@link TransportClient}.
|
||||
* @return A {@link TransportConnection}.
|
||||
*/
|
||||
public TransportClient getTransportClient(ComponentName transportComponent, String caller) {
|
||||
public TransportConnection getTransportClient(ComponentName transportComponent, String caller) {
|
||||
return getTransportClient(transportComponent, null, caller);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a {@link TransportClient} for the transport identified by {@param
|
||||
* Retrieves a {@link TransportConnection} for the transport identified by {@param
|
||||
* transportComponent} whose binding intent will have the {@param extras} extras.
|
||||
*
|
||||
* @param transportComponent The {@link ComponentName} of the transport.
|
||||
* @param extras A {@link Bundle} of extras to pass to the binding intent.
|
||||
* @param caller A {@link String} identifying the caller for logging/debugging purposes. Check
|
||||
* {@link TransportClient#connectAsync(TransportConnectionListener, String)} for more
|
||||
* {@link TransportConnection#connectAsync(TransportConnectionListener, String)} for more
|
||||
* details.
|
||||
* @return A {@link TransportClient}.
|
||||
* @return A {@link TransportConnection}.
|
||||
*/
|
||||
public TransportClient getTransportClient(
|
||||
public TransportConnection getTransportClient(
|
||||
ComponentName transportComponent, @Nullable Bundle extras, String caller) {
|
||||
Intent bindIntent = mIntentFunction.apply(transportComponent);
|
||||
if (extras != null) {
|
||||
@@ -105,11 +105,11 @@ public class TransportClientManager {
|
||||
return getTransportClient(transportComponent, caller, bindIntent);
|
||||
}
|
||||
|
||||
private TransportClient getTransportClient(
|
||||
private TransportConnection getTransportClient(
|
||||
ComponentName transportComponent, String caller, Intent bindIntent) {
|
||||
synchronized (mTransportClientsLock) {
|
||||
TransportClient transportClient =
|
||||
new TransportClient(
|
||||
TransportConnection transportConnection =
|
||||
new TransportConnection(
|
||||
mUserId,
|
||||
mContext,
|
||||
mTransportStats,
|
||||
@@ -117,33 +117,33 @@ public class TransportClientManager {
|
||||
transportComponent,
|
||||
Integer.toString(mTransportClientsCreated),
|
||||
caller);
|
||||
mTransportClientsCallerMap.put(transportClient, caller);
|
||||
mTransportClientsCallerMap.put(transportConnection, caller);
|
||||
mTransportClientsCreated++;
|
||||
TransportUtils.log(
|
||||
Priority.DEBUG,
|
||||
TAG,
|
||||
formatMessage(null, caller, "Retrieving " + transportClient));
|
||||
return transportClient;
|
||||
formatMessage(null, caller, "Retrieving " + transportConnection));
|
||||
return transportConnection;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disposes of the {@link TransportClient}.
|
||||
* Disposes of the {@link TransportConnection}.
|
||||
*
|
||||
* @param transportClient The {@link TransportClient} to be disposed of.
|
||||
* @param transportConnection The {@link TransportConnection} to be disposed of.
|
||||
* @param caller A {@link String} identifying the caller for logging/debugging purposes. Check
|
||||
* {@link TransportClient#connectAsync(TransportConnectionListener, String)} for more
|
||||
* {@link TransportConnection#connectAsync(TransportConnectionListener, String)} for more
|
||||
* details.
|
||||
*/
|
||||
public void disposeOfTransportClient(TransportClient transportClient, String caller) {
|
||||
transportClient.unbind(caller);
|
||||
transportClient.markAsDisposed();
|
||||
public void disposeOfTransportClient(TransportConnection transportConnection, String caller) {
|
||||
transportConnection.unbind(caller);
|
||||
transportConnection.markAsDisposed();
|
||||
synchronized (mTransportClientsLock) {
|
||||
TransportUtils.log(
|
||||
Priority.DEBUG,
|
||||
TAG,
|
||||
formatMessage(null, caller, "Disposing of " + transportClient));
|
||||
mTransportClientsCallerMap.remove(transportClient);
|
||||
formatMessage(null, caller, "Disposing of " + transportConnection));
|
||||
mTransportClientsCallerMap.remove(transportConnection);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,10 +151,10 @@ public class TransportClientManager {
|
||||
pw.println("Transport clients created: " + mTransportClientsCreated);
|
||||
synchronized (mTransportClientsLock) {
|
||||
pw.println("Current transport clients: " + mTransportClientsCallerMap.size());
|
||||
for (TransportClient transportClient : mTransportClientsCallerMap.keySet()) {
|
||||
String caller = mTransportClientsCallerMap.get(transportClient);
|
||||
pw.println(" " + transportClient + " [" + caller + "]");
|
||||
for (String logEntry : transportClient.getLogBuffer()) {
|
||||
for (TransportConnection transportConnection : mTransportClientsCallerMap.keySet()) {
|
||||
String caller = mTransportClientsCallerMap.get(transportConnection);
|
||||
pw.println(" " + transportConnection + " [" + caller + "]");
|
||||
for (String logEntry : transportConnection.getLogBuffer()) {
|
||||
pw.println(" " + logEntry);
|
||||
}
|
||||
}
|
||||
@@ -22,10 +22,10 @@ import com.android.internal.backup.IBackupTransport;
|
||||
|
||||
/**
|
||||
* Exception thrown when the {@link IBackupTransport} is not available. This happen when a {@link
|
||||
* TransportClient} connection attempt fails. Check {@link
|
||||
* TransportClient#connectAsync(TransportConnectionListener, String)} for when that happens.
|
||||
* TransportConnection} connection attempt fails. Check {@link
|
||||
* TransportConnection#connectAsync(TransportConnectionListener, String)} for when that happens.
|
||||
*
|
||||
* @see TransportClient#connectAsync(TransportConnectionListener, String)
|
||||
* @see TransportConnection#connectAsync(TransportConnectionListener, String)
|
||||
*/
|
||||
public class TransportNotAvailableException extends AndroidException {
|
||||
TransportNotAvailableException() {
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/** Responsible for aggregating {@link TransportClient} relevant times. */
|
||||
/** Responsible for aggregating {@link TransportConnection} relevant times. */
|
||||
public class TransportStats {
|
||||
private final Object mStatsLock = new Object();
|
||||
private final Map<ComponentName, Stats> mTransportStats = new HashMap<>();
|
||||
|
||||
@@ -127,7 +127,7 @@ import com.android.server.backup.params.ClearRetryParams;
|
||||
import com.android.server.backup.params.RestoreParams;
|
||||
import com.android.server.backup.restore.ActiveRestoreSession;
|
||||
import com.android.server.backup.restore.PerformUnifiedRestoreTask;
|
||||
import com.android.server.backup.transport.TransportClient;
|
||||
import com.android.server.backup.transport.TransportConnection;
|
||||
import com.android.server.backup.transport.TransportNotAvailableException;
|
||||
import com.android.server.backup.transport.TransportNotRegisteredException;
|
||||
import com.android.server.backup.utils.BackupEligibilityRules;
|
||||
@@ -1894,16 +1894,16 @@ public class UserBackupManagerService {
|
||||
return BackupManager.ERROR_BACKUP_NOT_ALLOWED;
|
||||
}
|
||||
|
||||
final TransportClient transportClient;
|
||||
final TransportConnection transportConnection;
|
||||
final String transportDirName;
|
||||
int operationType;
|
||||
try {
|
||||
transportDirName =
|
||||
mTransportManager.getTransportDirName(
|
||||
mTransportManager.getCurrentTransportName());
|
||||
transportClient =
|
||||
transportConnection =
|
||||
mTransportManager.getCurrentTransportClientOrThrow("BMS.requestBackup()");
|
||||
operationType = getOperationTypeFromTransport(transportClient);
|
||||
operationType = getOperationTypeFromTransport(transportConnection);
|
||||
} catch (TransportNotRegisteredException | TransportNotAvailableException
|
||||
| RemoteException e) {
|
||||
BackupObserverUtils.sendBackupFinished(observer, BackupManager.ERROR_TRANSPORT_ABORTED);
|
||||
@@ -1914,13 +1914,13 @@ public class UserBackupManagerService {
|
||||
}
|
||||
|
||||
OnTaskFinishedListener listener =
|
||||
caller -> mTransportManager.disposeOfTransportClient(transportClient, caller);
|
||||
caller -> mTransportManager.disposeOfTransportClient(transportConnection, caller);
|
||||
BackupEligibilityRules backupEligibilityRules = getEligibilityRulesForOperation(
|
||||
operationType);
|
||||
|
||||
Message msg = mBackupHandler.obtainMessage(MSG_REQUEST_BACKUP);
|
||||
msg.obj = getRequestBackupParams(packages, observer, monitor, flags, backupEligibilityRules,
|
||||
transportClient, transportDirName, listener);
|
||||
transportConnection, transportDirName, listener);
|
||||
mBackupHandler.sendMessage(msg);
|
||||
return BackupManager.SUCCESS;
|
||||
}
|
||||
@@ -1928,7 +1928,7 @@ public class UserBackupManagerService {
|
||||
@VisibleForTesting
|
||||
BackupParams getRequestBackupParams(String[] packages, IBackupObserver observer,
|
||||
IBackupManagerMonitor monitor, int flags, BackupEligibilityRules backupEligibilityRules,
|
||||
TransportClient transportClient, String transportDirName,
|
||||
TransportConnection transportConnection, String transportDirName,
|
||||
OnTaskFinishedListener listener) {
|
||||
ArrayList<String> fullBackupList = new ArrayList<>();
|
||||
ArrayList<String> kvBackupList = new ArrayList<>();
|
||||
@@ -1974,7 +1974,7 @@ public class UserBackupManagerService {
|
||||
|
||||
boolean nonIncrementalBackup = (flags & BackupManager.FLAG_NON_INCREMENTAL_BACKUP) != 0;
|
||||
|
||||
return new BackupParams(transportClient, transportDirName, kvBackupList, fullBackupList,
|
||||
return new BackupParams(transportConnection, transportDirName, kvBackupList, fullBackupList,
|
||||
observer, monitor, listener, /* userInitiated */ true, nonIncrementalBackup,
|
||||
backupEligibilityRules);
|
||||
}
|
||||
@@ -2875,10 +2875,10 @@ public class UserBackupManagerService {
|
||||
}
|
||||
mBackupHandler.removeMessages(MSG_RETRY_CLEAR);
|
||||
synchronized (mQueueLock) {
|
||||
TransportClient transportClient =
|
||||
TransportConnection transportConnection =
|
||||
mTransportManager
|
||||
.getTransportClient(transportName, "BMS.clearBackupData()");
|
||||
if (transportClient == null) {
|
||||
if (transportConnection == null) {
|
||||
// transport is currently unregistered -- make sure to retry
|
||||
Message msg = mBackupHandler.obtainMessage(MSG_RETRY_CLEAR,
|
||||
new ClearRetryParams(transportName, packageName));
|
||||
@@ -2888,11 +2888,11 @@ public class UserBackupManagerService {
|
||||
final long oldId = Binder.clearCallingIdentity();
|
||||
try {
|
||||
OnTaskFinishedListener listener = caller -> mTransportManager
|
||||
.disposeOfTransportClient(transportClient, caller);
|
||||
.disposeOfTransportClient(transportConnection, caller);
|
||||
mWakelock.acquire();
|
||||
Message msg = mBackupHandler.obtainMessage(
|
||||
MSG_RUN_CLEAR,
|
||||
new ClearParams(transportClient, info, listener));
|
||||
new ClearParams(transportConnection, info, listener));
|
||||
mBackupHandler.sendMessage(msg);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(oldId);
|
||||
@@ -3715,11 +3715,11 @@ public class UserBackupManagerService {
|
||||
|
||||
// And update our current-dataset bookkeeping
|
||||
String callerLogString = "BMS.updateStateForTransport()";
|
||||
TransportClient transportClient =
|
||||
TransportConnection transportConnection =
|
||||
mTransportManager.getTransportClient(newTransportName, callerLogString);
|
||||
if (transportClient != null) {
|
||||
if (transportConnection != null) {
|
||||
try {
|
||||
IBackupTransport transport = transportClient.connectOrThrow(callerLogString);
|
||||
IBackupTransport transport = transportConnection.connectOrThrow(callerLogString);
|
||||
mCurrentToken = transport.getCurrentRestoreSet();
|
||||
} catch (Exception e) {
|
||||
// Oops. We can't know the current dataset token, so reset and figure it out
|
||||
@@ -3733,7 +3733,7 @@ public class UserBackupManagerService {
|
||||
+ newTransportName
|
||||
+ " not available: current token = 0"));
|
||||
}
|
||||
mTransportManager.disposeOfTransportClient(transportClient, callerLogString);
|
||||
mTransportManager.disposeOfTransportClient(transportConnection, callerLogString);
|
||||
} else {
|
||||
Slog.w(
|
||||
TAG,
|
||||
@@ -3946,9 +3946,9 @@ public class UserBackupManagerService {
|
||||
skip = true;
|
||||
}
|
||||
|
||||
TransportClient transportClient =
|
||||
TransportConnection transportConnection =
|
||||
mTransportManager.getCurrentTransportClient("BMS.restoreAtInstall()");
|
||||
if (transportClient == null) {
|
||||
if (transportConnection == null) {
|
||||
if (DEBUG) Slog.w(TAG, addUserIdToLogMessage(mUserId, "No transport client"));
|
||||
skip = true;
|
||||
}
|
||||
@@ -3972,7 +3972,7 @@ public class UserBackupManagerService {
|
||||
mWakelock.acquire();
|
||||
|
||||
OnTaskFinishedListener listener = caller -> {
|
||||
mTransportManager.disposeOfTransportClient(transportClient, caller);
|
||||
mTransportManager.disposeOfTransportClient(transportConnection, caller);
|
||||
mWakelock.release();
|
||||
};
|
||||
|
||||
@@ -3984,7 +3984,7 @@ public class UserBackupManagerService {
|
||||
Message msg = mBackupHandler.obtainMessage(MSG_RUN_RESTORE);
|
||||
msg.obj =
|
||||
RestoreParams.createForRestoreAtInstall(
|
||||
transportClient,
|
||||
transportConnection,
|
||||
/* observer */ null,
|
||||
/* monitor */ null,
|
||||
restoreSet,
|
||||
@@ -4006,9 +4006,9 @@ public class UserBackupManagerService {
|
||||
if (skip) {
|
||||
// Auto-restore disabled or no way to attempt a restore
|
||||
|
||||
if (transportClient != null) {
|
||||
if (transportConnection != null) {
|
||||
mTransportManager.disposeOfTransportClient(
|
||||
transportClient, "BMS.restoreAtInstall()");
|
||||
transportConnection, "BMS.restoreAtInstall()");
|
||||
}
|
||||
|
||||
// Tell the PackageManager to proceed with the post-install handling for this package.
|
||||
@@ -4177,13 +4177,13 @@ public class UserBackupManagerService {
|
||||
final long oldToken = Binder.clearCallingIdentity();
|
||||
try {
|
||||
String callerLogString = "BMS.isAppEligibleForBackup";
|
||||
TransportClient transportClient =
|
||||
TransportConnection transportConnection =
|
||||
mTransportManager.getCurrentTransportClient(callerLogString);
|
||||
boolean eligible =
|
||||
mScheduledBackupEligibility.appIsRunningAndEligibleForBackupWithTransport(
|
||||
transportClient, packageName);
|
||||
if (transportClient != null) {
|
||||
mTransportManager.disposeOfTransportClient(transportClient, callerLogString);
|
||||
transportConnection, packageName);
|
||||
if (transportConnection != null) {
|
||||
mTransportManager.disposeOfTransportClient(transportConnection, callerLogString);
|
||||
}
|
||||
return eligible;
|
||||
} finally {
|
||||
@@ -4199,17 +4199,17 @@ public class UserBackupManagerService {
|
||||
final long oldToken = Binder.clearCallingIdentity();
|
||||
try {
|
||||
String callerLogString = "BMS.filterAppsEligibleForBackup";
|
||||
TransportClient transportClient =
|
||||
TransportConnection transportConnection =
|
||||
mTransportManager.getCurrentTransportClient(callerLogString);
|
||||
List<String> eligibleApps = new LinkedList<>();
|
||||
for (String packageName : packages) {
|
||||
if (mScheduledBackupEligibility.appIsRunningAndEligibleForBackupWithTransport(
|
||||
transportClient, packageName)) {
|
||||
transportConnection, packageName)) {
|
||||
eligibleApps.add(packageName);
|
||||
}
|
||||
}
|
||||
if (transportClient != null) {
|
||||
mTransportManager.disposeOfTransportClient(transportClient, callerLogString);
|
||||
if (transportConnection != null) {
|
||||
mTransportManager.disposeOfTransportClient(transportConnection, callerLogString);
|
||||
}
|
||||
return eligibleApps.toArray(new String[eligibleApps.size()]);
|
||||
} finally {
|
||||
@@ -4362,7 +4362,7 @@ public class UserBackupManagerService {
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@OperationType int getOperationTypeFromTransport(TransportClient transportClient)
|
||||
@OperationType int getOperationTypeFromTransport(TransportConnection transportConnection)
|
||||
throws TransportNotAvailableException, RemoteException {
|
||||
if (!shouldUseNewBackupEligibilityRules()) {
|
||||
// Return the default to stick to the legacy behaviour.
|
||||
@@ -4371,7 +4371,7 @@ public class UserBackupManagerService {
|
||||
|
||||
final long oldCallingId = Binder.clearCallingIdentity();
|
||||
try {
|
||||
IBackupTransport transport = transportClient.connectOrThrow(
|
||||
IBackupTransport transport = transportConnection.connectOrThrow(
|
||||
/* caller */ "BMS.getOperationTypeFromTransport");
|
||||
if ((transport.getTransportFlags() & BackupAgent.FLAG_DEVICE_TO_DEVICE_TRANSFER) != 0) {
|
||||
return OperationType.MIGRATION;
|
||||
|
||||
@@ -51,7 +51,7 @@ import com.android.server.backup.UserBackupManagerService;
|
||||
import com.android.server.backup.internal.OnTaskFinishedListener;
|
||||
import com.android.server.backup.internal.Operation;
|
||||
import com.android.server.backup.remote.RemoteCall;
|
||||
import com.android.server.backup.transport.TransportClient;
|
||||
import com.android.server.backup.transport.TransportConnection;
|
||||
import com.android.server.backup.transport.TransportNotAvailableException;
|
||||
import com.android.server.backup.utils.BackupEligibilityRules;
|
||||
import com.android.server.backup.utils.BackupManagerMonitorUtils;
|
||||
@@ -110,13 +110,15 @@ public class PerformFullTransportBackupTask extends FullBackupTask implements Ba
|
||||
String caller,
|
||||
BackupEligibilityRules backupEligibilityRules) {
|
||||
TransportManager transportManager = backupManagerService.getTransportManager();
|
||||
TransportClient transportClient = transportManager.getCurrentTransportClient(caller);
|
||||
TransportConnection transportConnection = transportManager.getCurrentTransportClient(
|
||||
caller);
|
||||
OnTaskFinishedListener listener =
|
||||
listenerCaller ->
|
||||
transportManager.disposeOfTransportClient(transportClient, listenerCaller);
|
||||
transportManager.disposeOfTransportClient(transportConnection,
|
||||
listenerCaller);
|
||||
return new PerformFullTransportBackupTask(
|
||||
backupManagerService,
|
||||
transportClient,
|
||||
transportConnection,
|
||||
observer,
|
||||
whichPackages,
|
||||
updateSchedule,
|
||||
@@ -145,7 +147,7 @@ public class PerformFullTransportBackupTask extends FullBackupTask implements Ba
|
||||
SinglePackageBackupRunner mBackupRunner;
|
||||
private final int mBackupRunnerOpToken;
|
||||
private final OnTaskFinishedListener mListener;
|
||||
private final TransportClient mTransportClient;
|
||||
private final TransportConnection mTransportConnection;
|
||||
private final int mUserId;
|
||||
|
||||
// This is true when a backup operation for some package is in progress.
|
||||
@@ -156,7 +158,7 @@ public class PerformFullTransportBackupTask extends FullBackupTask implements Ba
|
||||
private final BackupEligibilityRules mBackupEligibilityRules;
|
||||
|
||||
public PerformFullTransportBackupTask(UserBackupManagerService backupManagerService,
|
||||
TransportClient transportClient,
|
||||
TransportConnection transportConnection,
|
||||
IFullBackupRestoreObserver observer,
|
||||
String[] whichPackages, boolean updateSchedule,
|
||||
FullBackupJob runningJob, CountDownLatch latch, IBackupObserver backupObserver,
|
||||
@@ -164,7 +166,7 @@ public class PerformFullTransportBackupTask extends FullBackupTask implements Ba
|
||||
boolean userInitiated, BackupEligibilityRules backupEligibilityRules) {
|
||||
super(observer);
|
||||
this.mUserBackupManagerService = backupManagerService;
|
||||
mTransportClient = transportClient;
|
||||
mTransportConnection = transportConnection;
|
||||
mUpdateSchedule = updateSchedule;
|
||||
mLatch = latch;
|
||||
mJob = runningJob;
|
||||
@@ -299,7 +301,7 @@ public class PerformFullTransportBackupTask extends FullBackupTask implements Ba
|
||||
try {
|
||||
// If we're running a backup we should be connected to a transport
|
||||
IBackupTransport transport =
|
||||
mTransportClient.getConnectedTransport("PFTBT.handleCancel()");
|
||||
mTransportConnection.getConnectedTransport("PFTBT.handleCancel()");
|
||||
transport.cancelFullBackup();
|
||||
} catch (RemoteException | TransportNotAvailableException e) {
|
||||
Slog.w(TAG, "Error calling cancelFullBackup() on transport: " + e);
|
||||
@@ -351,7 +353,7 @@ public class PerformFullTransportBackupTask extends FullBackupTask implements Ba
|
||||
return;
|
||||
}
|
||||
|
||||
IBackupTransport transport = mTransportClient.connect("PFTBT.run()");
|
||||
IBackupTransport transport = mTransportConnection.connect("PFTBT.run()");
|
||||
if (transport == null) {
|
||||
Slog.w(TAG, "Transport not present; full data backup not performed");
|
||||
backupRunStatus = BackupManager.ERROR_TRANSPORT_ABORTED;
|
||||
@@ -395,7 +397,7 @@ public class PerformFullTransportBackupTask extends FullBackupTask implements Ba
|
||||
enginePipes = ParcelFileDescriptor.createPipe();
|
||||
mBackupRunner =
|
||||
new SinglePackageBackupRunner(enginePipes[1], currentPackage,
|
||||
mTransportClient, quota, mBackupRunnerOpToken,
|
||||
mTransportConnection, quota, mBackupRunnerOpToken,
|
||||
transport.getTransportFlags());
|
||||
// The runner dup'd the pipe half, so we close it here
|
||||
enginePipes[1].close();
|
||||
@@ -697,17 +699,17 @@ public class PerformFullTransportBackupTask extends FullBackupTask implements Ba
|
||||
class SinglePackageBackupPreflight implements BackupRestoreTask, FullBackupPreflight {
|
||||
final AtomicLong mResult = new AtomicLong(BackupTransport.AGENT_ERROR);
|
||||
final CountDownLatch mLatch = new CountDownLatch(1);
|
||||
final TransportClient mTransportClient;
|
||||
final TransportConnection mTransportConnection;
|
||||
final long mQuota;
|
||||
private final int mCurrentOpToken;
|
||||
private final int mTransportFlags;
|
||||
|
||||
SinglePackageBackupPreflight(
|
||||
TransportClient transportClient,
|
||||
TransportConnection transportConnection,
|
||||
long quota,
|
||||
int currentOpToken,
|
||||
int transportFlags) {
|
||||
mTransportClient = transportClient;
|
||||
mTransportConnection = transportConnection;
|
||||
mQuota = quota;
|
||||
mCurrentOpToken = currentOpToken;
|
||||
mTransportFlags = transportFlags;
|
||||
@@ -744,7 +746,7 @@ public class PerformFullTransportBackupTask extends FullBackupTask implements Ba
|
||||
}
|
||||
|
||||
IBackupTransport transport =
|
||||
mTransportClient.connectOrThrow("PFTBT$SPBP.preflightFullBackup()");
|
||||
mTransportConnection.connectOrThrow("PFTBT$SPBP.preflightFullBackup()");
|
||||
result = transport.checkFullBackupSize(totalSize);
|
||||
if (result == BackupTransport.TRANSPORT_QUOTA_EXCEEDED) {
|
||||
if (MORE_DEBUG) {
|
||||
@@ -817,14 +819,14 @@ public class PerformFullTransportBackupTask extends FullBackupTask implements Ba
|
||||
private final int mTransportFlags;
|
||||
|
||||
SinglePackageBackupRunner(ParcelFileDescriptor output, PackageInfo target,
|
||||
TransportClient transportClient, long quota, int currentOpToken, int transportFlags)
|
||||
throws IOException {
|
||||
TransportConnection transportConnection, long quota, int currentOpToken,
|
||||
int transportFlags) throws IOException {
|
||||
mOutput = ParcelFileDescriptor.dup(output.getFileDescriptor());
|
||||
mTarget = target;
|
||||
mCurrentOpToken = currentOpToken;
|
||||
mEphemeralToken = mUserBackupManagerService.generateRandomIntegerToken();
|
||||
mPreflight = new SinglePackageBackupPreflight(
|
||||
transportClient, quota, mEphemeralToken, transportFlags);
|
||||
transportConnection, quota, mEphemeralToken, transportFlags);
|
||||
mPreflightLatch = new CountDownLatch(1);
|
||||
mBackupLatch = new CountDownLatch(1);
|
||||
mPreflightResult = BackupTransport.AGENT_ERROR;
|
||||
|
||||
@@ -20,7 +20,6 @@ import static com.android.server.backup.BackupManagerService.DEBUG;
|
||||
import static com.android.server.backup.BackupManagerService.MORE_DEBUG;
|
||||
import static com.android.server.backup.BackupManagerService.TAG;
|
||||
|
||||
import android.app.backup.BackupManager;
|
||||
import android.app.backup.BackupManager.OperationType;
|
||||
import android.app.backup.RestoreSet;
|
||||
import android.os.Handler;
|
||||
@@ -52,7 +51,7 @@ import com.android.server.backup.params.RestoreGetSetsParams;
|
||||
import com.android.server.backup.params.RestoreParams;
|
||||
import com.android.server.backup.restore.PerformAdbRestoreTask;
|
||||
import com.android.server.backup.restore.PerformUnifiedRestoreTask;
|
||||
import com.android.server.backup.transport.TransportClient;
|
||||
import com.android.server.backup.transport.TransportConnection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -148,16 +147,16 @@ public class BackupHandler extends Handler {
|
||||
backupManagerService.setLastBackupPass(System.currentTimeMillis());
|
||||
|
||||
String callerLogString = "BH/MSG_RUN_BACKUP";
|
||||
TransportClient transportClient =
|
||||
TransportConnection transportConnection =
|
||||
transportManager.getCurrentTransportClient(callerLogString);
|
||||
IBackupTransport transport =
|
||||
transportClient != null
|
||||
? transportClient.connect(callerLogString)
|
||||
transportConnection != null
|
||||
? transportConnection.connect(callerLogString)
|
||||
: null;
|
||||
if (transport == null) {
|
||||
if (transportClient != null) {
|
||||
if (transportConnection != null) {
|
||||
transportManager
|
||||
.disposeOfTransportClient(transportClient, callerLogString);
|
||||
.disposeOfTransportClient(transportConnection, callerLogString);
|
||||
}
|
||||
Slog.v(TAG, "Backup requested but no transport available");
|
||||
break;
|
||||
@@ -212,10 +211,11 @@ public class BackupHandler extends Handler {
|
||||
OnTaskFinishedListener listener =
|
||||
caller ->
|
||||
transportManager
|
||||
.disposeOfTransportClient(transportClient, caller);
|
||||
.disposeOfTransportClient(transportConnection,
|
||||
caller);
|
||||
KeyValueBackupTask.start(
|
||||
backupManagerService,
|
||||
transportClient,
|
||||
transportConnection,
|
||||
transport.transportDirName(),
|
||||
queue,
|
||||
oldJournal,
|
||||
@@ -240,7 +240,7 @@ public class BackupHandler extends Handler {
|
||||
}
|
||||
|
||||
if (!staged) {
|
||||
transportManager.disposeOfTransportClient(transportClient, callerLogString);
|
||||
transportManager.disposeOfTransportClient(transportConnection, callerLogString);
|
||||
// if we didn't actually hand off the wakelock, rewind until next time
|
||||
synchronized (backupManagerService.getQueueLock()) {
|
||||
backupManagerService.setBackupRunning(false);
|
||||
@@ -296,7 +296,7 @@ public class BackupHandler extends Handler {
|
||||
PerformUnifiedRestoreTask task =
|
||||
new PerformUnifiedRestoreTask(
|
||||
backupManagerService,
|
||||
params.transportClient,
|
||||
params.mTransportConnection,
|
||||
params.observer,
|
||||
params.monitor,
|
||||
params.token,
|
||||
@@ -344,7 +344,7 @@ public class BackupHandler extends Handler {
|
||||
Runnable task =
|
||||
new PerformClearTask(
|
||||
backupManagerService,
|
||||
params.transportClient,
|
||||
params.mTransportConnection,
|
||||
params.packageInfo,
|
||||
params.listener);
|
||||
task.run();
|
||||
@@ -365,7 +365,7 @@ public class BackupHandler extends Handler {
|
||||
String callerLogString = "BH/MSG_RUN_GET_RESTORE_SETS";
|
||||
try {
|
||||
IBackupTransport transport =
|
||||
params.transportClient.connectOrThrow(callerLogString);
|
||||
params.mTransportConnection.connectOrThrow(callerLogString);
|
||||
sets = transport.getAvailableRestoreSets();
|
||||
// cache the result in the active session
|
||||
synchronized (params.session) {
|
||||
@@ -459,7 +459,7 @@ public class BackupHandler extends Handler {
|
||||
|
||||
KeyValueBackupTask.start(
|
||||
backupManagerService,
|
||||
params.transportClient,
|
||||
params.mTransportConnection,
|
||||
params.dirName,
|
||||
params.kvPackages,
|
||||
/* dataChangedJournal */ null,
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.server.backup.internal;
|
||||
|
||||
import com.android.server.backup.transport.TransportClient;
|
||||
import com.android.server.backup.transport.TransportConnection;
|
||||
import com.android.server.backup.transport.TransportConnectionListener;
|
||||
|
||||
/** Listener to be called when a task finishes, successfully or not. */
|
||||
@@ -27,7 +27,7 @@ public interface OnTaskFinishedListener {
|
||||
* Called when a task finishes, successfully or not.
|
||||
*
|
||||
* @param caller A {@link String} identifying the caller for logging/debugging purposes. Check
|
||||
* {@link TransportClient#connectAsync(TransportConnectionListener, String)} for more
|
||||
* {@link TransportConnection#connectAsync(TransportConnectionListener, String)} for more
|
||||
* details.
|
||||
*/
|
||||
void onFinished(String caller);
|
||||
|
||||
@@ -24,23 +24,23 @@ import android.util.Slog;
|
||||
import com.android.internal.backup.IBackupTransport;
|
||||
import com.android.server.backup.TransportManager;
|
||||
import com.android.server.backup.UserBackupManagerService;
|
||||
import com.android.server.backup.transport.TransportClient;
|
||||
import com.android.server.backup.transport.TransportConnection;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class PerformClearTask implements Runnable {
|
||||
private final UserBackupManagerService mBackupManagerService;
|
||||
private final TransportManager mTransportManager;
|
||||
private final TransportClient mTransportClient;
|
||||
private final TransportConnection mTransportConnection;
|
||||
private final PackageInfo mPackage;
|
||||
private final OnTaskFinishedListener mListener;
|
||||
|
||||
PerformClearTask(UserBackupManagerService backupManagerService,
|
||||
TransportClient transportClient, PackageInfo packageInfo,
|
||||
TransportConnection transportConnection, PackageInfo packageInfo,
|
||||
OnTaskFinishedListener listener) {
|
||||
mBackupManagerService = backupManagerService;
|
||||
mTransportManager = backupManagerService.getTransportManager();
|
||||
mTransportClient = transportClient;
|
||||
mTransportConnection = transportConnection;
|
||||
mPackage = packageInfo;
|
||||
mListener = listener;
|
||||
}
|
||||
@@ -51,12 +51,13 @@ public class PerformClearTask implements Runnable {
|
||||
try {
|
||||
// Clear the on-device backup state to ensure a full backup next time
|
||||
String transportDirName =
|
||||
mTransportManager.getTransportDirName(mTransportClient.getTransportComponent());
|
||||
mTransportManager.getTransportDirName(
|
||||
mTransportConnection.getTransportComponent());
|
||||
File stateDir = new File(mBackupManagerService.getBaseStateDir(), transportDirName);
|
||||
File stateFile = new File(stateDir, mPackage.packageName);
|
||||
stateFile.delete();
|
||||
|
||||
transport = mTransportClient.connectOrThrow(callerLogString);
|
||||
transport = mTransportConnection.connectOrThrow(callerLogString);
|
||||
// Tell the transport to remove all the persistent storage for the app
|
||||
// TODO - need to handle failures
|
||||
transport.clearBackupData(mPackage);
|
||||
|
||||
@@ -32,7 +32,7 @@ import com.android.internal.backup.IBackupTransport;
|
||||
import com.android.server.EventLogTags;
|
||||
import com.android.server.backup.TransportManager;
|
||||
import com.android.server.backup.UserBackupManagerService;
|
||||
import com.android.server.backup.transport.TransportClient;
|
||||
import com.android.server.backup.transport.TransportConnection;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -109,26 +109,26 @@ public class PerformInitializeTask implements Runnable {
|
||||
public void run() {
|
||||
// mWakelock is *acquired* when execution begins here
|
||||
String callerLogString = "PerformInitializeTask.run()";
|
||||
List<TransportClient> transportClientsToDisposeOf = new ArrayList<>(mQueue.length);
|
||||
List<TransportConnection> transportClientsToDisposeOf = new ArrayList<>(mQueue.length);
|
||||
int result = BackupTransport.TRANSPORT_OK;
|
||||
try {
|
||||
for (String transportName : mQueue) {
|
||||
TransportClient transportClient =
|
||||
TransportConnection transportConnection =
|
||||
mTransportManager.getTransportClient(transportName, callerLogString);
|
||||
if (transportClient == null) {
|
||||
if (transportConnection == null) {
|
||||
Slog.e(TAG, "Requested init for " + transportName + " but not found");
|
||||
continue;
|
||||
}
|
||||
transportClientsToDisposeOf.add(transportClient);
|
||||
transportClientsToDisposeOf.add(transportConnection);
|
||||
|
||||
Slog.i(TAG, "Initializing (wiping) backup transport storage: " + transportName);
|
||||
String transportDirName =
|
||||
mTransportManager.getTransportDirName(
|
||||
transportClient.getTransportComponent());
|
||||
transportConnection.getTransportComponent());
|
||||
EventLog.writeEvent(EventLogTags.BACKUP_START, transportDirName);
|
||||
long startRealtime = SystemClock.elapsedRealtime();
|
||||
|
||||
IBackupTransport transport = transportClient.connectOrThrow(callerLogString);
|
||||
IBackupTransport transport = transportConnection.connectOrThrow(callerLogString);
|
||||
int status = transport.initializeDevice();
|
||||
if (status != BackupTransport.TRANSPORT_OK) {
|
||||
Slog.e(TAG, "Transport error in initializeDevice()");
|
||||
@@ -170,8 +170,8 @@ public class PerformInitializeTask implements Runnable {
|
||||
Slog.e(TAG, "Unexpected error performing init", e);
|
||||
result = BackupTransport.TRANSPORT_ERROR;
|
||||
} finally {
|
||||
for (TransportClient transportClient : transportClientsToDisposeOf) {
|
||||
mTransportManager.disposeOfTransportClient(transportClient, callerLogString);
|
||||
for (TransportConnection transportConnection : transportClientsToDisposeOf) {
|
||||
mTransportManager.disposeOfTransportClient(transportConnection, callerLogString);
|
||||
}
|
||||
notifyFinished(result);
|
||||
mListener.onFinished(callerLogString);
|
||||
|
||||
@@ -65,7 +65,7 @@ import com.android.server.backup.internal.Operation;
|
||||
import com.android.server.backup.remote.RemoteCall;
|
||||
import com.android.server.backup.remote.RemoteCallable;
|
||||
import com.android.server.backup.remote.RemoteResult;
|
||||
import com.android.server.backup.transport.TransportClient;
|
||||
import com.android.server.backup.transport.TransportConnection;
|
||||
import com.android.server.backup.transport.TransportNotAvailableException;
|
||||
import com.android.server.backup.utils.BackupEligibilityRules;
|
||||
|
||||
@@ -192,10 +192,10 @@ public class KeyValueBackupTask implements BackupRestoreTask, Runnable {
|
||||
* dedicated thread and kicks off the operation in it.
|
||||
*
|
||||
* @param backupManagerService The {@link UserBackupManagerService} instance.
|
||||
* @param transportClient The {@link TransportClient} that contains the transport used for the
|
||||
* operation.
|
||||
* @param transportConnection The {@link TransportConnection} that contains the transport used
|
||||
* for the operation.
|
||||
* @param transportDirName The value of {@link IBackupTransport#transportDirName()} for the
|
||||
* transport whose {@link TransportClient} was provided above.
|
||||
* transport whose {@link TransportConnection} was provided above.
|
||||
* @param queue The list of package names that will be backed-up.
|
||||
* @param dataChangedJournal The old data-changed journal file that will be deleted when the
|
||||
* operation finishes (successfully or not) or {@code null}.
|
||||
@@ -211,7 +211,7 @@ public class KeyValueBackupTask implements BackupRestoreTask, Runnable {
|
||||
*/
|
||||
public static KeyValueBackupTask start(
|
||||
UserBackupManagerService backupManagerService,
|
||||
TransportClient transportClient,
|
||||
TransportConnection transportConnection,
|
||||
String transportDirName,
|
||||
List<String> queue,
|
||||
@Nullable DataChangedJournal dataChangedJournal,
|
||||
@@ -227,7 +227,7 @@ public class KeyValueBackupTask implements BackupRestoreTask, Runnable {
|
||||
KeyValueBackupTask task =
|
||||
new KeyValueBackupTask(
|
||||
backupManagerService,
|
||||
transportClient,
|
||||
transportConnection,
|
||||
transportDirName,
|
||||
queue,
|
||||
dataChangedJournal,
|
||||
@@ -245,7 +245,7 @@ public class KeyValueBackupTask implements BackupRestoreTask, Runnable {
|
||||
|
||||
private final UserBackupManagerService mBackupManagerService;
|
||||
private final PackageManager mPackageManager;
|
||||
private final TransportClient mTransportClient;
|
||||
private final TransportConnection mTransportConnection;
|
||||
private final BackupAgentTimeoutParameters mAgentTimeoutParameters;
|
||||
private final KeyValueBackupReporter mReporter;
|
||||
private final OnTaskFinishedListener mTaskFinishedListener;
|
||||
@@ -302,7 +302,7 @@ public class KeyValueBackupTask implements BackupRestoreTask, Runnable {
|
||||
@VisibleForTesting
|
||||
public KeyValueBackupTask(
|
||||
UserBackupManagerService backupManagerService,
|
||||
TransportClient transportClient,
|
||||
TransportConnection transportConnection,
|
||||
String transportDirName,
|
||||
List<String> queue,
|
||||
@Nullable DataChangedJournal journal,
|
||||
@@ -314,7 +314,7 @@ public class KeyValueBackupTask implements BackupRestoreTask, Runnable {
|
||||
BackupEligibilityRules backupEligibilityRules) {
|
||||
mBackupManagerService = backupManagerService;
|
||||
mPackageManager = backupManagerService.getPackageManager();
|
||||
mTransportClient = transportClient;
|
||||
mTransportConnection = transportConnection;
|
||||
mOriginalQueue = queue;
|
||||
// We need to retain the original queue contents in case of transport failure
|
||||
mQueue = new ArrayList<>(queue);
|
||||
@@ -418,7 +418,7 @@ public class KeyValueBackupTask implements BackupRestoreTask, Runnable {
|
||||
boolean noDataPackageEncountered = false;
|
||||
try {
|
||||
IBackupTransport transport =
|
||||
mTransportClient.connectOrThrow("KVBT.informTransportOfEmptyBackups()");
|
||||
mTransportConnection.connectOrThrow("KVBT.informTransportOfEmptyBackups()");
|
||||
|
||||
for (String packageName : succeedingPackages) {
|
||||
if (appsBackedUp.contains(packageName)) {
|
||||
@@ -463,7 +463,7 @@ public class KeyValueBackupTask implements BackupRestoreTask, Runnable {
|
||||
private boolean isEligibleForNoDataCall(PackageInfo packageInfo) {
|
||||
return mBackupEligibilityRules.appIsKeyValueOnly(packageInfo)
|
||||
&& mBackupEligibilityRules.appIsRunningAndEligibleForBackupWithTransport(
|
||||
mTransportClient, packageInfo.packageName);
|
||||
mTransportConnection, packageInfo.packageName);
|
||||
}
|
||||
|
||||
/** Send the "no data changed" message to a transport for a specific package */
|
||||
@@ -608,7 +608,7 @@ public class KeyValueBackupTask implements BackupRestoreTask, Runnable {
|
||||
mReporter.onQueueReady(mQueue);
|
||||
File pmState = new File(mStateDirectory, PM_PACKAGE);
|
||||
try {
|
||||
IBackupTransport transport = mTransportClient.connectOrThrow("KVBT.startTask()");
|
||||
IBackupTransport transport = mTransportConnection.connectOrThrow("KVBT.startTask()");
|
||||
String transportName = transport.name();
|
||||
if (transportName.contains("EncryptedLocalTransport")) {
|
||||
// Temporary code for EiTF POC. Only supports non-incremental backups.
|
||||
@@ -638,7 +638,7 @@ public class KeyValueBackupTask implements BackupRestoreTask, Runnable {
|
||||
private PerformFullTransportBackupTask createFullBackupTask(List<String> packages) {
|
||||
return new PerformFullTransportBackupTask(
|
||||
mBackupManagerService,
|
||||
mTransportClient,
|
||||
mTransportConnection,
|
||||
/* fullBackupRestoreObserver */ null,
|
||||
packages.toArray(new String[packages.size()]),
|
||||
/* updateSchedule */ false,
|
||||
@@ -764,7 +764,7 @@ public class KeyValueBackupTask implements BackupRestoreTask, Runnable {
|
||||
long currentToken = mBackupManagerService.getCurrentToken();
|
||||
if (mHasDataToBackup && (status == BackupTransport.TRANSPORT_OK) && (currentToken == 0)) {
|
||||
try {
|
||||
IBackupTransport transport = mTransportClient.connectOrThrow(callerLogString);
|
||||
IBackupTransport transport = mTransportConnection.connectOrThrow(callerLogString);
|
||||
transportName = transport.name();
|
||||
mBackupManagerService.setCurrentToken(transport.getCurrentRestoreSet());
|
||||
mBackupManagerService.writeRestoreTokens();
|
||||
@@ -836,7 +836,7 @@ public class KeyValueBackupTask implements BackupRestoreTask, Runnable {
|
||||
@GuardedBy("mQueueLock")
|
||||
private void triggerTransportInitializationLocked() throws Exception {
|
||||
IBackupTransport transport =
|
||||
mTransportClient.connectOrThrow("KVBT.triggerTransportInitializationLocked");
|
||||
mTransportConnection.connectOrThrow("KVBT.triggerTransportInitializationLocked");
|
||||
mBackupManagerService.getPendingInits().add(transport.name());
|
||||
deletePmStateFile();
|
||||
mBackupManagerService.backupNow();
|
||||
@@ -919,7 +919,8 @@ public class KeyValueBackupTask implements BackupRestoreTask, Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
IBackupTransport transport = mTransportClient.connectOrThrow("KVBT.extractAgentData()");
|
||||
IBackupTransport transport = mTransportConnection.connectOrThrow(
|
||||
"KVBT.extractAgentData()");
|
||||
long quota = transport.getBackupQuota(packageName, /* isFullBackup */ false);
|
||||
int transportFlags = transport.getTransportFlags();
|
||||
|
||||
@@ -1078,7 +1079,7 @@ public class KeyValueBackupTask implements BackupRestoreTask, Runnable {
|
||||
try (ParcelFileDescriptor backupData =
|
||||
ParcelFileDescriptor.open(backupDataFile, MODE_READ_ONLY)) {
|
||||
IBackupTransport transport =
|
||||
mTransportClient.connectOrThrow("KVBT.transportPerformBackup()");
|
||||
mTransportConnection.connectOrThrow("KVBT.transportPerformBackup()");
|
||||
mReporter.onTransportPerformBackup(packageName);
|
||||
int flags = getPerformBackupFlags(mUserInitiated, nonIncremental);
|
||||
|
||||
@@ -1131,7 +1132,7 @@ public class KeyValueBackupTask implements BackupRestoreTask, Runnable {
|
||||
if (agent != null) {
|
||||
try {
|
||||
IBackupTransport transport =
|
||||
mTransportClient.connectOrThrow("KVBT.agentDoQuotaExceeded()");
|
||||
mTransportConnection.connectOrThrow("KVBT.agentDoQuotaExceeded()");
|
||||
long quota = transport.getBackupQuota(packageName, false);
|
||||
remoteCall(
|
||||
callback -> agent.doQuotaExceeded(size, quota, callback),
|
||||
@@ -1227,7 +1228,7 @@ public class KeyValueBackupTask implements BackupRestoreTask, Runnable {
|
||||
long delay;
|
||||
try {
|
||||
IBackupTransport transport =
|
||||
mTransportClient.connectOrThrow("KVBT.revertTask()");
|
||||
mTransportConnection.connectOrThrow("KVBT.revertTask()");
|
||||
delay = transport.requestBackupTime();
|
||||
} catch (Exception e) {
|
||||
mReporter.onTransportRequestBackupTimeError(e);
|
||||
|
||||
@@ -20,14 +20,14 @@ import android.app.backup.IBackupManagerMonitor;
|
||||
import android.app.backup.IBackupObserver;
|
||||
|
||||
import com.android.server.backup.internal.OnTaskFinishedListener;
|
||||
import com.android.server.backup.transport.TransportClient;
|
||||
import com.android.server.backup.transport.TransportConnection;
|
||||
import com.android.server.backup.utils.BackupEligibilityRules;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class BackupParams {
|
||||
|
||||
public TransportClient transportClient;
|
||||
public TransportConnection mTransportConnection;
|
||||
public String dirName;
|
||||
public ArrayList<String> kvPackages;
|
||||
public ArrayList<String> fullPackages;
|
||||
@@ -38,11 +38,11 @@ public class BackupParams {
|
||||
public boolean nonIncrementalBackup;
|
||||
public BackupEligibilityRules mBackupEligibilityRules;
|
||||
|
||||
public BackupParams(TransportClient transportClient, String dirName,
|
||||
public BackupParams(TransportConnection transportConnection, String dirName,
|
||||
ArrayList<String> kvPackages, ArrayList<String> fullPackages, IBackupObserver observer,
|
||||
IBackupManagerMonitor monitor, OnTaskFinishedListener listener, boolean userInitiated,
|
||||
boolean nonIncrementalBackup, BackupEligibilityRules backupEligibilityRules) {
|
||||
this.transportClient = transportClient;
|
||||
this.mTransportConnection = transportConnection;
|
||||
this.dirName = dirName;
|
||||
this.kvPackages = kvPackages;
|
||||
this.fullPackages = fullPackages;
|
||||
|
||||
@@ -19,18 +19,18 @@ package com.android.server.backup.params;
|
||||
import android.content.pm.PackageInfo;
|
||||
|
||||
import com.android.server.backup.internal.OnTaskFinishedListener;
|
||||
import com.android.server.backup.transport.TransportClient;
|
||||
import com.android.server.backup.transport.TransportConnection;
|
||||
|
||||
public class ClearParams {
|
||||
public TransportClient transportClient;
|
||||
public TransportConnection mTransportConnection;
|
||||
public PackageInfo packageInfo;
|
||||
public OnTaskFinishedListener listener;
|
||||
|
||||
public ClearParams(
|
||||
TransportClient transportClient,
|
||||
TransportConnection transportConnection,
|
||||
PackageInfo packageInfo,
|
||||
OnTaskFinishedListener listener) {
|
||||
this.transportClient = transportClient;
|
||||
this.mTransportConnection = transportConnection;
|
||||
this.packageInfo = packageInfo;
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@@ -19,22 +19,21 @@ package com.android.server.backup.params;
|
||||
import android.app.backup.IBackupManagerMonitor;
|
||||
import android.app.backup.IRestoreObserver;
|
||||
|
||||
import com.android.internal.backup.IBackupTransport;
|
||||
import com.android.server.backup.internal.OnTaskFinishedListener;
|
||||
import com.android.server.backup.restore.ActiveRestoreSession;
|
||||
import com.android.server.backup.transport.TransportClient;
|
||||
import com.android.server.backup.transport.TransportConnection;
|
||||
|
||||
public class RestoreGetSetsParams {
|
||||
public final TransportClient transportClient;
|
||||
public final TransportConnection mTransportConnection;
|
||||
public final ActiveRestoreSession session;
|
||||
public final IRestoreObserver observer;
|
||||
public final IBackupManagerMonitor monitor;
|
||||
public final OnTaskFinishedListener listener;
|
||||
|
||||
public RestoreGetSetsParams(TransportClient _transportClient, ActiveRestoreSession _session,
|
||||
IRestoreObserver _observer, IBackupManagerMonitor _monitor,
|
||||
OnTaskFinishedListener _listener) {
|
||||
transportClient = _transportClient;
|
||||
public RestoreGetSetsParams(TransportConnection _transportConnection,
|
||||
ActiveRestoreSession _session, IRestoreObserver _observer,
|
||||
IBackupManagerMonitor _monitor, OnTaskFinishedListener _listener) {
|
||||
mTransportConnection = _transportConnection;
|
||||
session = _session;
|
||||
observer = _observer;
|
||||
monitor = _monitor;
|
||||
|
||||
@@ -22,14 +22,11 @@ import android.app.backup.IRestoreObserver;
|
||||
import android.content.pm.PackageInfo;
|
||||
|
||||
import com.android.server.backup.internal.OnTaskFinishedListener;
|
||||
import com.android.server.backup.transport.TransportClient;
|
||||
import com.android.server.backup.transport.TransportConnection;
|
||||
import com.android.server.backup.utils.BackupEligibilityRules;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class RestoreParams {
|
||||
public final TransportClient transportClient;
|
||||
public final TransportConnection mTransportConnection;
|
||||
public final IRestoreObserver observer;
|
||||
public final IBackupManagerMonitor monitor;
|
||||
public final long token;
|
||||
@@ -44,7 +41,7 @@ public class RestoreParams {
|
||||
* No kill after restore.
|
||||
*/
|
||||
public static RestoreParams createForSinglePackage(
|
||||
TransportClient transportClient,
|
||||
TransportConnection transportConnection,
|
||||
IRestoreObserver observer,
|
||||
IBackupManagerMonitor monitor,
|
||||
long token,
|
||||
@@ -52,7 +49,7 @@ public class RestoreParams {
|
||||
OnTaskFinishedListener listener,
|
||||
BackupEligibilityRules eligibilityRules) {
|
||||
return new RestoreParams(
|
||||
transportClient,
|
||||
transportConnection,
|
||||
observer,
|
||||
monitor,
|
||||
token,
|
||||
@@ -68,7 +65,7 @@ public class RestoreParams {
|
||||
* Kill after restore.
|
||||
*/
|
||||
public static RestoreParams createForRestoreAtInstall(
|
||||
TransportClient transportClient,
|
||||
TransportConnection transportConnection,
|
||||
IRestoreObserver observer,
|
||||
IBackupManagerMonitor monitor,
|
||||
long token,
|
||||
@@ -78,7 +75,7 @@ public class RestoreParams {
|
||||
BackupEligibilityRules backupEligibilityRules) {
|
||||
String[] filterSet = {packageName};
|
||||
return new RestoreParams(
|
||||
transportClient,
|
||||
transportConnection,
|
||||
observer,
|
||||
monitor,
|
||||
token,
|
||||
@@ -94,14 +91,14 @@ public class RestoreParams {
|
||||
* This is the form that Setup Wizard or similar restore UXes use.
|
||||
*/
|
||||
public static RestoreParams createForRestoreAll(
|
||||
TransportClient transportClient,
|
||||
TransportConnection transportConnection,
|
||||
IRestoreObserver observer,
|
||||
IBackupManagerMonitor monitor,
|
||||
long token,
|
||||
OnTaskFinishedListener listener,
|
||||
BackupEligibilityRules backupEligibilityRules) {
|
||||
return new RestoreParams(
|
||||
transportClient,
|
||||
transportConnection,
|
||||
observer,
|
||||
monitor,
|
||||
token,
|
||||
@@ -117,7 +114,7 @@ public class RestoreParams {
|
||||
* Caller specifies whether is considered a system-level restore.
|
||||
*/
|
||||
public static RestoreParams createForRestorePackages(
|
||||
TransportClient transportClient,
|
||||
TransportConnection transportConnection,
|
||||
IRestoreObserver observer,
|
||||
IBackupManagerMonitor monitor,
|
||||
long token,
|
||||
@@ -126,7 +123,7 @@ public class RestoreParams {
|
||||
OnTaskFinishedListener listener,
|
||||
BackupEligibilityRules backupEligibilityRules) {
|
||||
return new RestoreParams(
|
||||
transportClient,
|
||||
transportConnection,
|
||||
observer,
|
||||
monitor,
|
||||
token,
|
||||
@@ -139,7 +136,7 @@ public class RestoreParams {
|
||||
}
|
||||
|
||||
private RestoreParams(
|
||||
TransportClient transportClient,
|
||||
TransportConnection transportConnection,
|
||||
IRestoreObserver observer,
|
||||
IBackupManagerMonitor monitor,
|
||||
long token,
|
||||
@@ -149,7 +146,7 @@ public class RestoreParams {
|
||||
@Nullable String[] filterSet,
|
||||
OnTaskFinishedListener listener,
|
||||
BackupEligibilityRules backupEligibilityRules) {
|
||||
this.transportClient = transportClient;
|
||||
this.mTransportConnection = transportConnection;
|
||||
this.observer = observer;
|
||||
this.monitor = monitor;
|
||||
this.token = token;
|
||||
|
||||
@@ -26,7 +26,6 @@ import static com.android.server.backup.internal.BackupHandler.MSG_RUN_RESTORE;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.backup.BackupManager;
|
||||
import android.app.backup.IBackupManagerMonitor;
|
||||
import android.app.backup.IRestoreObserver;
|
||||
import android.app.backup.IRestoreSession;
|
||||
@@ -44,7 +43,7 @@ import com.android.server.backup.UserBackupManagerService;
|
||||
import com.android.server.backup.internal.OnTaskFinishedListener;
|
||||
import com.android.server.backup.params.RestoreGetSetsParams;
|
||||
import com.android.server.backup.params.RestoreParams;
|
||||
import com.android.server.backup.transport.TransportClient;
|
||||
import com.android.server.backup.transport.TransportConnection;
|
||||
import com.android.server.backup.utils.BackupEligibilityRules;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
@@ -104,10 +103,10 @@ public class ActiveRestoreSession extends IRestoreSession.Stub {
|
||||
|
||||
final long oldId = Binder.clearCallingIdentity();
|
||||
try {
|
||||
TransportClient transportClient =
|
||||
TransportConnection transportConnection =
|
||||
mTransportManager.getTransportClient(
|
||||
mTransportName, "RestoreSession.getAvailableRestoreSets()");
|
||||
if (transportClient == null) {
|
||||
if (transportConnection == null) {
|
||||
Slog.w(TAG, "Null transport client getting restore sets");
|
||||
return -1;
|
||||
}
|
||||
@@ -123,12 +122,13 @@ public class ActiveRestoreSession extends IRestoreSession.Stub {
|
||||
// Prevent lambda from leaking 'this'
|
||||
TransportManager transportManager = mTransportManager;
|
||||
OnTaskFinishedListener listener = caller -> {
|
||||
transportManager.disposeOfTransportClient(transportClient, caller);
|
||||
transportManager.disposeOfTransportClient(transportConnection, caller);
|
||||
wakelock.release();
|
||||
};
|
||||
Message msg = mBackupManagerService.getBackupHandler().obtainMessage(
|
||||
MSG_RUN_GET_RESTORE_SETS,
|
||||
new RestoreGetSetsParams(transportClient, this, observer, monitor, listener));
|
||||
new RestoreGetSetsParams(transportConnection, this, observer, monitor,
|
||||
listener));
|
||||
mBackupManagerService.getBackupHandler().sendMessage(msg);
|
||||
return 0;
|
||||
} catch (Exception e) {
|
||||
@@ -399,11 +399,11 @@ public class ActiveRestoreSession extends IRestoreSession.Stub {
|
||||
* Returns 0 if operation sent or -1 otherwise.
|
||||
*/
|
||||
private int sendRestoreToHandlerLocked(
|
||||
BiFunction<TransportClient, OnTaskFinishedListener, RestoreParams> restoreParamsBuilder,
|
||||
String callerLogString) {
|
||||
TransportClient transportClient =
|
||||
BiFunction<TransportConnection, OnTaskFinishedListener,
|
||||
RestoreParams> restoreParamsBuilder, String callerLogString) {
|
||||
TransportConnection transportConnection =
|
||||
mTransportManager.getTransportClient(mTransportName, callerLogString);
|
||||
if (transportClient == null) {
|
||||
if (transportConnection == null) {
|
||||
Slog.e(TAG, "Transport " + mTransportName + " got unregistered");
|
||||
return -1;
|
||||
}
|
||||
@@ -421,11 +421,11 @@ public class ActiveRestoreSession extends IRestoreSession.Stub {
|
||||
// Prevent lambda from leaking 'this'
|
||||
TransportManager transportManager = mTransportManager;
|
||||
OnTaskFinishedListener listener = caller -> {
|
||||
transportManager.disposeOfTransportClient(transportClient, caller);
|
||||
transportManager.disposeOfTransportClient(transportConnection, caller);
|
||||
wakelock.release();
|
||||
};
|
||||
Message msg = backupHandler.obtainMessage(MSG_RUN_RESTORE);
|
||||
msg.obj = restoreParamsBuilder.apply(transportClient, listener);
|
||||
msg.obj = restoreParamsBuilder.apply(transportConnection, listener);
|
||||
backupHandler.sendMessage(msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ import com.android.server.backup.PackageManagerBackupAgent.Metadata;
|
||||
import com.android.server.backup.TransportManager;
|
||||
import com.android.server.backup.UserBackupManagerService;
|
||||
import com.android.server.backup.internal.OnTaskFinishedListener;
|
||||
import com.android.server.backup.transport.TransportClient;
|
||||
import com.android.server.backup.transport.TransportConnection;
|
||||
import com.android.server.backup.utils.BackupEligibilityRules;
|
||||
import com.android.server.backup.utils.BackupManagerMonitorUtils;
|
||||
|
||||
@@ -87,7 +87,7 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask {
|
||||
private final int mUserId;
|
||||
private final TransportManager mTransportManager;
|
||||
// Transport client we're working with to do the restore
|
||||
private final TransportClient mTransportClient;
|
||||
private final TransportConnection mTransportConnection;
|
||||
|
||||
// Where per-transport saved state goes
|
||||
private File mStateDir;
|
||||
@@ -169,7 +169,7 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask {
|
||||
PerformUnifiedRestoreTask(UserBackupManagerService backupManagerService) {
|
||||
mListener = null;
|
||||
mAgentTimeoutParameters = null;
|
||||
mTransportClient = null;
|
||||
mTransportConnection = null;
|
||||
mTransportManager = null;
|
||||
mEphemeralOpToken = 0;
|
||||
mUserId = 0;
|
||||
@@ -181,7 +181,7 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask {
|
||||
// about releasing it.
|
||||
public PerformUnifiedRestoreTask(
|
||||
UserBackupManagerService backupManagerService,
|
||||
TransportClient transportClient,
|
||||
TransportConnection transportConnection,
|
||||
IRestoreObserver observer,
|
||||
IBackupManagerMonitor monitor,
|
||||
long restoreSetToken,
|
||||
@@ -198,7 +198,7 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask {
|
||||
mState = UnifiedRestoreState.INITIAL;
|
||||
mStartRealtime = SystemClock.elapsedRealtime();
|
||||
|
||||
mTransportClient = transportClient;
|
||||
mTransportConnection = transportConnection;
|
||||
mObserver = observer;
|
||||
mMonitor = monitor;
|
||||
mToken = restoreSetToken;
|
||||
@@ -386,7 +386,8 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask {
|
||||
|
||||
try {
|
||||
String transportDirName =
|
||||
mTransportManager.getTransportDirName(mTransportClient.getTransportComponent());
|
||||
mTransportManager.getTransportDirName(
|
||||
mTransportConnection.getTransportComponent());
|
||||
mStateDir = new File(backupManagerService.getBaseStateDir(), transportDirName);
|
||||
|
||||
// Fetch the current metadata from the dataset first
|
||||
@@ -397,7 +398,7 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask {
|
||||
PackageInfo[] packages = mAcceptSet.toArray(new PackageInfo[0]);
|
||||
|
||||
IBackupTransport transport =
|
||||
mTransportClient.connectOrThrow("PerformUnifiedRestoreTask.startRestore()");
|
||||
mTransportConnection.connectOrThrow("PerformUnifiedRestoreTask.startRestore()");
|
||||
|
||||
mStatus = transport.startRestore(mToken, packages);
|
||||
if (mStatus != BackupTransport.TRANSPORT_OK) {
|
||||
@@ -495,7 +496,7 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask {
|
||||
UnifiedRestoreState nextState = UnifiedRestoreState.FINAL;
|
||||
try {
|
||||
IBackupTransport transport =
|
||||
mTransportClient.connectOrThrow(
|
||||
mTransportConnection.connectOrThrow(
|
||||
"PerformUnifiedRestoreTask.dispatchNextRestore()");
|
||||
mRestoreDescription = transport.nextRestorePackage();
|
||||
final String pkgName = (mRestoreDescription != null)
|
||||
@@ -709,7 +710,7 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask {
|
||||
|
||||
try {
|
||||
IBackupTransport transport =
|
||||
mTransportClient.connectOrThrow(
|
||||
mTransportConnection.connectOrThrow(
|
||||
"PerformUnifiedRestoreTask.initiateOneRestore()");
|
||||
|
||||
// Run the transport's restore pass
|
||||
@@ -939,7 +940,7 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask {
|
||||
|
||||
String callerLogString = "PerformUnifiedRestoreTask$StreamFeederThread.run()";
|
||||
try {
|
||||
IBackupTransport transport = mTransportClient.connectOrThrow(callerLogString);
|
||||
IBackupTransport transport = mTransportConnection.connectOrThrow(callerLogString);
|
||||
while (status == BackupTransport.TRANSPORT_OK) {
|
||||
// have the transport write some of the restoring data to us
|
||||
int result = transport.getNextFullRestoreDataChunk(tWriteEnd);
|
||||
@@ -1032,7 +1033,7 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask {
|
||||
// level is immaterial; we need to tell the transport to bail
|
||||
try {
|
||||
IBackupTransport transport =
|
||||
mTransportClient.connectOrThrow(callerLogString);
|
||||
mTransportConnection.connectOrThrow(callerLogString);
|
||||
transport.abortFullRestore();
|
||||
} catch (Exception e) {
|
||||
// transport itself is dead; make sure we handle this as a
|
||||
@@ -1095,7 +1096,7 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask {
|
||||
String callerLogString = "PerformUnifiedRestoreTask.finalizeRestore()";
|
||||
try {
|
||||
IBackupTransport transport =
|
||||
mTransportClient.connectOrThrow(callerLogString);
|
||||
mTransportConnection.connectOrThrow(callerLogString);
|
||||
transport.finishRestore();
|
||||
} catch (Exception e) {
|
||||
Slog.e(TAG, "Error finishing restore", e);
|
||||
|
||||
@@ -42,11 +42,10 @@ import android.util.Slog;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.backup.IBackupTransport;
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.server.backup.transport.TransportClient;
|
||||
import com.android.server.backup.transport.TransportConnection;
|
||||
|
||||
import com.google.android.collect.Sets;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -225,7 +224,7 @@ public class BackupEligibilityRules {
|
||||
* </ol>
|
||||
*/
|
||||
public boolean appIsRunningAndEligibleForBackupWithTransport(
|
||||
@Nullable TransportClient transportClient,
|
||||
@Nullable TransportConnection transportConnection,
|
||||
String packageName) {
|
||||
try {
|
||||
PackageInfo packageInfo = mPackageManager.getPackageInfoAsUser(packageName,
|
||||
@@ -236,10 +235,10 @@ public class BackupEligibilityRules {
|
||||
|| appIsDisabled(applicationInfo)) {
|
||||
return false;
|
||||
}
|
||||
if (transportClient != null) {
|
||||
if (transportConnection != null) {
|
||||
try {
|
||||
IBackupTransport transport =
|
||||
transportClient.connectOrThrow(
|
||||
transportConnection.connectOrThrow(
|
||||
"AppBackupUtils.appIsRunningAndEligibleForBackupWithTransport");
|
||||
return transport.isAppEligibleForBackup(
|
||||
packageInfo, appGetsFullBackup(packageInfo));
|
||||
|
||||
@@ -55,8 +55,8 @@ import android.platform.test.annotations.Presubmit;
|
||||
import com.android.server.backup.testing.TransportData;
|
||||
import com.android.server.backup.testing.TransportTestUtils.TransportMock;
|
||||
import com.android.server.backup.transport.OnTransportRegisteredListener;
|
||||
import com.android.server.backup.transport.TransportClient;
|
||||
import com.android.server.backup.transport.TransportClientManager;
|
||||
import com.android.server.backup.transport.TransportConnection;
|
||||
import com.android.server.backup.transport.TransportConnectionManager;
|
||||
import com.android.server.backup.transport.TransportNotRegisteredException;
|
||||
import com.android.server.testing.shadows.ShadowApplicationPackageManager;
|
||||
|
||||
@@ -85,7 +85,7 @@ public class TransportManagerTest {
|
||||
private static final String PACKAGE_B = "some.package.b";
|
||||
|
||||
@Mock private OnTransportRegisteredListener mListener;
|
||||
@Mock private TransportClientManager mTransportClientManager;
|
||||
@Mock private TransportConnectionManager mTransportConnectionManager;
|
||||
private TransportData mTransportA1;
|
||||
private TransportData mTransportA2;
|
||||
private TransportData mTransportB1;
|
||||
@@ -206,7 +206,7 @@ public class TransportManagerTest {
|
||||
|
||||
transportManager.registerTransports();
|
||||
|
||||
verify(mTransportClientManager)
|
||||
verify(mTransportConnectionManager)
|
||||
.getTransportClient(
|
||||
eq(mTransportA1.getTransportComponent()),
|
||||
argThat(
|
||||
@@ -433,10 +433,10 @@ public class TransportManagerTest {
|
||||
TransportManager transportManager =
|
||||
createTransportManagerWithRegisteredTransports(mTransportA1, mTransportA2);
|
||||
|
||||
TransportClient transportClient =
|
||||
TransportConnection transportConnection =
|
||||
transportManager.getTransportClient(mTransportA1.transportName, "caller");
|
||||
|
||||
assertThat(transportClient.getTransportComponent())
|
||||
assertThat(transportConnection.getTransportComponent())
|
||||
.isEqualTo(mTransportA1.getTransportComponent());
|
||||
}
|
||||
|
||||
@@ -453,10 +453,10 @@ public class TransportManagerTest {
|
||||
null,
|
||||
null);
|
||||
|
||||
TransportClient transportClient =
|
||||
TransportConnection transportConnection =
|
||||
transportManager.getTransportClient(mTransportA1.transportName, "caller");
|
||||
|
||||
assertThat(transportClient).isNull();
|
||||
assertThat(transportConnection).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -471,9 +471,10 @@ public class TransportManagerTest {
|
||||
null,
|
||||
null);
|
||||
|
||||
TransportClient transportClient = transportManager.getTransportClient("newName", "caller");
|
||||
TransportConnection transportConnection = transportManager.getTransportClient(
|
||||
"newName", "caller");
|
||||
|
||||
assertThat(transportClient.getTransportComponent())
|
||||
assertThat(transportConnection.getTransportComponent())
|
||||
.isEqualTo(mTransportA1.getTransportComponent());
|
||||
}
|
||||
|
||||
@@ -482,9 +483,10 @@ public class TransportManagerTest {
|
||||
TransportManager transportManager =
|
||||
createTransportManagerWithRegisteredTransports(mTransportA1, mTransportA2);
|
||||
|
||||
TransportClient transportClient = transportManager.getCurrentTransportClient("caller");
|
||||
TransportConnection transportConnection = transportManager.getCurrentTransportClient(
|
||||
"caller");
|
||||
|
||||
assertThat(transportClient.getTransportComponent())
|
||||
assertThat(transportConnection.getTransportComponent())
|
||||
.isEqualTo(mTransportA1.getTransportComponent());
|
||||
}
|
||||
|
||||
@@ -660,12 +662,12 @@ public class TransportManagerTest {
|
||||
List<TransportMock> transportMocks = new ArrayList<>(transports.length);
|
||||
for (TransportData transport : transports) {
|
||||
TransportMock transportMock = mockTransport(transport);
|
||||
when(mTransportClientManager.getTransportClient(
|
||||
when(mTransportConnectionManager.getTransportClient(
|
||||
eq(transport.getTransportComponent()), any()))
|
||||
.thenReturn(transportMock.transportClient);
|
||||
when(mTransportClientManager.getTransportClient(
|
||||
.thenReturn(transportMock.mTransportConnection);
|
||||
when(mTransportConnectionManager.getTransportClient(
|
||||
eq(transport.getTransportComponent()), any(), any()))
|
||||
.thenReturn(transportMock.transportClient);
|
||||
.thenReturn(transportMock.mTransportConnection);
|
||||
transportMocks.add(transportMock);
|
||||
}
|
||||
return transportMocks;
|
||||
@@ -706,7 +708,7 @@ public class TransportManagerTest {
|
||||
.map(TransportData::getTransportComponent)
|
||||
.collect(toSet()),
|
||||
selectedTransport != null ? selectedTransport.transportName : null,
|
||||
mTransportClientManager);
|
||||
mTransportConnectionManager);
|
||||
transportManager.setOnTransportRegisteredListener(mListener);
|
||||
return transportManager;
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ public class UserBackupManagerServiceTest {
|
||||
|
||||
assertThat(result).isTrue();
|
||||
verify(mTransportManager)
|
||||
.disposeOfTransportClient(eq(transportMock.transportClient), any());
|
||||
.disposeOfTransportClient(eq(transportMock.mTransportConnection), any());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -282,7 +282,7 @@ public class UserBackupManagerServiceTest {
|
||||
|
||||
assertThat(filtered).asList().containsExactly(PACKAGE_1);
|
||||
verify(mTransportManager)
|
||||
.disposeOfTransportClient(eq(transportMock.transportClient), any());
|
||||
.disposeOfTransportClient(eq(transportMock.mTransportConnection), any());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -357,7 +357,7 @@ public class UserBackupManagerServiceTest {
|
||||
assertThat(getSettingsTransport()).isEqualTo(mNewTransport.transportName);
|
||||
assertThat(oldTransport).isEqualTo(mOldTransport.transportName);
|
||||
verify(mTransportManager)
|
||||
.disposeOfTransportClient(eq(mNewTransportMock.transportClient), any());
|
||||
.disposeOfTransportClient(eq(mNewTransportMock.mTransportConnection), any());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -395,7 +395,7 @@ public class UserBackupManagerServiceTest {
|
||||
assertThat(getSettingsTransport()).isEqualTo(mNewTransport.transportName);
|
||||
verify(callback).onSuccess(eq(mNewTransport.transportName));
|
||||
verify(mTransportManager)
|
||||
.disposeOfTransportClient(eq(mNewTransportMock.transportClient), any());
|
||||
.disposeOfTransportClient(eq(mNewTransportMock.mTransportConnection), any());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,7 +50,7 @@ import com.android.server.backup.UserBackupManagerService;
|
||||
import com.android.server.backup.testing.TransportData;
|
||||
import com.android.server.backup.testing.TransportTestUtils;
|
||||
import com.android.server.backup.testing.TransportTestUtils.TransportMock;
|
||||
import com.android.server.backup.transport.TransportClient;
|
||||
import com.android.server.backup.transport.TransportConnection;
|
||||
import com.android.server.testing.shadows.ShadowSlog;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -285,7 +285,7 @@ public class PerformInitializeTaskTest {
|
||||
TransportData transport = transportsIterator.next();
|
||||
verify(mTransportManager).getTransportClient(eq(transport.transportName), any());
|
||||
verify(mTransportManager)
|
||||
.disposeOfTransportClient(eq(transportMock.transportClient), any());
|
||||
.disposeOfTransportClient(eq(transportMock.mTransportConnection), any());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,9 +303,9 @@ public class PerformInitializeTaskTest {
|
||||
performInitializeTask.run();
|
||||
|
||||
verify(mTransportManager)
|
||||
.disposeOfTransportClient(eq(transportMocks.get(0).transportClient), any());
|
||||
.disposeOfTransportClient(eq(transportMocks.get(0).mTransportConnection), any());
|
||||
verify(mTransportManager)
|
||||
.disposeOfTransportClient(eq(transportMocks.get(1).transportClient), any());
|
||||
.disposeOfTransportClient(eq(transportMocks.get(1).mTransportConnection), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -328,14 +328,16 @@ public class PerformInitializeTaskTest {
|
||||
setUpTransports(mTransportManager, transport1, transport2);
|
||||
String registeredTransportName = transport2.transportName;
|
||||
IBackupTransport registeredTransport = transportMocks.get(1).transport;
|
||||
TransportClient registeredTransportClient = transportMocks.get(1).transportClient;
|
||||
TransportConnection
|
||||
registeredTransportConnection = transportMocks.get(1).mTransportConnection;
|
||||
PerformInitializeTask performInitializeTask =
|
||||
createPerformInitializeTask(transport1.transportName, transport2.transportName);
|
||||
|
||||
performInitializeTask.run();
|
||||
|
||||
verify(registeredTransport).initializeDevice();
|
||||
verify(mTransportManager).disposeOfTransportClient(eq(registeredTransportClient), any());
|
||||
verify(mTransportManager).disposeOfTransportClient(eq(registeredTransportConnection),
|
||||
any());
|
||||
verify(mObserver).onResult(eq(registeredTransportName), eq(TRANSPORT_OK));
|
||||
}
|
||||
|
||||
@@ -347,7 +349,7 @@ public class PerformInitializeTaskTest {
|
||||
performInitializeTask.run();
|
||||
|
||||
verify(mTransportManager)
|
||||
.disposeOfTransportClient(eq(transportMock.transportClient), any());
|
||||
.disposeOfTransportClient(eq(transportMock.mTransportConnection), any());
|
||||
verify(mObserver).backupFinished(eq(TRANSPORT_ERROR));
|
||||
verify(mListener).onFinished(any());
|
||||
}
|
||||
@@ -356,13 +358,13 @@ public class PerformInitializeTaskTest {
|
||||
public void testRun_whenTransportThrowsDeadObjectException() throws Exception {
|
||||
TransportMock transportMock = setUpTransport(mTransport);
|
||||
IBackupTransport transport = transportMock.transport;
|
||||
TransportClient transportClient = transportMock.transportClient;
|
||||
TransportConnection transportConnection = transportMock.mTransportConnection;
|
||||
when(transport.initializeDevice()).thenThrow(DeadObjectException.class);
|
||||
PerformInitializeTask performInitializeTask = createPerformInitializeTask(mTransportName);
|
||||
|
||||
performInitializeTask.run();
|
||||
|
||||
verify(mTransportManager).disposeOfTransportClient(eq(transportClient), any());
|
||||
verify(mTransportManager).disposeOfTransportClient(eq(transportConnection), any());
|
||||
verify(mObserver).backupFinished(eq(TRANSPORT_ERROR));
|
||||
verify(mListener).onFinished(any());
|
||||
}
|
||||
|
||||
@@ -2665,7 +2665,7 @@ public class KeyValueBackupTaskTest {
|
||||
KeyValueBackupTask task =
|
||||
new KeyValueBackupTask(
|
||||
mBackupManagerService,
|
||||
transportMock.transportClient,
|
||||
transportMock.mTransportConnection,
|
||||
transportMock.transportData.transportDirName,
|
||||
queue,
|
||||
mOldJournal,
|
||||
|
||||
@@ -202,7 +202,7 @@ public class ActiveRestoreSessionTest {
|
||||
verify(mObserver)
|
||||
.restoreSetsAvailable(aryEq(new RestoreSet[] {mRestoreSet1, mRestoreSet2}));
|
||||
verify(mTransportManager)
|
||||
.disposeOfTransportClient(eq(transportMock.transportClient), any());
|
||||
.disposeOfTransportClient(eq(transportMock.mTransportConnection), any());
|
||||
assertThat(mWakeLock.isHeld()).isFalse();
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ public class ActiveRestoreSessionTest {
|
||||
verify(mObserver).restoreSetsAvailable(isNull());
|
||||
assertEventLogged(EventLogTags.RESTORE_TRANSPORT_FAILURE);
|
||||
verify(mTransportManager)
|
||||
.disposeOfTransportClient(eq(transportMock.transportClient), any());
|
||||
.disposeOfTransportClient(eq(transportMock.mTransportConnection), any());
|
||||
assertThat(mWakeLock.isHeld()).isFalse();
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ public class ActiveRestoreSessionTest {
|
||||
mShadowBackupLooper.runToEndOfTasks();
|
||||
assertThat(result).isEqualTo(0);
|
||||
verify(mTransportManager)
|
||||
.disposeOfTransportClient(eq(transportMock.transportClient), any());
|
||||
.disposeOfTransportClient(eq(transportMock.mTransportConnection), any());
|
||||
assertThat(mWakeLock.isHeld()).isFalse();
|
||||
assertThat(mBackupManagerService.isRestoreInProgress()).isFalse();
|
||||
// Verify it created the task properly
|
||||
@@ -341,7 +341,7 @@ public class ActiveRestoreSessionTest {
|
||||
mShadowBackupLooper.runToEndOfTasks();
|
||||
assertThat(result).isEqualTo(0);
|
||||
verify(mTransportManager)
|
||||
.disposeOfTransportClient(eq(transportMock.transportClient), any());
|
||||
.disposeOfTransportClient(eq(transportMock.mTransportConnection), any());
|
||||
assertThat(mWakeLock.isHeld()).isFalse();
|
||||
assertThat(mBackupManagerService.isRestoreInProgress()).isFalse();
|
||||
ShadowPerformUnifiedRestoreTask shadowTask =
|
||||
@@ -463,7 +463,7 @@ public class ActiveRestoreSessionTest {
|
||||
mShadowBackupLooper.runToEndOfTasks();
|
||||
assertThat(result).isEqualTo(0);
|
||||
verify(mTransportManager)
|
||||
.disposeOfTransportClient(eq(transportMock.transportClient), any());
|
||||
.disposeOfTransportClient(eq(transportMock.mTransportConnection), any());
|
||||
assertThat(mWakeLock.isHeld()).isFalse();
|
||||
assertThat(mBackupManagerService.isRestoreInProgress()).isFalse();
|
||||
ShadowPerformUnifiedRestoreTask shadowTask =
|
||||
|
||||
@@ -36,7 +36,7 @@ import android.os.RemoteException;
|
||||
|
||||
import com.android.internal.backup.IBackupTransport;
|
||||
import com.android.server.backup.TransportManager;
|
||||
import com.android.server.backup.transport.TransportClient;
|
||||
import com.android.server.backup.transport.TransportConnection;
|
||||
import com.android.server.backup.transport.TransportNotAvailableException;
|
||||
import com.android.server.backup.transport.TransportNotRegisteredException;
|
||||
|
||||
@@ -91,9 +91,9 @@ public class TransportTestUtils {
|
||||
|| status == TransportStatus.REGISTERED_UNAVAILABLE) {
|
||||
// Transport registered
|
||||
when(transportManager.getCurrentTransportClient(any()))
|
||||
.thenReturn(transportMock.transportClient);
|
||||
.thenReturn(transportMock.mTransportConnection);
|
||||
when(transportManager.getCurrentTransportClientOrThrow(any()))
|
||||
.thenReturn(transportMock.transportClient);
|
||||
.thenReturn(transportMock.mTransportConnection);
|
||||
} else {
|
||||
// Transport not registered
|
||||
when(transportManager.getCurrentTransportClient(any())).thenReturn(null);
|
||||
@@ -123,9 +123,9 @@ public class TransportTestUtils {
|
||||
|| status == TransportStatus.REGISTERED_UNAVAILABLE) {
|
||||
// Transport registered
|
||||
when(transportManager.getTransportClient(eq(transportName), any()))
|
||||
.thenReturn(transportMock.transportClient);
|
||||
.thenReturn(transportMock.mTransportConnection);
|
||||
when(transportManager.getTransportClientOrThrow(eq(transportName), any()))
|
||||
.thenReturn(transportMock.transportClient);
|
||||
.thenReturn(transportMock.mTransportConnection);
|
||||
when(transportManager.getTransportName(transportComponent)).thenReturn(transportName);
|
||||
when(transportManager.getTransportDirName(eq(transportName)))
|
||||
.thenReturn(transportDirName);
|
||||
@@ -150,28 +150,28 @@ public class TransportTestUtils {
|
||||
}
|
||||
|
||||
public static TransportMock mockTransport(TransportData transport) throws Exception {
|
||||
final TransportClient transportClientMock;
|
||||
final TransportConnection transportConnectionMock;
|
||||
int status = transport.transportStatus;
|
||||
ComponentName transportComponent = transport.getTransportComponent();
|
||||
if (status == TransportStatus.REGISTERED_AVAILABLE
|
||||
|| status == TransportStatus.REGISTERED_UNAVAILABLE) {
|
||||
// Transport registered
|
||||
transportClientMock = mock(TransportClient.class);
|
||||
when(transportClientMock.getTransportComponent()).thenReturn(transportComponent);
|
||||
transportConnectionMock = mock(TransportConnection.class);
|
||||
when(transportConnectionMock.getTransportComponent()).thenReturn(transportComponent);
|
||||
if (status == TransportStatus.REGISTERED_AVAILABLE) {
|
||||
// Transport registered and available
|
||||
IBackupTransport transportMock = mockTransportBinder(transport);
|
||||
when(transportClientMock.connectOrThrow(any())).thenReturn(transportMock);
|
||||
when(transportClientMock.connect(any())).thenReturn(transportMock);
|
||||
when(transportConnectionMock.connectOrThrow(any())).thenReturn(transportMock);
|
||||
when(transportConnectionMock.connect(any())).thenReturn(transportMock);
|
||||
|
||||
return new TransportMock(transport, transportClientMock, transportMock);
|
||||
return new TransportMock(transport, transportConnectionMock, transportMock);
|
||||
} else {
|
||||
// Transport registered but unavailable
|
||||
when(transportClientMock.connectOrThrow(any()))
|
||||
when(transportConnectionMock.connectOrThrow(any()))
|
||||
.thenThrow(TransportNotAvailableException.class);
|
||||
when(transportClientMock.connect(any())).thenReturn(null);
|
||||
when(transportConnectionMock.connect(any())).thenReturn(null);
|
||||
|
||||
return new TransportMock(transport, transportClientMock, null);
|
||||
return new TransportMock(transport, transportConnectionMock, null);
|
||||
}
|
||||
} else {
|
||||
// Transport not registered
|
||||
@@ -198,15 +198,15 @@ public class TransportTestUtils {
|
||||
|
||||
public static class TransportMock {
|
||||
public final TransportData transportData;
|
||||
@Nullable public final TransportClient transportClient;
|
||||
@Nullable public final TransportConnection mTransportConnection;
|
||||
@Nullable public final IBackupTransport transport;
|
||||
|
||||
private TransportMock(
|
||||
TransportData transportData,
|
||||
@Nullable TransportClient transportClient,
|
||||
@Nullable TransportConnection transportConnection,
|
||||
@Nullable IBackupTransport transport) {
|
||||
this.transportData = transportData;
|
||||
this.transportClient = transportClient;
|
||||
this.mTransportConnection = transportConnection;
|
||||
this.transport = transport;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,14 +44,14 @@ import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Presubmit
|
||||
public class TransportClientManagerTest {
|
||||
public class TransportConnectionManagerTest {
|
||||
private static final String PACKAGE_NAME = "random.package.name";
|
||||
private static final String CLASS_NAME = "random.package.name.transport.Transport";
|
||||
|
||||
@Mock private Context mContext;
|
||||
@Mock private TransportConnectionListener mTransportConnectionListener;
|
||||
private @UserIdInt int mUserId;
|
||||
private TransportClientManager mTransportClientManager;
|
||||
private TransportConnectionManager mTransportConnectionManager;
|
||||
private ComponentName mTransportComponent;
|
||||
private Intent mBindIntent;
|
||||
|
||||
@@ -60,8 +60,8 @@ public class TransportClientManagerTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mUserId = UserHandle.USER_SYSTEM;
|
||||
mTransportClientManager =
|
||||
new TransportClientManager(mUserId, mContext, new TransportStats());
|
||||
mTransportConnectionManager =
|
||||
new TransportConnectionManager(mUserId, mContext, new TransportStats());
|
||||
mTransportComponent = new ComponentName(PACKAGE_NAME, CLASS_NAME);
|
||||
mBindIntent = new Intent(SERVICE_ACTION_TRANSPORT_HOST).setComponent(mTransportComponent);
|
||||
|
||||
@@ -75,11 +75,11 @@ public class TransportClientManagerTest {
|
||||
|
||||
@Test
|
||||
public void testGetTransportClient() {
|
||||
TransportClient transportClient =
|
||||
mTransportClientManager.getTransportClient(mTransportComponent, "caller");
|
||||
TransportConnection transportConnection =
|
||||
mTransportConnectionManager.getTransportClient(mTransportComponent, "caller");
|
||||
|
||||
// Connect to be able to extract the intent
|
||||
transportClient.connectAsync(mTransportConnectionListener, "caller");
|
||||
transportConnection.connectAsync(mTransportConnectionListener, "caller");
|
||||
verify(mContext)
|
||||
.bindServiceAsUser(
|
||||
argThat(matchesIntentAndExtras(mBindIntent)),
|
||||
@@ -93,10 +93,11 @@ public class TransportClientManagerTest {
|
||||
Bundle extras = new Bundle();
|
||||
extras.putBoolean("random_extra", true);
|
||||
|
||||
TransportClient transportClient =
|
||||
mTransportClientManager.getTransportClient(mTransportComponent, extras, "caller");
|
||||
TransportConnection transportConnection =
|
||||
mTransportConnectionManager.getTransportClient(mTransportComponent, extras,
|
||||
"caller");
|
||||
|
||||
transportClient.connectAsync(mTransportConnectionListener, "caller");
|
||||
transportConnection.connectAsync(mTransportConnectionListener, "caller");
|
||||
mBindIntent.putExtras(extras);
|
||||
verify(mContext)
|
||||
.bindServiceAsUser(
|
||||
@@ -108,13 +109,13 @@ public class TransportClientManagerTest {
|
||||
|
||||
@Test
|
||||
public void testDisposeOfTransportClient() {
|
||||
TransportClient transportClient =
|
||||
spy(mTransportClientManager.getTransportClient(mTransportComponent, "caller"));
|
||||
TransportConnection transportConnection =
|
||||
spy(mTransportConnectionManager.getTransportClient(mTransportComponent, "caller"));
|
||||
|
||||
mTransportClientManager.disposeOfTransportClient(transportClient, "caller");
|
||||
mTransportConnectionManager.disposeOfTransportClient(transportConnection, "caller");
|
||||
|
||||
verify(transportClient).unbind(any());
|
||||
verify(transportClient).markAsDisposed();
|
||||
verify(transportConnection).unbind(any());
|
||||
verify(transportConnection).markAsDisposed();
|
||||
}
|
||||
|
||||
private ArgumentMatcher<Intent> matchesIntentAndExtras(Intent expectedIntent) {
|
||||
@@ -77,7 +77,7 @@ import java.util.function.Supplier;
|
||||
FrameworkShadowLooper.class
|
||||
})
|
||||
@Presubmit
|
||||
public class TransportClientTest {
|
||||
public class TransportConnectionTest {
|
||||
private static final String PACKAGE_NAME = "some.package.name";
|
||||
|
||||
@Mock private Context mContext;
|
||||
@@ -86,7 +86,7 @@ public class TransportClientTest {
|
||||
@Mock private IBackupTransport.Stub mTransportBinder;
|
||||
@UserIdInt private int mUserId;
|
||||
private TransportStats mTransportStats;
|
||||
private TransportClient mTransportClient;
|
||||
private TransportConnection mTransportConnection;
|
||||
private ComponentName mTransportComponent;
|
||||
private String mTransportString;
|
||||
private Intent mBindIntent;
|
||||
@@ -106,8 +106,8 @@ public class TransportClientTest {
|
||||
mTransportString = mTransportComponent.flattenToShortString();
|
||||
mTransportStats = new TransportStats();
|
||||
mBindIntent = new Intent(SERVICE_ACTION_TRANSPORT_HOST).setComponent(mTransportComponent);
|
||||
mTransportClient =
|
||||
new TransportClient(
|
||||
mTransportConnection =
|
||||
new TransportConnection(
|
||||
mUserId,
|
||||
mContext,
|
||||
mTransportStats,
|
||||
@@ -132,12 +132,12 @@ public class TransportClientTest {
|
||||
|
||||
@Test
|
||||
public void testGetTransportComponent_returnsTransportComponent() {
|
||||
assertThat(mTransportClient.getTransportComponent()).isEqualTo(mTransportComponent);
|
||||
assertThat(mTransportConnection.getTransportComponent()).isEqualTo(mTransportComponent);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConnectAsync_callsBindService() {
|
||||
mTransportClient.connectAsync(mTransportConnectionListener, "caller");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener, "caller");
|
||||
|
||||
verify(mContext)
|
||||
.bindServiceAsUser(
|
||||
@@ -149,42 +149,42 @@ public class TransportClientTest {
|
||||
|
||||
@Test
|
||||
public void testConnectAsync_callsListenerWhenConnected() {
|
||||
mTransportClient.connectAsync(mTransportConnectionListener, "caller");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener, "caller");
|
||||
ServiceConnection connection = verifyBindServiceAsUserAndCaptureServiceConnection(mContext);
|
||||
|
||||
connection.onServiceConnected(mTransportComponent, mTransportBinder);
|
||||
|
||||
mShadowMainLooper.runToEndOfTasks();
|
||||
verify(mTransportConnectionListener)
|
||||
.onTransportConnectionResult(any(IBackupTransport.class), eq(mTransportClient));
|
||||
.onTransportConnectionResult(any(IBackupTransport.class), eq(mTransportConnection));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConnectAsync_whenPendingConnection_callsAllListenersWhenConnected() {
|
||||
mTransportClient.connectAsync(mTransportConnectionListener, "caller1");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener, "caller1");
|
||||
ServiceConnection connection = verifyBindServiceAsUserAndCaptureServiceConnection(mContext);
|
||||
|
||||
mTransportClient.connectAsync(mTransportConnectionListener2, "caller2");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener2, "caller2");
|
||||
|
||||
connection.onServiceConnected(mTransportComponent, mTransportBinder);
|
||||
mShadowMainLooper.runToEndOfTasks();
|
||||
verify(mTransportConnectionListener)
|
||||
.onTransportConnectionResult(any(IBackupTransport.class), eq(mTransportClient));
|
||||
.onTransportConnectionResult(any(IBackupTransport.class), eq(mTransportConnection));
|
||||
verify(mTransportConnectionListener2)
|
||||
.onTransportConnectionResult(any(IBackupTransport.class), eq(mTransportClient));
|
||||
.onTransportConnectionResult(any(IBackupTransport.class), eq(mTransportConnection));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConnectAsync_whenAlreadyConnected_callsListener() {
|
||||
mTransportClient.connectAsync(mTransportConnectionListener, "caller1");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener, "caller1");
|
||||
ServiceConnection connection = verifyBindServiceAsUserAndCaptureServiceConnection(mContext);
|
||||
connection.onServiceConnected(mTransportComponent, mTransportBinder);
|
||||
|
||||
mTransportClient.connectAsync(mTransportConnectionListener2, "caller2");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener2, "caller2");
|
||||
|
||||
mShadowMainLooper.runToEndOfTasks();
|
||||
verify(mTransportConnectionListener2)
|
||||
.onTransportConnectionResult(any(IBackupTransport.class), eq(mTransportClient));
|
||||
.onTransportConnectionResult(any(IBackupTransport.class), eq(mTransportConnection));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -196,11 +196,11 @@ public class TransportClientTest {
|
||||
any(UserHandle.class)))
|
||||
.thenReturn(false);
|
||||
|
||||
mTransportClient.connectAsync(mTransportConnectionListener, "caller");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener, "caller");
|
||||
|
||||
mShadowMainLooper.runToEndOfTasks();
|
||||
verify(mTransportConnectionListener)
|
||||
.onTransportConnectionResult(isNull(), eq(mTransportClient));
|
||||
.onTransportConnectionResult(isNull(), eq(mTransportConnection));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -212,7 +212,7 @@ public class TransportClientTest {
|
||||
any(UserHandle.class)))
|
||||
.thenReturn(false);
|
||||
|
||||
mTransportClient.connectAsync(mTransportConnectionListener, "caller");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener, "caller");
|
||||
|
||||
ServiceConnection connection = verifyBindServiceAsUserAndCaptureServiceConnection(mContext);
|
||||
verify(mContext).unbindService(eq(connection));
|
||||
@@ -220,64 +220,64 @@ public class TransportClientTest {
|
||||
|
||||
@Test
|
||||
public void testConnectAsync_afterOnServiceDisconnectedBeforeNewConnection_callsListener() {
|
||||
mTransportClient.connectAsync(mTransportConnectionListener, "caller1");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener, "caller1");
|
||||
ServiceConnection connection = verifyBindServiceAsUserAndCaptureServiceConnection(mContext);
|
||||
connection.onServiceConnected(mTransportComponent, mTransportBinder);
|
||||
connection.onServiceDisconnected(mTransportComponent);
|
||||
|
||||
mTransportClient.connectAsync(mTransportConnectionListener2, "caller1");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener2, "caller1");
|
||||
|
||||
verify(mTransportConnectionListener2)
|
||||
.onTransportConnectionResult(isNull(), eq(mTransportClient));
|
||||
.onTransportConnectionResult(isNull(), eq(mTransportConnection));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConnectAsync_afterOnServiceDisconnectedAfterNewConnection_callsListener() {
|
||||
mTransportClient.connectAsync(mTransportConnectionListener, "caller1");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener, "caller1");
|
||||
ServiceConnection connection = verifyBindServiceAsUserAndCaptureServiceConnection(mContext);
|
||||
connection.onServiceConnected(mTransportComponent, mTransportBinder);
|
||||
connection.onServiceDisconnected(mTransportComponent);
|
||||
connection.onServiceConnected(mTransportComponent, mTransportBinder);
|
||||
|
||||
mTransportClient.connectAsync(mTransportConnectionListener2, "caller1");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener2, "caller1");
|
||||
|
||||
// Yes, it should return null because the object became unusable, check design doc
|
||||
verify(mTransportConnectionListener2)
|
||||
.onTransportConnectionResult(isNull(), eq(mTransportClient));
|
||||
.onTransportConnectionResult(isNull(), eq(mTransportConnection));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConnectAsync_callsListenerIfBindingDies() {
|
||||
mTransportClient.connectAsync(mTransportConnectionListener, "caller");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener, "caller");
|
||||
ServiceConnection connection = verifyBindServiceAsUserAndCaptureServiceConnection(mContext);
|
||||
|
||||
connection.onBindingDied(mTransportComponent);
|
||||
|
||||
mShadowMainLooper.runToEndOfTasks();
|
||||
verify(mTransportConnectionListener)
|
||||
.onTransportConnectionResult(isNull(), eq(mTransportClient));
|
||||
.onTransportConnectionResult(isNull(), eq(mTransportConnection));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConnectAsync_whenPendingConnection_callsListenersIfBindingDies() {
|
||||
mTransportClient.connectAsync(mTransportConnectionListener, "caller1");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener, "caller1");
|
||||
ServiceConnection connection = verifyBindServiceAsUserAndCaptureServiceConnection(mContext);
|
||||
|
||||
mTransportClient.connectAsync(mTransportConnectionListener2, "caller2");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener2, "caller2");
|
||||
|
||||
connection.onBindingDied(mTransportComponent);
|
||||
mShadowMainLooper.runToEndOfTasks();
|
||||
verify(mTransportConnectionListener)
|
||||
.onTransportConnectionResult(isNull(), eq(mTransportClient));
|
||||
.onTransportConnectionResult(isNull(), eq(mTransportConnection));
|
||||
verify(mTransportConnectionListener2)
|
||||
.onTransportConnectionResult(isNull(), eq(mTransportClient));
|
||||
.onTransportConnectionResult(isNull(), eq(mTransportConnection));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConnectAsync_beforeFrameworkCall_logsBoundTransitionEvent() {
|
||||
ShadowEventLog.setUp();
|
||||
|
||||
mTransportClient.connectAsync(mTransportConnectionListener, "caller1");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener, "caller1");
|
||||
|
||||
assertEventLogged(EventLogTags.BACKUP_TRANSPORT_LIFECYCLE, mTransportString, 1);
|
||||
}
|
||||
@@ -285,7 +285,7 @@ public class TransportClientTest {
|
||||
@Test
|
||||
public void testConnectAsync_afterOnServiceConnected_logsBoundAndConnectedTransitionEvents() {
|
||||
ShadowEventLog.setUp();
|
||||
mTransportClient.connectAsync(mTransportConnectionListener, "caller1");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener, "caller1");
|
||||
ServiceConnection connection = verifyBindServiceAsUserAndCaptureServiceConnection(mContext);
|
||||
|
||||
connection.onServiceConnected(mTransportComponent, mTransportBinder);
|
||||
@@ -297,7 +297,7 @@ public class TransportClientTest {
|
||||
@Test
|
||||
public void testConnectAsync_afterOnBindingDied_logsBoundAndUnboundTransitionEvents() {
|
||||
ShadowEventLog.setUp();
|
||||
mTransportClient.connectAsync(mTransportConnectionListener, "caller1");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener, "caller1");
|
||||
ServiceConnection connection = verifyBindServiceAsUserAndCaptureServiceConnection(mContext);
|
||||
|
||||
connection.onBindingDied(mTransportComponent);
|
||||
@@ -308,37 +308,37 @@ public class TransportClientTest {
|
||||
|
||||
@Test
|
||||
public void testConnect_whenConnected_returnsTransport() throws Exception {
|
||||
mTransportClient.connectAsync(mTransportConnectionListener, "caller1");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener, "caller1");
|
||||
ServiceConnection connection = verifyBindServiceAsUserAndCaptureServiceConnection(mContext);
|
||||
connection.onServiceConnected(mTransportComponent, mTransportBinder);
|
||||
|
||||
IBackupTransport transportBinder =
|
||||
runInWorkerThread(() -> mTransportClient.connect("caller2"));
|
||||
runInWorkerThread(() -> mTransportConnection.connect("caller2"));
|
||||
|
||||
assertThat(transportBinder).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConnect_afterOnServiceDisconnected_returnsNull() throws Exception {
|
||||
mTransportClient.connectAsync(mTransportConnectionListener, "caller1");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener, "caller1");
|
||||
ServiceConnection connection = verifyBindServiceAsUserAndCaptureServiceConnection(mContext);
|
||||
connection.onServiceConnected(mTransportComponent, mTransportBinder);
|
||||
connection.onServiceDisconnected(mTransportComponent);
|
||||
|
||||
IBackupTransport transportBinder =
|
||||
runInWorkerThread(() -> mTransportClient.connect("caller2"));
|
||||
runInWorkerThread(() -> mTransportConnection.connect("caller2"));
|
||||
|
||||
assertThat(transportBinder).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConnect_afterOnBindingDied_returnsNull() throws Exception {
|
||||
mTransportClient.connectAsync(mTransportConnectionListener, "caller1");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener, "caller1");
|
||||
ServiceConnection connection = verifyBindServiceAsUserAndCaptureServiceConnection(mContext);
|
||||
connection.onBindingDied(mTransportComponent);
|
||||
|
||||
IBackupTransport transportBinder =
|
||||
runInWorkerThread(() -> mTransportClient.connect("caller2"));
|
||||
runInWorkerThread(() -> mTransportConnection.connect("caller2"));
|
||||
|
||||
assertThat(transportBinder).isNull();
|
||||
}
|
||||
@@ -350,30 +350,31 @@ public class TransportClientTest {
|
||||
// reentrant lock can't be acquired by the listener at the call-site of bindServiceAsUser(),
|
||||
// which is what would happened if we mocked bindServiceAsUser() to call the listener
|
||||
// inline.
|
||||
TransportClient transportClient = spy(mTransportClient);
|
||||
TransportConnection transportConnection = spy(mTransportConnection);
|
||||
doAnswer(
|
||||
invocation -> {
|
||||
TransportConnectionListener listener = invocation.getArgument(0);
|
||||
listener.onTransportConnectionResult(mTransportBinder, transportClient);
|
||||
listener.onTransportConnectionResult(mTransportBinder,
|
||||
transportConnection);
|
||||
return null;
|
||||
})
|
||||
.when(transportClient)
|
||||
.when(transportConnection)
|
||||
.connectAsync(any(), any());
|
||||
|
||||
IBackupTransport transportBinder =
|
||||
runInWorkerThread(() -> transportClient.connect("caller"));
|
||||
runInWorkerThread(() -> transportConnection.connect("caller"));
|
||||
|
||||
assertThat(transportBinder).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnbind_whenConnected_logsDisconnectedAndUnboundTransitionEvents() {
|
||||
mTransportClient.connectAsync(mTransportConnectionListener, "caller1");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener, "caller1");
|
||||
ServiceConnection connection = verifyBindServiceAsUserAndCaptureServiceConnection(mContext);
|
||||
connection.onServiceConnected(mTransportComponent, mTransportBinder);
|
||||
ShadowEventLog.setUp();
|
||||
|
||||
mTransportClient.unbind("caller1");
|
||||
mTransportConnection.unbind("caller1");
|
||||
|
||||
assertEventLogged(EventLogTags.BACKUP_TRANSPORT_CONNECTION, mTransportString, 0);
|
||||
assertEventLogged(EventLogTags.BACKUP_TRANSPORT_LIFECYCLE, mTransportString, 0);
|
||||
@@ -382,7 +383,7 @@ public class TransportClientTest {
|
||||
@Test
|
||||
public void
|
||||
testOnServiceDisconnected_whenConnected_logsDisconnectedAndUnboundTransitionEvents() {
|
||||
mTransportClient.connectAsync(mTransportConnectionListener, "caller1");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener, "caller1");
|
||||
ServiceConnection connection = verifyBindServiceAsUserAndCaptureServiceConnection(mContext);
|
||||
connection.onServiceConnected(mTransportComponent, mTransportBinder);
|
||||
ShadowEventLog.setUp();
|
||||
@@ -395,7 +396,7 @@ public class TransportClientTest {
|
||||
|
||||
@Test
|
||||
public void testOnBindingDied_whenConnected_logsDisconnectedAndUnboundTransitionEvents() {
|
||||
mTransportClient.connectAsync(mTransportConnectionListener, "caller1");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener, "caller1");
|
||||
ServiceConnection connection = verifyBindServiceAsUserAndCaptureServiceConnection(mContext);
|
||||
connection.onServiceConnected(mTransportComponent, mTransportBinder);
|
||||
ShadowEventLog.setUp();
|
||||
@@ -408,60 +409,60 @@ public class TransportClientTest {
|
||||
|
||||
@Test
|
||||
public void testMarkAsDisposed_whenCreated() {
|
||||
mTransportClient.markAsDisposed();
|
||||
mTransportConnection.markAsDisposed();
|
||||
|
||||
// No exception thrown
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMarkAsDisposed_afterOnBindingDied() {
|
||||
mTransportClient.connectAsync(mTransportConnectionListener, "caller1");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener, "caller1");
|
||||
ServiceConnection connection = verifyBindServiceAsUserAndCaptureServiceConnection(mContext);
|
||||
connection.onBindingDied(mTransportComponent);
|
||||
|
||||
mTransportClient.markAsDisposed();
|
||||
mTransportConnection.markAsDisposed();
|
||||
|
||||
// No exception thrown
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMarkAsDisposed_whenConnectedAndUnbound() {
|
||||
mTransportClient.connectAsync(mTransportConnectionListener, "caller1");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener, "caller1");
|
||||
ServiceConnection connection = verifyBindServiceAsUserAndCaptureServiceConnection(mContext);
|
||||
connection.onServiceConnected(mTransportComponent, mTransportBinder);
|
||||
mTransportClient.unbind("caller1");
|
||||
mTransportConnection.unbind("caller1");
|
||||
|
||||
mTransportClient.markAsDisposed();
|
||||
mTransportConnection.markAsDisposed();
|
||||
|
||||
// No exception thrown
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMarkAsDisposed_afterOnServiceDisconnected() {
|
||||
mTransportClient.connectAsync(mTransportConnectionListener, "caller1");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener, "caller1");
|
||||
ServiceConnection connection = verifyBindServiceAsUserAndCaptureServiceConnection(mContext);
|
||||
connection.onServiceConnected(mTransportComponent, mTransportBinder);
|
||||
connection.onServiceDisconnected(mTransportComponent);
|
||||
|
||||
mTransportClient.markAsDisposed();
|
||||
mTransportConnection.markAsDisposed();
|
||||
|
||||
// No exception thrown
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMarkAsDisposed_whenBound() {
|
||||
mTransportClient.connectAsync(mTransportConnectionListener, "caller1");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener, "caller1");
|
||||
|
||||
expectThrows(RuntimeException.class, mTransportClient::markAsDisposed);
|
||||
expectThrows(RuntimeException.class, mTransportConnection::markAsDisposed);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMarkAsDisposed_whenConnected() {
|
||||
mTransportClient.connectAsync(mTransportConnectionListener, "caller1");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener, "caller1");
|
||||
ServiceConnection connection = verifyBindServiceAsUserAndCaptureServiceConnection(mContext);
|
||||
connection.onServiceConnected(mTransportComponent, mTransportBinder);
|
||||
|
||||
expectThrows(RuntimeException.class, mTransportClient::markAsDisposed);
|
||||
expectThrows(RuntimeException.class, mTransportConnection::markAsDisposed);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -469,36 +470,36 @@ public class TransportClientTest {
|
||||
public void testFinalize_afterCreated() throws Throwable {
|
||||
ShadowLog.reset();
|
||||
|
||||
mTransportClient.finalize();
|
||||
mTransportConnection.finalize();
|
||||
|
||||
assertLogcatAtMost(TransportClient.TAG, Log.INFO);
|
||||
assertLogcatAtMost(TransportConnection.TAG, Log.INFO);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("FinalizeCalledExplicitly")
|
||||
public void testFinalize_whenBound() throws Throwable {
|
||||
mTransportClient.connectAsync(mTransportConnectionListener, "caller1");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener, "caller1");
|
||||
ShadowLog.reset();
|
||||
|
||||
mTransportClient.finalize();
|
||||
mTransportConnection.finalize();
|
||||
|
||||
assertLogcatAtLeast(TransportClient.TAG, Log.ERROR);
|
||||
assertLogcatAtLeast(TransportConnection.TAG, Log.ERROR);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("FinalizeCalledExplicitly")
|
||||
public void testFinalize_whenConnected() throws Throwable {
|
||||
mTransportClient.connectAsync(mTransportConnectionListener, "caller1");
|
||||
mTransportConnection.connectAsync(mTransportConnectionListener, "caller1");
|
||||
ServiceConnection connection = verifyBindServiceAsUserAndCaptureServiceConnection(mContext);
|
||||
connection.onServiceConnected(mTransportComponent, mTransportBinder);
|
||||
ShadowLog.reset();
|
||||
|
||||
mTransportClient.finalize();
|
||||
mTransportConnection.finalize();
|
||||
|
||||
expectThrows(
|
||||
TransportNotAvailableException.class,
|
||||
() -> mTransportClient.getConnectedTransport("caller1"));
|
||||
assertLogcatAtLeast(TransportClient.TAG, Log.ERROR);
|
||||
() -> mTransportConnection.getConnectedTransport("caller1"));
|
||||
assertLogcatAtLeast(TransportConnection.TAG, Log.ERROR);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -506,7 +507,7 @@ public class TransportClientTest {
|
||||
public void testFinalize_whenNotMarkedAsDisposed() throws Throwable {
|
||||
ShadowCloseGuard.setUp();
|
||||
|
||||
mTransportClient.finalize();
|
||||
mTransportConnection.finalize();
|
||||
|
||||
assertThat(ShadowCloseGuard.hasReported()).isTrue();
|
||||
}
|
||||
@@ -514,10 +515,10 @@ public class TransportClientTest {
|
||||
@Test
|
||||
@SuppressWarnings("FinalizeCalledExplicitly")
|
||||
public void testFinalize_whenMarkedAsDisposed() throws Throwable {
|
||||
mTransportClient.markAsDisposed();
|
||||
mTransportConnection.markAsDisposed();
|
||||
ShadowCloseGuard.setUp();
|
||||
|
||||
mTransportClient.finalize();
|
||||
mTransportConnection.finalize();
|
||||
|
||||
assertThat(ShadowCloseGuard.hasReported()).isFalse();
|
||||
}
|
||||
@@ -19,9 +19,8 @@ package com.android.server.testing.shadows;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
|
||||
import com.android.server.backup.transport.TransportClient;
|
||||
import com.android.server.backup.transport.TransportConnection;
|
||||
import com.android.server.backup.utils.BackupEligibilityRules;
|
||||
|
||||
import org.robolectric.annotation.Implementation;
|
||||
@@ -54,7 +53,7 @@ public class ShadowBackupEligibilityRules {
|
||||
|
||||
@Implementation
|
||||
protected boolean appIsRunningAndEligibleForBackupWithTransport(
|
||||
@Nullable TransportClient transportClient,
|
||||
@Nullable TransportConnection transportConnection,
|
||||
String packageName) {
|
||||
return sAppsRunningAndEligibleForBackupWithTransport.contains(packageName);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.android.server.backup.UserBackupManagerService;
|
||||
import com.android.server.backup.internal.OnTaskFinishedListener;
|
||||
import com.android.server.backup.keyvalue.KeyValueBackupReporter;
|
||||
import com.android.server.backup.keyvalue.KeyValueBackupTask;
|
||||
import com.android.server.backup.transport.TransportClient;
|
||||
import com.android.server.backup.transport.TransportConnection;
|
||||
import com.android.server.backup.utils.BackupEligibilityRules;
|
||||
|
||||
import org.robolectric.annotation.Implementation;
|
||||
@@ -56,7 +56,7 @@ public class ShadowKeyValueBackupTask {
|
||||
@Implementation
|
||||
protected void __constructor__(
|
||||
UserBackupManagerService backupManagerService,
|
||||
TransportClient transportClient,
|
||||
TransportConnection transportConnection,
|
||||
String transportDirName,
|
||||
List<String> queue,
|
||||
@Nullable DataChangedJournal dataChangedJournal,
|
||||
|
||||
@@ -24,15 +24,12 @@ import android.content.pm.PackageInfo;
|
||||
import com.android.server.backup.UserBackupManagerService;
|
||||
import com.android.server.backup.internal.OnTaskFinishedListener;
|
||||
import com.android.server.backup.restore.PerformUnifiedRestoreTask;
|
||||
import com.android.server.backup.transport.TransportClient;
|
||||
import com.android.server.backup.transport.TransportConnection;
|
||||
import com.android.server.backup.utils.BackupEligibilityRules;
|
||||
|
||||
import org.robolectric.annotation.Implementation;
|
||||
import org.robolectric.annotation.Implements;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Implements(PerformUnifiedRestoreTask.class)
|
||||
public class ShadowPerformUnifiedRestoreTask {
|
||||
@Nullable private static ShadowPerformUnifiedRestoreTask sLastShadow;
|
||||
@@ -60,7 +57,7 @@ public class ShadowPerformUnifiedRestoreTask {
|
||||
@Implementation
|
||||
protected void __constructor__(
|
||||
UserBackupManagerService backupManagerService,
|
||||
TransportClient transportClient,
|
||||
TransportConnection transportConnection,
|
||||
IRestoreObserver observer,
|
||||
IBackupManagerMonitor monitor,
|
||||
long restoreSetToken,
|
||||
|
||||
@@ -38,7 +38,7 @@ import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.server.backup.internal.OnTaskFinishedListener;
|
||||
import com.android.server.backup.params.BackupParams;
|
||||
import com.android.server.backup.transport.TransportClient;
|
||||
import com.android.server.backup.transport.TransportConnection;
|
||||
import com.android.server.backup.utils.BackupEligibilityRules;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -57,7 +57,8 @@ public class UserBackupManagerServiceTest {
|
||||
@Mock IBackupManagerMonitor mBackupManagerMonitor;
|
||||
@Mock IBackupObserver mBackupObserver;
|
||||
@Mock PackageManager mPackageManager;
|
||||
@Mock TransportClient mTransportClient;
|
||||
@Mock
|
||||
TransportConnection mTransportConnection;
|
||||
@Mock IBackupTransport mBackupTransport;
|
||||
@Mock BackupEligibilityRules mBackupEligibilityRules;
|
||||
|
||||
@@ -96,7 +97,7 @@ public class UserBackupManagerServiceTest {
|
||||
|
||||
BackupParams params = mService.getRequestBackupParams(TEST_PACKAGES, mBackupObserver,
|
||||
mBackupManagerMonitor, /* flags */ 0, mBackupEligibilityRules,
|
||||
mTransportClient, /* transportDirName */ "", OnTaskFinishedListener.NOP);
|
||||
mTransportConnection, /* transportDirName */ "", OnTaskFinishedListener.NOP);
|
||||
|
||||
assertThat(params.kvPackages).isEmpty();
|
||||
assertThat(params.fullPackages).contains(TEST_PACKAGE);
|
||||
@@ -112,7 +113,7 @@ public class UserBackupManagerServiceTest {
|
||||
|
||||
BackupParams params = mService.getRequestBackupParams(TEST_PACKAGES, mBackupObserver,
|
||||
mBackupManagerMonitor, /* flags */ 0, mBackupEligibilityRules,
|
||||
mTransportClient, /* transportDirName */ "", OnTaskFinishedListener.NOP);
|
||||
mTransportConnection, /* transportDirName */ "", OnTaskFinishedListener.NOP);
|
||||
|
||||
assertThat(params.kvPackages).contains(TEST_PACKAGE);
|
||||
assertThat(params.fullPackages).isEmpty();
|
||||
@@ -128,7 +129,7 @@ public class UserBackupManagerServiceTest {
|
||||
|
||||
BackupParams params = mService.getRequestBackupParams(TEST_PACKAGES, mBackupObserver,
|
||||
mBackupManagerMonitor, /* flags */ 0, mBackupEligibilityRules,
|
||||
mTransportClient, /* transportDirName */ "", OnTaskFinishedListener.NOP);
|
||||
mTransportConnection, /* transportDirName */ "", OnTaskFinishedListener.NOP);
|
||||
|
||||
assertThat(params.kvPackages).isEmpty();
|
||||
assertThat(params.fullPackages).isEmpty();
|
||||
@@ -138,10 +139,10 @@ public class UserBackupManagerServiceTest {
|
||||
@Test
|
||||
public void testGetOperationTypeFromTransport_returnsBackupByDefault()
|
||||
throws Exception {
|
||||
when(mTransportClient.connectOrThrow(any())).thenReturn(mBackupTransport);
|
||||
when(mTransportConnection.connectOrThrow(any())).thenReturn(mBackupTransport);
|
||||
when(mBackupTransport.getTransportFlags()).thenReturn(0);
|
||||
|
||||
int operationType = mService.getOperationTypeFromTransport(mTransportClient);
|
||||
int operationType = mService.getOperationTypeFromTransport(mTransportConnection);
|
||||
|
||||
assertThat(operationType).isEqualTo(OperationType.BACKUP);
|
||||
}
|
||||
@@ -153,11 +154,11 @@ public class UserBackupManagerServiceTest {
|
||||
// rolled out.
|
||||
mService.shouldUseNewBackupEligibilityRules = true;
|
||||
|
||||
when(mTransportClient.connectOrThrow(any())).thenReturn(mBackupTransport);
|
||||
when(mTransportConnection.connectOrThrow(any())).thenReturn(mBackupTransport);
|
||||
when(mBackupTransport.getTransportFlags()).thenReturn(
|
||||
BackupAgent.FLAG_DEVICE_TO_DEVICE_TRANSFER);
|
||||
|
||||
int operationType = mService.getOperationTypeFromTransport(mTransportClient);
|
||||
int operationType = mService.getOperationTypeFromTransport(mTransportConnection);
|
||||
|
||||
assertThat(operationType).isEqualTo(OperationType.MIGRATION);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user