blob: 9e799f6f14f3d4d711f7e318ccfbd34b8e5ee63a [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.server.am;
18
Dianne Hackbornf51f6122013-02-04 18:23:34 -080019import android.app.AppOpsManager;
Dianne Hackborna750a632015-06-16 17:18:23 -070020import android.app.BroadcastOptions;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080021import android.content.ComponentName;
Ng Zhi An1eb7d382018-08-24 13:27:54 -070022import android.content.IIntentReceiver;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080023import android.content.Intent;
24import android.content.pm.ActivityInfo;
25import android.content.pm.ResolveInfo;
26import android.os.Binder;
27import android.os.Bundle;
28import android.os.IBinder;
29import android.os.SystemClock;
Wale Ogunwaleca1c1252015-05-15 12:49:13 -070030import android.os.UserHandle;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080031import android.util.PrintWriterPrinter;
Dianne Hackborn39792d22010-08-19 18:01:52 -070032import android.util.TimeUtils;
Yi Jin129fc6c2017-09-28 15:48:38 -070033import android.util.proto.ProtoOutputStream;
34
Riddle Hsu7fdd90a2018-05-01 00:37:59 +080035import com.android.internal.annotations.VisibleForTesting;
36
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080037import java.io.PrintWriter;
Dianne Hackborn865907d2015-10-21 17:12:53 -070038import java.text.SimpleDateFormat;
Fyodor Kupolovd4fd8c72015-07-13 19:19:25 -070039import java.util.Arrays;
Dianne Hackbornd99b2932011-08-18 14:39:58 -070040import java.util.Date;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080041import java.util.List;
Wale Ogunwaleca1c1252015-05-15 12:49:13 -070042import java.util.Set;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080043
44/**
45 * An active intent broadcast.
46 */
Dianne Hackbornbe4e6aa2013-06-07 13:25:29 -070047final class BroadcastRecord extends Binder {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080048 final Intent intent; // the original intent that generated us
Dianne Hackborna40cfeb2013-03-25 17:49:36 -070049 final ComponentName targetComp; // original component name set on the intent
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080050 final ProcessRecord callerApp; // process that sent this
51 final String callerPackage; // who sent this
52 final int callingPid; // the pid of who sent this
53 final int callingUid; // the uid of who sent this
Chad Brubaker816c83b2017-03-02 10:27:59 -080054 final boolean callerInstantApp; // caller is an Instant App?
Dianne Hackborn68d881c2009-10-05 13:58:17 -070055 final boolean ordered; // serialize the send to receivers?
56 final boolean sticky; // originated from existing sticky data?
Dianne Hackborn12527f92009-11-11 17:39:50 -080057 final boolean initialSticky; // initial broadcast from register to sticky?
Dianne Hackborn786b4402012-08-27 15:14:02 -070058 final int userId; // user id this broadcast was for
Ben Gruver49660c72013-08-06 19:54:08 -070059 final String resolvedType; // the resolved data type
Fyodor Kupolovd4fd8c72015-07-13 19:19:25 -070060 final String[] requiredPermissions; // permissions the caller has required
Dianne Hackbornf51f6122013-02-04 18:23:34 -080061 final int appOp; // an app op that is associated with this broadcast
Dianne Hackborna750a632015-06-16 17:18:23 -070062 final BroadcastOptions options; // BroadcastOptions supplied by caller
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080063 final List receivers; // contains BroadcastFilter and ResolveInfo
Dianne Hackborne0e413e2015-12-09 17:22:26 -080064 final int[] delivery; // delivery state of each receiver
Ng Zhi An1eb7d382018-08-24 13:27:54 -070065 final long[] duration; // duration a receiver took to process broadcast
Johannes Carlssonb5a86542010-10-27 10:08:10 +020066 IIntentReceiver resultTo; // who receives final result if non-null
Jeff Brown9fb3fd12014-09-29 15:32:12 -070067 long enqueueClockTime; // the clock time the broadcast was enqueued
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080068 long dispatchTime; // when dispatch started on this set of receivers
Dianne Hackbornd99b2932011-08-18 14:39:58 -070069 long dispatchClockTime; // the clock time the dispatch started
Dianne Hackborn12527f92009-11-11 17:39:50 -080070 long receiverTime; // when current receiver started for timeouts.
71 long finishTime; // when we finished the broadcast.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080072 int resultCode; // current result code value.
73 String resultData; // current result data value.
74 Bundle resultExtras; // current result extra data values.
75 boolean resultAbort; // current result abortBroadcast value.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080076 int nextReceiver; // next receiver to be executed.
77 IBinder receiver; // who is currently running, null if none.
78 int state;
79 int anrCount; // has this broadcast record hit any ANRs?
Dianne Hackbornbc02a392016-06-02 17:15:08 -070080 int manifestCount; // number of manifest receivers dispatched.
81 int manifestSkipCount; // number of manifest receivers skipped.
Dianne Hackborn40c8db52012-02-10 18:59:48 -080082 BroadcastQueue queue; // the outbound queue handling this broadcast
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080083
Michal Karpinskiac116df2018-12-10 17:51:42 +000084 // if set to true, app's process will be temporarily whitelisted to start activities
85 // from background for the duration of the broadcast dispatch
86 final boolean allowBackgroundActivityStarts;
87
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080088 static final int IDLE = 0;
89 static final int APP_RECEIVE = 1;
90 static final int CALL_IN_RECEIVE = 2;
91 static final int CALL_DONE_RECEIVE = 3;
Dianne Hackborn6285a322013-09-18 12:09:47 -070092 static final int WAITING_SERVICES = 4;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080093
Dianne Hackborne0e413e2015-12-09 17:22:26 -080094 static final int DELIVERY_PENDING = 0;
95 static final int DELIVERY_DELIVERED = 1;
96 static final int DELIVERY_SKIPPED = 2;
97 static final int DELIVERY_TIMEOUT = 3;
98
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080099 // The following are set when we are calling a receiver (one that
100 // was found in our list of registered receivers).
101 BroadcastFilter curFilter;
102
103 // The following are set only when we are launching a receiver (one
104 // that was found by querying the package manager).
105 ProcessRecord curApp; // hosting application of current receiver.
106 ComponentName curComponent; // the receiver class that is currently running.
107 ActivityInfo curReceiver; // info about the receiver that is currently running.
108
Dianne Hackborn865907d2015-10-21 17:12:53 -0700109 void dump(PrintWriter pw, String prefix, SimpleDateFormat sdf) {
Dianne Hackborn39792d22010-08-19 18:01:52 -0700110 final long now = SystemClock.uptimeMillis();
111
Dianne Hackborn786b4402012-08-27 15:14:02 -0700112 pw.print(prefix); pw.print(this); pw.print(" to user "); pw.println(userId);
Dianne Hackbornc0bd7472012-10-09 14:00:30 -0700113 pw.print(prefix); pw.println(intent.toInsecureString());
Dianne Hackborna40cfeb2013-03-25 17:49:36 -0700114 if (targetComp != null && targetComp != intent.getComponent()) {
115 pw.print(prefix); pw.print(" targetComp: "); pw.println(targetComp.toShortString());
116 }
Dianne Hackbornc0bd7472012-10-09 14:00:30 -0700117 Bundle bundle = intent.getExtras();
118 if (bundle != null) {
Dianne Hackborna40cfeb2013-03-25 17:49:36 -0700119 pw.print(prefix); pw.print(" extras: "); pw.println(bundle.toString());
Dianne Hackborn12527f92009-11-11 17:39:50 -0800120 }
Dianne Hackborn043fcd92010-10-06 14:27:34 -0700121 pw.print(prefix); pw.print("caller="); pw.print(callerPackage); pw.print(" ");
122 pw.print(callerApp != null ? callerApp.toShortString() : "null");
Dianne Hackborn39792d22010-08-19 18:01:52 -0700123 pw.print(" pid="); pw.print(callingPid);
124 pw.print(" uid="); pw.println(callingUid);
Fyodor Kupolovd4fd8c72015-07-13 19:19:25 -0700125 if ((requiredPermissions != null && requiredPermissions.length > 0)
126 || appOp != AppOpsManager.OP_NONE) {
127 pw.print(prefix); pw.print("requiredPermissions=");
128 pw.print(Arrays.toString(requiredPermissions));
129 pw.print(" appOp="); pw.println(appOp);
Dianne Hackborn12527f92009-11-11 17:39:50 -0800130 }
Dianne Hackborna750a632015-06-16 17:18:23 -0700131 if (options != null) {
132 pw.print(prefix); pw.print("options="); pw.println(options.toBundle());
133 }
Jeff Brown9fb3fd12014-09-29 15:32:12 -0700134 pw.print(prefix); pw.print("enqueueClockTime=");
Dianne Hackborn865907d2015-10-21 17:12:53 -0700135 pw.print(sdf.format(new Date(enqueueClockTime)));
Jeff Brown9fb3fd12014-09-29 15:32:12 -0700136 pw.print(" dispatchClockTime=");
Dianne Hackborn865907d2015-10-21 17:12:53 -0700137 pw.println(sdf.format(new Date(dispatchClockTime)));
Dianne Hackborn39792d22010-08-19 18:01:52 -0700138 pw.print(prefix); pw.print("dispatchTime=");
139 TimeUtils.formatDuration(dispatchTime, now, pw);
Dianne Hackborn865907d2015-10-21 17:12:53 -0700140 pw.print(" (");
141 TimeUtils.formatDuration(dispatchClockTime-enqueueClockTime, pw);
142 pw.print(" since enq)");
Dianne Hackborn12527f92009-11-11 17:39:50 -0800143 if (finishTime != 0) {
Dianne Hackborn39792d22010-08-19 18:01:52 -0700144 pw.print(" finishTime="); TimeUtils.formatDuration(finishTime, now, pw);
Dianne Hackborn865907d2015-10-21 17:12:53 -0700145 pw.print(" (");
146 TimeUtils.formatDuration(finishTime-dispatchTime, pw);
147 pw.print(" since disp)");
Dianne Hackborn12527f92009-11-11 17:39:50 -0800148 } else {
Dianne Hackborn39792d22010-08-19 18:01:52 -0700149 pw.print(" receiverTime="); TimeUtils.formatDuration(receiverTime, now, pw);
Dianne Hackborn12527f92009-11-11 17:39:50 -0800150 }
Dianne Hackborn39792d22010-08-19 18:01:52 -0700151 pw.println("");
Dianne Hackborn12527f92009-11-11 17:39:50 -0800152 if (anrCount != 0) {
Dianne Hackborn39792d22010-08-19 18:01:52 -0700153 pw.print(prefix); pw.print("anrCount="); pw.println(anrCount);
Dianne Hackborn12527f92009-11-11 17:39:50 -0800154 }
155 if (resultTo != null || resultCode != -1 || resultData != null) {
Dianne Hackborn39792d22010-08-19 18:01:52 -0700156 pw.print(prefix); pw.print("resultTo="); pw.print(resultTo);
157 pw.print(" resultCode="); pw.print(resultCode);
158 pw.print(" resultData="); pw.println(resultData);
Dianne Hackborn12527f92009-11-11 17:39:50 -0800159 }
160 if (resultExtras != null) {
Dianne Hackborn39792d22010-08-19 18:01:52 -0700161 pw.print(prefix); pw.print("resultExtras="); pw.println(resultExtras);
Dianne Hackborn12527f92009-11-11 17:39:50 -0800162 }
163 if (resultAbort || ordered || sticky || initialSticky) {
Dianne Hackborn39792d22010-08-19 18:01:52 -0700164 pw.print(prefix); pw.print("resultAbort="); pw.print(resultAbort);
165 pw.print(" ordered="); pw.print(ordered);
166 pw.print(" sticky="); pw.print(sticky);
167 pw.print(" initialSticky="); pw.println(initialSticky);
Dianne Hackborn12527f92009-11-11 17:39:50 -0800168 }
169 if (nextReceiver != 0 || receiver != null) {
Dianne Hackborn39792d22010-08-19 18:01:52 -0700170 pw.print(prefix); pw.print("nextReceiver="); pw.print(nextReceiver);
171 pw.print(" receiver="); pw.println(receiver);
Dianne Hackborn12527f92009-11-11 17:39:50 -0800172 }
173 if (curFilter != null) {
Dianne Hackborn39792d22010-08-19 18:01:52 -0700174 pw.print(prefix); pw.print("curFilter="); pw.println(curFilter);
Dianne Hackborn12527f92009-11-11 17:39:50 -0800175 }
176 if (curReceiver != null) {
Dianne Hackborn39792d22010-08-19 18:01:52 -0700177 pw.print(prefix); pw.print("curReceiver="); pw.println(curReceiver);
Dianne Hackborn12527f92009-11-11 17:39:50 -0800178 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800179 if (curApp != null) {
Dianne Hackborn39792d22010-08-19 18:01:52 -0700180 pw.print(prefix); pw.print("curApp="); pw.println(curApp);
181 pw.print(prefix); pw.print("curComponent=");
182 pw.println((curComponent != null ? curComponent.toShortString() : "--"));
Dianne Hackborn399cccb2010-04-13 22:57:49 -0700183 if (curReceiver != null && curReceiver.applicationInfo != null) {
Dianne Hackborn39792d22010-08-19 18:01:52 -0700184 pw.print(prefix); pw.print("curSourceDir=");
185 pw.println(curReceiver.applicationInfo.sourceDir);
Dianne Hackborn399cccb2010-04-13 22:57:49 -0700186 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800187 }
Dianne Hackborn786b4402012-08-27 15:14:02 -0700188 if (state != IDLE) {
189 String stateStr = " (?)";
190 switch (state) {
191 case APP_RECEIVE: stateStr=" (APP_RECEIVE)"; break;
192 case CALL_IN_RECEIVE: stateStr=" (CALL_IN_RECEIVE)"; break;
193 case CALL_DONE_RECEIVE: stateStr=" (CALL_DONE_RECEIVE)"; break;
Dianne Hackborn6285a322013-09-18 12:09:47 -0700194 case WAITING_SERVICES: stateStr=" (WAITING_SERVICES)"; break;
Dianne Hackborn786b4402012-08-27 15:14:02 -0700195 }
196 pw.print(prefix); pw.print("state="); pw.print(state); pw.println(stateStr);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800197 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800198 final int N = receivers != null ? receivers.size() : 0;
199 String p2 = prefix + " ";
200 PrintWriterPrinter printer = new PrintWriterPrinter(pw);
Wale Ogunwaleca1c1252015-05-15 12:49:13 -0700201 for (int i = 0; i < N; i++) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800202 Object o = receivers.get(i);
Dianne Hackborne0e413e2015-12-09 17:22:26 -0800203 pw.print(prefix);
204 switch (delivery[i]) {
205 case DELIVERY_PENDING: pw.print("Pending"); break;
206 case DELIVERY_DELIVERED: pw.print("Deliver"); break;
207 case DELIVERY_SKIPPED: pw.print("Skipped"); break;
208 case DELIVERY_TIMEOUT: pw.print("Timeout"); break;
209 default: pw.print("???????"); break;
210 }
Ng Zhi An1eb7d382018-08-24 13:27:54 -0700211 pw.print(" "); TimeUtils.formatDuration(duration[i], pw);
Dianne Hackborne0e413e2015-12-09 17:22:26 -0800212 pw.print(" #"); pw.print(i); pw.print(": ");
213 if (o instanceof BroadcastFilter) {
214 pw.println(o);
215 ((BroadcastFilter) o).dumpBrief(pw, p2);
216 } else if (o instanceof ResolveInfo) {
217 pw.println("(manifest)");
218 ((ResolveInfo) o).dump(printer, p2, 0);
219 } else {
220 pw.println(o);
221 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800222 }
223 }
224
Dianne Hackborn40c8db52012-02-10 18:59:48 -0800225 BroadcastRecord(BroadcastQueue _queue,
Christopher Tatef46723b2012-01-26 14:19:24 -0800226 Intent _intent, ProcessRecord _callerApp, String _callerPackage,
Chad Brubaker816c83b2017-03-02 10:27:59 -0800227 int _callingPid, int _callingUid, boolean _callerInstantApp, String _resolvedType,
228 String[] _requiredPermissions, int _appOp, BroadcastOptions _options, List _receivers,
229 IIntentReceiver _resultTo, int _resultCode, String _resultData, Bundle _resultExtras,
Michal Karpinskiac116df2018-12-10 17:51:42 +0000230 boolean _serialized, boolean _sticky, boolean _initialSticky, int _userId,
231 boolean _allowBackgroundActivityStarts) {
Dianne Hackborn448489a2016-09-29 10:55:10 -0700232 if (_intent == null) {
233 throw new NullPointerException("Can't construct with a null intent");
234 }
Christopher Tatef46723b2012-01-26 14:19:24 -0800235 queue = _queue;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800236 intent = _intent;
Dianne Hackborna40cfeb2013-03-25 17:49:36 -0700237 targetComp = _intent.getComponent();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800238 callerApp = _callerApp;
239 callerPackage = _callerPackage;
240 callingPid = _callingPid;
241 callingUid = _callingUid;
Chad Brubaker816c83b2017-03-02 10:27:59 -0800242 callerInstantApp = _callerInstantApp;
Ben Gruver49660c72013-08-06 19:54:08 -0700243 resolvedType = _resolvedType;
Fyodor Kupolovd4fd8c72015-07-13 19:19:25 -0700244 requiredPermissions = _requiredPermissions;
Dianne Hackbornf51f6122013-02-04 18:23:34 -0800245 appOp = _appOp;
Dianne Hackborna750a632015-06-16 17:18:23 -0700246 options = _options;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800247 receivers = _receivers;
Dianne Hackborne0e413e2015-12-09 17:22:26 -0800248 delivery = new int[_receivers != null ? _receivers.size() : 0];
Ng Zhi An1eb7d382018-08-24 13:27:54 -0700249 duration = new long[delivery.length];
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800250 resultTo = _resultTo;
251 resultCode = _resultCode;
252 resultData = _resultData;
253 resultExtras = _resultExtras;
254 ordered = _serialized;
Dianne Hackborn68d881c2009-10-05 13:58:17 -0700255 sticky = _sticky;
Dianne Hackborn12527f92009-11-11 17:39:50 -0800256 initialSticky = _initialSticky;
Dianne Hackborn786b4402012-08-27 15:14:02 -0700257 userId = _userId;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800258 nextReceiver = 0;
259 state = IDLE;
Michal Karpinskiac116df2018-12-10 17:51:42 +0000260 allowBackgroundActivityStarts = _allowBackgroundActivityStarts;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800261 }
262
Makoto Onuki97f82f22017-05-31 16:20:21 -0700263 /**
264 * Copy constructor which takes a different intent.
265 * Only used by {@link #maybeStripForHistory}.
266 */
267 private BroadcastRecord(BroadcastRecord from, Intent newIntent) {
268 intent = newIntent;
269 targetComp = newIntent.getComponent();
270
271 callerApp = from.callerApp;
272 callerPackage = from.callerPackage;
273 callingPid = from.callingPid;
274 callingUid = from.callingUid;
275 callerInstantApp = from.callerInstantApp;
276 ordered = from.ordered;
277 sticky = from.sticky;
278 initialSticky = from.initialSticky;
279 userId = from.userId;
280 resolvedType = from.resolvedType;
281 requiredPermissions = from.requiredPermissions;
282 appOp = from.appOp;
283 options = from.options;
284 receivers = from.receivers;
285 delivery = from.delivery;
Ng Zhi An1eb7d382018-08-24 13:27:54 -0700286 duration = from.duration;
Makoto Onuki97f82f22017-05-31 16:20:21 -0700287 resultTo = from.resultTo;
288 enqueueClockTime = from.enqueueClockTime;
289 dispatchTime = from.dispatchTime;
290 dispatchClockTime = from.dispatchClockTime;
291 receiverTime = from.receiverTime;
292 finishTime = from.finishTime;
293 resultCode = from.resultCode;
294 resultData = from.resultData;
295 resultExtras = from.resultExtras;
296 resultAbort = from.resultAbort;
297 nextReceiver = from.nextReceiver;
298 receiver = from.receiver;
299 state = from.state;
300 anrCount = from.anrCount;
301 manifestCount = from.manifestCount;
302 manifestSkipCount = from.manifestSkipCount;
303 queue = from.queue;
Michal Karpinskiac116df2018-12-10 17:51:42 +0000304 allowBackgroundActivityStarts = from.allowBackgroundActivityStarts;
Makoto Onuki97f82f22017-05-31 16:20:21 -0700305 }
306
307 public BroadcastRecord maybeStripForHistory() {
308 if (!intent.canStripForHistory()) {
309 return this;
310 }
311 return new BroadcastRecord(this, intent.maybeStripForHistory());
312 }
313
Riddle Hsu7fdd90a2018-05-01 00:37:59 +0800314 @VisibleForTesting
Wale Ogunwaleca1c1252015-05-15 12:49:13 -0700315 boolean cleanupDisabledPackageReceiversLocked(
316 String packageName, Set<String> filterByClasses, int userId, boolean doit) {
Riddle Hsu7fdd90a2018-05-01 00:37:59 +0800317 if (receivers == null) {
318 return false;
319 }
320
321 final boolean cleanupAllUsers = userId == UserHandle.USER_ALL;
322 final boolean sendToAllUsers = this.userId == UserHandle.USER_ALL;
323 if (this.userId != userId && !cleanupAllUsers && !sendToAllUsers) {
Wale Ogunwaleca1c1252015-05-15 12:49:13 -0700324 return false;
325 }
326
327 boolean didSomething = false;
328 Object o;
329 for (int i = receivers.size() - 1; i >= 0; i--) {
330 o = receivers.get(i);
331 if (!(o instanceof ResolveInfo)) {
332 continue;
333 }
334 ActivityInfo info = ((ResolveInfo)o).activityInfo;
335
336 final boolean sameComponent = packageName == null
337 || (info.applicationInfo.packageName.equals(packageName)
338 && (filterByClasses == null || filterByClasses.contains(info.name)));
Riddle Hsu7fdd90a2018-05-01 00:37:59 +0800339 if (sameComponent && (cleanupAllUsers
340 || UserHandle.getUserId(info.applicationInfo.uid) == userId)) {
Wale Ogunwaleca1c1252015-05-15 12:49:13 -0700341 if (!doit) {
342 return true;
343 }
344 didSomething = true;
345 receivers.remove(i);
Wale Ogunwale9a6e13c2015-08-03 15:21:44 -0700346 if (i < nextReceiver) {
347 nextReceiver--;
348 }
Wale Ogunwaleca1c1252015-05-15 12:49:13 -0700349 }
350 }
Wale Ogunwale9a6e13c2015-08-03 15:21:44 -0700351 nextReceiver = Math.min(nextReceiver, receivers.size());
Wale Ogunwaleca1c1252015-05-15 12:49:13 -0700352
353 return didSomething;
354 }
355
Yi Jin129fc6c2017-09-28 15:48:38 -0700356 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800357 public String toString() {
358 return "BroadcastRecord{"
359 + Integer.toHexString(System.identityHashCode(this))
Dianne Hackbornb12e1352012-09-26 11:39:20 -0700360 + " u" + userId + " " + intent.getAction() + "}";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800361 }
Yi Jin129fc6c2017-09-28 15:48:38 -0700362
363 public void writeToProto(ProtoOutputStream proto, long fieldId) {
364 long token = proto.start(fieldId);
365 proto.write(BroadcastRecordProto.USER_ID, userId);
366 proto.write(BroadcastRecordProto.INTENT_ACTION, intent.getAction());
367 proto.end(token);
368 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800369}