Merge "Fix typo: decrement not increment"

This commit is contained in:
TreeHugger Robot
2019-01-29 22:49:22 +00:00
committed by Android (Google) Code Review
2 changed files with 27 additions and 1 deletions

View File

@@ -312,7 +312,7 @@ public class BroadcastDispatcher {
final Intent intent = r.intent;
// Any in-flight broadcast has already been popped, and cannot be replaced.
// (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);
if (old.userId == r.userId && intent.filterEquals(old.intent)) {
if (DEBUG_BROADCAST) {

View File

@@ -77,6 +77,7 @@ public class ActivityTestMain extends Activity {
static final int MSG_SPAM_ALARM = 2;
static final int MSG_SLOW_RECEIVER = 3;
static final int MSG_SLOW_ALARM_RECEIVER = 4;
static final int MSG_REPLACE_BROADCAST = 5;
final Handler mHandler = new Handler() {
@Override
@@ -138,6 +139,20 @@ public class ActivityTestMain extends Activity {
Log.i(TAG, "Setting alarm for now + 5 seconds");
am.setExact(AlarmManager.ELAPSED_REALTIME, now + 5_000, pi);
} 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);
}
@@ -418,6 +433,12 @@ public class ActivityTestMain extends Activity {
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() {
@Override public boolean onMenuItemClick(MenuItem item) {
ActivityManager.AppTask task = findDocTask();
@@ -616,6 +637,11 @@ public class ActivityTestMain extends Activity {
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) {
ScrollView scroller = new ScrollView(this);
scroller.addView(view, new ScrollView.LayoutParams(ScrollView.LayoutParams.MATCH_PARENT,