Loading services/backup/java/com/android/server/backup/TransportManager.java +9 −7 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.backup; import android.annotation.Nullable; import android.annotation.UserIdInt; import android.annotation.WorkerThread; import android.app.backup.BackupManager; import android.app.backup.BackupTransport; Loading @@ -29,7 +30,6 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.os.Bundle; import android.os.RemoteException; import android.os.UserHandle; import android.util.ArrayMap; import android.util.ArraySet; import android.util.Slog; Loading Loading @@ -61,7 +61,7 @@ public class TransportManager { public static final String SERVICE_ACTION_TRANSPORT_HOST = "android.backup.TRANSPORT_HOST"; private final Intent mTransportServiceIntent = new Intent(SERVICE_ACTION_TRANSPORT_HOST); private final Context mContext; private final @UserIdInt int mUserId; private final PackageManager mPackageManager; private final Set<ComponentName> mTransportWhitelist; private final TransportClientManager mTransportClientManager; Loading @@ -86,22 +86,24 @@ public class TransportManager { @Nullable private volatile String mCurrentTransportName; TransportManager(Context context, Set<ComponentName> whitelist, String selectedTransport) { mContext = context; TransportManager(@UserIdInt int userId, Context context, Set<ComponentName> whitelist, String selectedTransport) { mUserId = userId; mPackageManager = context.getPackageManager(); mTransportWhitelist = Preconditions.checkNotNull(whitelist); mCurrentTransportName = selectedTransport; mTransportStats = new TransportStats(); mTransportClientManager = new TransportClientManager(context, mTransportStats); mTransportClientManager = new TransportClientManager(mUserId, context, mTransportStats); } @VisibleForTesting TransportManager( @UserIdInt int userId, Context context, Set<ComponentName> whitelist, String selectedTransport, TransportClientManager transportClientManager) { mContext = context; mUserId = userId; mPackageManager = context.getPackageManager(); mTransportWhitelist = Preconditions.checkNotNull(whitelist); mCurrentTransportName = selectedTransport; Loading Loading @@ -575,7 +577,7 @@ public class TransportManager { private void registerTransportsForIntent( Intent intent, Predicate<ComponentName> transportComponentFilter) { List<ResolveInfo> hosts = mPackageManager.queryIntentServicesAsUser(intent, 0, UserHandle.USER_SYSTEM); mPackageManager.queryIntentServicesAsUser(intent, 0, mUserId); if (hosts == null) { return; } Loading services/backup/java/com/android/server/backup/UserBackupManagerService.java +1 −1 Original line number Diff line number Diff line Loading @@ -384,7 +384,7 @@ public class UserBackupManagerService { Slog.v(TAG, "Starting with transport " + currentTransport); } TransportManager transportManager = new TransportManager(context, transportWhitelist, currentTransport); new TransportManager(userId, context, transportWhitelist, currentTransport); File baseStateDir = UserBackupManagerFiles.getBaseStateDir(userId); File dataDir = UserBackupManagerFiles.getDataDir(userId); Loading services/backup/java/com/android/server/backup/transport/TransportClient.java +7 −2 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static com.android.server.backup.transport.TransportUtils.formatMessage; import android.annotation.IntDef; import android.annotation.Nullable; import android.annotation.UserIdInt; import android.annotation.WorkerThread; import android.content.ComponentName; import android.content.Context; Loading @@ -34,7 +35,6 @@ import android.os.UserHandle; import android.text.format.DateFormat; import android.util.ArrayMap; import android.util.EventLog; import android.util.Slog; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -79,6 +79,7 @@ public class TransportClient { @VisibleForTesting static final String TAG = "TransportClient"; private static final int LOG_BUFFER_SIZE = 5; private final @UserIdInt int mUserId; private final Context mContext; private final TransportStats mTransportStats; private final Intent mBindIntent; Loading Loading @@ -106,6 +107,7 @@ public class TransportClient { private volatile IBackupTransport mTransport; TransportClient( @UserIdInt int userId, Context context, TransportStats transportStats, Intent bindIntent, Loading @@ -113,6 +115,7 @@ public class TransportClient { String identifier, String caller) { this( userId, context, transportStats, bindIntent, Loading @@ -124,6 +127,7 @@ public class TransportClient { @VisibleForTesting TransportClient( @UserIdInt int userId, Context context, TransportStats transportStats, Intent bindIntent, Loading @@ -131,6 +135,7 @@ public class TransportClient { String identifier, String caller, Handler listenerHandler) { mUserId = userId; mContext = context; mTransportStats = transportStats; mTransportComponent = transportComponent; Loading Loading @@ -213,7 +218,7 @@ public class TransportClient { mBindIntent, mConnection, Context.BIND_AUTO_CREATE, UserHandle.SYSTEM); UserHandle.of(mUserId)); if (hasBound) { // We don't need to set a time-out because we are guaranteed to get a call // back in ServiceConnection, either an onServiceConnected() or Loading services/backup/java/com/android/server/backup/transport/TransportClientManager.java +8 −1 Original line number Diff line number Diff line Loading @@ -19,12 +19,15 @@ package com.android.server.backup.transport; import static com.android.server.backup.TransportManager.SERVICE_ACTION_TRANSPORT_HOST; import static com.android.server.backup.transport.TransportUtils.formatMessage; import android.annotation.UserIdInt; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.os.Bundle; import com.android.server.backup.TransportManager; import com.android.server.backup.transport.TransportUtils.Priority; import java.io.PrintWriter; import java.util.Map; import java.util.WeakHashMap; Loading @@ -36,13 +39,16 @@ import java.util.WeakHashMap; public class TransportClientManager { private static final String TAG = "TransportClientManager"; 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<>(); public TransportClientManager(Context context, TransportStats transportStats) { public TransportClientManager(@UserIdInt int userId, Context context, TransportStats transportStats) { mUserId = userId; mContext = context; mTransportStats = transportStats; } Loading Loading @@ -89,6 +95,7 @@ public class TransportClientManager { synchronized (mTransportClientsLock) { TransportClient transportClient = new TransportClient( mUserId, mContext, mTransportStats, bindIntent, Loading services/robotests/backup/src/com/android/server/backup/TransportManagerTest.java +5 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ import static java.util.stream.Collectors.toSet; import static java.util.stream.Stream.concat; import android.annotation.Nullable; import android.annotation.UserIdInt; import android.app.backup.BackupManager; import android.app.backup.BackupTransport; import android.content.ComponentName; Loading @@ -48,6 +49,7 @@ import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.os.UserHandle; import android.platform.test.annotations.Presubmit; import com.android.server.backup.testing.TransportData; Loading Loading @@ -84,12 +86,14 @@ public class TransportManagerTest { private TransportData mTransportA2; private TransportData mTransportB1; private ShadowPackageManager mShadowPackageManager; private @UserIdInt int mUserId; private Context mContext; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); mUserId = UserHandle.USER_SYSTEM; mContext = RuntimeEnvironment.application; mShadowPackageManager = shadowOf(mContext.getPackageManager()); Loading Loading @@ -684,6 +688,7 @@ public class TransportManagerTest { @Nullable TransportData selectedTransport, TransportData... transports) { TransportManager transportManager = new TransportManager( mUserId, mContext, merge(selectedTransport, transports) .stream() Loading Loading
services/backup/java/com/android/server/backup/TransportManager.java +9 −7 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.backup; import android.annotation.Nullable; import android.annotation.UserIdInt; import android.annotation.WorkerThread; import android.app.backup.BackupManager; import android.app.backup.BackupTransport; Loading @@ -29,7 +30,6 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.os.Bundle; import android.os.RemoteException; import android.os.UserHandle; import android.util.ArrayMap; import android.util.ArraySet; import android.util.Slog; Loading Loading @@ -61,7 +61,7 @@ public class TransportManager { public static final String SERVICE_ACTION_TRANSPORT_HOST = "android.backup.TRANSPORT_HOST"; private final Intent mTransportServiceIntent = new Intent(SERVICE_ACTION_TRANSPORT_HOST); private final Context mContext; private final @UserIdInt int mUserId; private final PackageManager mPackageManager; private final Set<ComponentName> mTransportWhitelist; private final TransportClientManager mTransportClientManager; Loading @@ -86,22 +86,24 @@ public class TransportManager { @Nullable private volatile String mCurrentTransportName; TransportManager(Context context, Set<ComponentName> whitelist, String selectedTransport) { mContext = context; TransportManager(@UserIdInt int userId, Context context, Set<ComponentName> whitelist, String selectedTransport) { mUserId = userId; mPackageManager = context.getPackageManager(); mTransportWhitelist = Preconditions.checkNotNull(whitelist); mCurrentTransportName = selectedTransport; mTransportStats = new TransportStats(); mTransportClientManager = new TransportClientManager(context, mTransportStats); mTransportClientManager = new TransportClientManager(mUserId, context, mTransportStats); } @VisibleForTesting TransportManager( @UserIdInt int userId, Context context, Set<ComponentName> whitelist, String selectedTransport, TransportClientManager transportClientManager) { mContext = context; mUserId = userId; mPackageManager = context.getPackageManager(); mTransportWhitelist = Preconditions.checkNotNull(whitelist); mCurrentTransportName = selectedTransport; Loading Loading @@ -575,7 +577,7 @@ public class TransportManager { private void registerTransportsForIntent( Intent intent, Predicate<ComponentName> transportComponentFilter) { List<ResolveInfo> hosts = mPackageManager.queryIntentServicesAsUser(intent, 0, UserHandle.USER_SYSTEM); mPackageManager.queryIntentServicesAsUser(intent, 0, mUserId); if (hosts == null) { return; } Loading
services/backup/java/com/android/server/backup/UserBackupManagerService.java +1 −1 Original line number Diff line number Diff line Loading @@ -384,7 +384,7 @@ public class UserBackupManagerService { Slog.v(TAG, "Starting with transport " + currentTransport); } TransportManager transportManager = new TransportManager(context, transportWhitelist, currentTransport); new TransportManager(userId, context, transportWhitelist, currentTransport); File baseStateDir = UserBackupManagerFiles.getBaseStateDir(userId); File dataDir = UserBackupManagerFiles.getDataDir(userId); Loading
services/backup/java/com/android/server/backup/transport/TransportClient.java +7 −2 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static com.android.server.backup.transport.TransportUtils.formatMessage; import android.annotation.IntDef; import android.annotation.Nullable; import android.annotation.UserIdInt; import android.annotation.WorkerThread; import android.content.ComponentName; import android.content.Context; Loading @@ -34,7 +35,6 @@ import android.os.UserHandle; import android.text.format.DateFormat; import android.util.ArrayMap; import android.util.EventLog; import android.util.Slog; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -79,6 +79,7 @@ public class TransportClient { @VisibleForTesting static final String TAG = "TransportClient"; private static final int LOG_BUFFER_SIZE = 5; private final @UserIdInt int mUserId; private final Context mContext; private final TransportStats mTransportStats; private final Intent mBindIntent; Loading Loading @@ -106,6 +107,7 @@ public class TransportClient { private volatile IBackupTransport mTransport; TransportClient( @UserIdInt int userId, Context context, TransportStats transportStats, Intent bindIntent, Loading @@ -113,6 +115,7 @@ public class TransportClient { String identifier, String caller) { this( userId, context, transportStats, bindIntent, Loading @@ -124,6 +127,7 @@ public class TransportClient { @VisibleForTesting TransportClient( @UserIdInt int userId, Context context, TransportStats transportStats, Intent bindIntent, Loading @@ -131,6 +135,7 @@ public class TransportClient { String identifier, String caller, Handler listenerHandler) { mUserId = userId; mContext = context; mTransportStats = transportStats; mTransportComponent = transportComponent; Loading Loading @@ -213,7 +218,7 @@ public class TransportClient { mBindIntent, mConnection, Context.BIND_AUTO_CREATE, UserHandle.SYSTEM); UserHandle.of(mUserId)); if (hasBound) { // We don't need to set a time-out because we are guaranteed to get a call // back in ServiceConnection, either an onServiceConnected() or Loading
services/backup/java/com/android/server/backup/transport/TransportClientManager.java +8 −1 Original line number Diff line number Diff line Loading @@ -19,12 +19,15 @@ package com.android.server.backup.transport; import static com.android.server.backup.TransportManager.SERVICE_ACTION_TRANSPORT_HOST; import static com.android.server.backup.transport.TransportUtils.formatMessage; import android.annotation.UserIdInt; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.os.Bundle; import com.android.server.backup.TransportManager; import com.android.server.backup.transport.TransportUtils.Priority; import java.io.PrintWriter; import java.util.Map; import java.util.WeakHashMap; Loading @@ -36,13 +39,16 @@ import java.util.WeakHashMap; public class TransportClientManager { private static final String TAG = "TransportClientManager"; 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<>(); public TransportClientManager(Context context, TransportStats transportStats) { public TransportClientManager(@UserIdInt int userId, Context context, TransportStats transportStats) { mUserId = userId; mContext = context; mTransportStats = transportStats; } Loading Loading @@ -89,6 +95,7 @@ public class TransportClientManager { synchronized (mTransportClientsLock) { TransportClient transportClient = new TransportClient( mUserId, mContext, mTransportStats, bindIntent, Loading
services/robotests/backup/src/com/android/server/backup/TransportManagerTest.java +5 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ import static java.util.stream.Collectors.toSet; import static java.util.stream.Stream.concat; import android.annotation.Nullable; import android.annotation.UserIdInt; import android.app.backup.BackupManager; import android.app.backup.BackupTransport; import android.content.ComponentName; Loading @@ -48,6 +49,7 @@ import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.os.UserHandle; import android.platform.test.annotations.Presubmit; import com.android.server.backup.testing.TransportData; Loading Loading @@ -84,12 +86,14 @@ public class TransportManagerTest { private TransportData mTransportA2; private TransportData mTransportB1; private ShadowPackageManager mShadowPackageManager; private @UserIdInt int mUserId; private Context mContext; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); mUserId = UserHandle.USER_SYSTEM; mContext = RuntimeEnvironment.application; mShadowPackageManager = shadowOf(mContext.getPackageManager()); Loading Loading @@ -684,6 +688,7 @@ public class TransportManagerTest { @Nullable TransportData selectedTransport, TransportData... transports) { TransportManager transportManager = new TransportManager( mUserId, mContext, merge(selectedTransport, transports) .stream() Loading