Log broadcast type and delivery policy.
Include broadcast type and delivery policy in the BroadcastDeliveryEventReported atom. Bug: 254521331 Test: statsd_testdrive 475 Test: atest services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueTest.java Test: atest services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueModernImplTest.java Change-Id: I94e1de8c3c766da4aa4f3ea6b62cf8cd01a5e8e5
This commit is contained in:
@@ -264,7 +264,7 @@ public class BroadcastQueueImpl extends BroadcastQueue {
|
||||
if (oldRecord.resultTo != null) {
|
||||
try {
|
||||
oldRecord.mIsReceiverAppRunning = true;
|
||||
performReceiveLocked(oldRecord.resultToApp, oldRecord.resultTo,
|
||||
performReceiveLocked(oldRecord, oldRecord.resultToApp, oldRecord.resultTo,
|
||||
oldRecord.intent,
|
||||
Activity.RESULT_CANCELED, null, null,
|
||||
false, false, oldRecord.shareIdentity, oldRecord.userId,
|
||||
@@ -613,7 +613,9 @@ public class BroadcastQueueImpl extends BroadcastQueue {
|
||||
finishTime - r.receiverTime,
|
||||
packageState,
|
||||
r.curApp.info.packageName,
|
||||
r.callerPackage);
|
||||
r.callerPackage,
|
||||
r.calculateTypeForLogging(),
|
||||
r.getDeliveryGroupPolicy());
|
||||
}
|
||||
if (state == BroadcastRecord.IDLE) {
|
||||
Slog.w(TAG_BROADCAST, "finishReceiver [" + mQueueName + "] called but state is IDLE");
|
||||
@@ -740,7 +742,7 @@ public class BroadcastQueueImpl extends BroadcastQueue {
|
||||
}
|
||||
}
|
||||
|
||||
public void performReceiveLocked(ProcessRecord app, IIntentReceiver receiver,
|
||||
public void performReceiveLocked(BroadcastRecord r, ProcessRecord app, IIntentReceiver receiver,
|
||||
Intent intent, int resultCode, String data, Bundle extras,
|
||||
boolean ordered, boolean sticky, boolean shareIdentity, int sendingUser,
|
||||
int receiverUid, int callingUid, String callingPackage,
|
||||
@@ -793,7 +795,8 @@ public class BroadcastQueueImpl extends BroadcastQueue {
|
||||
BROADCAST_DELIVERY_EVENT_REPORTED__PROC_START_TYPE__PROCESS_START_TYPE_WARM,
|
||||
dispatchDelay, receiveDelay, 0 /* finish_delay */,
|
||||
SERVICE_REQUEST_EVENT_REPORTED__PACKAGE_STOPPED_STATE__PACKAGE_STATE_NORMAL,
|
||||
app != null ? app.info.packageName : null, callingPackage);
|
||||
app != null ? app.info.packageName : null, callingPackage,
|
||||
r.calculateTypeForLogging(), r.getDeliveryGroupPolicy());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -869,7 +872,7 @@ public class BroadcastQueueImpl extends BroadcastQueue {
|
||||
maybeAddBackgroundStartPrivileges(filter.receiverList.app, r);
|
||||
maybeScheduleTempAllowlistLocked(filter.owningUid, r, r.options);
|
||||
maybeReportBroadcastDispatchedEventLocked(r, filter.owningUid);
|
||||
performReceiveLocked(filter.receiverList.app, filter.receiverList.receiver,
|
||||
performReceiveLocked(r, filter.receiverList.app, filter.receiverList.receiver,
|
||||
prepareReceiverIntent(r.intent, filteredExtras), r.resultCode, r.resultData,
|
||||
r.resultExtras, r.ordered, r.initialSticky, r.shareIdentity, r.userId,
|
||||
filter.receiverList.uid, r.callingUid, r.callerPackage,
|
||||
@@ -1160,7 +1163,7 @@ public class BroadcastQueueImpl extends BroadcastQueue {
|
||||
r.dispatchTime = now;
|
||||
}
|
||||
r.mIsReceiverAppRunning = true;
|
||||
performReceiveLocked(r.resultToApp, r.resultTo,
|
||||
performReceiveLocked(r, r.resultToApp, r.resultTo,
|
||||
new Intent(r.intent), r.resultCode,
|
||||
r.resultData, r.resultExtras, false, false, r.shareIdentity,
|
||||
r.userId, r.callingUid, r.callingUid, r.callerPackage,
|
||||
|
||||
@@ -703,8 +703,7 @@ class BroadcastQueueModernImpl extends BroadcastQueue {
|
||||
if (mService.shouldIgnoreDeliveryGroupPolicy(r.intent.getAction())) {
|
||||
return;
|
||||
}
|
||||
final int policy = (r.options != null)
|
||||
? r.options.getDeliveryGroupPolicy() : BroadcastOptions.DELIVERY_GROUP_POLICY_ALL;
|
||||
final int policy = r.getDeliveryGroupPolicy();
|
||||
final BroadcastConsumer broadcastConsumer;
|
||||
switch (policy) {
|
||||
case BroadcastOptions.DELIVERY_GROUP_POLICY_ALL:
|
||||
@@ -1892,7 +1891,8 @@ class BroadcastQueueModernImpl extends BroadcastQueue {
|
||||
: SERVICE_REQUEST_EVENT_REPORTED__PACKAGE_STOPPED_STATE__PACKAGE_STATE_NORMAL;
|
||||
FrameworkStatsLog.write(BROADCAST_DELIVERY_EVENT_REPORTED, uid, senderUid, actionName,
|
||||
receiverType, type, dispatchDelay, receiveDelay, finishDelay, packageState,
|
||||
app != null ? app.info.packageName : null, r.callerPackage);
|
||||
app != null ? app.info.packageName : null, r.callerPackage,
|
||||
r.calculateTypeForLogging(), r.getDeliveryGroupPolicy());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,19 @@
|
||||
package com.android.server.am;
|
||||
|
||||
import static android.app.ActivityManager.RESTRICTION_LEVEL_BACKGROUND_RESTRICTED;
|
||||
import static android.app.AppProtoEnums.BROADCAST_TYPE_ALARM;
|
||||
import static android.app.AppProtoEnums.BROADCAST_TYPE_BACKGROUND;
|
||||
import static android.app.AppProtoEnums.BROADCAST_TYPE_DEFERRABLE_UNTIL_ACTIVE;
|
||||
import static android.app.AppProtoEnums.BROADCAST_TYPE_FOREGROUND;
|
||||
import static android.app.AppProtoEnums.BROADCAST_TYPE_INITIAL_STICKY;
|
||||
import static android.app.AppProtoEnums.BROADCAST_TYPE_INTERACTIVE;
|
||||
import static android.app.AppProtoEnums.BROADCAST_TYPE_NONE;
|
||||
import static android.app.AppProtoEnums.BROADCAST_TYPE_ORDERED;
|
||||
import static android.app.AppProtoEnums.BROADCAST_TYPE_PRIORITIZED;
|
||||
import static android.app.AppProtoEnums.BROADCAST_TYPE_PUSH_MESSAGE;
|
||||
import static android.app.AppProtoEnums.BROADCAST_TYPE_PUSH_MESSAGE_OVER_QUOTA;
|
||||
import static android.app.AppProtoEnums.BROADCAST_TYPE_RESULT_TO;
|
||||
import static android.app.AppProtoEnums.BROADCAST_TYPE_STICKY;
|
||||
|
||||
import static com.android.server.am.BroadcastConstants.DEFER_BOOT_COMPLETED_BROADCAST_ALL;
|
||||
import static com.android.server.am.BroadcastConstants.DEFER_BOOT_COMPLETED_BROADCAST_BACKGROUND_RESTRICTED_ONLY;
|
||||
@@ -35,6 +48,7 @@ import android.app.ActivityManagerInternal;
|
||||
import android.app.AppOpsManager;
|
||||
import android.app.BackgroundStartPrivileges;
|
||||
import android.app.BroadcastOptions;
|
||||
import android.app.BroadcastOptions.DeliveryGroupPolicy;
|
||||
import android.app.compat.CompatChanges;
|
||||
import android.content.ComponentName;
|
||||
import android.content.IIntentReceiver;
|
||||
@@ -1015,6 +1029,46 @@ final class BroadcastRecord extends Binder {
|
||||
}
|
||||
}
|
||||
|
||||
int calculateTypeForLogging() {
|
||||
int type = BROADCAST_TYPE_NONE;
|
||||
if (isForeground()) {
|
||||
type |= BROADCAST_TYPE_FOREGROUND;
|
||||
} else {
|
||||
type |= BROADCAST_TYPE_BACKGROUND;
|
||||
}
|
||||
if (alarm) {
|
||||
type |= BROADCAST_TYPE_ALARM;
|
||||
}
|
||||
if (interactive) {
|
||||
type |= BROADCAST_TYPE_INTERACTIVE;
|
||||
}
|
||||
if (ordered) {
|
||||
type |= BROADCAST_TYPE_ORDERED;
|
||||
}
|
||||
if (prioritized) {
|
||||
type |= BROADCAST_TYPE_PRIORITIZED;
|
||||
}
|
||||
if (resultTo != null) {
|
||||
type |= BROADCAST_TYPE_RESULT_TO;
|
||||
}
|
||||
if (deferUntilActive) {
|
||||
type |= BROADCAST_TYPE_DEFERRABLE_UNTIL_ACTIVE;
|
||||
}
|
||||
if (pushMessage) {
|
||||
type |= BROADCAST_TYPE_PUSH_MESSAGE;
|
||||
}
|
||||
if (pushMessageOverQuota) {
|
||||
type |= BROADCAST_TYPE_PUSH_MESSAGE_OVER_QUOTA;
|
||||
}
|
||||
if (sticky) {
|
||||
type |= BROADCAST_TYPE_STICKY;
|
||||
}
|
||||
if (initialSticky) {
|
||||
type |= BROADCAST_TYPE_INITIAL_STICKY;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
public BroadcastRecord maybeStripForHistory() {
|
||||
if (!intent.canStripForHistory()) {
|
||||
return this;
|
||||
@@ -1110,6 +1164,12 @@ final class BroadcastRecord extends Binder {
|
||||
return true;
|
||||
}
|
||||
|
||||
@DeliveryGroupPolicy
|
||||
int getDeliveryGroupPolicy() {
|
||||
return (options != null) ? options.getDeliveryGroupPolicy()
|
||||
: BroadcastOptions.DELIVERY_GROUP_POLICY_ALL;
|
||||
}
|
||||
|
||||
boolean matchesDeliveryGroup(@NonNull BroadcastRecord other) {
|
||||
return matchesDeliveryGroup(this, other);
|
||||
}
|
||||
|
||||
@@ -1406,7 +1406,8 @@ public final class BroadcastQueueModernImplTest {
|
||||
eq(getUidForPackage(PACKAGE_GREEN)), anyInt(), eq(Intent.ACTION_TIME_TICK),
|
||||
eq(BROADCAST_DELIVERY_EVENT_REPORTED__RECEIVER_TYPE__MANIFEST),
|
||||
eq(BROADCAST_DELIVERY_EVENT_REPORTED__PROC_START_TYPE__PROCESS_START_TYPE_COLD),
|
||||
anyLong(), anyLong(), anyLong(), anyInt(), nullable(String.class), anyString()),
|
||||
anyLong(), anyLong(), anyLong(), anyInt(), nullable(String.class),
|
||||
anyString(), anyInt(), anyInt()),
|
||||
times(1));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user