Loading services/core/java/com/android/server/notification/NotificationManagerService.java +2 −4 Original line number Diff line number Diff line Loading @@ -2871,8 +2871,7 @@ public class NotificationManagerService extends SystemService { adjustedSbn.getUser(), GroupHelper.AUTOGROUP_KEY, System.currentTimeMillis()); summaryRecord = new NotificationRecord(getContext(), summarySbn, notificationRecord.getChannel(), mRankingHelper.supportsChannels( summarySbn.getPackageName(), summarySbn.getUid())); notificationRecord.getChannel()); summaries.put(pkg, summarySbn.getKey()); } } Loading Loading @@ -3211,8 +3210,7 @@ public class NotificationManagerService extends SystemService { final StatusBarNotification n = new StatusBarNotification( pkg, opPkg, id, tag, notificationUid, callingPid, notification, user, null, System.currentTimeMillis()); final NotificationRecord r = new NotificationRecord(getContext(), n, channel, mRankingHelper.supportsChannels(pkg, notificationUid)); final NotificationRecord r = new NotificationRecord(getContext(), n, channel); if (!checkDisqualifyingFeatures(userId, notificationUid, id,tag, r)) { return; Loading services/core/java/com/android/server/notification/NotificationRecord.java +25 −9 Original line number Diff line number Diff line Loading @@ -116,7 +116,7 @@ public final class NotificationRecord { private int mSuppressedVisualEffects = 0; private String mUserExplanation; private String mPeopleExplanation; private boolean mSupportsChannels = false; private boolean mPreChannelsNotification = true; private Uri mSound; private long[] mVibration; private AudioAttributes mAttributes; Loading @@ -129,7 +129,7 @@ public final class NotificationRecord { @VisibleForTesting public NotificationRecord(Context context, StatusBarNotification sbn, NotificationChannel channel, boolean supportsChannels) NotificationChannel channel) { this.sbn = sbn; mOriginalFlags = sbn.getNotification().flags; Loading @@ -139,7 +139,7 @@ public final class NotificationRecord { mContext = context; stats = new NotificationUsageStats.SingleNotificationStats(); mChannel = channel; mSupportsChannels = supportsChannels; mPreChannelsNotification = isPreChannelsNotification(); mSound = calculateSound(); mVibration = calculateVibration(); mAttributes = calculateAttributes(); Loading @@ -147,11 +147,27 @@ public final class NotificationRecord { mLight = calculateLights(); } private boolean isPreChannelsNotification() { try { if (NotificationChannel.DEFAULT_CHANNEL_ID.equals(getChannel().getId())) { final ApplicationInfo applicationInfo = mContext.getPackageManager().getApplicationInfoAsUser(sbn.getPackageName(), 0, UserHandle.getUserId(sbn.getUid())); if (applicationInfo.targetSdkVersion <= Build.VERSION_CODES.N_MR1) { return true; } } } catch (NameNotFoundException e) { Slog.e(TAG, "Can't find package", e); } return false; } private Uri calculateSound() { final Notification n = sbn.getNotification(); Uri sound = mChannel.getSound(); if (!mSupportsChannels && (getChannel().getUserLockedFields() if (mPreChannelsNotification && (getChannel().getUserLockedFields() & NotificationChannel.USER_LOCKED_SOUND) == 0) { final boolean useDefaultSound = (n.defaults & Notification.DEFAULT_SOUND) != 0; Loading @@ -176,7 +192,7 @@ public final class NotificationRecord { : defaultLightColor; Light light = getChannel().shouldShowLights() ? new Light(channelLightColor, defaultLightOn, defaultLightOff) : null; if (!mSupportsChannels if (mPreChannelsNotification && (getChannel().getUserLockedFields() & NotificationChannel.USER_LOCKED_LIGHTS) == 0) { final Notification notification = sbn.getNotification(); Loading Loading @@ -207,7 +223,7 @@ public final class NotificationRecord { } else { vibration = null; } if (!mSupportsChannels if (mPreChannelsNotification && (getChannel().getUserLockedFields() & NotificationChannel.USER_LOCKED_VIBRATION) == 0) { final Notification notification = sbn.getNotification(); Loading @@ -229,7 +245,7 @@ public final class NotificationRecord { attributes = Notification.AUDIO_ATTRIBUTES_DEFAULT; } if (!mSupportsChannels if (mPreChannelsNotification && (getChannel().getUserLockedFields() & NotificationChannel.USER_LOCKED_SOUND) == 0) { if (n.audioAttributes != null) { Loading Loading @@ -278,7 +294,7 @@ public final class NotificationRecord { stats.requestedImportance = requestedImportance; stats.isNoisy = mSound != null || mVibration != null; if (!mSupportsChannels if (mPreChannelsNotification && (importance == IMPORTANCE_UNSPECIFIED || (getChannel().getUserLockedFields() & NotificationChannel.USER_LOCKED_IMPORTANCE) == 0)) { Loading Loading @@ -445,7 +461,7 @@ public final class NotificationRecord { pw.println(prefix + "mVisibleSinceMs=" + mVisibleSinceMs); pw.println(prefix + "mUpdateTimeMs=" + mUpdateTimeMs); pw.println(prefix + "mSuppressedVisualEffects= " + mSuppressedVisualEffects); if (!mSupportsChannels) { if (mPreChannelsNotification) { pw.println(prefix + String.format("defaults=0x%08x flags=0x%08x", notification.defaults, notification.flags)); pw.println(prefix + "n.sound=" + notification.sound); Loading services/core/java/com/android/server/notification/RankingConfig.java +0 −2 Original line number Diff line number Diff line Loading @@ -42,6 +42,4 @@ public interface RankingConfig { void permanentlyDeleteNotificationChannel(String pkg, int uid, String channelId); void permanentlyDeleteNotificationChannels(String pkg, int uid); ParceledListSlice<NotificationChannel> getNotificationChannels(String pkg, int uid, boolean includeDeleted); boolean supportsChannels(String pkg, int uid); } services/core/java/com/android/server/notification/RankingHelper.java +8 −39 Original line number Diff line number Diff line Loading @@ -273,14 +273,8 @@ public class RankingHelper implements RankingConfig { } private boolean shouldHaveDefaultChannel(Record r) throws NameNotFoundException { if (supportsChannels(r)) { return false; } final int userId = UserHandle.getUserId(r.uid); final ApplicationInfo applicationInfo = mPm.getApplicationInfoAsUser(r.pkg, PackageManager.MATCH_DIRECT_BOOT_AWARE | PackageManager.MATCH_DIRECT_BOOT_UNAWARE, userId); final ApplicationInfo applicationInfo = mPm.getApplicationInfoAsUser(r.pkg, 0, userId); if (applicationInfo.targetSdkVersion > Build.VERSION_CODES.N_MR1) { // O apps should not have the default channel. return false; Loading Loading @@ -505,31 +499,6 @@ public class RankingHelper implements RankingConfig { return getOrCreateRecord(pkg, uid).visibility; } @Override public boolean supportsChannels(String pkg, int uid) { Record r = getOrCreateRecord(pkg, uid); if (r == null) { return false; } if (r.channels.size() == 1 && r.channels.containsKey(NotificationChannel.DEFAULT_CHANNEL_ID)) { return false; } return true; } private boolean supportsChannels(Record r) { if (r.channels.size() == 1 && r.channels.containsKey(NotificationChannel.DEFAULT_CHANNEL_ID)) { return false; } return (r.channels.size() > 0); } @Override public void createNotificationChannelGroup(String pkg, int uid, NotificationChannelGroup group, boolean fromTargetApp) { Loading Loading @@ -602,10 +571,6 @@ public class RankingHelper implements RankingConfig { r.channels.put(channel.getId(), channel); MetricsLogger.action(getChannelLog(channel, pkg).setType( MetricsProto.MetricsEvent.TYPE_OPEN)); // Remove Default Channel. r.channels.remove(NotificationChannel.DEFAULT_CHANNEL_ID); updateConfig(); } Loading Loading @@ -702,7 +667,13 @@ public class RankingHelper implements RankingConfig { if (r == null) { return; } r.channels.clear(); int N = r.channels.size() - 1; for (int i = N; i >= 0; i--) { String key = r.channels.keyAt(i); if (!NotificationChannel.DEFAULT_CHANNEL_ID.equals(key)) { r.channels.remove(key); } } updateConfig(); } Loading Loading @@ -1066,8 +1037,6 @@ public class RankingHelper implements RankingConfig { final int uid = uidList[i]; synchronized (mRecords) { mRecords.remove(recordKey(pkg, uid)); // reset to default settings and re-add misc channel for pre-O apps getOrCreateRecord(pkg, uid); } mRestoredWithoutUids.remove(pkg); updated = true; Loading services/tests/notification/src/com/android/server/notification/BadgeExtractorTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ public class BadgeExtractorTest { Notification n = builder.build(); StatusBarNotification sbn = new StatusBarNotification(mPkg, mPkg, mId, mTag, mUid, mPid, n, mUser, null, System.currentTimeMillis()); NotificationRecord r = new NotificationRecord(getContext(), sbn, channel, true); NotificationRecord r = new NotificationRecord(getContext(), sbn, channel); return r; } Loading Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +2 −4 Original line number Diff line number Diff line Loading @@ -2871,8 +2871,7 @@ public class NotificationManagerService extends SystemService { adjustedSbn.getUser(), GroupHelper.AUTOGROUP_KEY, System.currentTimeMillis()); summaryRecord = new NotificationRecord(getContext(), summarySbn, notificationRecord.getChannel(), mRankingHelper.supportsChannels( summarySbn.getPackageName(), summarySbn.getUid())); notificationRecord.getChannel()); summaries.put(pkg, summarySbn.getKey()); } } Loading Loading @@ -3211,8 +3210,7 @@ public class NotificationManagerService extends SystemService { final StatusBarNotification n = new StatusBarNotification( pkg, opPkg, id, tag, notificationUid, callingPid, notification, user, null, System.currentTimeMillis()); final NotificationRecord r = new NotificationRecord(getContext(), n, channel, mRankingHelper.supportsChannels(pkg, notificationUid)); final NotificationRecord r = new NotificationRecord(getContext(), n, channel); if (!checkDisqualifyingFeatures(userId, notificationUid, id,tag, r)) { return; Loading
services/core/java/com/android/server/notification/NotificationRecord.java +25 −9 Original line number Diff line number Diff line Loading @@ -116,7 +116,7 @@ public final class NotificationRecord { private int mSuppressedVisualEffects = 0; private String mUserExplanation; private String mPeopleExplanation; private boolean mSupportsChannels = false; private boolean mPreChannelsNotification = true; private Uri mSound; private long[] mVibration; private AudioAttributes mAttributes; Loading @@ -129,7 +129,7 @@ public final class NotificationRecord { @VisibleForTesting public NotificationRecord(Context context, StatusBarNotification sbn, NotificationChannel channel, boolean supportsChannels) NotificationChannel channel) { this.sbn = sbn; mOriginalFlags = sbn.getNotification().flags; Loading @@ -139,7 +139,7 @@ public final class NotificationRecord { mContext = context; stats = new NotificationUsageStats.SingleNotificationStats(); mChannel = channel; mSupportsChannels = supportsChannels; mPreChannelsNotification = isPreChannelsNotification(); mSound = calculateSound(); mVibration = calculateVibration(); mAttributes = calculateAttributes(); Loading @@ -147,11 +147,27 @@ public final class NotificationRecord { mLight = calculateLights(); } private boolean isPreChannelsNotification() { try { if (NotificationChannel.DEFAULT_CHANNEL_ID.equals(getChannel().getId())) { final ApplicationInfo applicationInfo = mContext.getPackageManager().getApplicationInfoAsUser(sbn.getPackageName(), 0, UserHandle.getUserId(sbn.getUid())); if (applicationInfo.targetSdkVersion <= Build.VERSION_CODES.N_MR1) { return true; } } } catch (NameNotFoundException e) { Slog.e(TAG, "Can't find package", e); } return false; } private Uri calculateSound() { final Notification n = sbn.getNotification(); Uri sound = mChannel.getSound(); if (!mSupportsChannels && (getChannel().getUserLockedFields() if (mPreChannelsNotification && (getChannel().getUserLockedFields() & NotificationChannel.USER_LOCKED_SOUND) == 0) { final boolean useDefaultSound = (n.defaults & Notification.DEFAULT_SOUND) != 0; Loading @@ -176,7 +192,7 @@ public final class NotificationRecord { : defaultLightColor; Light light = getChannel().shouldShowLights() ? new Light(channelLightColor, defaultLightOn, defaultLightOff) : null; if (!mSupportsChannels if (mPreChannelsNotification && (getChannel().getUserLockedFields() & NotificationChannel.USER_LOCKED_LIGHTS) == 0) { final Notification notification = sbn.getNotification(); Loading Loading @@ -207,7 +223,7 @@ public final class NotificationRecord { } else { vibration = null; } if (!mSupportsChannels if (mPreChannelsNotification && (getChannel().getUserLockedFields() & NotificationChannel.USER_LOCKED_VIBRATION) == 0) { final Notification notification = sbn.getNotification(); Loading @@ -229,7 +245,7 @@ public final class NotificationRecord { attributes = Notification.AUDIO_ATTRIBUTES_DEFAULT; } if (!mSupportsChannels if (mPreChannelsNotification && (getChannel().getUserLockedFields() & NotificationChannel.USER_LOCKED_SOUND) == 0) { if (n.audioAttributes != null) { Loading Loading @@ -278,7 +294,7 @@ public final class NotificationRecord { stats.requestedImportance = requestedImportance; stats.isNoisy = mSound != null || mVibration != null; if (!mSupportsChannels if (mPreChannelsNotification && (importance == IMPORTANCE_UNSPECIFIED || (getChannel().getUserLockedFields() & NotificationChannel.USER_LOCKED_IMPORTANCE) == 0)) { Loading Loading @@ -445,7 +461,7 @@ public final class NotificationRecord { pw.println(prefix + "mVisibleSinceMs=" + mVisibleSinceMs); pw.println(prefix + "mUpdateTimeMs=" + mUpdateTimeMs); pw.println(prefix + "mSuppressedVisualEffects= " + mSuppressedVisualEffects); if (!mSupportsChannels) { if (mPreChannelsNotification) { pw.println(prefix + String.format("defaults=0x%08x flags=0x%08x", notification.defaults, notification.flags)); pw.println(prefix + "n.sound=" + notification.sound); Loading
services/core/java/com/android/server/notification/RankingConfig.java +0 −2 Original line number Diff line number Diff line Loading @@ -42,6 +42,4 @@ public interface RankingConfig { void permanentlyDeleteNotificationChannel(String pkg, int uid, String channelId); void permanentlyDeleteNotificationChannels(String pkg, int uid); ParceledListSlice<NotificationChannel> getNotificationChannels(String pkg, int uid, boolean includeDeleted); boolean supportsChannels(String pkg, int uid); }
services/core/java/com/android/server/notification/RankingHelper.java +8 −39 Original line number Diff line number Diff line Loading @@ -273,14 +273,8 @@ public class RankingHelper implements RankingConfig { } private boolean shouldHaveDefaultChannel(Record r) throws NameNotFoundException { if (supportsChannels(r)) { return false; } final int userId = UserHandle.getUserId(r.uid); final ApplicationInfo applicationInfo = mPm.getApplicationInfoAsUser(r.pkg, PackageManager.MATCH_DIRECT_BOOT_AWARE | PackageManager.MATCH_DIRECT_BOOT_UNAWARE, userId); final ApplicationInfo applicationInfo = mPm.getApplicationInfoAsUser(r.pkg, 0, userId); if (applicationInfo.targetSdkVersion > Build.VERSION_CODES.N_MR1) { // O apps should not have the default channel. return false; Loading Loading @@ -505,31 +499,6 @@ public class RankingHelper implements RankingConfig { return getOrCreateRecord(pkg, uid).visibility; } @Override public boolean supportsChannels(String pkg, int uid) { Record r = getOrCreateRecord(pkg, uid); if (r == null) { return false; } if (r.channels.size() == 1 && r.channels.containsKey(NotificationChannel.DEFAULT_CHANNEL_ID)) { return false; } return true; } private boolean supportsChannels(Record r) { if (r.channels.size() == 1 && r.channels.containsKey(NotificationChannel.DEFAULT_CHANNEL_ID)) { return false; } return (r.channels.size() > 0); } @Override public void createNotificationChannelGroup(String pkg, int uid, NotificationChannelGroup group, boolean fromTargetApp) { Loading Loading @@ -602,10 +571,6 @@ public class RankingHelper implements RankingConfig { r.channels.put(channel.getId(), channel); MetricsLogger.action(getChannelLog(channel, pkg).setType( MetricsProto.MetricsEvent.TYPE_OPEN)); // Remove Default Channel. r.channels.remove(NotificationChannel.DEFAULT_CHANNEL_ID); updateConfig(); } Loading Loading @@ -702,7 +667,13 @@ public class RankingHelper implements RankingConfig { if (r == null) { return; } r.channels.clear(); int N = r.channels.size() - 1; for (int i = N; i >= 0; i--) { String key = r.channels.keyAt(i); if (!NotificationChannel.DEFAULT_CHANNEL_ID.equals(key)) { r.channels.remove(key); } } updateConfig(); } Loading Loading @@ -1066,8 +1037,6 @@ public class RankingHelper implements RankingConfig { final int uid = uidList[i]; synchronized (mRecords) { mRecords.remove(recordKey(pkg, uid)); // reset to default settings and re-add misc channel for pre-O apps getOrCreateRecord(pkg, uid); } mRestoredWithoutUids.remove(pkg); updated = true; Loading
services/tests/notification/src/com/android/server/notification/BadgeExtractorTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ public class BadgeExtractorTest { Notification n = builder.build(); StatusBarNotification sbn = new StatusBarNotification(mPkg, mPkg, mId, mTag, mUid, mPid, n, mUser, null, System.currentTimeMillis()); NotificationRecord r = new NotificationRecord(getContext(), sbn, channel, true); NotificationRecord r = new NotificationRecord(getContext(), sbn, channel); return r; } Loading