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

Commit 74fec184 authored by shafik's avatar shafik
Browse files

Refine broadcast in commitRollback

Silence qualified user warning by using sendBroadcastAsUser.
The user is UserHandle.SYSTEM.
Limit recievers to those holding MANAGE_ROLLBACKS permission.

Test: warning does not appear in logcat when running atest RollbackTest
Fixes: 128280826
Change-Id: I85b905d2b20f3993859ec87948f309c1934a4a26
parent 0e6c7c9d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2438,7 +2438,7 @@ public class Intent implements Parcelable, Cloneable {
     * Broadcast Action: A rollback has been committed.
     *
     * <p class="note">This is a protected intent that can only be sent
     * by the system.
     * by the system. The receiver must hold MANAGE_ROLLBACK permission.
     *
     * @hide
     */
+3 −5
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import android.os.HandlerThread;
import android.os.ParcelFileDescriptor;
import android.os.Process;
import android.os.SystemClock;
import android.os.UserHandle;
import android.provider.DeviceConfig;
import android.util.IntArray;
import android.util.Log;
@@ -455,11 +456,8 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {

                            Intent broadcast = new Intent(Intent.ACTION_ROLLBACK_COMMITTED);

                            // TODO: This call emits the warning "Calling a method in the
                            // system process without a qualified user". Fix that.
                            // TODO: Limit this to receivers holding the
                            // MANAGE_ROLLBACKS or TEST_MANAGE_ROLLBACKS permissions?
                            mContext.sendBroadcast(broadcast);
                            mContext.sendBroadcastAsUser(broadcast, UserHandle.SYSTEM,
                                    Manifest.permission.MANAGE_ROLLBACKS);
                        });
                    }
            );
+2 −1
Original line number Diff line number Diff line
@@ -87,7 +87,8 @@ public class RollbackTest {
            RollbackTestUtils.adoptShellPermissionIdentity(
                    Manifest.permission.INSTALL_PACKAGES,
                    Manifest.permission.DELETE_PACKAGES,
                    Manifest.permission.TEST_MANAGE_ROLLBACKS);
                    Manifest.permission.TEST_MANAGE_ROLLBACKS,
                    Manifest.permission.MANAGE_ROLLBACKS);

            // Register a broadcast receiver for notification when the
            // rollback has been committed.