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

Commit 698b322c authored by Sudheer Shanka's avatar Sudheer Shanka Committed by Automerger Merge Worker
Browse files

Merge "Log broadcast type and delivery policy." into udc-dev am: 858a4798

parents 1c0e5cff 858a4798
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -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,
@@ -615,7 +615,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");
@@ -742,7 +744,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,
@@ -795,7 +797,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());
        }
    }

@@ -871,7 +874,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,
@@ -1162,7 +1165,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,
+3 −3
Original line number Diff line number Diff line
@@ -731,8 +731,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:
@@ -1932,7 +1931,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());
        }
    }

+60 −0
Original line number Diff line number Diff line
@@ -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;
@@ -1018,6 +1032,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;
@@ -1113,6 +1167,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);
    }
+2 −1
Original line number Diff line number Diff line
@@ -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));
    }