10cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato/* 20cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * Copyright (C) 2010 The Android Open Source Project 30cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * 40cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * Licensed under the Apache License, Version 2.0 (the "License"); 50cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * you may not use this file except in compliance with the License. 60cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * You may obtain a copy of the License at 70cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * 80cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * http://www.apache.org/licenses/LICENSE-2.0 90cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * 100cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * Unless required by applicable law or agreed to in writing, software 110cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * distributed under the License is distributed on an "AS IS" BASIS, 120cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 130cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * See the License for the specific language governing permissions and 140cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * limitations under the License. 150cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato */ 160cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato 170cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onoratopackage com.android.internal.statusbar; 180cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato 190cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onoratoimport android.os.Parcel; 200cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onoratoimport android.os.Parcelable; 2198edc951712823dbf5db2b7e9c203a0e98fc616bAmith Yamasaniimport android.os.UserHandle; 220cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato 230cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onoratopublic class StatusBarIcon implements Parcelable { 240cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato public String iconPackage; 2598edc951712823dbf5db2b7e9c203a0e98fc616bAmith Yamasani public UserHandle user; 260cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato public int iconId; 270cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato public int iconLevel; 28514ad663f0a8b239cc59409175e0bd489c591aa0Joe Onorato public boolean visible = true; 2918e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato public int number; 306179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov public CharSequence contentDescription; 310cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato 3298edc951712823dbf5db2b7e9c203a0e98fc616bAmith Yamasani public StatusBarIcon(String iconPackage, UserHandle user, int iconId, int iconLevel, int number, 336179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov CharSequence contentDescription) { 340e26dffd6cfcb09b08a94a857b891fdef7fe2b1eJoe Onorato this.iconPackage = iconPackage; 3598edc951712823dbf5db2b7e9c203a0e98fc616bAmith Yamasani this.user = user; 360e26dffd6cfcb09b08a94a857b891fdef7fe2b1eJoe Onorato this.iconId = iconId; 370e26dffd6cfcb09b08a94a857b891fdef7fe2b1eJoe Onorato this.iconLevel = iconLevel; 380e26dffd6cfcb09b08a94a857b891fdef7fe2b1eJoe Onorato this.number = number; 396179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov this.contentDescription = contentDescription; 400e26dffd6cfcb09b08a94a857b891fdef7fe2b1eJoe Onorato } 410e26dffd6cfcb09b08a94a857b891fdef7fe2b1eJoe Onorato 426179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov @Override 43514ad663f0a8b239cc59409175e0bd489c591aa0Joe Onorato public String toString() { 4498edc951712823dbf5db2b7e9c203a0e98fc616bAmith Yamasani return "StatusBarIcon(pkg=" + this.iconPackage + "user=" + user.getIdentifier() 4598edc951712823dbf5db2b7e9c203a0e98fc616bAmith Yamasani + " id=0x" + Integer.toHexString(this.iconId) 4618e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato + " level=" + this.iconLevel + " visible=" + visible 4718e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato + " num=" + this.number + " )"; 48514ad663f0a8b239cc59409175e0bd489c591aa0Joe Onorato } 49514ad663f0a8b239cc59409175e0bd489c591aa0Joe Onorato 506179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov @Override 510cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato public StatusBarIcon clone() { 5298edc951712823dbf5db2b7e9c203a0e98fc616bAmith Yamasani StatusBarIcon that = new StatusBarIcon(this.iconPackage, this.user, this.iconId, 5398edc951712823dbf5db2b7e9c203a0e98fc616bAmith Yamasani this.iconLevel, this.number, this.contentDescription); 54514ad663f0a8b239cc59409175e0bd489c591aa0Joe Onorato that.visible = this.visible; 55514ad663f0a8b239cc59409175e0bd489c591aa0Joe Onorato return that; 560cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato } 570cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato 580cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato /** 590cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * Unflatten the StatusBarIcon from a parcel. 600cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato */ 610cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato public StatusBarIcon(Parcel in) { 620cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato readFromParcel(in); 630cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato } 640cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato 650cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato public void readFromParcel(Parcel in) { 660cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato this.iconPackage = in.readString(); 6798edc951712823dbf5db2b7e9c203a0e98fc616bAmith Yamasani this.user = (UserHandle) in.readParcelable(null); 680cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato this.iconId = in.readInt(); 690cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato this.iconLevel = in.readInt(); 70514ad663f0a8b239cc59409175e0bd489c591aa0Joe Onorato this.visible = in.readInt() != 0; 7118e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato this.number = in.readInt(); 726179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov this.contentDescription = in.readCharSequence(); 730cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato } 740cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato 750cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato public void writeToParcel(Parcel out, int flags) { 760cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato out.writeString(this.iconPackage); 7798edc951712823dbf5db2b7e9c203a0e98fc616bAmith Yamasani out.writeParcelable(this.user, 0); 780cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato out.writeInt(this.iconId); 790cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato out.writeInt(this.iconLevel); 80e345fff2f80947b0a821f6674c197a02b7bff08eJoe Onorato out.writeInt(this.visible ? 1 : 0); 8118e69dfc7235f8a4bfe257f9d1c43539049a22ceJoe Onorato out.writeInt(this.number); 826179ea3196e9306d3f14361fe9ef14191b1edba6Svetoslav Ganov out.writeCharSequence(this.contentDescription); 830cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato } 840cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato 850cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato public int describeContents() { 860cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato return 0; 870cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato } 880cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato 890cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato /** 900cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato * Parcelable.Creator that instantiates StatusBarIcon objects 910cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato */ 920cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato public static final Parcelable.Creator<StatusBarIcon> CREATOR 930cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato = new Parcelable.Creator<StatusBarIcon>() 940cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato { 950cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato public StatusBarIcon createFromParcel(Parcel parcel) 960cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato { 970cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato return new StatusBarIcon(parcel); 980cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato } 990cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato 1000cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato public StatusBarIcon[] newArray(int size) 1010cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato { 1020cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato return new StatusBarIcon[size]; 1030cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato } 1040cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato }; 1050cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato} 1060cbda99f8721ad9b03ada04d2637fb75a2a0fecaJoe Onorato 107