118e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato/* 218e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato * Copyright (C) 2008 The Android Open Source Project 318e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato * 418e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato * Licensed under the Apache License, Version 2.0 (the "License"); 518e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato * you may not use this file except in compliance with the License. 618e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato * You may obtain a copy of the License at 718e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato * 818e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato * http://www.apache.org/licenses/LICENSE-2.0 918e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato * 1018e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato * Unless required by applicable law or agreed to in writing, software 1118e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato * distributed under the License is distributed on an "AS IS" BASIS, 1218e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1318e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato * See the License for the specific language governing permissions and 1418e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato * limitations under the License. 1518e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato */ 1618e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato 175feceebb892d4cb5777cea3c6174b206705d456bDaniel Sandlerpackage android.service.notification; 1818e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato 1918e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onoratoimport android.app.Notification; 2068079d54f3690885df9c5bbb691090633f3ef541Dan Sandlerimport android.content.Context; 2168079d54f3690885df9c5bbb691090633f3ef541Dan Sandlerimport android.content.pm.ApplicationInfo; 2268079d54f3690885df9c5bbb691090633f3ef541Dan Sandlerimport android.content.pm.PackageManager; 2318e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onoratoimport android.os.Parcel; 2418e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onoratoimport android.os.Parcelable; 25f02b60aa4f367516f40cf3d60fffae0c6fe3e1b8Dianne Hackbornimport android.os.UserHandle; 2618e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato 272561b0b10a55841a08e0e1d467e73e10b1bf256dDaniel Sandler/** 28fde19b106b2b77bc3540b04445357870caf878b5Daniel Sandler * Class encapsulating a Notification. Sent by the NotificationManagerService to clients including 295feceebb892d4cb5777cea3c6174b206705d456bDaniel Sandler * the status bar and any {@link android.service.notification.NotificationListenerService}s. 302561b0b10a55841a08e0e1d467e73e10b1bf256dDaniel Sandler */ 3118e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onoratopublic class StatusBarNotification implements Parcelable { 32e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler private final String pkg; 33e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler private final int id; 34e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler private final String tag; 35a4294297d46cc0b9f45897bc688c267502cce3efJohn Spurlock private final String key; 361031c974855ff4117a6d7866e664295786840319Chris Wren private final String groupKey; 375feceebb892d4cb5777cea3c6174b206705d456bDaniel Sandler 38e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler private final int uid; 398fd7f1ed7c11d35b3f2a97878e68ee38a551dd15Christoph Studer private final String opPkg; 40e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler private final int initialPid; 41e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler private final Notification notification; 42e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler private final UserHandle user; 43e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler private final long postTime; 446d51571835737c7502a2e111ee9dc2527ebad984Jeff Sharkey 45e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler private final int score; 4668079d54f3690885df9c5bbb691090633f3ef541Dan Sandler private Context mContext; // used for inflation & icon expansion 475feceebb892d4cb5777cea3c6174b206705d456bDaniel Sandler 485feceebb892d4cb5777cea3c6174b206705d456bDaniel Sandler /** @hide */ 498fd7f1ed7c11d35b3f2a97878e68ee38a551dd15Christoph Studer public StatusBarNotification(String pkg, String opPkg, int id, String tag, int uid, 50fde19b106b2b77bc3540b04445357870caf878b5Daniel Sandler int initialPid, int score, Notification notification, UserHandle user) { 518fd7f1ed7c11d35b3f2a97878e68ee38a551dd15Christoph Studer this(pkg, opPkg, id, tag, uid, initialPid, score, notification, user, 52fde19b106b2b77bc3540b04445357870caf878b5Daniel Sandler System.currentTimeMillis()); 53fde19b106b2b77bc3540b04445357870caf878b5Daniel Sandler } 54fde19b106b2b77bc3540b04445357870caf878b5Daniel Sandler 558fd7f1ed7c11d35b3f2a97878e68ee38a551dd15Christoph Studer public StatusBarNotification(String pkg, String opPkg, int id, String tag, int uid, 56fde19b106b2b77bc3540b04445357870caf878b5Daniel Sandler int initialPid, int score, Notification notification, UserHandle user, 57fde19b106b2b77bc3540b04445357870caf878b5Daniel Sandler long postTime) { 5818e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato if (pkg == null) throw new NullPointerException(); 5918e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato if (notification == null) throw new NullPointerException(); 6018e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato 6118e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato this.pkg = pkg; 628fd7f1ed7c11d35b3f2a97878e68ee38a551dd15Christoph Studer this.opPkg = opPkg; 6318e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato this.id = id; 6418e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato this.tag = tag; 659d39d0cb361c5d3bba04a6bacf299be2162a6e92Dianne Hackborn this.uid = uid; 669d39d0cb361c5d3bba04a6bacf299be2162a6e92Dianne Hackborn this.initialPid = initialPid; 672561b0b10a55841a08e0e1d467e73e10b1bf256dDaniel Sandler this.score = score; 6818e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato this.notification = notification; 696d51571835737c7502a2e111ee9dc2527ebad984Jeff Sharkey this.user = user; 70fde19b106b2b77bc3540b04445357870caf878b5Daniel Sandler this.postTime = postTime; 71a4294297d46cc0b9f45897bc688c267502cce3efJohn Spurlock this.key = key(); 721031c974855ff4117a6d7866e664295786840319Chris Wren this.groupKey = groupKey(); 7318e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato } 7418e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato 7518e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato public StatusBarNotification(Parcel in) { 7618e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato this.pkg = in.readString(); 778fd7f1ed7c11d35b3f2a97878e68ee38a551dd15Christoph Studer this.opPkg = in.readString(); 7818e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato this.id = in.readInt(); 7918e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato if (in.readInt() != 0) { 8018e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato this.tag = in.readString(); 8118e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato } else { 8218e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato this.tag = null; 8318e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato } 849d39d0cb361c5d3bba04a6bacf299be2162a6e92Dianne Hackborn this.uid = in.readInt(); 859d39d0cb361c5d3bba04a6bacf299be2162a6e92Dianne Hackborn this.initialPid = in.readInt(); 862561b0b10a55841a08e0e1d467e73e10b1bf256dDaniel Sandler this.score = in.readInt(); 8718e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato this.notification = new Notification(in); 886d51571835737c7502a2e111ee9dc2527ebad984Jeff Sharkey this.user = UserHandle.readFromParcel(in); 89fde19b106b2b77bc3540b04445357870caf878b5Daniel Sandler this.postTime = in.readLong(); 90a4294297d46cc0b9f45897bc688c267502cce3efJohn Spurlock this.key = key(); 911031c974855ff4117a6d7866e664295786840319Chris Wren this.groupKey = groupKey(); 92a4294297d46cc0b9f45897bc688c267502cce3efJohn Spurlock } 93a4294297d46cc0b9f45897bc688c267502cce3efJohn Spurlock 94a4294297d46cc0b9f45897bc688c267502cce3efJohn Spurlock private String key() { 95ff8dbe52eb3452df4d2cbd7af90483969bb061f4Christoph Studer return user.getIdentifier() + "|" + pkg + "|" + id + "|" + tag + "|" + uid; 9618e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato } 9718e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato 981031c974855ff4117a6d7866e664295786840319Chris Wren private String groupKey() { 991031c974855ff4117a6d7866e664295786840319Chris Wren final String group = getNotification().getGroup(); 1001031c974855ff4117a6d7866e664295786840319Chris Wren final String sortKey = getNotification().getSortKey(); 1011031c974855ff4117a6d7866e664295786840319Chris Wren if (group == null && sortKey == null) { 1021031c974855ff4117a6d7866e664295786840319Chris Wren // a group of one 1031031c974855ff4117a6d7866e664295786840319Chris Wren return key; 1041031c974855ff4117a6d7866e664295786840319Chris Wren } 1051031c974855ff4117a6d7866e664295786840319Chris Wren return user.getIdentifier() + "|" + pkg + "|" + 1061031c974855ff4117a6d7866e664295786840319Chris Wren (group == null 1071031c974855ff4117a6d7866e664295786840319Chris Wren ? "p:" + notification.priority 1081031c974855ff4117a6d7866e664295786840319Chris Wren : "g:" + group); 1091031c974855ff4117a6d7866e664295786840319Chris Wren } 1101031c974855ff4117a6d7866e664295786840319Chris Wren 11118e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato public void writeToParcel(Parcel out, int flags) { 11218e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato out.writeString(this.pkg); 1138fd7f1ed7c11d35b3f2a97878e68ee38a551dd15Christoph Studer out.writeString(this.opPkg); 11418e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato out.writeInt(this.id); 11518e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato if (this.tag != null) { 11618e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato out.writeInt(1); 11718e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato out.writeString(this.tag); 11818e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato } else { 11918e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato out.writeInt(0); 12018e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato } 1219d39d0cb361c5d3bba04a6bacf299be2162a6e92Dianne Hackborn out.writeInt(this.uid); 1229d39d0cb361c5d3bba04a6bacf299be2162a6e92Dianne Hackborn out.writeInt(this.initialPid); 1232561b0b10a55841a08e0e1d467e73e10b1bf256dDaniel Sandler out.writeInt(this.score); 12418e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato this.notification.writeToParcel(out, flags); 1256d51571835737c7502a2e111ee9dc2527ebad984Jeff Sharkey user.writeToParcel(out, flags); 126fde19b106b2b77bc3540b04445357870caf878b5Daniel Sandler 127fde19b106b2b77bc3540b04445357870caf878b5Daniel Sandler out.writeLong(this.postTime); 12818e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato } 12918e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato 13018e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato public int describeContents() { 13118e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato return 0; 13218e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato } 13318e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato 13418e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato public static final Parcelable.Creator<StatusBarNotification> CREATOR 13518e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato = new Parcelable.Creator<StatusBarNotification>() 13618e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato { 13718e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato public StatusBarNotification createFromParcel(Parcel parcel) 13818e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato { 13918e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato return new StatusBarNotification(parcel); 14018e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato } 14118e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato 14218e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato public StatusBarNotification[] newArray(int size) 14318e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato { 14418e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato return new StatusBarNotification[size]; 14518e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato } 14618e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato }; 14718e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato 1481a497d3a2b1496c12949e47e55f8e46d8f585be5Daniel Sandler /** 1491a497d3a2b1496c12949e47e55f8e46d8f585be5Daniel Sandler * @hide 1501a497d3a2b1496c12949e47e55f8e46d8f585be5Daniel Sandler */ 1511a497d3a2b1496c12949e47e55f8e46d8f585be5Daniel Sandler public StatusBarNotification cloneLight() { 1521a497d3a2b1496c12949e47e55f8e46d8f585be5Daniel Sandler final Notification no = new Notification(); 1531a497d3a2b1496c12949e47e55f8e46d8f585be5Daniel Sandler this.notification.cloneInto(no, false); // light copy 1548fd7f1ed7c11d35b3f2a97878e68ee38a551dd15Christoph Studer return new StatusBarNotification(this.pkg, this.opPkg, 1551a497d3a2b1496c12949e47e55f8e46d8f585be5Daniel Sandler this.id, this.tag, this.uid, this.initialPid, 1561a497d3a2b1496c12949e47e55f8e46d8f585be5Daniel Sandler this.score, no, this.user, this.postTime); 1571a497d3a2b1496c12949e47e55f8e46d8f585be5Daniel Sandler } 1581a497d3a2b1496c12949e47e55f8e46d8f585be5Daniel Sandler 1596d51571835737c7502a2e111ee9dc2527ebad984Jeff Sharkey @Override 16018e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato public StatusBarNotification clone() { 1618fd7f1ed7c11d35b3f2a97878e68ee38a551dd15Christoph Studer return new StatusBarNotification(this.pkg, this.opPkg, 162fde19b106b2b77bc3540b04445357870caf878b5Daniel Sandler this.id, this.tag, this.uid, this.initialPid, 163fde19b106b2b77bc3540b04445357870caf878b5Daniel Sandler this.score, this.notification.clone(), this.user, this.postTime); 16418e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato } 16518e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato 1666d51571835737c7502a2e111ee9dc2527ebad984Jeff Sharkey @Override 16718e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato public String toString() { 168fde19b106b2b77bc3540b04445357870caf878b5Daniel Sandler return String.format( 169a4294297d46cc0b9f45897bc688c267502cce3efJohn Spurlock "StatusBarNotification(pkg=%s user=%s id=%d tag=%s score=%d key=%s: %s)", 170fde19b106b2b77bc3540b04445357870caf878b5Daniel Sandler this.pkg, this.user, this.id, this.tag, 171a4294297d46cc0b9f45897bc688c267502cce3efJohn Spurlock this.score, this.key, this.notification); 17218e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato } 17318e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato 1745feceebb892d4cb5777cea3c6174b206705d456bDaniel Sandler /** Convenience method to check the notification's flags for 1755feceebb892d4cb5777cea3c6174b206705d456bDaniel Sandler * {@link Notification#FLAG_ONGOING_EVENT}. 1765feceebb892d4cb5777cea3c6174b206705d456bDaniel Sandler */ 177e345fff2f80947b0a821f6674c197a02b7bff08eJoe Onorato public boolean isOngoing() { 178e345fff2f80947b0a821f6674c197a02b7bff08eJoe Onorato return (notification.flags & Notification.FLAG_ONGOING_EVENT) != 0; 179e345fff2f80947b0a821f6674c197a02b7bff08eJoe Onorato } 180e345fff2f80947b0a821f6674c197a02b7bff08eJoe Onorato 1815feceebb892d4cb5777cea3c6174b206705d456bDaniel Sandler /** Convenience method to check the notification's flags for 1825feceebb892d4cb5777cea3c6174b206705d456bDaniel Sandler * either {@link Notification#FLAG_ONGOING_EVENT} or 1835feceebb892d4cb5777cea3c6174b206705d456bDaniel Sandler * {@link Notification#FLAG_NO_CLEAR}. 1845feceebb892d4cb5777cea3c6174b206705d456bDaniel Sandler */ 1855dd1169ae95162383acf00d1e9a1886e0ac99a70Joe Onorato public boolean isClearable() { 1865dd1169ae95162383acf00d1e9a1886e0ac99a70Joe Onorato return ((notification.flags & Notification.FLAG_ONGOING_EVENT) == 0) 1875dd1169ae95162383acf00d1e9a1886e0ac99a70Joe Onorato && ((notification.flags & Notification.FLAG_NO_CLEAR) == 0); 1885dd1169ae95162383acf00d1e9a1886e0ac99a70Joe Onorato } 189b9301c3a686df05950710ec80e2cd691c3082871Daniel Sandler 190a263e4e438746f91fb78857bd569ba4f796a346dKenny Guy /** 191a263e4e438746f91fb78857bd569ba4f796a346dKenny Guy * Returns a userHandle for the instance of the app that posted this notification. 192a263e4e438746f91fb78857bd569ba4f796a346dKenny Guy * 193a263e4e438746f91fb78857bd569ba4f796a346dKenny Guy * @deprecated Use {@link #getUser()} instead. 194a263e4e438746f91fb78857bd569ba4f796a346dKenny Guy */ 195b9301c3a686df05950710ec80e2cd691c3082871Daniel Sandler public int getUserId() { 19650cdf7c3069eb2cf82acbad73c322b7a5f3af4b1Dianne Hackborn return this.user.getIdentifier(); 197b9301c3a686df05950710ec80e2cd691c3082871Daniel Sandler } 198e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler 199e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler /** The package of the app that posted the notification. */ 2004f91efdf421e354ee2033ed640e4150cf0cef21bDaniel Sandler public String getPackageName() { 201e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler return pkg; 202e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler } 203e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler 20426510320646339fc59e01d392f96efeeac6d91ddScott Main /** The id supplied to {@link android.app.NotificationManager#notify(int,Notification)}. */ 205e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler public int getId() { 206e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler return id; 207e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler } 208e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler 20926510320646339fc59e01d392f96efeeac6d91ddScott Main /** The tag supplied to {@link android.app.NotificationManager#notify(int,Notification)}, 21026510320646339fc59e01d392f96efeeac6d91ddScott Main * or null if no tag was specified. */ 211e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler public String getTag() { 212e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler return tag; 213e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler } 214e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler 215e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler /** The notifying app's calling uid. @hide */ 216e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler public int getUid() { 217e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler return uid; 218e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler } 219e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler 2208fd7f1ed7c11d35b3f2a97878e68ee38a551dd15Christoph Studer /** The package used for AppOps tracking. @hide */ 2218fd7f1ed7c11d35b3f2a97878e68ee38a551dd15Christoph Studer public String getOpPkg() { 2228fd7f1ed7c11d35b3f2a97878e68ee38a551dd15Christoph Studer return opPkg; 223e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler } 224e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler 225e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler /** @hide */ 226e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler public int getInitialPid() { 227e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler return initialPid; 228e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler } 229e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler 230e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler /** The {@link android.app.Notification} supplied to 23126510320646339fc59e01d392f96efeeac6d91ddScott Main * {@link android.app.NotificationManager#notify(int,Notification)}. */ 232e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler public Notification getNotification() { 233e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler return notification; 234e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler } 235e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler 236e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler /** 237e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler * The {@link android.os.UserHandle} for whom this notification is intended. 238e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler */ 239e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler public UserHandle getUser() { 240e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler return user; 241e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler } 242e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler 243e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler /** The time (in {@link System#currentTimeMillis} time) the notification was posted, 244e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler * which may be different than {@link android.app.Notification#when}. 245e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler */ 246e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler public long getPostTime() { 247e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler return postTime; 248e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler } 249e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler 250e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler /** @hide */ 251e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler public int getScore() { 252e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler return score; 253e6f7f2e3a01b8deb00e03ccfa93751c315f14ef0Daniel Sandler } 254a4294297d46cc0b9f45897bc688c267502cce3efJohn Spurlock 255a4294297d46cc0b9f45897bc688c267502cce3efJohn Spurlock /** 256a4294297d46cc0b9f45897bc688c267502cce3efJohn Spurlock * A unique instance key for this notification record. 257a4294297d46cc0b9f45897bc688c267502cce3efJohn Spurlock */ 258a4294297d46cc0b9f45897bc688c267502cce3efJohn Spurlock public String getKey() { 259a4294297d46cc0b9f45897bc688c267502cce3efJohn Spurlock return key; 260a4294297d46cc0b9f45897bc688c267502cce3efJohn Spurlock } 2611031c974855ff4117a6d7866e664295786840319Chris Wren 2621031c974855ff4117a6d7866e664295786840319Chris Wren /** 2631031c974855ff4117a6d7866e664295786840319Chris Wren * A key that indicates the group with which this message ranks. 2641031c974855ff4117a6d7866e664295786840319Chris Wren */ 2651031c974855ff4117a6d7866e664295786840319Chris Wren public String getGroupKey() { 2661031c974855ff4117a6d7866e664295786840319Chris Wren return groupKey; 2671031c974855ff4117a6d7866e664295786840319Chris Wren } 26868079d54f3690885df9c5bbb691090633f3ef541Dan Sandler 26968079d54f3690885df9c5bbb691090633f3ef541Dan Sandler /** 27068079d54f3690885df9c5bbb691090633f3ef541Dan Sandler * @hide 27168079d54f3690885df9c5bbb691090633f3ef541Dan Sandler */ 27268079d54f3690885df9c5bbb691090633f3ef541Dan Sandler public Context getPackageContext(Context context) { 27368079d54f3690885df9c5bbb691090633f3ef541Dan Sandler if (mContext == null) { 27468079d54f3690885df9c5bbb691090633f3ef541Dan Sandler try { 27568079d54f3690885df9c5bbb691090633f3ef541Dan Sandler ApplicationInfo ai = context.getPackageManager() 27668079d54f3690885df9c5bbb691090633f3ef541Dan Sandler .getApplicationInfo(pkg, PackageManager.GET_UNINSTALLED_PACKAGES); 27768079d54f3690885df9c5bbb691090633f3ef541Dan Sandler mContext = context.createApplicationContext(ai, 27868079d54f3690885df9c5bbb691090633f3ef541Dan Sandler Context.CONTEXT_RESTRICTED); 27968079d54f3690885df9c5bbb691090633f3ef541Dan Sandler } catch (PackageManager.NameNotFoundException e) { 28068079d54f3690885df9c5bbb691090633f3ef541Dan Sandler mContext = null; 28168079d54f3690885df9c5bbb691090633f3ef541Dan Sandler } 28268079d54f3690885df9c5bbb691090633f3ef541Dan Sandler } 28368079d54f3690885df9c5bbb691090633f3ef541Dan Sandler if (mContext == null) { 28468079d54f3690885df9c5bbb691090633f3ef541Dan Sandler mContext = context; 28568079d54f3690885df9c5bbb691090633f3ef541Dan Sandler } 28668079d54f3690885df9c5bbb691090633f3ef541Dan Sandler return mContext; 28768079d54f3690885df9c5bbb691090633f3ef541Dan Sandler } 28818e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato} 289