Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f856447c authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Add API for NAS to tell us it doesn't support some adjustments" into main

parents 1357cebe 0bd3685b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -13046,6 +13046,7 @@ package android.service.notification {
    method public void onPanelHidden();
    method public void onPanelRevealed(int);
    method public void onSuggestedReplySent(@NonNull String, @NonNull CharSequence, int);
    method @FlaggedApi("android.service.notification.notification_classification") public final void setAdjustmentTypeSupportedState(@NonNull String, boolean);
    method public final void unsnoozeNotification(@NonNull String);
    field public static final String ACTION_NOTIFICATION_ASSISTANT_DETAIL_SETTINGS = "android.service.notification.action.NOTIFICATION_ASSISTANT_DETAIL_SETTINGS";
    field @FlaggedApi("android.service.notification.notification_classification") public static final String ACTION_NOTIFICATION_ASSISTANT_FEEDBACK_SETTINGS = "android.service.notification.action.NOTIFICATION_ASSISTANT_FEEDBACK_SETTINGS";
+1 −0
Original line number Diff line number Diff line
@@ -396,6 +396,7 @@ package android.app {
    method public void cleanUpCallersAfter(long);
    method @FlaggedApi("android.app.modes_api") @NonNull public android.service.notification.ZenPolicy getDefaultZenPolicy();
    method public android.content.ComponentName getEffectsSuppressor();
    method @FlaggedApi("android.service.notification.notification_classification") @NonNull public java.util.Set<java.lang.String> getUnsupportedAdjustmentTypes();
    method public boolean isNotificationPolicyAccessGrantedForPackage(@NonNull String);
    method @FlaggedApi("android.app.modes_api") public boolean removeAutomaticZenRule(@NonNull String, boolean);
    method @FlaggedApi("android.app.api_rich_ongoing") public void setCanPostPromotedNotifications(@NonNull String, int, boolean);
+4 −1
Original line number Diff line number Diff line
@@ -160,8 +160,8 @@ interface INotificationManager
    void requestBindProvider(in ComponentName component);
    void requestUnbindProvider(in IConditionProvider token);

    void setNotificationsShownFromListener(in INotificationListener token, in String[] keys);

    void setNotificationsShownFromListener(in INotificationListener token, in String[] keys);
    ParceledListSlice getActiveNotificationsFromListener(in INotificationListener token, in String[] keys, int trim);
    ParceledListSlice getSnoozedNotificationsFromListener(in INotificationListener token, int trim);
    void clearRequestedListenerHints(in INotificationListener token);
@@ -261,4 +261,7 @@ interface INotificationManager
    void setCanBePromoted(String pkg, int uid, boolean promote, boolean fromUser);
    boolean appCanBePromoted(String pkg, int uid);
    boolean canBePromoted(String pkg);

    void setAdjustmentTypeSupportedState(in INotificationListener token, String key, boolean supported);
    List<String> getUnsupportedAdjustmentTypes();
}
+17 −0
Original line number Diff line number Diff line
@@ -68,9 +68,11 @@ import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.Executor;

/**
@@ -3094,4 +3096,19 @@ public class NotificationManager {
        }
    }

    /**
     * Returns the list of {@link Adjustment} keys that the current approved
     * {@link android.service.notification.NotificationAssistantService} does not support.
     * @hide
     */
    @TestApi
    @FlaggedApi(android.service.notification.Flags.FLAG_NOTIFICATION_CLASSIFICATION)
    public @NonNull Set<String> getUnsupportedAdjustmentTypes() {
        INotificationManager service = getService();
        try {
            return new HashSet<>(service.getUnsupportedAdjustmentTypes());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
}
+17 −0
Original line number Diff line number Diff line
@@ -393,6 +393,23 @@ public abstract class NotificationAssistantService extends NotificationListenerS
        }
    }

    /**
     * Informs the notification manager about what {@link Adjustment Adjustments} are supported by
     * this NAS.
     *
     * For backwards compatibility, we assume all Adjustment types are supported by the NAS.
     */
    @FlaggedApi(Flags.FLAG_NOTIFICATION_CLASSIFICATION)
    public final void setAdjustmentTypeSupportedState(@NonNull @Adjustment.Keys String key,
            boolean supported) {
        if (!isBound()) return;
        try {
            getNotificationInterface().setAdjustmentTypeSupportedState(mWrapper, key, supported);
        } catch (android.os.RemoteException ex) {
            Log.v(TAG, "Unable to contact notification manager", ex);
        }
    }

    private class NotificationAssistantServiceWrapper extends NotificationListenerWrapper {
        @Override
        public void onNotificationEnqueuedWithChannel(IStatusBarNotificationHolder sbnHolder,
Loading