1 /* 2 * Copyright (C) 2008 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 17 package com.android.internal.statusbar; 18 19 import android.app.Notification; 20 import android.os.Parcel; 21 import android.os.Parcelable; 22 import android.widget.RemoteViews; 23 24 25 /* 26 boolean clearable = !n.ongoingEvent && ((notification.flags & Notification.FLAG_NO_CLEAR) == 0); 27 28 29 // TODO: make this restriction do something smarter like never fill 30 // more than two screens. "Why would anyone need more than 80 characters." :-/ 31 final int maxTickerLen = 80; 32 if (truncatedTicker != null && truncatedTicker.length() > maxTickerLen) { 33 truncatedTicker = truncatedTicker.subSequence(0, maxTickerLen); 34 } 35 */ 36 37 public class StatusBarNotification implements Parcelable { 38 public String pkg; 39 public int id; 40 public String tag; 41 public int uid; 42 public int initialPid; 43 public Notification notification; 44 45 public StatusBarNotification() { 46 } 47 48 public StatusBarNotification(String pkg, int id, String tag, 49 int uid, int initialPid, Notification notification) { 50 if (pkg == null) throw new NullPointerException(); 51 if (notification == null) throw new NullPointerException(); 52 53 this.pkg = pkg; 54 this.id = id; 55 this.tag = tag; 56 this.uid = uid; 57 this.initialPid = initialPid; 58 this.notification = notification; 59 } 60 61 public StatusBarNotification(Parcel in) { 62 readFromParcel(in); 63 } 64 65 public void readFromParcel(Parcel in) { 66 this.pkg = in.readString(); 67 this.id = in.readInt(); 68 if (in.readInt() != 0) { 69 this.tag = in.readString(); 70 } else { 71 this.tag = null; 72 } 73 this.uid = in.readInt(); 74 this.initialPid = in.readInt(); 75 this.notification = new Notification(in); 76 } 77 78 public void writeToParcel(Parcel out, int flags) { 79 out.writeString(this.pkg); 80 out.writeInt(this.id); 81 if (this.tag != null) { 82 out.writeInt(1); 83 out.writeString(this.tag); 84 } else { 85 out.writeInt(0); 86 } 87 out.writeInt(this.uid); 88 out.writeInt(this.initialPid); 89 this.notification.writeToParcel(out, flags); 90 } 91 92 public int describeContents() { 93 return 0; 94 } 95 96 public static final Parcelable.Creator<StatusBarNotification> CREATOR 97 = new Parcelable.Creator<StatusBarNotification>() 98 { 99 public StatusBarNotification createFromParcel(Parcel parcel) 100 { 101 return new StatusBarNotification(parcel); 102 } 103 104 public StatusBarNotification[] newArray(int size) 105 { 106 return new StatusBarNotification[size]; 107 } 108 }; 109 110 public StatusBarNotification clone() { 111 return new StatusBarNotification(this.pkg, this.id, this.tag, 112 this.uid, this.initialPid, this.notification.clone()); 113 } 114 115 public String toString() { 116 return "StatusBarNotification(package=" + pkg + " id=" + id + " tag=" + tag 117 + " notification=" + notification + ")"; 118 } 119 120 public boolean isOngoing() { 121 return (notification.flags & Notification.FLAG_ONGOING_EVENT) != 0; 122 } 123 124 } 125 126 127