Merge "make the notification enqueue rate threshold a setting" into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
43c3a7e5a7
@@ -8981,6 +8981,14 @@ public final class Settings {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static final String ENABLE_CELLULAR_ON_BOOT = "enable_cellular_on_boot";
|
public static final String ENABLE_CELLULAR_ON_BOOT = "enable_cellular_on_boot";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum allowed notification enqueue rate in Hertz.
|
||||||
|
*
|
||||||
|
* Should be a float, and includes both posts and updates.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final String MAX_NOTIFICATION_ENQUEUE_RATE = "max_notification_enqueue_rate";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ public class NotificationManagerService extends SystemService {
|
|||||||
= SystemProperties.getBoolean("debug.child_notifs", true);
|
= SystemProperties.getBoolean("debug.child_notifs", true);
|
||||||
|
|
||||||
static final int MAX_PACKAGE_NOTIFICATIONS = 50;
|
static final int MAX_PACKAGE_NOTIFICATIONS = 50;
|
||||||
static final float MAX_PACKAGE_ENQUEUE_RATE = 50f;
|
static final float DEFAULT_MAX_NOTIFICATION_ENQUEUE_RATE = 50f;
|
||||||
|
|
||||||
// message codes
|
// message codes
|
||||||
static final int MESSAGE_TIMEOUT = 2;
|
static final int MESSAGE_TIMEOUT = 2;
|
||||||
@@ -305,6 +305,7 @@ public class NotificationManagerService extends SystemService {
|
|||||||
private static final int MY_PID = Process.myPid();
|
private static final int MY_PID = Process.myPid();
|
||||||
private RankingHandler mRankingHandler;
|
private RankingHandler mRankingHandler;
|
||||||
private long mLastOverRateLogTime;
|
private long mLastOverRateLogTime;
|
||||||
|
private float mMaxPackageEnqueueRate = DEFAULT_MAX_NOTIFICATION_ENQUEUE_RATE;
|
||||||
|
|
||||||
private static class Archive {
|
private static class Archive {
|
||||||
final int mBufferSize;
|
final int mBufferSize;
|
||||||
@@ -817,6 +818,8 @@ public class NotificationManagerService extends SystemService {
|
|||||||
private final class SettingsObserver extends ContentObserver {
|
private final class SettingsObserver extends ContentObserver {
|
||||||
private final Uri NOTIFICATION_LIGHT_PULSE_URI
|
private final Uri NOTIFICATION_LIGHT_PULSE_URI
|
||||||
= Settings.System.getUriFor(Settings.System.NOTIFICATION_LIGHT_PULSE);
|
= Settings.System.getUriFor(Settings.System.NOTIFICATION_LIGHT_PULSE);
|
||||||
|
private final Uri NOTIFICATION_RATE_LIMIT_URI
|
||||||
|
= Settings.Global.getUriFor(Settings.Global.MAX_NOTIFICATION_ENQUEUE_RATE);
|
||||||
|
|
||||||
SettingsObserver(Handler handler) {
|
SettingsObserver(Handler handler) {
|
||||||
super(handler);
|
super(handler);
|
||||||
@@ -826,6 +829,8 @@ public class NotificationManagerService extends SystemService {
|
|||||||
ContentResolver resolver = getContext().getContentResolver();
|
ContentResolver resolver = getContext().getContentResolver();
|
||||||
resolver.registerContentObserver(NOTIFICATION_LIGHT_PULSE_URI,
|
resolver.registerContentObserver(NOTIFICATION_LIGHT_PULSE_URI,
|
||||||
false, this, UserHandle.USER_ALL);
|
false, this, UserHandle.USER_ALL);
|
||||||
|
resolver.registerContentObserver(NOTIFICATION_RATE_LIMIT_URI,
|
||||||
|
false, this, UserHandle.USER_ALL);
|
||||||
update(null);
|
update(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -843,6 +848,10 @@ public class NotificationManagerService extends SystemService {
|
|||||||
updateNotificationPulse();
|
updateNotificationPulse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (uri == null || NOTIFICATION_RATE_LIMIT_URI.equals(uri)) {
|
||||||
|
mMaxPackageEnqueueRate = Settings.Global.getFloat(resolver,
|
||||||
|
Settings.Global.MAX_NOTIFICATION_ENQUEUE_RATE, mMaxPackageEnqueueRate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -899,6 +908,10 @@ public class NotificationManagerService extends SystemService {
|
|||||||
public void onStart() {
|
public void onStart() {
|
||||||
Resources resources = getContext().getResources();
|
Resources resources = getContext().getResources();
|
||||||
|
|
||||||
|
mMaxPackageEnqueueRate = Settings.Global.getFloat(getContext().getContentResolver(),
|
||||||
|
Settings.Global.MAX_NOTIFICATION_ENQUEUE_RATE,
|
||||||
|
DEFAULT_MAX_NOTIFICATION_ENQUEUE_RATE);
|
||||||
|
|
||||||
mAm = ActivityManagerNative.getDefault();
|
mAm = ActivityManagerNative.getDefault();
|
||||||
mAppOps = (AppOpsManager) getContext().getSystemService(Context.APP_OPS_SERVICE);
|
mAppOps = (AppOpsManager) getContext().getSystemService(Context.APP_OPS_SERVICE);
|
||||||
mVibrator = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
|
mVibrator = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
|
||||||
@@ -2369,6 +2382,7 @@ public class NotificationManagerService extends SystemService {
|
|||||||
pw.println(" mDisableNotificationEffects=" + mDisableNotificationEffects);
|
pw.println(" mDisableNotificationEffects=" + mDisableNotificationEffects);
|
||||||
pw.println(" mCallState=" + callStateToString(mCallState));
|
pw.println(" mCallState=" + callStateToString(mCallState));
|
||||||
pw.println(" mSystemReady=" + mSystemReady);
|
pw.println(" mSystemReady=" + mSystemReady);
|
||||||
|
pw.println(" mMaxPackageEnqueueRate=" + mMaxPackageEnqueueRate);
|
||||||
}
|
}
|
||||||
pw.println(" mArchive=" + mArchive.toString());
|
pw.println(" mArchive=" + mArchive.toString());
|
||||||
Iterator<StatusBarNotification> iter = mArchive.descendingIterator();
|
Iterator<StatusBarNotification> iter = mArchive.descendingIterator();
|
||||||
@@ -2512,7 +2526,7 @@ public class NotificationManagerService extends SystemService {
|
|||||||
if (!isSystemNotification && !isNotificationFromListener) {
|
if (!isSystemNotification && !isNotificationFromListener) {
|
||||||
synchronized (mNotificationList) {
|
synchronized (mNotificationList) {
|
||||||
final float appEnqueueRate = mUsageStats.getAppEnqueueRate(pkg);
|
final float appEnqueueRate = mUsageStats.getAppEnqueueRate(pkg);
|
||||||
if (appEnqueueRate > MAX_PACKAGE_ENQUEUE_RATE) {
|
if (appEnqueueRate > mMaxPackageEnqueueRate) {
|
||||||
mUsageStats.registerOverRateQuota(pkg);
|
mUsageStats.registerOverRateQuota(pkg);
|
||||||
final long now = SystemClock.elapsedRealtime();
|
final long now = SystemClock.elapsedRealtime();
|
||||||
if ((now - mLastOverRateLogTime) > MIN_PACKAGE_OVERRATE_LOG_INTERVAL) {
|
if ((now - mLastOverRateLogTime) > MIN_PACKAGE_OVERRATE_LOG_INTERVAL) {
|
||||||
|
|||||||
Reference in New Issue
Block a user