Extend ROLLBACK_COMMITTED broadcast for the multi-user case
For the case where there are multiple users on the device, the ROLLBACK_COMMITTED broadcast should be sent to all users for which the package is being rolled back. Test: atest RollbackTest Test: atest SecondaryUserRollbackTest Bug: 139060321 Change-Id: I901ff8a3331c7a8a8585c855a0caead347321d5d Merged-In: I8e20da321f52ebf9e6d584a8c59d2a3106a32212
This commit is contained in:
@@ -388,7 +388,7 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
|
||||
|
||||
// Get a context for the caller to use to install the downgraded
|
||||
// version of the package.
|
||||
Context context = null;
|
||||
final Context context;
|
||||
try {
|
||||
context = mContext.createPackageContext(callerPackageName, 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
@@ -434,7 +434,6 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
|
||||
}
|
||||
int sessionId = packageInstaller.createSession(params);
|
||||
PackageInstaller.Session session = packageInstaller.openSession(sessionId);
|
||||
|
||||
File[] packageCodePaths = RollbackStore.getPackageCodePaths(
|
||||
data, info.getPackageName());
|
||||
if (packageCodePaths == null) {
|
||||
@@ -504,8 +503,10 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
|
||||
|
||||
Intent broadcast = new Intent(Intent.ACTION_ROLLBACK_COMMITTED);
|
||||
|
||||
mContext.sendBroadcastAsUser(broadcast, UserHandle.SYSTEM,
|
||||
Manifest.permission.MANAGE_ROLLBACKS);
|
||||
for (UserInfo userInfo : UserManager.get(mContext).getUsers(true)) {
|
||||
mContext.sendBroadcastAsUser(broadcast, userInfo.getUserHandle(),
|
||||
Manifest.permission.MANAGE_ROLLBACKS);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
@@ -154,15 +154,8 @@ public class RollbackTest {
|
||||
// TODO: Race condition between the timeout and when the broadcast is
|
||||
// received could lead to test flakiness.
|
||||
Intent broadcast = broadcastReceiver.poll(5, TimeUnit.SECONDS);
|
||||
if (context.getUser().isSystem()) {
|
||||
// Only system user should receive those broadcasts.
|
||||
assertThat(broadcast).isNotNull();
|
||||
assertThat(broadcastReceiver.poll(0, TimeUnit.SECONDS)).isNull();
|
||||
} else {
|
||||
// This is in case the test was running under a secondary user, in which case
|
||||
// the broadcast won't be received here.
|
||||
assertThat(broadcast).isNull();
|
||||
}
|
||||
assertThat(broadcast).isNotNull();
|
||||
assertThat(broadcastReceiver.poll(0, TimeUnit.SECONDS)).isNull();
|
||||
|
||||
// Verify the recent rollback has been recorded.
|
||||
RollbackInfo committed = getUniqueRollbackInfoForPackage(
|
||||
|
||||
Reference in New Issue
Block a user