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

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

Merge "Add the ability to turn off NAS capabilities individually"

parents 6be24edf ad6dd357
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -547,6 +547,7 @@ package android.app {
  }
  public class NotificationManager {
    method @NonNull public java.util.List<java.lang.String> getAllowedAssistantCapabilities();
    method @Nullable public android.content.ComponentName getAllowedNotificationAssistant();
    method public boolean isNotificationAssistantAccessGranted(@NonNull android.content.ComponentName);
    method public void setNotificationAssistantAccessGranted(@Nullable android.content.ComponentName, boolean);
@@ -6639,6 +6640,7 @@ package android.service.notification {
    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 @NonNull public final android.os.IBinder onBind(@Nullable android.content.Intent);
    method public void onCapabilitiesChanged();
    method public void onNotificationDirectReplied(@NonNull String);
    method @Nullable public abstract android.service.notification.Adjustment onNotificationEnqueued(@NonNull android.service.notification.StatusBarNotification);
    method @Nullable public android.service.notification.Adjustment onNotificationEnqueued(@NonNull android.service.notification.StatusBarNotification, @NonNull android.app.NotificationChannel);
+4 −0
Original line number Diff line number Diff line
@@ -70,6 +70,10 @@ interface INotificationManager
    boolean areNotificationsEnabled(String pkg);
    int getPackageImportance(String pkg);

    List<String> getAllowedAssistantCapabilities(String pkg);
    void allowAssistantCapability(String adjustmentType);
    void disallowAssistantCapability(String adjustmentType);

    boolean shouldHideSilentStatusIcons(String callingPkg);
    void setHideSilentStatusIcons(boolean hide);

+20 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import android.os.ServiceManager;
import android.os.StrictMode;
import android.os.UserHandle;
import android.provider.Settings.Global;
import android.service.notification.Adjustment;
import android.service.notification.Condition;
import android.service.notification.StatusBarNotification;
import android.service.notification.ZenModeConfig;
@@ -1182,6 +1183,25 @@ public class NotificationManager {
        }
    }

    /**
     * Returns the list of {@link android.service.notification.Adjustment adjustment keys} that can
     * be modified by the current {@link android.service.notification.NotificationAssistantService}.
     *
     * <p>Only callable by the current
     * {@link android.service.notification.NotificationAssistantService}.
     * See {@link #isNotificationAssistantAccessGranted(ComponentName)}</p>
     * @hide
     */
    @SystemApi
    public @NonNull @Adjustment.Keys List<String> getAllowedAssistantCapabilities() {
        INotificationManager service = getService();
        try {
            return service.getAllowedAssistantCapabilities(mContext.getOpPackageName());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /** @hide */
    public boolean isNotificationPolicyAccessGrantedForPackage(String pkg) {
        INotificationManager service = getService();
+12 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
package android.service.notification;

import android.annotation.NonNull;
import android.annotation.StringDef;
import android.annotation.SystemApi;
import android.app.Notification;
import android.os.Bundle;
@@ -23,6 +24,9 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.os.UserHandle;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * Ranking updates from the Assistant.
 *
@@ -43,6 +47,14 @@ public final class Adjustment implements Parcelable {
    private final Bundle mSignals;
    private final int mUser;

    /** @hide */
    @StringDef (prefix = { "KEY_" }, value = {
            KEY_CONTEXTUAL_ACTIONS, KEY_GROUP_KEY, KEY_IMPORTANCE, KEY_PEOPLE, KEY_SNOOZE_CRITERIA,
            KEY_TEXT_REPLIES, KEY_USER_SENTIMENT
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface Keys {}

    /**
     * Data type: ArrayList of {@code String}, where each is a representation of a
     * {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}.
+10 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.annotation.SdkConstant;
import android.annotation.SystemApi;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
@@ -141,7 +142,6 @@ public abstract class NotificationAssistantService extends NotificationListenerS
        return onNotificationEnqueued(sbn);
    }


    /**
     * Implement this method to learn when notifications are removed, how they were interacted with
     * before removal, and why they were removed.
@@ -215,6 +215,15 @@ public abstract class NotificationAssistantService extends NotificationListenerS
            @Source int source) {
    }

    /**
     * Implement this to know when a user has changed which features of
     * their notifications the assistant can modify.
     * <p> Query {@link NotificationManager#getAllowedAssistantCapabilities()} to see what
     * {@link Adjustment adjustments} you are currently allowed to make.</p>
     */
    public void onCapabilitiesChanged() {
    }

    /**
     * Updates a notification.  N.B. this won’t cause
     * an existing notification to alert, but might allow a future update to
Loading