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

This commit is contained in:
Julia Reynolds
2019-03-21 13:09:00 +00:00
committed by Android (Google) Code Review
8 changed files with 163 additions and 1 deletions

View File

@@ -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);

View File

@@ -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();

View File

@@ -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}.

View File

@@ -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