blob: 137cf577ab7c9dbdb9c8ebd80d4f53a8fc2ee2f9 [file] [log] [blame]
Julia Reynoldse46bb372016-03-17 11:05:58 -04001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16package android.service.notification;
17
Julia Reynolds1327d3c2017-02-17 09:26:45 -050018import android.annotation.SystemApi;
19import android.annotation.TestApi;
Julia Reynolds22f02b32016-12-01 15:05:13 -050020import android.app.NotificationChannel;
Julia Reynoldse46bb372016-03-17 11:05:58 -040021import android.os.Bundle;
22import android.os.Parcel;
23import android.os.Parcelable;
24
25/**
Julia Reynolds77b2cc92016-11-08 14:41:09 -050026 * Ranking updates from the Assistant.
Julia Reynolds1327d3c2017-02-17 09:26:45 -050027 * @hide
Julia Reynoldse46bb372016-03-17 11:05:58 -040028 */
Julia Reynolds1327d3c2017-02-17 09:26:45 -050029@SystemApi
30@TestApi
Julia Reynoldse46bb372016-03-17 11:05:58 -040031public final class Adjustment implements Parcelable {
32 private final String mPackage;
33 private final String mKey;
Julia Reynoldse46bb372016-03-17 11:05:58 -040034 private final CharSequence mExplanation;
Julia Reynoldse46bb372016-03-17 11:05:58 -040035 private final Bundle mSignals;
Julia Reynoldseae43fb2016-05-09 12:42:58 -040036 private final int mUser;
Julia Reynoldse46bb372016-03-17 11:05:58 -040037
Julia Reynoldse46bb372016-03-17 11:05:58 -040038 /**
Julia Reynolds22f02b32016-12-01 15:05:13 -050039 * 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)}.
42 */
43 public static final String KEY_PEOPLE = "key_people";
44 /**
Julia Reynolds79672302017-01-12 08:30:16 -050045 * 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}.
Julia Reynolds22f02b32016-12-01 15:05:13 -050049 */
50 public static final String KEY_SNOOZE_CRITERIA = "key_snooze_criteria";
51
52 /**
Julia Reynoldse46bb372016-03-17 11:05:58 -040053 * Create a notification adjustment.
54 *
55 * @param pkg The package of the notification.
56 * @param key The notification key.
Julia Reynolds22f02b32016-12-01 15:05:13 -050057 * @param signals A bundle of signals that should inform notification display, ordering, and
58 * interruptiveness.
Julia Reynoldse46bb372016-03-17 11:05:58 -040059 * @param explanation A human-readable justification for the adjustment.
Julia Reynoldse46bb372016-03-17 11:05:58 -040060 */
Julia Reynolds22f02b32016-12-01 15:05:13 -050061 public Adjustment(String pkg, String key, Bundle signals, CharSequence explanation, int user) {
Julia Reynoldse46bb372016-03-17 11:05:58 -040062 mPackage = pkg;
63 mKey = key;
Julia Reynoldse46bb372016-03-17 11:05:58 -040064 mSignals = signals;
65 mExplanation = explanation;
Julia Reynoldseae43fb2016-05-09 12:42:58 -040066 mUser = user;
Julia Reynoldse46bb372016-03-17 11:05:58 -040067 }
68
69 protected Adjustment(Parcel in) {
70 if (in.readInt() == 1) {
71 mPackage = in.readString();
72 } else {
73 mPackage = null;
74 }
75 if (in.readInt() == 1) {
76 mKey = in.readString();
77 } else {
78 mKey = null;
79 }
Julia Reynoldse46bb372016-03-17 11:05:58 -040080 if (in.readInt() == 1) {
81 mExplanation = in.readCharSequence();
82 } else {
83 mExplanation = null;
84 }
Julia Reynoldse46bb372016-03-17 11:05:58 -040085 mSignals = in.readBundle();
Julia Reynoldseae43fb2016-05-09 12:42:58 -040086 mUser = in.readInt();
Julia Reynoldse46bb372016-03-17 11:05:58 -040087 }
88
89 public static final Creator<Adjustment> CREATOR = new Creator<Adjustment>() {
90 @Override
91 public Adjustment createFromParcel(Parcel in) {
92 return new Adjustment(in);
93 }
94
95 @Override
96 public Adjustment[] newArray(int size) {
97 return new Adjustment[size];
98 }
99 };
100
101 public String getPackage() {
102 return mPackage;
103 }
104
105 public String getKey() {
106 return mKey;
107 }
108
Julia Reynoldse46bb372016-03-17 11:05:58 -0400109 public CharSequence getExplanation() {
110 return mExplanation;
111 }
112
Julia Reynoldse46bb372016-03-17 11:05:58 -0400113 public Bundle getSignals() {
114 return mSignals;
115 }
116
Julia Reynoldseae43fb2016-05-09 12:42:58 -0400117 public int getUser() {
118 return mUser;
119 }
120
Julia Reynoldse46bb372016-03-17 11:05:58 -0400121 @Override
122 public int describeContents() {
123 return 0;
124 }
125
126 @Override
127 public void writeToParcel(Parcel dest, int flags) {
128 if (mPackage != null) {
129 dest.writeInt(1);
130 dest.writeString(mPackage);
131 } else {
132 dest.writeInt(0);
133 }
134 if (mKey != null) {
135 dest.writeInt(1);
136 dest.writeString(mKey);
137 } else {
138 dest.writeInt(0);
139 }
Julia Reynoldse46bb372016-03-17 11:05:58 -0400140 if (mExplanation != null) {
141 dest.writeInt(1);
142 dest.writeCharSequence(mExplanation);
143 } else {
144 dest.writeInt(0);
145 }
Julia Reynoldse46bb372016-03-17 11:05:58 -0400146 dest.writeBundle(mSignals);
Julia Reynoldseae43fb2016-05-09 12:42:58 -0400147 dest.writeInt(mUser);
Julia Reynoldse46bb372016-03-17 11:05:58 -0400148 }
149}