Merge "Add a flag to limit notif-seen signal changes to T targeting apps." into tm-dev am: 92762b949b

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

Change-Id: If28e11bd56073cccda831d74b8e78e2d22967207
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Sudheer Shanka
2022-05-20 18:17:05 +00:00
committed by Automerger Merge Worker

View File

@@ -225,6 +225,11 @@ public class AppStandbyController
| PackageManager.MATCH_DISABLED_COMPONENTS | PackageManager.MATCH_DISABLED_COMPONENTS
| PackageManager.MATCH_SYSTEM_ONLY; | PackageManager.MATCH_SYSTEM_ONLY;
private static final int NOTIFICATION_SEEN_PROMOTED_BUCKET_FOR_PRE_T_APPS =
STANDBY_BUCKET_WORKING_SET;
private static final long NOTIFICATION_SEEN_HOLD_DURATION_FOR_PRE_T_APPS =
COMPRESS_TIME ? 12 * ONE_MINUTE : 12 * ONE_HOUR;
// To name the lock for stack traces // To name the lock for stack traces
static class Lock {} static class Lock {}
@@ -320,11 +325,17 @@ public class AppStandbyController
int mNotificationSeenPromotedBucket = int mNotificationSeenPromotedBucket =
ConstantsObserver.DEFAULT_NOTIFICATION_SEEN_PROMOTED_BUCKET; ConstantsObserver.DEFAULT_NOTIFICATION_SEEN_PROMOTED_BUCKET;
/** /**
* If true, tell each {@link AppIdleStateChangeListener} to give quota bump for each * If {@code true}, tell each {@link AppIdleStateChangeListener} to give quota bump for each
* notification seen event. * notification seen event.
*/ */
private boolean mTriggerQuotaBumpOnNotificationSeen = private boolean mTriggerQuotaBumpOnNotificationSeen =
ConstantsObserver.DEFAULT_TRIGGER_QUOTA_BUMP_ON_NOTIFICATION_SEEN; ConstantsObserver.DEFAULT_TRIGGER_QUOTA_BUMP_ON_NOTIFICATION_SEEN;
/**
* If {@code true}, we will retain the pre-T impact of notification signal on apps targeting
* pre-T sdk levels regardless of other flag changes.
*/
boolean mRetainNotificationSeenImpactForPreTApps =
ConstantsObserver.DEFAULT_RETAIN_NOTIFICATION_SEEN_IMPACT_FOR_PRE_T_APPS;
/** Minimum time a system update event should keep the buckets elevated. */ /** Minimum time a system update event should keep the buckets elevated. */
long mSystemUpdateUsageTimeoutMillis = ConstantsObserver.DEFAULT_SYSTEM_UPDATE_TIMEOUT; long mSystemUpdateUsageTimeoutMillis = ConstantsObserver.DEFAULT_SYSTEM_UPDATE_TIMEOUT;
/** Maximum time to wait for a prediction before using simple timeouts to downgrade buckets. */ /** Maximum time to wait for a prediction before using simple timeouts to downgrade buckets. */
@@ -1098,17 +1109,29 @@ public class AppStandbyController
final int subReason = usageEventToSubReason(eventType); final int subReason = usageEventToSubReason(eventType);
final int reason = REASON_MAIN_USAGE | subReason; final int reason = REASON_MAIN_USAGE | subReason;
if (eventType == UsageEvents.Event.NOTIFICATION_SEEN) { if (eventType == UsageEvents.Event.NOTIFICATION_SEEN) {
if (mTriggerQuotaBumpOnNotificationSeen) { final int notificationSeenPromotedBucket;
mHandler.obtainMessage(MSG_TRIGGER_LISTENER_QUOTA_BUMP, userId, -1, pkg) final long notificationSeenTimeoutMillis;
.sendToTarget(); if (mRetainNotificationSeenImpactForPreTApps
&& getTargetSdkVersion(pkg) < Build.VERSION_CODES.TIRAMISU) {
notificationSeenPromotedBucket =
NOTIFICATION_SEEN_PROMOTED_BUCKET_FOR_PRE_T_APPS;
notificationSeenTimeoutMillis =
NOTIFICATION_SEEN_HOLD_DURATION_FOR_PRE_T_APPS;
} else {
if (mTriggerQuotaBumpOnNotificationSeen) {
mHandler.obtainMessage(MSG_TRIGGER_LISTENER_QUOTA_BUMP, userId, -1, pkg)
.sendToTarget();
}
notificationSeenPromotedBucket = mNotificationSeenPromotedBucket;
notificationSeenTimeoutMillis = mNotificationSeenTimeoutMillis;
} }
// Notification-seen elevates to a higher bucket (depending on // Notification-seen elevates to a higher bucket (depending on
// {@link ConstantsObserver#KEY_NOTIFICATION_SEEN_PROMOTED_BUCKET}) but doesn't // {@link ConstantsObserver#KEY_NOTIFICATION_SEEN_PROMOTED_BUCKET}) but doesn't
// change usage time. // change usage time.
mAppIdleHistory.reportUsage(appHistory, pkg, userId, mAppIdleHistory.reportUsage(appHistory, pkg, userId,
mNotificationSeenPromotedBucket, subReason, notificationSeenPromotedBucket, subReason,
0, elapsedRealtime + mNotificationSeenTimeoutMillis); 0, elapsedRealtime + notificationSeenTimeoutMillis);
nextCheckDelay = mNotificationSeenTimeoutMillis; nextCheckDelay = notificationSeenTimeoutMillis;
} else if (eventType == UsageEvents.Event.SLICE_PINNED) { } else if (eventType == UsageEvents.Event.SLICE_PINNED) {
// Mild usage elevates to WORKING_SET but doesn't change usage time. // Mild usage elevates to WORKING_SET but doesn't change usage time.
mAppIdleHistory.reportUsage(appHistory, pkg, userId, mAppIdleHistory.reportUsage(appHistory, pkg, userId,
@@ -1149,6 +1172,10 @@ public class AppStandbyController
} }
} }
private int getTargetSdkVersion(String packageName) {
return mInjector.getPackageManagerInternal().getPackageTargetSdkVersion(packageName);
}
/** /**
* Returns the lowest standby bucket that is better than {@code targetBucket} and has an * Returns the lowest standby bucket that is better than {@code targetBucket} and has an
* valid expiry time (i.e. the expiry time is not yet elapsed). * valid expiry time (i.e. the expiry time is not yet elapsed).
@@ -2226,6 +2253,9 @@ public class AppStandbyController
pw.print(" mTriggerQuotaBumpOnNotificationSeen="); pw.print(" mTriggerQuotaBumpOnNotificationSeen=");
pw.print(mTriggerQuotaBumpOnNotificationSeen); pw.print(mTriggerQuotaBumpOnNotificationSeen);
pw.println(); pw.println();
pw.print(" mRetainNotificationSeenImpactForPreTApps=");
pw.print(mRetainNotificationSeenImpactForPreTApps);
pw.println();
pw.print(" mSlicePinnedTimeoutMillis="); pw.print(" mSlicePinnedTimeoutMillis=");
TimeUtils.formatDuration(mSlicePinnedTimeoutMillis, pw); TimeUtils.formatDuration(mSlicePinnedTimeoutMillis, pw);
pw.println(); pw.println();
@@ -2712,6 +2742,8 @@ public class AppStandbyController
"notification_seen_duration"; "notification_seen_duration";
private static final String KEY_NOTIFICATION_SEEN_PROMOTED_BUCKET = private static final String KEY_NOTIFICATION_SEEN_PROMOTED_BUCKET =
"notification_seen_promoted_bucket"; "notification_seen_promoted_bucket";
private static final String KEY_RETAIN_NOTIFICATION_SEEN_IMPACT_FOR_PRE_T_APPS =
"retain_notification_seen_impact_for_pre_t_apps";
private static final String KEY_TRIGGER_QUOTA_BUMP_ON_NOTIFICATION_SEEN = private static final String KEY_TRIGGER_QUOTA_BUMP_ON_NOTIFICATION_SEEN =
"trigger_quota_bump_on_notification_seen"; "trigger_quota_bump_on_notification_seen";
private static final String KEY_SLICE_PINNED_HOLD_DURATION = private static final String KEY_SLICE_PINNED_HOLD_DURATION =
@@ -2773,6 +2805,7 @@ public class AppStandbyController
COMPRESS_TIME ? 12 * ONE_MINUTE : 12 * ONE_HOUR; COMPRESS_TIME ? 12 * ONE_MINUTE : 12 * ONE_HOUR;
public static final int DEFAULT_NOTIFICATION_SEEN_PROMOTED_BUCKET = public static final int DEFAULT_NOTIFICATION_SEEN_PROMOTED_BUCKET =
STANDBY_BUCKET_WORKING_SET; STANDBY_BUCKET_WORKING_SET;
public static final boolean DEFAULT_RETAIN_NOTIFICATION_SEEN_IMPACT_FOR_PRE_T_APPS = false;
public static final boolean DEFAULT_TRIGGER_QUOTA_BUMP_ON_NOTIFICATION_SEEN = false; public static final boolean DEFAULT_TRIGGER_QUOTA_BUMP_ON_NOTIFICATION_SEEN = false;
public static final long DEFAULT_SYSTEM_UPDATE_TIMEOUT = public static final long DEFAULT_SYSTEM_UPDATE_TIMEOUT =
COMPRESS_TIME ? 2 * ONE_MINUTE : 2 * ONE_HOUR; COMPRESS_TIME ? 2 * ONE_MINUTE : 2 * ONE_HOUR;
@@ -2874,6 +2907,11 @@ public class AppStandbyController
KEY_NOTIFICATION_SEEN_PROMOTED_BUCKET, KEY_NOTIFICATION_SEEN_PROMOTED_BUCKET,
DEFAULT_NOTIFICATION_SEEN_PROMOTED_BUCKET); DEFAULT_NOTIFICATION_SEEN_PROMOTED_BUCKET);
break; break;
case KEY_RETAIN_NOTIFICATION_SEEN_IMPACT_FOR_PRE_T_APPS:
mRetainNotificationSeenImpactForPreTApps = properties.getBoolean(
KEY_RETAIN_NOTIFICATION_SEEN_IMPACT_FOR_PRE_T_APPS,
DEFAULT_RETAIN_NOTIFICATION_SEEN_IMPACT_FOR_PRE_T_APPS);
break;
case KEY_TRIGGER_QUOTA_BUMP_ON_NOTIFICATION_SEEN: case KEY_TRIGGER_QUOTA_BUMP_ON_NOTIFICATION_SEEN:
mTriggerQuotaBumpOnNotificationSeen = properties.getBoolean( mTriggerQuotaBumpOnNotificationSeen = properties.getBoolean(
KEY_TRIGGER_QUOTA_BUMP_ON_NOTIFICATION_SEEN, KEY_TRIGGER_QUOTA_BUMP_ON_NOTIFICATION_SEEN,