diff options
author | Joe Onorato <joeo@android.com> | 2010-05-13 18:49:00 -0700 |
---|---|---|
committer | Joe Onorato <joeo@android.com> | 2010-06-02 14:48:41 -0700 |
commit | 514ad663f0a8b239cc59409175e0bd489c591aa0 (patch) | |
tree | 9e768d8f86c6e7e6c8ff6cb93a8799f0c584c657 | |
parent | fb78cd99f9b08d70f1b4bfdbd847d5d746507052 (diff) | |
download | frameworks_base-514ad663f0a8b239cc59409175e0bd489c591aa0.zip frameworks_base-514ad663f0a8b239cc59409175e0bd489c591aa0.tar.gz frameworks_base-514ad663f0a8b239cc59409175e0bd489c591aa0.tar.bz2 |
Set the visibility of the icons.
Change-Id: Ib414718f1c51f1d306308a989d5d31d8e3ea7fd1
6 files changed, 42 insertions, 22 deletions
diff --git a/core/java/com/android/internal/statusbar/StatusBarIcon.java b/core/java/com/android/internal/statusbar/StatusBarIcon.java index 330b407..455e17b 100644 --- a/core/java/com/android/internal/statusbar/StatusBarIcon.java +++ b/core/java/com/android/internal/statusbar/StatusBarIcon.java @@ -26,6 +26,7 @@ public class StatusBarIcon implements Parcelable { public String iconPackage; public int iconId; public int iconLevel; + public boolean visible = true; private StatusBarIcon() { } @@ -36,8 +37,15 @@ public class StatusBarIcon implements Parcelable { this.iconLevel = iconLevel; } + public String toString() { + return "StatusBarIcon(pkg=" + this.iconPackage + " id=0x" + Integer.toHexString(this.iconId) + + " level=" + this.iconLevel + " visible=" + visible + ")"; + } + public StatusBarIcon clone() { - return new StatusBarIcon(this.iconPackage, this.iconId, this.iconLevel); + StatusBarIcon that = new StatusBarIcon(this.iconPackage, this.iconId, this.iconLevel); + that.visible = this.visible; + return that; } /** @@ -51,12 +59,14 @@ public class StatusBarIcon implements Parcelable { this.iconPackage = in.readString(); this.iconId = in.readInt(); this.iconLevel = in.readInt(); + this.visible = in.readInt() != 0; } public void writeToParcel(Parcel out, int flags) { out.writeString(this.iconPackage); out.writeInt(this.iconId); out.writeInt(this.iconLevel); + out.writeInt(this.visible ? 1 : 0); } public int describeContents() { diff --git a/core/java/com/android/internal/statusbar/StatusBarIconList.java b/core/java/com/android/internal/statusbar/StatusBarIconList.java index 61002d5..478d245 100644 --- a/core/java/com/android/internal/statusbar/StatusBarIconList.java +++ b/core/java/com/android/internal/statusbar/StatusBarIconList.java @@ -155,13 +155,7 @@ public class StatusBarIconList implements Parcelable { final int N = mSlots.length; pw.println("Icon list:"); for (int i=0; i<N; i++) { - final StatusBarIcon icon = mIcons[i]; - if (icon == null) { - pw.printf(" %2d: (%s) null\n", i, mSlots[i]); - } else { - pw.printf(" %2d: (%s) pkg=%s id=0x%08x level=%d\n", i, mSlots[i], icon.iconPackage, - icon.iconId, icon.iconLevel); - } + pw.printf(" %2d: (%s) %s\n", i, mSlots[i], mIcons[i]); } } } diff --git a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/CommandQueue.java b/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/CommandQueue.java index b21f65d..502de10 100644 --- a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/CommandQueue.java +++ b/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/CommandQueue.java @@ -18,12 +18,14 @@ package com.android.policy.statusbar.phone; import android.os.Handler; import android.os.Message; +import android.util.Log; import com.android.internal.statusbar.IStatusBar; import com.android.internal.statusbar.StatusBarIcon; import com.android.internal.statusbar.StatusBarIconList; class CommandQueue extends IStatusBar.Stub { + private static final String TAG = "StatusBar.CommandQueue"; private static final int MSG_MASK = 0xffff0000; private static final int INDEX_MASK = 0x0000ffff; diff --git a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/PhoneStatusBarService.java b/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/PhoneStatusBarService.java index 5614203..50664b7 100644 --- a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/PhoneStatusBarService.java +++ b/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/PhoneStatusBarService.java @@ -359,16 +359,6 @@ public class PhoneStatusBarService extends StatusBarService { } } - /* private */ void performSetIconVisibility(IBinder key, boolean visible) { - synchronized (mIconMap) { - if (SPEW) { - Slog.d(TAG, "performSetIconVisibility key=" + key + " visible=" + visible); - } - StatusBarIconData icon = mIconMap.get(key); - icon.view.setVisibility(visible ? View.VISIBLE : View.GONE); - } - } - StatusBarNotification getNotification(IBinder key) { synchronized (mNotificationData) { return mNotificationData.get(key); diff --git a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/StatusBarIconView.java b/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/StatusBarIconView.java index 96d663c..4200fad 100644 --- a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/StatusBarIconView.java +++ b/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/StatusBarIconView.java @@ -54,12 +54,17 @@ public class StatusBarIconView extends AnimatedImageView { && mIcon.iconId == icon.iconId; final boolean levelEquals = iconEquals && mIcon.iconLevel == icon.iconLevel; + final boolean visibilityEquals = mIcon != null + && mIcon.visible == icon.visible; if (!iconEquals) { setImageDrawable(getIcon(icon)); } if (!levelEquals) { setImageLevel(icon.iconLevel); } + if (!visibilityEquals) { + setVisibility(icon.visible ? VISIBLE : GONE); + } mIcon = icon.clone(); } diff --git a/services/java/com/android/server/status/StatusBarManagerService.java b/services/java/com/android/server/status/StatusBarManagerService.java index 3072fe5..31e42e9 100644 --- a/services/java/com/android/server/status/StatusBarManagerService.java +++ b/services/java/com/android/server/status/StatusBarManagerService.java @@ -184,7 +184,6 @@ public class StatusBarManagerService extends IStatusBarService.Stub } public void setIcon(String slot, CharSequence text) { - } public void setIcon(String slot, String iconPackage, int iconId, int iconLevel) { @@ -212,6 +211,29 @@ public class StatusBarManagerService extends IStatusBarService.Stub public void setIconVisibility(String slot, boolean visible) { enforceStatusBar(); + synchronized (mIcons) { + int index = mIcons.getSlotIndex(slot); + if (index < 0) { + throw new SecurityException("invalid status bar icon slot: " + slot); + } + + StatusBarIcon icon = mIcons.getIcon(index); + if (icon == null) { + return; + } + + if (icon.visible != visible) { + icon.visible = visible; + + // Tell the client. If it fails, it'll restart soon and we'll sync up. + if (mBar != null) { + try { + mBar.setIcon(index, icon); + } catch (RemoteException ex) { + } + } + } + } } public void removeIcon(String slot) { @@ -380,9 +402,6 @@ public class StatusBarManagerService extends IStatusBarService.Stub return; } - Slog.d(TAG, "dump!!!"); - pw.println("status!"); - synchronized (mIcons) { mIcons.dump(pw); } |