Add push messaging as a trigger for proc start am: 8fcf1d63c6

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20112890

Change-Id: Ia1b7c4fe3462c191d241b00db4050892324959ec
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Suprabh Shukla
2022-10-04 22:22:55 +00:00
committed by Automerger Merge Worker
4 changed files with 47 additions and 2 deletions

View File

@@ -528,6 +528,28 @@ public class BroadcastOptions extends ComponentOptions {
return mIsAlarmBroadcast;
}
/**
* Did this broadcast originate from a push message from the server?
*
* @return true if this broadcast is a push message, false otherwise.
* @hide
*/
public boolean isPushMessagingBroadcast() {
return mTemporaryAppAllowlistReasonCode == PowerExemptionManager.REASON_PUSH_MESSAGING;
}
/**
* Did this broadcast originate from a push message from the server which was over the allowed
* quota?
*
* @return true if this broadcast is a push message over quota, false otherwise.
* @hide
*/
public boolean isPushMessagingOverQuotaBroadcast() {
return mTemporaryAppAllowlistReasonCode
== PowerExemptionManager.REASON_PUSH_MESSAGING_OVER_QUOTA;
}
/** {@hide} */
public long getRequireCompatChangeId() {
return mRequireCompatChangeId;

View File

@@ -1921,8 +1921,7 @@ public final class BroadcastQueue {
info.activityInfo.applicationInfo, true,
r.intent.getFlags() | Intent.FLAG_FROM_BACKGROUND,
new HostingRecord(HostingRecord.HOSTING_TYPE_BROADCAST, r.curComponent,
r.intent.getAction(), (r.alarm ? HostingRecord.TRIGGER_TYPE_ALARM
: HostingRecord.TRIGGER_TYPE_UNKNOWN)),
r.intent.getAction(), getHostingRecordTriggerType(r)),
isActivityCapable ? ZYGOTE_POLICY_FLAG_LATENCY_SENSITIVE : ZYGOTE_POLICY_FLAG_EMPTY,
(r.intent.getFlags() & Intent.FLAG_RECEIVER_BOOT_UPGRADE) != 0, false);
if (r.curApp == null) {
@@ -1945,6 +1944,16 @@ public final class BroadcastQueue {
mPendingBroadcastRecvIndex = recIdx;
}
private String getHostingRecordTriggerType(BroadcastRecord r) {
if (r.alarm) {
return HostingRecord.TRIGGER_TYPE_ALARM;
} else if (r.pushMessage) {
return HostingRecord.TRIGGER_TYPE_PUSH_MESSAGE;
} else if (r.pushMessageOverQuota) {
return HostingRecord.TRIGGER_TYPE_PUSH_MESSAGE_OVER_QUOTA;
}
return HostingRecord.TRIGGER_TYPE_UNKNOWN;
}
@Nullable
private String getTargetPackage(BroadcastRecord r) {

View File

@@ -71,6 +71,8 @@ final class BroadcastRecord extends Binder {
final boolean ordered; // serialize the send to receivers?
final boolean sticky; // originated from existing sticky data?
final boolean alarm; // originated from an alarm triggering?
final boolean pushMessage; // originated from a push message?
final boolean pushMessageOverQuota; // originated from a push message which was over quota?
final boolean initialSticky; // initial broadcast from register to sticky?
final int userId; // user id this broadcast was for
final String resolvedType; // the resolved data type
@@ -309,6 +311,8 @@ final class BroadcastRecord extends Binder {
mBackgroundActivityStartsToken = backgroundActivityStartsToken;
this.timeoutExempt = timeoutExempt;
alarm = options != null && options.isAlarmBroadcast();
pushMessage = options != null && options.isPushMessagingBroadcast();
pushMessageOverQuota = options != null && options.isPushMessagingOverQuotaBroadcast();
}
/**
@@ -362,6 +366,8 @@ final class BroadcastRecord extends Binder {
mBackgroundActivityStartsToken = from.mBackgroundActivityStartsToken;
timeoutExempt = from.timeoutExempt;
alarm = from.alarm;
pushMessage = from.pushMessage;
pushMessageOverQuota = from.pushMessageOverQuota;
}
/**

View File

@@ -30,6 +30,8 @@ import static com.android.internal.util.FrameworkStatsLog.PROCESS_START_TIME__HO
import static com.android.internal.util.FrameworkStatsLog.PROCESS_START_TIME__HOSTING_TYPE_ID__HOSTING_TYPE_SERVICE;
import static com.android.internal.util.FrameworkStatsLog.PROCESS_START_TIME__HOSTING_TYPE_ID__HOSTING_TYPE_SYSTEM;
import static com.android.internal.util.FrameworkStatsLog.PROCESS_START_TIME__HOSTING_TYPE_ID__HOSTING_TYPE_TOP_ACTIVITY;
import static com.android.internal.util.FrameworkStatsLog.PROCESS_START_TIME__TRIGGER_TYPE__TRIGGER_PUSH_MESSAGE;
import static com.android.internal.util.FrameworkStatsLog.PROCESS_START_TIME__TRIGGER_TYPE__TRIGGER_PUSH_MESSAGE_OVER_QUOTA;
import static com.android.internal.util.FrameworkStatsLog.PROCESS_START_TIME__TRIGGER_TYPE__TRIGGER_TYPE_ALARM;
import static com.android.internal.util.FrameworkStatsLog.PROCESS_START_TIME__TRIGGER_TYPE__TRIGGER_TYPE_UNKNOWN;
import static com.android.internal.util.FrameworkStatsLog.PROCESS_START_TIME__TYPE__UNKNOWN;
@@ -93,6 +95,8 @@ public final class HostingRecord {
public static final String TRIGGER_TYPE_UNKNOWN = "unknown";
public static final String TRIGGER_TYPE_ALARM = "alarm";
public static final String TRIGGER_TYPE_PUSH_MESSAGE = "push_message";
public static final String TRIGGER_TYPE_PUSH_MESSAGE_OVER_QUOTA = "push_message_over_quota";
@NonNull private final String mHostingType;
private final String mHostingName;
@@ -308,6 +312,10 @@ public final class HostingRecord {
switch(triggerType) {
case TRIGGER_TYPE_ALARM:
return PROCESS_START_TIME__TRIGGER_TYPE__TRIGGER_TYPE_ALARM;
case TRIGGER_TYPE_PUSH_MESSAGE:
return PROCESS_START_TIME__TRIGGER_TYPE__TRIGGER_PUSH_MESSAGE;
case TRIGGER_TYPE_PUSH_MESSAGE_OVER_QUOTA:
return PROCESS_START_TIME__TRIGGER_TYPE__TRIGGER_PUSH_MESSAGE_OVER_QUOTA;
default:
return PROCESS_START_TIME__TRIGGER_TYPE__TRIGGER_TYPE_UNKNOWN;
}