Julia Reynolds | e46bb37 | 2016-03-17 11:05:58 -0400 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package android.service.notification; |
| 17 | |
Julia Reynolds | 1327d3c | 2017-02-17 09:26:45 -0500 | [diff] [blame] | 18 | import android.annotation.SystemApi; |
| 19 | import android.annotation.TestApi; |
Julia Reynolds | 22f02b3 | 2016-12-01 15:05:13 -0500 | [diff] [blame] | 20 | import android.app.NotificationChannel; |
Julia Reynolds | e46bb37 | 2016-03-17 11:05:58 -0400 | [diff] [blame] | 21 | import android.os.Bundle; |
| 22 | import android.os.Parcel; |
| 23 | import android.os.Parcelable; |
| 24 | |
| 25 | /** |
Julia Reynolds | 77b2cc9 | 2016-11-08 14:41:09 -0500 | [diff] [blame] | 26 | * Ranking updates from the Assistant. |
Julia Reynolds | 1327d3c | 2017-02-17 09:26:45 -0500 | [diff] [blame] | 27 | * @hide |
Julia Reynolds | e46bb37 | 2016-03-17 11:05:58 -0400 | [diff] [blame] | 28 | */ |
Julia Reynolds | 1327d3c | 2017-02-17 09:26:45 -0500 | [diff] [blame] | 29 | @SystemApi |
| 30 | @TestApi |
Julia Reynolds | e46bb37 | 2016-03-17 11:05:58 -0400 | [diff] [blame] | 31 | public final class Adjustment implements Parcelable { |
| 32 | private final String mPackage; |
| 33 | private final String mKey; |
Julia Reynolds | e46bb37 | 2016-03-17 11:05:58 -0400 | [diff] [blame] | 34 | private final CharSequence mExplanation; |
Julia Reynolds | e46bb37 | 2016-03-17 11:05:58 -0400 | [diff] [blame] | 35 | private final Bundle mSignals; |
Julia Reynolds | eae43fb | 2016-05-09 12:42:58 -0400 | [diff] [blame] | 36 | private final int mUser; |
Julia Reynolds | e46bb37 | 2016-03-17 11:05:58 -0400 | [diff] [blame] | 37 | |
Julia Reynolds | e46bb37 | 2016-03-17 11:05:58 -0400 | [diff] [blame] | 38 | /** |
Julia Reynolds | 22f02b3 | 2016-12-01 15:05:13 -0500 | [diff] [blame] | 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)}. |
| 42 | */ |
| 43 | public static final String KEY_PEOPLE = "key_people"; |
| 44 | /** |
Julia Reynolds | 7967230 | 2017-01-12 08:30:16 -0500 | [diff] [blame] | 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}. |
Julia Reynolds | 22f02b3 | 2016-12-01 15:05:13 -0500 | [diff] [blame] | 49 | */ |
| 50 | public static final String KEY_SNOOZE_CRITERIA = "key_snooze_criteria"; |
| 51 | |
| 52 | /** |
Julia Reynolds | e46bb37 | 2016-03-17 11:05:58 -0400 | [diff] [blame] | 53 | * Create a notification adjustment. |
| 54 | * |
| 55 | * @param pkg The package of the notification. |
| 56 | * @param key The notification key. |
Julia Reynolds | 22f02b3 | 2016-12-01 15:05:13 -0500 | [diff] [blame] | 57 | * @param signals A bundle of signals that should inform notification display, ordering, and |
| 58 | * interruptiveness. |
Julia Reynolds | e46bb37 | 2016-03-17 11:05:58 -0400 | [diff] [blame] | 59 | * @param explanation A human-readable justification for the adjustment. |
Julia Reynolds | e46bb37 | 2016-03-17 11:05:58 -0400 | [diff] [blame] | 60 | */ |
Julia Reynolds | 22f02b3 | 2016-12-01 15:05:13 -0500 | [diff] [blame] | 61 | public Adjustment(String pkg, String key, Bundle signals, CharSequence explanation, int user) { |
Julia Reynolds | e46bb37 | 2016-03-17 11:05:58 -0400 | [diff] [blame] | 62 | mPackage = pkg; |
| 63 | mKey = key; |
Julia Reynolds | e46bb37 | 2016-03-17 11:05:58 -0400 | [diff] [blame] | 64 | mSignals = signals; |
| 65 | mExplanation = explanation; |
Julia Reynolds | eae43fb | 2016-05-09 12:42:58 -0400 | [diff] [blame] | 66 | mUser = user; |
Julia Reynolds | e46bb37 | 2016-03-17 11:05:58 -0400 | [diff] [blame] | 67 | } |
| 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 Reynolds | e46bb37 | 2016-03-17 11:05:58 -0400 | [diff] [blame] | 80 | if (in.readInt() == 1) { |
| 81 | mExplanation = in.readCharSequence(); |
| 82 | } else { |
| 83 | mExplanation = null; |
| 84 | } |
Julia Reynolds | e46bb37 | 2016-03-17 11:05:58 -0400 | [diff] [blame] | 85 | mSignals = in.readBundle(); |
Julia Reynolds | eae43fb | 2016-05-09 12:42:58 -0400 | [diff] [blame] | 86 | mUser = in.readInt(); |
Julia Reynolds | e46bb37 | 2016-03-17 11:05:58 -0400 | [diff] [blame] | 87 | } |
| 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 Reynolds | e46bb37 | 2016-03-17 11:05:58 -0400 | [diff] [blame] | 109 | public CharSequence getExplanation() { |
| 110 | return mExplanation; |
| 111 | } |
| 112 | |
Julia Reynolds | e46bb37 | 2016-03-17 11:05:58 -0400 | [diff] [blame] | 113 | public Bundle getSignals() { |
| 114 | return mSignals; |
| 115 | } |
| 116 | |
Julia Reynolds | eae43fb | 2016-05-09 12:42:58 -0400 | [diff] [blame] | 117 | public int getUser() { |
| 118 | return mUser; |
| 119 | } |
| 120 | |
Julia Reynolds | e46bb37 | 2016-03-17 11:05:58 -0400 | [diff] [blame] | 121 | @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 Reynolds | e46bb37 | 2016-03-17 11:05:58 -0400 | [diff] [blame] | 140 | if (mExplanation != null) { |
| 141 | dest.writeInt(1); |
| 142 | dest.writeCharSequence(mExplanation); |
| 143 | } else { |
| 144 | dest.writeInt(0); |
| 145 | } |
Julia Reynolds | e46bb37 | 2016-03-17 11:05:58 -0400 | [diff] [blame] | 146 | dest.writeBundle(mSignals); |
Julia Reynolds | eae43fb | 2016-05-09 12:42:58 -0400 | [diff] [blame] | 147 | dest.writeInt(mUser); |
Julia Reynolds | e46bb37 | 2016-03-17 11:05:58 -0400 | [diff] [blame] | 148 | } |
| 149 | } |