Loading core/java/android/service/notification/Adjustment.java +14 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ package android.service.notification; import android.annotation.SystemApi; import android.annotation.TestApi; import android.app.NotificationChannel; import android.app.Notification; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; Loading Loading @@ -48,6 +48,12 @@ public final class Adjustment implements Parcelable { * {@link NotificationAssistantService#onNotificationSnoozedUntilContext}. */ public static final String KEY_SNOOZE_CRITERIA = "key_snooze_criteria"; /** * Data type: String. Used to change what {@link Notification#getGroup() group} a notification * belongs to. * @hide */ public static final String KEY_GROUP_KEY = "key_group_key"; /** * Create a notification adjustment. Loading Loading @@ -146,4 +152,11 @@ public final class Adjustment implements Parcelable { dest.writeBundle(mSignals); dest.writeInt(mUser); } @Override public String toString() { return "Adjustment{" + "mSignals=" + mSignals + '}'; } } core/res/res/values/config.xml +9 −1 Original line number Diff line number Diff line Loading @@ -2230,11 +2230,19 @@ <string-array name="config_disabledUntilUsedPreinstalledCarrierApps" translatable="false" /> <!-- The list of classes that should be added to the notification ranking pipline. See {@link com.android.server.notification.NotificationSignalExtractor} --> See {@link com.android.server.notification.NotificationSignalExtractor} If you add a new extractor to this list make sure to update NotificationManagerService.handleRankingSort()--> <string-array name="config_notificationSignalExtractors"> <!-- many of the following extractors depend on the notification channel, so this extractor must come first --> <item>com.android.server.notification.NotificationChannelExtractor</item> <item>com.android.server.notification.NotificationAdjustmentExtractor</item> <!-- depends on AdjustmentExtractor--> <item>com.android.server.notification.ValidateNotificationPeople</item> <item>com.android.server.notification.PriorityExtractor</item> <item>com.android.server.notification.ImportanceExtractor</item> <!-- depends on ImportanceExtractor--> <item>com.android.server.notification.NotificationIntrusivenessExtractor</item> <item>com.android.server.notification.VisibilityExtractor</item> <item>com.android.server.notification.BadgeExtractor</item> Loading services/core/java/com/android/server/notification/BadgeExtractor.java +5 −3 Original line number Diff line number Diff line Loading @@ -47,9 +47,11 @@ public class BadgeExtractor implements NotificationSignalExtractor { if (!userWantsBadges || !appCanShowBadge) { record.setShowBadge(false); } else { record.setShowBadge(mConfig.getNotificationChannel(record.sbn.getPackageName(), record.sbn.getUid(), record.getChannel().getId(), false).canShowBadge() && appCanShowBadge); if (record.getChannel() != null) { record.setShowBadge(record.getChannel().canShowBadge() && appCanShowBadge); } else { record.setShowBadge(appCanShowBadge); } } return null; Loading services/core/java/com/android/server/notification/NotificationAdjustmentExtractor.java 0 → 100644 +48 −0 Original line number Diff line number Diff line /** * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.notification; import android.content.Context; import android.util.Slog; /** * Applies adjustments from the group helper and notification assistant */ public class NotificationAdjustmentExtractor implements NotificationSignalExtractor { private static final String TAG = "BadgeExtractor"; private static final boolean DBG = false; public void initialize(Context ctx, NotificationUsageStats usageStats) { if (DBG) Slog.d(TAG, "Initializing " + getClass().getSimpleName() + "."); } public RankingReconsideration process(NotificationRecord record) { if (record == null || record.getNotification() == null) { if (DBG) Slog.d(TAG, "skipping empty notification"); return null; } record.applyAdjustments(); return null; } @Override public void setConfig(RankingConfig config) { // config is not used } } services/core/java/com/android/server/notification/NotificationChannelExtractor.java 0 → 100644 +55 −0 Original line number Diff line number Diff line /** * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.notification; import android.content.Context; import android.util.Slog; /** * Stores the latest notification channel information for this notification */ public class NotificationChannelExtractor implements NotificationSignalExtractor { private static final String TAG = "BadgeExtractor"; private static final boolean DBG = false; private RankingConfig mConfig; public void initialize(Context ctx, NotificationUsageStats usageStats) { if (DBG) Slog.d(TAG, "Initializing " + getClass().getSimpleName() + "."); } public RankingReconsideration process(NotificationRecord record) { if (record == null || record.getNotification() == null) { if (DBG) Slog.d(TAG, "skipping empty notification"); return null; } if (mConfig == null) { if (DBG) Slog.d(TAG, "missing config"); return null; } record.updateNotificationChannel(mConfig.getNotificationChannel(record.sbn.getPackageName(), record.sbn.getUid(), record.getChannel().getId(), false)); return null; } @Override public void setConfig(RankingConfig config) { mConfig = config; } } Loading
core/java/android/service/notification/Adjustment.java +14 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ package android.service.notification; import android.annotation.SystemApi; import android.annotation.TestApi; import android.app.NotificationChannel; import android.app.Notification; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; Loading Loading @@ -48,6 +48,12 @@ public final class Adjustment implements Parcelable { * {@link NotificationAssistantService#onNotificationSnoozedUntilContext}. */ public static final String KEY_SNOOZE_CRITERIA = "key_snooze_criteria"; /** * Data type: String. Used to change what {@link Notification#getGroup() group} a notification * belongs to. * @hide */ public static final String KEY_GROUP_KEY = "key_group_key"; /** * Create a notification adjustment. Loading Loading @@ -146,4 +152,11 @@ public final class Adjustment implements Parcelable { dest.writeBundle(mSignals); dest.writeInt(mUser); } @Override public String toString() { return "Adjustment{" + "mSignals=" + mSignals + '}'; } }
core/res/res/values/config.xml +9 −1 Original line number Diff line number Diff line Loading @@ -2230,11 +2230,19 @@ <string-array name="config_disabledUntilUsedPreinstalledCarrierApps" translatable="false" /> <!-- The list of classes that should be added to the notification ranking pipline. See {@link com.android.server.notification.NotificationSignalExtractor} --> See {@link com.android.server.notification.NotificationSignalExtractor} If you add a new extractor to this list make sure to update NotificationManagerService.handleRankingSort()--> <string-array name="config_notificationSignalExtractors"> <!-- many of the following extractors depend on the notification channel, so this extractor must come first --> <item>com.android.server.notification.NotificationChannelExtractor</item> <item>com.android.server.notification.NotificationAdjustmentExtractor</item> <!-- depends on AdjustmentExtractor--> <item>com.android.server.notification.ValidateNotificationPeople</item> <item>com.android.server.notification.PriorityExtractor</item> <item>com.android.server.notification.ImportanceExtractor</item> <!-- depends on ImportanceExtractor--> <item>com.android.server.notification.NotificationIntrusivenessExtractor</item> <item>com.android.server.notification.VisibilityExtractor</item> <item>com.android.server.notification.BadgeExtractor</item> Loading
services/core/java/com/android/server/notification/BadgeExtractor.java +5 −3 Original line number Diff line number Diff line Loading @@ -47,9 +47,11 @@ public class BadgeExtractor implements NotificationSignalExtractor { if (!userWantsBadges || !appCanShowBadge) { record.setShowBadge(false); } else { record.setShowBadge(mConfig.getNotificationChannel(record.sbn.getPackageName(), record.sbn.getUid(), record.getChannel().getId(), false).canShowBadge() && appCanShowBadge); if (record.getChannel() != null) { record.setShowBadge(record.getChannel().canShowBadge() && appCanShowBadge); } else { record.setShowBadge(appCanShowBadge); } } return null; Loading
services/core/java/com/android/server/notification/NotificationAdjustmentExtractor.java 0 → 100644 +48 −0 Original line number Diff line number Diff line /** * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.notification; import android.content.Context; import android.util.Slog; /** * Applies adjustments from the group helper and notification assistant */ public class NotificationAdjustmentExtractor implements NotificationSignalExtractor { private static final String TAG = "BadgeExtractor"; private static final boolean DBG = false; public void initialize(Context ctx, NotificationUsageStats usageStats) { if (DBG) Slog.d(TAG, "Initializing " + getClass().getSimpleName() + "."); } public RankingReconsideration process(NotificationRecord record) { if (record == null || record.getNotification() == null) { if (DBG) Slog.d(TAG, "skipping empty notification"); return null; } record.applyAdjustments(); return null; } @Override public void setConfig(RankingConfig config) { // config is not used } }
services/core/java/com/android/server/notification/NotificationChannelExtractor.java 0 → 100644 +55 −0 Original line number Diff line number Diff line /** * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.notification; import android.content.Context; import android.util.Slog; /** * Stores the latest notification channel information for this notification */ public class NotificationChannelExtractor implements NotificationSignalExtractor { private static final String TAG = "BadgeExtractor"; private static final boolean DBG = false; private RankingConfig mConfig; public void initialize(Context ctx, NotificationUsageStats usageStats) { if (DBG) Slog.d(TAG, "Initializing " + getClass().getSimpleName() + "."); } public RankingReconsideration process(NotificationRecord record) { if (record == null || record.getNotification() == null) { if (DBG) Slog.d(TAG, "skipping empty notification"); return null; } if (mConfig == null) { if (DBG) Slog.d(TAG, "missing config"); return null; } record.updateNotificationChannel(mConfig.getNotificationChannel(record.sbn.getPackageName(), record.sbn.getUid(), record.getChannel().getId(), false)); return null; } @Override public void setConfig(RankingConfig config) { mConfig = config; } }