Merge "Add @Nullable and @NonNull to new Notification API"
This commit is contained in:
committed by
Android (Google) Code Review
commit
10b6c6d10e
@@ -5786,7 +5786,7 @@ package android.app {
|
||||
method public boolean areBubblesAllowed();
|
||||
method public boolean areNotificationsEnabled();
|
||||
method public boolean areNotificationsPaused();
|
||||
method public boolean canNotifyAsPackage(String);
|
||||
method public boolean canNotifyAsPackage(@NonNull String);
|
||||
method public void cancel(int);
|
||||
method public void cancel(String, int);
|
||||
method public void cancelAll();
|
||||
@@ -5807,15 +5807,15 @@ package android.app {
|
||||
method public java.util.List<android.app.NotificationChannel> getNotificationChannels();
|
||||
method @Nullable public String getNotificationDelegate();
|
||||
method public android.app.NotificationManager.Policy getNotificationPolicy();
|
||||
method public boolean isNotificationAssistantAccessGranted(android.content.ComponentName);
|
||||
method public boolean isNotificationAssistantAccessGranted(@NonNull android.content.ComponentName);
|
||||
method public boolean isNotificationListenerAccessGranted(android.content.ComponentName);
|
||||
method public boolean isNotificationPolicyAccessGranted();
|
||||
method public void notify(int, android.app.Notification);
|
||||
method public void notify(String, int, android.app.Notification);
|
||||
method public void notifyAsPackage(@NonNull String, @NonNull String, int, android.app.Notification);
|
||||
method public void notifyAsPackage(@NonNull String, @NonNull String, int, @NonNull android.app.Notification);
|
||||
method public boolean removeAutomaticZenRule(String);
|
||||
method public void revokeNotificationDelegate();
|
||||
method public void setAutomaticZenRuleState(String, android.service.notification.Condition);
|
||||
method public void setAutomaticZenRuleState(@NonNull String, @NonNull android.service.notification.Condition);
|
||||
method public final void setInterruptionFilter(int);
|
||||
method public void setNotificationDelegate(@NonNull String);
|
||||
method public void setNotificationPolicy(@NonNull android.app.NotificationManager.Policy);
|
||||
@@ -41597,13 +41597,13 @@ package android.service.media {
|
||||
package android.service.notification {
|
||||
|
||||
public final class Adjustment implements android.os.Parcelable {
|
||||
ctor public Adjustment(String, String, android.os.Bundle, CharSequence, android.os.UserHandle);
|
||||
ctor public Adjustment(@NonNull String, @NonNull String, @NonNull android.os.Bundle, @NonNull CharSequence, @NonNull android.os.UserHandle);
|
||||
method public int describeContents();
|
||||
method public CharSequence getExplanation();
|
||||
method public String getKey();
|
||||
method public String getPackage();
|
||||
method public android.os.Bundle getSignals();
|
||||
method public android.os.UserHandle getUserHandle();
|
||||
method @NonNull public CharSequence getExplanation();
|
||||
method @NonNull public String getKey();
|
||||
method @NonNull public String getPackage();
|
||||
method @NonNull public android.os.Bundle getSignals();
|
||||
method @NonNull public android.os.UserHandle getUserHandle();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.service.notification.Adjustment> CREATOR;
|
||||
field public static final String KEY_CONTEXTUAL_ACTIONS = "key_contextual_actions";
|
||||
@@ -41661,17 +41661,17 @@ package android.service.notification {
|
||||
|
||||
public abstract class NotificationAssistantService extends android.service.notification.NotificationListenerService {
|
||||
ctor public NotificationAssistantService();
|
||||
method public final void adjustNotification(android.service.notification.Adjustment);
|
||||
method public final void adjustNotifications(java.util.List<android.service.notification.Adjustment>);
|
||||
method public final void adjustNotification(@NonNull android.service.notification.Adjustment);
|
||||
method public final void adjustNotifications(@NonNull java.util.List<android.service.notification.Adjustment>);
|
||||
method public void onActionInvoked(@NonNull String, @NonNull android.app.Notification.Action, int);
|
||||
method public final android.os.IBinder onBind(android.content.Intent);
|
||||
method @NonNull public final android.os.IBinder onBind(@Nullable android.content.Intent);
|
||||
method public void onNotificationDirectReplied(@NonNull String);
|
||||
method public abstract android.service.notification.Adjustment onNotificationEnqueued(android.service.notification.StatusBarNotification);
|
||||
method public android.service.notification.Adjustment onNotificationEnqueued(android.service.notification.StatusBarNotification, android.app.NotificationChannel);
|
||||
method @Nullable public android.service.notification.Adjustment onNotificationEnqueued(@NonNull android.service.notification.StatusBarNotification, @NonNull android.app.NotificationChannel);
|
||||
method public void onNotificationExpansionChanged(@NonNull String, boolean, boolean);
|
||||
method public void onNotificationRemoved(android.service.notification.StatusBarNotification, android.service.notification.NotificationListenerService.RankingMap, android.service.notification.NotificationStats, int);
|
||||
method public void onNotificationRemoved(@NonNull android.service.notification.StatusBarNotification, @NonNull android.service.notification.NotificationListenerService.RankingMap, @NonNull android.service.notification.NotificationStats, int);
|
||||
method public abstract void onNotificationSnoozedUntilContext(android.service.notification.StatusBarNotification, String);
|
||||
method public void onNotificationsSeen(java.util.List<java.lang.String>);
|
||||
method public void onNotificationsSeen(@NonNull java.util.List<java.lang.String>);
|
||||
method public void onSuggestedReplySent(@NonNull String, @NonNull CharSequence, int);
|
||||
method public final void unsnoozeNotification(String);
|
||||
field public static final String SERVICE_INTERFACE = "android.service.notification.NotificationAssistantService";
|
||||
@@ -41761,8 +41761,8 @@ package android.service.notification {
|
||||
method public long getLastAudiblyAlertedMillis();
|
||||
method public String getOverrideGroupKey();
|
||||
method public int getRank();
|
||||
method public java.util.List<android.app.Notification.Action> getSmartActions();
|
||||
method public java.util.List<java.lang.CharSequence> getSmartReplies();
|
||||
method @NonNull public java.util.List<android.app.Notification.Action> getSmartActions();
|
||||
method @NonNull public java.util.List<java.lang.CharSequence> getSmartReplies();
|
||||
method public int getSuppressedVisualEffects();
|
||||
method public int getUserSentiment();
|
||||
method public boolean isAmbient();
|
||||
|
||||
@@ -465,7 +465,7 @@ public class NotificationManager {
|
||||
* show the user. Must not be null.
|
||||
*/
|
||||
public void notifyAsPackage(@NonNull String targetPackage, @NonNull String tag, int id,
|
||||
Notification notification) {
|
||||
@NonNull Notification notification) {
|
||||
INotificationManager service = getService();
|
||||
String sender = mContext.getPackageName();
|
||||
|
||||
@@ -638,7 +638,7 @@ public class NotificationManager {
|
||||
*
|
||||
* See {@link #setNotificationDelegate(String)}.
|
||||
*/
|
||||
public boolean canNotifyAsPackage(String pkg) {
|
||||
public boolean canNotifyAsPackage(@NonNull String pkg) {
|
||||
INotificationManager service = getService();
|
||||
try {
|
||||
return service.canNotifyAsPackage(mContext.getPackageName(), pkg);
|
||||
@@ -1008,7 +1008,7 @@ public class NotificationManager {
|
||||
* @param id The id of the rule whose state should change
|
||||
* @param condition The new state of this rule
|
||||
*/
|
||||
public void setAutomaticZenRuleState(String id, Condition condition) {
|
||||
public void setAutomaticZenRuleState(@NonNull String id, @NonNull Condition condition) {
|
||||
INotificationManager service = getService();
|
||||
try {
|
||||
service.setAutomaticZenRuleState(id, condition);
|
||||
@@ -1169,7 +1169,7 @@ public class NotificationManager {
|
||||
* TODO: STOPSHIP: Add correct intent
|
||||
* {@link android.provider.Settings#ACTION_MANAGE_DEFAULT_APPS_SETTINGS}.
|
||||
*/
|
||||
public boolean isNotificationAssistantAccessGranted(ComponentName assistant) {
|
||||
public boolean isNotificationAssistantAccessGranted(@NonNull ComponentName assistant) {
|
||||
INotificationManager service = getService();
|
||||
try {
|
||||
return service.isNotificationAssistantAccessGranted(assistant);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package android.service.notification;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.SystemApi;
|
||||
import android.app.Notification;
|
||||
import android.os.Bundle;
|
||||
@@ -132,8 +133,9 @@ public final class Adjustment implements Parcelable {
|
||||
* @param explanation A human-readable justification for the adjustment.
|
||||
* @param userHandle User handle for for whose the adjustments will be applied.
|
||||
*/
|
||||
public Adjustment(String pkg, String key, Bundle signals, CharSequence explanation,
|
||||
UserHandle userHandle) {
|
||||
public Adjustment(@NonNull String pkg, @NonNull String key, @NonNull Bundle signals,
|
||||
@NonNull CharSequence explanation,
|
||||
@NonNull UserHandle userHandle) {
|
||||
mPackage = pkg;
|
||||
mKey = key;
|
||||
mSignals = signals;
|
||||
@@ -177,19 +179,19 @@ public final class Adjustment implements Parcelable {
|
||||
}
|
||||
};
|
||||
|
||||
public String getPackage() {
|
||||
public @NonNull String getPackage() {
|
||||
return mPackage;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
public @NonNull String getKey() {
|
||||
return mKey;
|
||||
}
|
||||
|
||||
public CharSequence getExplanation() {
|
||||
public @NonNull CharSequence getExplanation() {
|
||||
return mExplanation;
|
||||
}
|
||||
|
||||
public Bundle getSignals() {
|
||||
public @NonNull Bundle getSignals() {
|
||||
return mSignals;
|
||||
}
|
||||
|
||||
@@ -199,7 +201,7 @@ public final class Adjustment implements Parcelable {
|
||||
return mUser;
|
||||
}
|
||||
|
||||
public UserHandle getUserHandle() {
|
||||
public @NonNull UserHandle getUserHandle() {
|
||||
return UserHandle.of(mUser);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ import static java.lang.annotation.RetentionPolicy.SOURCE;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SdkConstant;
|
||||
import android.annotation.SystemApi;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
@@ -90,7 +90,7 @@ public abstract class NotificationAssistantService extends NotificationListenerS
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IBinder onBind(Intent intent) {
|
||||
public final @NonNull IBinder onBind(@Nullable Intent intent) {
|
||||
if (mWrapper == null) {
|
||||
mWrapper = new NotificationAssistantServiceWrapper();
|
||||
}
|
||||
@@ -126,8 +126,8 @@ public abstract class NotificationAssistantService extends NotificationListenerS
|
||||
* @param channel the channel the notification was posted to
|
||||
* @return an adjustment or null to take no action, within 100ms.
|
||||
*/
|
||||
public Adjustment onNotificationEnqueued(StatusBarNotification sbn,
|
||||
NotificationChannel channel) {
|
||||
public @Nullable Adjustment onNotificationEnqueued(@NonNull StatusBarNotification sbn,
|
||||
@NonNull NotificationChannel channel) {
|
||||
return onNotificationEnqueued(sbn);
|
||||
}
|
||||
|
||||
@@ -155,8 +155,9 @@ public abstract class NotificationAssistantService extends NotificationListenerS
|
||||
* @param reason see {@link #REASON_LISTENER_CANCEL}, etc.
|
||||
*/
|
||||
@Override
|
||||
public void onNotificationRemoved(StatusBarNotification sbn, RankingMap rankingMap,
|
||||
NotificationStats stats, int reason) {
|
||||
public void onNotificationRemoved(@NonNull StatusBarNotification sbn,
|
||||
@NonNull RankingMap rankingMap,
|
||||
@NonNull NotificationStats stats, int reason) {
|
||||
onNotificationRemoved(sbn, rankingMap, reason);
|
||||
}
|
||||
|
||||
@@ -164,7 +165,7 @@ public abstract class NotificationAssistantService extends NotificationListenerS
|
||||
* Implement this to know when a user has seen notifications, as triggered by
|
||||
* {@link #setNotificationsShown(String[])}.
|
||||
*/
|
||||
public void onNotificationsSeen(List<String> keys) {
|
||||
public void onNotificationsSeen(@NonNull List<String> keys) {
|
||||
|
||||
}
|
||||
|
||||
@@ -211,7 +212,7 @@ public abstract class NotificationAssistantService extends NotificationListenerS
|
||||
*
|
||||
* @param adjustment the adjustment with an explanation
|
||||
*/
|
||||
public final void adjustNotification(Adjustment adjustment) {
|
||||
public final void adjustNotification(@NonNull Adjustment adjustment) {
|
||||
if (!isBound()) return;
|
||||
try {
|
||||
getNotificationInterface().applyAdjustmentFromAssistant(mWrapper, adjustment);
|
||||
@@ -228,7 +229,7 @@ public abstract class NotificationAssistantService extends NotificationListenerS
|
||||
*
|
||||
* @param adjustments a list of adjustments with explanations
|
||||
*/
|
||||
public final void adjustNotifications(List<Adjustment> adjustments) {
|
||||
public final void adjustNotifications(@NonNull List<Adjustment> adjustments) {
|
||||
if (!isBound()) return;
|
||||
try {
|
||||
getNotificationInterface().applyAdjustmentsFromAssistant(mWrapper, adjustments);
|
||||
|
||||
@@ -1638,7 +1638,7 @@ public abstract class NotificationListenerService extends Service {
|
||||
* Returns a list of smart {@link Notification.Action} that can be added by the
|
||||
* {@link NotificationAssistantService}
|
||||
*/
|
||||
public List<Notification.Action> getSmartActions() {
|
||||
public @NonNull List<Notification.Action> getSmartActions() {
|
||||
return mSmartActions;
|
||||
}
|
||||
|
||||
@@ -1646,7 +1646,7 @@ public abstract class NotificationListenerService extends Service {
|
||||
* Returns a list of smart replies that can be added by the
|
||||
* {@link NotificationAssistantService}
|
||||
*/
|
||||
public List<CharSequence> getSmartReplies() {
|
||||
public @NonNull List<CharSequence> getSmartReplies() {
|
||||
return mSmartReplies;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user