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

Commit 57ff4b45 authored by Michael Groover's avatar Michael Groover Committed by Gerrit Code Review
Browse files

Merge "Override registerReceiver methods in test Context to accept flags"

parents 4e6ce5ed f73b5584
Loading
Loading
Loading
Loading
+28 −1
Original line number Diff line number Diff line
@@ -147,12 +147,39 @@ public class BroadcastInterceptingContext extends ContextWrapper {

    @Override
    public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
        return registerReceiver(receiver, filter, null, null);
        return registerReceiver(receiver, filter, null, null, 0);
    }

    /**
     * Registers the specified {@code receiver} to listen for broadcasts that match the {@code
     * filter} in the current process.
     *
     * <p>Since this method only listens for broadcasts in the current process, the provided {@code
     * flags} are ignored; this method is primarily intended to allow receivers that register with
     * flags to register in the current process during tests.
     */
    @Override
    public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter, int flags) {
        return registerReceiver(receiver, filter, null, null, flags);
    }

    @Override
    public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter,
            String broadcastPermission, Handler scheduler) {
        return registerReceiver(receiver, filter, broadcastPermission, scheduler, 0);
    }

    /**
     * Registers the specified {@code receiver} to listen for broadcasts that match the {@code
     * filter} to run in the context of the specified {@code scheduler} in the current process.
     *
     * <p>Since this method only listens for broadcasts in the current process, the provided {@code
     * flags} are ignored; this method is primarily intended to allow receivers that register with
     * flags to register in the current process during tests.
     */
    @Override
    public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter,
            String broadcastPermission, Handler scheduler, int flags) {
        synchronized (mInterceptors) {
            mInterceptors.add(new BroadcastInterceptor(receiver, filter, scheduler));
        }