• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
18 import android.annotation.SystemApi;
19 import android.net.Uri;
20 import android.os.Bundle;
21 import android.os.Parcel;
22 import android.os.Parcelable;
23 
24 /**
25  * Ranking updates from the Ranker.
26  *
27  * @hide
28  */
29 @SystemApi
30 public final class Adjustment implements Parcelable {
31     private final String mPackage;
32     private final String mKey;
33     private final int mImportance;
34     private final CharSequence mExplanation;
35     private final Uri mReference;
36     private final Bundle mSignals;
37     private final int mUser;
38 
39     public static final String GROUP_KEY_OVERRIDE_KEY = "group_key_override";
40     public static final String NEEDS_AUTOGROUPING_KEY = "autogroup_needed";
41 
42     /**
43      * Create a notification adjustment.
44      *
45      * @param pkg The package of the notification.
46      * @param key The notification key.
47      * @param importance The recommended importance of the notification.
48      * @param signals A bundle of signals that should inform notification grouping and ordering.
49      * @param explanation A human-readable justification for the adjustment.
50      * @param reference A reference to an external object that augments the
51      *                  explanation, such as a
52      *                  {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI},
53      *                  or null.
54      */
Adjustment(String pkg, String key, int importance, Bundle signals, CharSequence explanation, Uri reference, int user)55     public Adjustment(String pkg, String key, int importance, Bundle signals,
56             CharSequence explanation, Uri reference, int user) {
57         mPackage = pkg;
58         mKey = key;
59         mImportance = importance;
60         mSignals = signals;
61         mExplanation = explanation;
62         mReference = reference;
63         mUser = user;
64     }
65 
Adjustment(Parcel in)66     protected Adjustment(Parcel in) {
67         if (in.readInt() == 1) {
68             mPackage = in.readString();
69         } else {
70             mPackage = null;
71         }
72         if (in.readInt() == 1) {
73             mKey = in.readString();
74         } else {
75             mKey = null;
76         }
77         mImportance = in.readInt();
78         if (in.readInt() == 1) {
79             mExplanation = in.readCharSequence();
80         } else {
81             mExplanation = null;
82         }
83         mReference = in.readParcelable(Uri.class.getClassLoader());
84         mSignals = in.readBundle();
85         mUser = in.readInt();
86     }
87 
88     public static final Creator<Adjustment> CREATOR = new Creator<Adjustment>() {
89         @Override
90         public Adjustment createFromParcel(Parcel in) {
91             return new Adjustment(in);
92         }
93 
94         @Override
95         public Adjustment[] newArray(int size) {
96             return new Adjustment[size];
97         }
98     };
99 
getPackage()100     public String getPackage() {
101         return mPackage;
102     }
103 
getKey()104     public String getKey() {
105         return mKey;
106     }
107 
getImportance()108     public int getImportance() {
109         return mImportance;
110     }
111 
getExplanation()112     public CharSequence getExplanation() {
113         return mExplanation;
114     }
115 
getReference()116     public Uri getReference() {
117         return mReference;
118     }
119 
getSignals()120     public Bundle getSignals() {
121         return mSignals;
122     }
123 
getUser()124     public int getUser() {
125         return mUser;
126     }
127 
128     @Override
describeContents()129     public int describeContents() {
130         return 0;
131     }
132 
133     @Override
writeToParcel(Parcel dest, int flags)134     public void writeToParcel(Parcel dest, int flags) {
135         if (mPackage != null) {
136             dest.writeInt(1);
137             dest.writeString(mPackage);
138         } else {
139             dest.writeInt(0);
140         }
141         if (mKey != null) {
142             dest.writeInt(1);
143             dest.writeString(mKey);
144         } else {
145             dest.writeInt(0);
146         }
147         dest.writeInt(mImportance);
148         if (mExplanation != null) {
149             dest.writeInt(1);
150             dest.writeCharSequence(mExplanation);
151         } else {
152             dest.writeInt(0);
153         }
154         dest.writeParcelable(mReference, flags);
155         dest.writeBundle(mSignals);
156         dest.writeInt(mUser);
157     }
158 }
159