Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e243c751 authored by Gavin Corkery's avatar Gavin Corkery Committed by android-build-merger
Browse files

Extend ROLLBACK_COMMITTED broadcast for the multi-user case am: e92720dd

am: 4bcb79bb

Change-Id: Ic948985ff2954d1b4cd14388a3d16a5745cf337f
parents 21640f38 4bcb79bb
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -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,
                            for (UserInfo userInfo : UserManager.get(mContext).getUsers(true)) {
                                mContext.sendBroadcastAsUser(broadcast, userInfo.getUserHandle(),
                                        Manifest.permission.MANAGE_ROLLBACKS);
                            }
                        });
                    }
            );
+2 −9
Original line number Diff line number Diff line
@@ -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();
            }

            // Verify the recent rollback has been recorded.
            RollbackInfo committed = getUniqueRollbackInfoForPackage(