Merge changes from topics "log-intent-flags", "priority-procstate" into udc-dev

* changes:
  Log intent filter priority and broadcast sender priority.
  Include intent flags in BroadcastDeliveryEventReported atom.
This commit is contained in:
Sudheer Shanka
2023-06-05 19:32:43 +00:00
committed by Android (Google) Code Review
5 changed files with 24 additions and 8 deletions

View File

@@ -269,7 +269,7 @@ public class BroadcastQueueImpl extends BroadcastQueue {
Activity.RESULT_CANCELED, null, null,
false, false, oldRecord.shareIdentity, oldRecord.userId,
oldRecord.callingUid, r.callingUid, r.callerPackage,
SystemClock.uptimeMillis() - oldRecord.enqueueTime, 0);
SystemClock.uptimeMillis() - oldRecord.enqueueTime, 0, 0);
} catch (RemoteException e) {
Slog.w(TAG, "Failure ["
+ mQueueName + "] sending broadcast result of "
@@ -617,7 +617,10 @@ public class BroadcastQueueImpl extends BroadcastQueue {
r.curApp.info.packageName,
r.callerPackage,
r.calculateTypeForLogging(),
r.getDeliveryGroupPolicy());
r.getDeliveryGroupPolicy(),
r.intent.getFlags(),
BroadcastRecord.getReceiverPriority(curReceiver),
r.callerProcState);
}
if (state == BroadcastRecord.IDLE) {
Slog.w(TAG_BROADCAST, "finishReceiver [" + mQueueName + "] called but state is IDLE");
@@ -748,7 +751,7 @@ public class BroadcastQueueImpl extends BroadcastQueue {
Intent intent, int resultCode, String data, Bundle extras,
boolean ordered, boolean sticky, boolean shareIdentity, int sendingUser,
int receiverUid, int callingUid, String callingPackage,
long dispatchDelay, long receiveDelay) throws RemoteException {
long dispatchDelay, long receiveDelay, int priority) throws RemoteException {
// If the broadcaster opted-in to sharing their identity, then expose package visibility for
// the receiver.
if (shareIdentity) {
@@ -798,7 +801,8 @@ public class BroadcastQueueImpl extends BroadcastQueue {
dispatchDelay, receiveDelay, 0 /* finish_delay */,
SERVICE_REQUEST_EVENT_REPORTED__PACKAGE_STOPPED_STATE__PACKAGE_STATE_NORMAL,
app != null ? app.info.packageName : null, callingPackage,
r.calculateTypeForLogging(), r.getDeliveryGroupPolicy());
r.calculateTypeForLogging(), r.getDeliveryGroupPolicy(), r.intent.getFlags(),
priority, r.callerProcState);
}
}
@@ -879,7 +883,7 @@ public class BroadcastQueueImpl extends BroadcastQueue {
r.resultExtras, r.ordered, r.initialSticky, r.shareIdentity, r.userId,
filter.receiverList.uid, r.callingUid, r.callerPackage,
r.dispatchTime - r.enqueueTime,
r.receiverTime - r.dispatchTime);
r.receiverTime - r.dispatchTime, filter.getPriority());
// parallel broadcasts are fire-and-forget, not bookended by a call to
// finishReceiverLocked(), so we manage their activity-start token here
if (filter.receiverList.app != null
@@ -1170,7 +1174,7 @@ public class BroadcastQueueImpl extends BroadcastQueue {
r.resultData, r.resultExtras, false, false, r.shareIdentity,
r.userId, r.callingUid, r.callingUid, r.callerPackage,
r.dispatchTime - r.enqueueTime,
now - r.dispatchTime);
now - r.dispatchTime, 0);
logBootCompletedBroadcastCompletionLatencyIfPossible(r);
// Set this to null so that the reference
// (local and remote) isn't kept in the mBroadcastHistory.

View File

@@ -1933,7 +1933,8 @@ class BroadcastQueueModernImpl extends BroadcastQueue {
FrameworkStatsLog.write(BROADCAST_DELIVERY_EVENT_REPORTED, uid, senderUid, actionName,
receiverType, type, dispatchDelay, receiveDelay, finishDelay, packageState,
app != null ? app.info.packageName : null, r.callerPackage,
r.calculateTypeForLogging(), r.getDeliveryGroupPolicy());
r.calculateTypeForLogging(), r.getDeliveryGroupPolicy(), r.intent.getFlags(),
BroadcastRecord.getReceiverPriority(receiver), r.callerProcState);
}
}

View File

@@ -44,6 +44,8 @@ import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UptimeMillisLong;
import android.app.ActivityManager;
import android.app.ActivityManager.ProcessState;
import android.app.ActivityManagerInternal;
import android.app.AppOpsManager;
import android.app.BackgroundStartPrivileges;
@@ -93,6 +95,7 @@ final class BroadcastRecord extends Binder {
final @Nullable String callerFeatureId; // which feature in the package sent this
final int callingPid; // the pid of who sent this
final int callingUid; // the uid of who sent this
final @ProcessState int callerProcState; // Procstate of the caller process at enqueue time.
final int originalStickyCallingUid;
// if this is a sticky broadcast, the Uid of the original sender
@@ -462,6 +465,8 @@ final class BroadcastRecord extends Binder {
callerFeatureId = _callerFeatureId;
callingPid = _callingPid;
callingUid = _callingUid;
callerProcState = callerApp == null ? ActivityManager.PROCESS_STATE_UNKNOWN
: callerApp.getCurProcState();
callerInstantApp = _callerInstantApp;
callerInstrumented = isCallerInstrumented(_callerApp, _callingUid);
resolvedType = _resolvedType;
@@ -515,6 +520,7 @@ final class BroadcastRecord extends Binder {
callerFeatureId = from.callerFeatureId;
callingPid = from.callingPid;
callingUid = from.callingUid;
callerProcState = from.callerProcState;
callerInstantApp = from.callerInstantApp;
callerInstrumented = from.callerInstrumented;
ordered = from.ordered;

View File

@@ -669,6 +669,11 @@ class ProcessRecord implements WindowProcessListener {
return mOnewayThread;
}
@GuardedBy(anyOf = {"mService", "mProcLock"})
int getCurProcState() {
return mState.getCurProcState();
}
@GuardedBy({"mService", "mProcLock"})
public void makeActive(IApplicationThread thread, ProcessStatsService tracker) {
mProfile.onProcessActive(thread, tracker);

View File

@@ -1407,7 +1407,7 @@ public final class BroadcastQueueModernImplTest {
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(), anyInt(), anyInt()),
anyString(), anyInt(), anyInt(), anyInt(), anyInt(), anyInt()),
times(1));
}