Loading core/java/android/service/notification/NotificationListenerService.java +3 −2 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ import com.android.internal.os.SomeArgs; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Objects; Loading Loading @@ -1802,7 +1803,7 @@ public abstract class NotificationListenerService extends Service { * {@link NotificationAssistantService} */ public @NonNull List<Notification.Action> getSmartActions() { return mSmartActions; return mSmartActions == null ? Collections.emptyList() : mSmartActions; } /** Loading @@ -1810,7 +1811,7 @@ public abstract class NotificationListenerService extends Service { * {@link NotificationAssistantService} */ public @NonNull List<CharSequence> getSmartReplies() { return mSmartReplies; return mSmartReplies == null ? Collections.emptyList() : mSmartReplies; } /** Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java +2 −2 Original line number Diff line number Diff line Loading @@ -329,11 +329,11 @@ public final class NotificationEntry extends ListEntry { return mRanking.canBubble(); } public @Nullable List<Notification.Action> getSmartActions() { public @NonNull List<Notification.Action> getSmartActions() { return mRanking.getSmartActions(); } public @Nullable List<CharSequence> getSmartReplies() { public @NonNull List<CharSequence> getSmartReplies() { return mRanking.getSmartReplies(); } Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartRepliesAndActionsInflater.kt +23 −26 Original line number Diff line number Diff line Loading @@ -204,31 +204,28 @@ interface SmartRepliesAndActionsInflater { } // Apps didn't provide any smart replies / actions, use those from NAS (if any). if (smartReplies == null && smartActions == null) { smartReplies = entry.smartReplies ?.takeIf { it.isNotEmpty() } ?.let { entryReplies -> freeformRemoteInputActionPair ?.takeIf { it.second.allowGeneratedReplies && it.second.actionIntent != null }?.let { freeformPair -> SmartReplies( val entryReplies = entry.smartReplies val entryActions = entry.smartActions if (entryReplies.isNotEmpty() && freeformRemoteInputActionPair != null && freeformRemoteInputActionPair.second.allowGeneratedReplies && freeformRemoteInputActionPair.second.actionIntent != null) { smartReplies = SmartReplies( entryReplies, freeformPair.first, freeformPair.second.actionIntent, freeformRemoteInputActionPair.first, freeformRemoteInputActionPair.second.actionIntent, true /* fromAssistant */) } } smartActions = entry.smartActions ?.takeIf { it.isNotEmpty() && notification.allowSystemGeneratedContextualActions }?.let { entryActions -> if (entryActions.isNotEmpty() && notification.allowSystemGeneratedContextualActions) { val systemGeneratedActions: List<Notification.Action> = when { activityManagerWrapper.isLockTaskKioskModeActive -> // Filter actions if we're in kiosk-mode - we don't care about // screen pinning mode, since notifications aren't shown there // anyway. // Filter actions if we're in kiosk-mode - we don't care about screen // pinning mode, since notifications aren't shown there anyway. filterAllowlistedLockTaskApps(entryActions) else -> entryActions } SmartActions(systemGeneratedActions, true /* fromAssistant */) smartActions = SmartActions(systemGeneratedActions, true /* fromAssistant */) } } return SmartRepliesAndActions(smartReplies, smartActions) Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java +3 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import static android.service.notification.NotificationListenerService.REASON_CA import static com.android.systemui.statusbar.notification.NotificationEntryManager.UNDEFINED_DISMISS_REASON; import static com.google.common.truth.Truth.assertThat; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertNull; import static junit.framework.Assert.assertTrue; Loading Loading @@ -346,7 +348,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase { setSmartActions(mEntry.getKey(), null); mEntryManager.updateNotificationRanking(mRankingMap); assertNull(mEntry.getSmartActions()); assertThat(mEntry.getSmartActions()).isEmpty(); } @Test Loading Loading
core/java/android/service/notification/NotificationListenerService.java +3 −2 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ import com.android.internal.os.SomeArgs; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Objects; Loading Loading @@ -1802,7 +1803,7 @@ public abstract class NotificationListenerService extends Service { * {@link NotificationAssistantService} */ public @NonNull List<Notification.Action> getSmartActions() { return mSmartActions; return mSmartActions == null ? Collections.emptyList() : mSmartActions; } /** Loading @@ -1810,7 +1811,7 @@ public abstract class NotificationListenerService extends Service { * {@link NotificationAssistantService} */ public @NonNull List<CharSequence> getSmartReplies() { return mSmartReplies; return mSmartReplies == null ? Collections.emptyList() : mSmartReplies; } /** Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java +2 −2 Original line number Diff line number Diff line Loading @@ -329,11 +329,11 @@ public final class NotificationEntry extends ListEntry { return mRanking.canBubble(); } public @Nullable List<Notification.Action> getSmartActions() { public @NonNull List<Notification.Action> getSmartActions() { return mRanking.getSmartActions(); } public @Nullable List<CharSequence> getSmartReplies() { public @NonNull List<CharSequence> getSmartReplies() { return mRanking.getSmartReplies(); } Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartRepliesAndActionsInflater.kt +23 −26 Original line number Diff line number Diff line Loading @@ -204,31 +204,28 @@ interface SmartRepliesAndActionsInflater { } // Apps didn't provide any smart replies / actions, use those from NAS (if any). if (smartReplies == null && smartActions == null) { smartReplies = entry.smartReplies ?.takeIf { it.isNotEmpty() } ?.let { entryReplies -> freeformRemoteInputActionPair ?.takeIf { it.second.allowGeneratedReplies && it.second.actionIntent != null }?.let { freeformPair -> SmartReplies( val entryReplies = entry.smartReplies val entryActions = entry.smartActions if (entryReplies.isNotEmpty() && freeformRemoteInputActionPair != null && freeformRemoteInputActionPair.second.allowGeneratedReplies && freeformRemoteInputActionPair.second.actionIntent != null) { smartReplies = SmartReplies( entryReplies, freeformPair.first, freeformPair.second.actionIntent, freeformRemoteInputActionPair.first, freeformRemoteInputActionPair.second.actionIntent, true /* fromAssistant */) } } smartActions = entry.smartActions ?.takeIf { it.isNotEmpty() && notification.allowSystemGeneratedContextualActions }?.let { entryActions -> if (entryActions.isNotEmpty() && notification.allowSystemGeneratedContextualActions) { val systemGeneratedActions: List<Notification.Action> = when { activityManagerWrapper.isLockTaskKioskModeActive -> // Filter actions if we're in kiosk-mode - we don't care about // screen pinning mode, since notifications aren't shown there // anyway. // Filter actions if we're in kiosk-mode - we don't care about screen // pinning mode, since notifications aren't shown there anyway. filterAllowlistedLockTaskApps(entryActions) else -> entryActions } SmartActions(systemGeneratedActions, true /* fromAssistant */) smartActions = SmartActions(systemGeneratedActions, true /* fromAssistant */) } } return SmartRepliesAndActions(smartReplies, smartActions) Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java +3 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import static android.service.notification.NotificationListenerService.REASON_CA import static com.android.systemui.statusbar.notification.NotificationEntryManager.UNDEFINED_DISMISS_REASON; import static com.google.common.truth.Truth.assertThat; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertNull; import static junit.framework.Assert.assertTrue; Loading Loading @@ -346,7 +348,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase { setSmartActions(mEntry.getKey(), null); mEntryManager.updateNotificationRanking(mRankingMap); assertNull(mEntry.getSmartActions()); assertThat(mEntry.getSmartActions()).isEmpty(); } @Test Loading