2 * Copyright (C) 2016 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package android.service.notification;
18 import android.annotation.SystemApi;
19 import android.annotation.TestApi;
20 import android.app.Notification;
21 import android.os.Bundle;
22 import android.os.Parcel;
23 import android.os.Parcelable;
26 * Ranking updates from the Assistant.
31 public final class Adjustment implements Parcelable {
32 private final String mPackage;
33 private final String mKey;
34 private final CharSequence mExplanation;
35 private final Bundle mSignals;
36 private final int mUser;
39 * Data type: ArrayList of {@code String}, where each is a representation of a
40 * {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}.
41 * See {@link android.app.Notification.Builder#addPerson(String)}.
43 public static final String KEY_PEOPLE = "key_people";
45 * Parcelable {@code ArrayList} of {@link SnoozeCriterion}. These criteria may be visible to
46 * users. If a user chooses to snooze a notification until one of these criterion, the
47 * assistant will be notified via
48 * {@link NotificationAssistantService#onNotificationSnoozedUntilContext}.
50 public static final String KEY_SNOOZE_CRITERIA = "key_snooze_criteria";
52 * Data type: String. Used to change what {@link Notification#getGroup() group} a notification
56 public static final String KEY_GROUP_KEY = "key_group_key";
59 * Create a notification adjustment.
61 * @param pkg The package of the notification.
62 * @param key The notification key.
63 * @param signals A bundle of signals that should inform notification display, ordering, and
65 * @param explanation A human-readable justification for the adjustment.
67 public Adjustment(String pkg, String key, Bundle signals, CharSequence explanation, int user) {
71 mExplanation = explanation;
75 protected Adjustment(Parcel in) {
76 if (in.readInt() == 1) {
77 mPackage = in.readString();
81 if (in.readInt() == 1) {
82 mKey = in.readString();
86 if (in.readInt() == 1) {
87 mExplanation = in.readCharSequence();
91 mSignals = in.readBundle();
95 public static final Creator<Adjustment> CREATOR = new Creator<Adjustment>() {
97 public Adjustment createFromParcel(Parcel in) {
98 return new Adjustment(in);
102 public Adjustment[] newArray(int size) {
103 return new Adjustment[size];
107 public String getPackage() {
111 public String getKey() {
115 public CharSequence getExplanation() {
119 public Bundle getSignals() {
123 public int getUser() {
128 public int describeContents() {
133 public void writeToParcel(Parcel dest, int flags) {
134 if (mPackage != null) {
136 dest.writeString(mPackage);
142 dest.writeString(mKey);
146 if (mExplanation != null) {
148 dest.writeCharSequence(mExplanation);
152 dest.writeBundle(mSignals);
153 dest.writeInt(mUser);
157 public String toString() {
159 + "mSignals=" + mSignals