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

Commit d4caf851 authored by Christopher Tate's avatar Christopher Tate
Browse files

Fix typo: decrement not increment

When iterating a list backwards, one must decrement the index
rather than increment it.

Bug: 123562063
Test: test procedure given in bug
Test: tests/ActivityTests
Change-Id: I09d7bd045ff00291befe9d4e829d153f41a01a15
parent 917955a4
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -312,7 +312,7 @@ public class BroadcastDispatcher {
        final Intent intent = r.intent;
        final Intent intent = r.intent;
        // Any in-flight broadcast has already been popped, and cannot be replaced.
        // Any in-flight broadcast has already been popped, and cannot be replaced.
        // (This preserves existing behavior of the replacement API)
        // (This preserves existing behavior of the replacement API)
        for (int i = list.size() - 1; i >= 0; i++) {
        for (int i = list.size() - 1; i >= 0; i--) {
            old = list.get(i);
            old = list.get(i);
            if (old.userId == r.userId && intent.filterEquals(old.intent)) {
            if (old.userId == r.userId && intent.filterEquals(old.intent)) {
                if (DEBUG_BROADCAST) {
                if (DEBUG_BROADCAST) {
+26 −0
Original line number Original line Diff line number Diff line
@@ -77,6 +77,7 @@ public class ActivityTestMain extends Activity {
    static final int MSG_SPAM_ALARM = 2;
    static final int MSG_SPAM_ALARM = 2;
    static final int MSG_SLOW_RECEIVER = 3;
    static final int MSG_SLOW_RECEIVER = 3;
    static final int MSG_SLOW_ALARM_RECEIVER = 4;
    static final int MSG_SLOW_ALARM_RECEIVER = 4;
    static final int MSG_REPLACE_BROADCAST = 5;


    final Handler mHandler = new Handler() {
    final Handler mHandler = new Handler() {
        @Override
        @Override
@@ -138,6 +139,20 @@ public class ActivityTestMain extends Activity {
                    Log.i(TAG, "Setting alarm for now + 5 seconds");
                    Log.i(TAG, "Setting alarm for now + 5 seconds");
                    am.setExact(AlarmManager.ELAPSED_REALTIME, now + 5_000, pi);
                    am.setExact(AlarmManager.ELAPSED_REALTIME, now + 5_000, pi);
                } break;
                } break;
                case MSG_REPLACE_BROADCAST: {
                    Intent intent = new Intent(ActivityTestMain.this, SlowReceiver.class);
                    intent.setAction(SLOW_RECEIVER_ACTION);
                    intent.putExtra(SLOW_RECEIVER_EXTRA, 1);
                    sendOrderedBroadcast(intent, null, mSlowReceiverCompletion, mHandler,
                            Activity.RESULT_OK, null, null);
                    intent.putExtra(SLOW_RECEIVER_EXTRA, 2);
                    sendOrderedBroadcast(intent, null, mSlowReceiverCompletion, mHandler,
                            Activity.RESULT_OK, null, null);
                    intent.putExtra(SLOW_RECEIVER_EXTRA, 5038);
                    intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
                    sendOrderedBroadcast(intent, null, mSlowReceiverCompletion, mHandler,
                            Activity.RESULT_OK, null, null);
                } break;
            }
            }
            super.handleMessage(msg);
            super.handleMessage(msg);
        }
        }
@@ -418,6 +433,12 @@ public class ActivityTestMain extends Activity {
                return true;
                return true;
            }
            }
        });
        });
        menu.add("Replace broadcast").setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
            @Override public boolean onMenuItemClick(MenuItem item) {
                scheduleReplaceBroadcast();
                return true;
            }
        });
        menu.add("Stack Doc").setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        menu.add("Stack Doc").setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
            @Override public boolean onMenuItemClick(MenuItem item) {
            @Override public boolean onMenuItemClick(MenuItem item) {
                ActivityManager.AppTask task = findDocTask();
                ActivityManager.AppTask task = findDocTask();
@@ -616,6 +637,11 @@ public class ActivityTestMain extends Activity {
        mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_SLOW_ALARM_RECEIVER), 500);
        mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_SLOW_ALARM_RECEIVER), 500);
    }
    }


    void scheduleReplaceBroadcast() {
        mHandler.removeMessages(MSG_REPLACE_BROADCAST);
        mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_REPLACE_BROADCAST), 500);
    }

    private View scrollWrap(View view) {
    private View scrollWrap(View view) {
        ScrollView scroller = new ScrollView(this);
        ScrollView scroller = new ScrollView(this);
        scroller.addView(view, new ScrollView.LayoutParams(ScrollView.LayoutParams.MATCH_PARENT,
        scroller.addView(view, new ScrollView.LayoutParams(ScrollView.LayoutParams.MATCH_PARENT,