| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package android.service.notification; |
| 17 |
|
| 18 |
import android.annotation.NonNull; |
| 19 |
import android.annotation.Nullable; |
| 20 |
import android.annotation.StringDef; |
| 21 |
import android.annotation.SystemApi; |
| 22 |
import android.app.Notification; |
| 23 |
import android.os.Bundle; |
| 24 |
import android.os.Parcel; |
| 25 |
import android.os.Parcelable; |
| 26 |
import android.os.UserHandle; |
| 27 |
|
| 28 |
import java.lang.annotation.Retention; |
| 29 |
import java.lang.annotation.RetentionPolicy; |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
@SystemApi |
| 44 |
public final class Adjustment implements Parcelable { |
| 45 |
private final String mPackage; |
| 46 |
private final String mKey; |
| 47 |
private final CharSequence mExplanation; |
| 48 |
private final Bundle mSignals; |
| 49 |
private final int mUser; |
| 50 |
@Nullable private String mIssuer; |
| 51 |
|
| 52 |
|
| 53 |
@StringDef (prefix = { "KEY_" }, value = { |
| 54 |
KEY_CONTEXTUAL_ACTIONS, KEY_GROUP_KEY, KEY_IMPORTANCE, KEY_PEOPLE, KEY_SNOOZE_CRITERIA, |
| 55 |
KEY_TEXT_REPLIES, KEY_USER_SENTIMENT |
| 56 |
}) |
| 57 |
@Retention(RetentionPolicy.SOURCE) |
| 58 |
public @interface Keys {} |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
@SystemApi |
| 67 |
public static final String KEY_PEOPLE = "key_people"; |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
public static final String KEY_SNOOZE_CRITERIA = "key_snooze_criteria"; |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
public static final String KEY_GROUP_KEY = "key_group_key"; |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
public static final String KEY_USER_SENTIMENT = "key_user_sentiment"; |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
public static final String KEY_CONTEXTUAL_ACTIONS = "key_contextual_actions"; |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
public static final String KEY_TEXT_REPLIES = "key_text_replies"; |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
public static final String KEY_IMPORTANCE = "key_importance"; |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
public static final String KEY_RANKING_SCORE = "key_ranking_score"; |
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
@SystemApi |
| 136 |
public static final String KEY_NOT_CONVERSATION = "key_not_conversation"; |
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
@SystemApi |
| 149 |
public Adjustment(String pkg, String key, Bundle signals, CharSequence explanation, int user) { |
| 150 |
mPackage = pkg; |
| 151 |
mKey = key; |
| 152 |
mSignals = signals; |
| 153 |
mExplanation = explanation; |
| 154 |
mUser = user; |
| 155 |
} |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
public Adjustment(@NonNull String pkg, @NonNull String key, @NonNull Bundle signals, |
| 168 |
@NonNull CharSequence explanation, |
| 169 |
@NonNull UserHandle userHandle) { |
| 170 |
mPackage = pkg; |
| 171 |
mKey = key; |
| 172 |
mSignals = signals; |
| 173 |
mExplanation = explanation; |
| 174 |
mUser = userHandle.getIdentifier(); |
| 175 |
} |
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
@SystemApi |
| 181 |
protected Adjustment(Parcel in) { |
| 182 |
if (in.readInt() == 1) { |
| 183 |
mPackage = in.readString(); |
| 184 |
} else { |
| 185 |
mPackage = null; |
| 186 |
} |
| 187 |
if (in.readInt() == 1) { |
| 188 |
mKey = in.readString(); |
| 189 |
} else { |
| 190 |
mKey = null; |
| 191 |
} |
| 192 |
if (in.readInt() == 1) { |
| 193 |
mExplanation = in.readCharSequence(); |
| 194 |
} else { |
| 195 |
mExplanation = null; |
| 196 |
} |
| 197 |
mSignals = in.readBundle(); |
| 198 |
mUser = in.readInt(); |
| 199 |
mIssuer = in.readString(); |
| 200 |
} |
| 201 |
|
| 202 |
public static final @android.annotation.NonNull Creator<Adjustment> CREATOR = new Creator<Adjustment>() { |
| 203 |
@Override |
| 204 |
public Adjustment createFromParcel(Parcel in) { |
| 205 |
return new Adjustment(in); |
| 206 |
} |
| 207 |
|
| 208 |
@Override |
| 209 |
public Adjustment[] newArray(int size) { |
| 210 |
return new Adjustment[size]; |
| 211 |
} |
| 212 |
}; |
| 213 |
|
| 214 |
public @NonNull String getPackage() { |
| 215 |
return mPackage; |
| 216 |
} |
| 217 |
|
| 218 |
public @NonNull String getKey() { |
| 219 |
return mKey; |
| 220 |
} |
| 221 |
|
| 222 |
public @NonNull CharSequence getExplanation() { |
| 223 |
return mExplanation; |
| 224 |
} |
| 225 |
|
| 226 |
public @NonNull Bundle getSignals() { |
| 227 |
return mSignals; |
| 228 |
} |
| 229 |
|
| 230 |
|
| 231 |
@SystemApi |
| 232 |
public int getUser() { |
| 233 |
return mUser; |
| 234 |
} |
| 235 |
|
| 236 |
public @NonNull UserHandle getUserHandle() { |
| 237 |
return UserHandle.of(mUser); |
| 238 |
} |
| 239 |
|
| 240 |
@Override |
| 241 |
public int describeContents() { |
| 242 |
return 0; |
| 243 |
} |
| 244 |
|
| 245 |
@Override |
| 246 |
public void writeToParcel(Parcel dest, int flags) { |
| 247 |
if (mPackage != null) { |
| 248 |
dest.writeInt(1); |
| 249 |
dest.writeString(mPackage); |
| 250 |
} else { |
| 251 |
dest.writeInt(0); |
| 252 |
} |
| 253 |
if (mKey != null) { |
| 254 |
dest.writeInt(1); |
| 255 |
dest.writeString(mKey); |
| 256 |
} else { |
| 257 |
dest.writeInt(0); |
| 258 |
} |
| 259 |
if (mExplanation != null) { |
| 260 |
dest.writeInt(1); |
| 261 |
dest.writeCharSequence(mExplanation); |
| 262 |
} else { |
| 263 |
dest.writeInt(0); |
| 264 |
} |
| 265 |
dest.writeBundle(mSignals); |
| 266 |
dest.writeInt(mUser); |
| 267 |
dest.writeString(mIssuer); |
| 268 |
} |
| 269 |
|
| 270 |
@NonNull |
| 271 |
@Override |
| 272 |
public String toString() { |
| 273 |
return "Adjustment{" |
| 274 |
+ "mSignals=" + mSignals |
| 275 |
+ '}'; |
| 276 |
} |
| 277 |
|
| 278 |
|
| 279 |
public void setIssuer(@Nullable String issuer) { |
| 280 |
mIssuer = issuer; |
| 281 |
} |
| 282 |
|
| 283 |
|
| 284 |
public @Nullable String getIssuer() { |
| 285 |
return mIssuer; |
| 286 |
} |
| 287 |
} |