Loading core/java/android/service/notification/Adjustment.java +1 −1 Original line number Diff line number Diff line Loading @@ -225,7 +225,7 @@ public final class Adjustment implements Parcelable { public static final int TYPE_CONTENT_RECOMMENDATION = 4; /** * Data type: String, a summarization of the text of the notification, or, if provided for * Data type: CharSequence, a summarization of the text of the notification, or, if provided for * a group summary, a summarization of the text of all of the notificatrions in the group. * Send this key with a null value to remove an existing summarization. */ Loading services/core/java/com/android/server/notification/NotificationRecord.java +7 −1 Original line number Diff line number Diff line Loading @@ -817,7 +817,13 @@ public final class NotificationRecord { } if ((android.app.Flags.nmSummarizationUi() || android.app.Flags.nmSummarization()) && signals.containsKey(KEY_SUMMARIZATION)) { mSummarization = signals.getString(KEY_SUMMARIZATION); CharSequence summary = signals.getCharSequence(KEY_SUMMARIZATION, signals.getString(KEY_SUMMARIZATION)); if (summary != null) { mSummarization = summary.toString(); } else { mSummarization = null; } EventLogTags.writeNotificationAdjusted(getKey(), KEY_SUMMARIZATION, Boolean.toString(mSummarization != null)); } Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationRecordTest.java +59 −0 Original line number Diff line number Diff line Loading @@ -1008,6 +1008,65 @@ public class NotificationRecordTest extends UiServiceTestCase { assertFalse(record.getIsAppImportanceLocked()); } @Test @EnableFlags(Flags.FLAG_NM_SUMMARIZATION) public void testSummarization_null() { StatusBarNotification sbn = getNotification(PKG_O, true /* noisy */, true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */, false /* lights */, false /* defaultLights */, groupId /* group */); NotificationRecord record = new NotificationRecord(mMockContext, sbn, channel); assertThat(record.getSummarization()).isNull(); Bundle signals = new Bundle(); signals.putCharSequence(Adjustment.KEY_SUMMARIZATION, null); record.addAdjustment(new Adjustment(mPkg, record.getKey(), signals, null, sbn.getUserId())); record.applyAdjustments(); assertThat(record.getSummarization()).isNull(); } @Test @EnableFlags(Flags.FLAG_NM_SUMMARIZATION) public void testSummarization_charSequence() { CharSequence summary = "hello"; StatusBarNotification sbn = getNotification(PKG_O, true /* noisy */, true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */, false /* lights */, false /* defaultLights */, groupId /* group */); NotificationRecord record = new NotificationRecord(mMockContext, sbn, channel); assertThat(record.getSummarization()).isNull(); Bundle signals = new Bundle(); signals.putCharSequence(Adjustment.KEY_SUMMARIZATION, summary); record.addAdjustment(new Adjustment(mPkg, record.getKey(), signals, null, sbn.getUserId())); record.applyAdjustments(); assertThat(record.getSummarization()).isEqualTo(summary.toString()); } @Test @EnableFlags(Flags.FLAG_NM_SUMMARIZATION) public void testSummarization_string() { String summary = "hello"; StatusBarNotification sbn = getNotification(PKG_O, true /* noisy */, true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */, false /* lights */, false /* defaultLights */, groupId /* group */); NotificationRecord record = new NotificationRecord(mMockContext, sbn, channel); assertThat(record.getSummarization()).isNull(); Bundle signals = new Bundle(); signals.putCharSequence(Adjustment.KEY_SUMMARIZATION, summary); record.addAdjustment(new Adjustment(mPkg, record.getKey(), signals, null, sbn.getUserId())); record.applyAdjustments(); assertThat(record.getSummarization()).isEqualTo(summary); } @Test public void testSensitiveContent() { StatusBarNotification sbn = getNotification(PKG_O, true /* noisy */, Loading Loading
core/java/android/service/notification/Adjustment.java +1 −1 Original line number Diff line number Diff line Loading @@ -225,7 +225,7 @@ public final class Adjustment implements Parcelable { public static final int TYPE_CONTENT_RECOMMENDATION = 4; /** * Data type: String, a summarization of the text of the notification, or, if provided for * Data type: CharSequence, a summarization of the text of the notification, or, if provided for * a group summary, a summarization of the text of all of the notificatrions in the group. * Send this key with a null value to remove an existing summarization. */ Loading
services/core/java/com/android/server/notification/NotificationRecord.java +7 −1 Original line number Diff line number Diff line Loading @@ -817,7 +817,13 @@ public final class NotificationRecord { } if ((android.app.Flags.nmSummarizationUi() || android.app.Flags.nmSummarization()) && signals.containsKey(KEY_SUMMARIZATION)) { mSummarization = signals.getString(KEY_SUMMARIZATION); CharSequence summary = signals.getCharSequence(KEY_SUMMARIZATION, signals.getString(KEY_SUMMARIZATION)); if (summary != null) { mSummarization = summary.toString(); } else { mSummarization = null; } EventLogTags.writeNotificationAdjusted(getKey(), KEY_SUMMARIZATION, Boolean.toString(mSummarization != null)); } Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationRecordTest.java +59 −0 Original line number Diff line number Diff line Loading @@ -1008,6 +1008,65 @@ public class NotificationRecordTest extends UiServiceTestCase { assertFalse(record.getIsAppImportanceLocked()); } @Test @EnableFlags(Flags.FLAG_NM_SUMMARIZATION) public void testSummarization_null() { StatusBarNotification sbn = getNotification(PKG_O, true /* noisy */, true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */, false /* lights */, false /* defaultLights */, groupId /* group */); NotificationRecord record = new NotificationRecord(mMockContext, sbn, channel); assertThat(record.getSummarization()).isNull(); Bundle signals = new Bundle(); signals.putCharSequence(Adjustment.KEY_SUMMARIZATION, null); record.addAdjustment(new Adjustment(mPkg, record.getKey(), signals, null, sbn.getUserId())); record.applyAdjustments(); assertThat(record.getSummarization()).isNull(); } @Test @EnableFlags(Flags.FLAG_NM_SUMMARIZATION) public void testSummarization_charSequence() { CharSequence summary = "hello"; StatusBarNotification sbn = getNotification(PKG_O, true /* noisy */, true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */, false /* lights */, false /* defaultLights */, groupId /* group */); NotificationRecord record = new NotificationRecord(mMockContext, sbn, channel); assertThat(record.getSummarization()).isNull(); Bundle signals = new Bundle(); signals.putCharSequence(Adjustment.KEY_SUMMARIZATION, summary); record.addAdjustment(new Adjustment(mPkg, record.getKey(), signals, null, sbn.getUserId())); record.applyAdjustments(); assertThat(record.getSummarization()).isEqualTo(summary.toString()); } @Test @EnableFlags(Flags.FLAG_NM_SUMMARIZATION) public void testSummarization_string() { String summary = "hello"; StatusBarNotification sbn = getNotification(PKG_O, true /* noisy */, true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */, false /* lights */, false /* defaultLights */, groupId /* group */); NotificationRecord record = new NotificationRecord(mMockContext, sbn, channel); assertThat(record.getSummarization()).isNull(); Bundle signals = new Bundle(); signals.putCharSequence(Adjustment.KEY_SUMMARIZATION, summary); record.addAdjustment(new Adjustment(mPkg, record.getKey(), signals, null, sbn.getUserId())); record.applyAdjustments(); assertThat(record.getSummarization()).isEqualTo(summary); } @Test public void testSensitiveContent() { StatusBarNotification sbn = getNotification(PKG_O, true /* noisy */, Loading