diff options
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/app/StatusBarManager.java | 19 | ||||
-rw-r--r-- | core/java/com/android/internal/statusbar/IStatusBar.aidl | 27 | ||||
-rw-r--r-- | core/java/com/android/internal/statusbar/IStatusBarService.aidl (renamed from core/java/android/app/IStatusBarService.aidl) | 14 | ||||
-rw-r--r-- | core/java/com/android/internal/statusbar/StatusBarIcon.aidl (renamed from core/java/android/app/IStatusBar.aidl) | 13 | ||||
-rw-r--r-- | core/java/com/android/internal/statusbar/StatusBarIcon.java | 83 | ||||
-rw-r--r-- | core/java/com/android/internal/statusbar/StatusBarIconList.aidl | 20 | ||||
-rw-r--r-- | core/java/com/android/internal/statusbar/StatusBarIconList.java | 167 |
7 files changed, 316 insertions, 27 deletions
diff --git a/core/java/android/app/StatusBarManager.java b/core/java/android/app/StatusBarManager.java index 746b2d5..8905268 100644 --- a/core/java/android/app/StatusBarManager.java +++ b/core/java/android/app/StatusBarManager.java @@ -23,6 +23,8 @@ import android.os.RemoteException; import android.os.IBinder; import android.os.ServiceManager; +import com.android.internal.statusbar.IStatusBarService; + /** * Allows an app to control the status bar. * @@ -116,27 +118,18 @@ public class StatusBarManager { } } - public IBinder addIcon(String slot, int iconId, int iconLevel) { - try { - return mService.addIcon(slot, mContext.getPackageName(), iconId, iconLevel); - } catch (RemoteException ex) { - // system process is dead anyway. - throw new RuntimeException(ex); - } - } - - public void updateIcon(IBinder key, String slot, int iconId, int iconLevel) { + public void setIcon(String slot, int iconId, int iconLevel) { try { - mService.updateIcon(key, slot, mContext.getPackageName(), iconId, iconLevel); + mService.setIcon(slot, mContext.getPackageName(), iconId, iconLevel); } catch (RemoteException ex) { // system process is dead anyway. throw new RuntimeException(ex); } } - public void removeIcon(IBinder key) { + public void removeIcon(String slot) { try { - mService.removeIcon(key); + mService.removeIcon(slot); } catch (RemoteException ex) { // system process is dead anyway. throw new RuntimeException(ex); diff --git a/core/java/com/android/internal/statusbar/IStatusBar.aidl b/core/java/com/android/internal/statusbar/IStatusBar.aidl new file mode 100644 index 0000000..2a5ae15 --- /dev/null +++ b/core/java/com/android/internal/statusbar/IStatusBar.aidl @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2007, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.statusbar; + +import com.android.internal.statusbar.StatusBarIcon; + +/** @hide */ +oneway interface IStatusBar +{ + void setIcon(int index, in StatusBarIcon icon); + void removeIcon(int index); +} + diff --git a/core/java/android/app/IStatusBarService.aidl b/core/java/com/android/internal/statusbar/IStatusBarService.aidl index ccde41a..0a9c8da 100644 --- a/core/java/android/app/IStatusBarService.aidl +++ b/core/java/com/android/internal/statusbar/IStatusBarService.aidl @@ -14,9 +14,11 @@ * limitations under the License. */ -package android.app; +package com.android.internal.statusbar; -import android.app.IStatusBar; +import com.android.internal.statusbar.IStatusBar; +import com.android.internal.statusbar.StatusBarIcon; +import com.android.internal.statusbar.StatusBarIconList; /** @hide */ interface IStatusBarService @@ -25,10 +27,10 @@ interface IStatusBarService void deactivate(); void toggle(); void disable(int what, IBinder token, String pkg); - IBinder addIcon(String slot, String iconPackage, int iconId, int iconLevel); - void updateIcon(IBinder key, String slot, String iconPackage, int iconId, int iconLevel); - void removeIcon(IBinder key); + void setIcon(String slot, String iconPackage, int iconId, int iconLevel); + void setIconVisibility(String slot, boolean visible); + void removeIcon(String slot); // ---- Methods below are for use by the status bar policy services ---- - void registerStatusBar(IStatusBar callbacks); + void registerStatusBar(IStatusBar callbacks, out StatusBarIconList state); } diff --git a/core/java/android/app/IStatusBar.aidl b/core/java/com/android/internal/statusbar/StatusBarIcon.aidl index 8d571ef..311a077 100644 --- a/core/java/android/app/IStatusBar.aidl +++ b/core/java/com/android/internal/statusbar/StatusBarIcon.aidl @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2007, The Android Open Source Project +/* + * Copyright (c) 2010, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,11 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -package android.app; -/** @hide */ -interface IStatusBar -{ -} +package com.android.internal.statusbar; + +parcelable StatusBarIcon; diff --git a/core/java/com/android/internal/statusbar/StatusBarIcon.java b/core/java/com/android/internal/statusbar/StatusBarIcon.java new file mode 100644 index 0000000..330b407 --- /dev/null +++ b/core/java/com/android/internal/statusbar/StatusBarIcon.java @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.statusbar; + +import android.os.Parcel; +import android.os.Parcelable; + +/** + * @hide + */ +public class StatusBarIcon implements Parcelable { + public String iconPackage; + public int iconId; + public int iconLevel; + + private StatusBarIcon() { + } + + public StatusBarIcon(String iconPackage, int iconId, int iconLevel) { + this.iconPackage = iconPackage; + this.iconId = iconId; + this.iconLevel = iconLevel; + } + + public StatusBarIcon clone() { + return new StatusBarIcon(this.iconPackage, this.iconId, this.iconLevel); + } + + /** + * Unflatten the StatusBarIcon from a parcel. + */ + public StatusBarIcon(Parcel in) { + readFromParcel(in); + } + + public void readFromParcel(Parcel in) { + this.iconPackage = in.readString(); + this.iconId = in.readInt(); + this.iconLevel = in.readInt(); + } + + public void writeToParcel(Parcel out, int flags) { + out.writeString(this.iconPackage); + out.writeInt(this.iconId); + out.writeInt(this.iconLevel); + } + + public int describeContents() { + return 0; + } + + /** + * Parcelable.Creator that instantiates StatusBarIcon objects + */ + public static final Parcelable.Creator<StatusBarIcon> CREATOR + = new Parcelable.Creator<StatusBarIcon>() + { + public StatusBarIcon createFromParcel(Parcel parcel) + { + return new StatusBarIcon(parcel); + } + + public StatusBarIcon[] newArray(int size) + { + return new StatusBarIcon[size]; + } + }; +} + diff --git a/core/java/com/android/internal/statusbar/StatusBarIconList.aidl b/core/java/com/android/internal/statusbar/StatusBarIconList.aidl new file mode 100644 index 0000000..c745120 --- /dev/null +++ b/core/java/com/android/internal/statusbar/StatusBarIconList.aidl @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2010, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.statusbar; + +parcelable StatusBarIconList; + diff --git a/core/java/com/android/internal/statusbar/StatusBarIconList.java b/core/java/com/android/internal/statusbar/StatusBarIconList.java new file mode 100644 index 0000000..61002d5 --- /dev/null +++ b/core/java/com/android/internal/statusbar/StatusBarIconList.java @@ -0,0 +1,167 @@ +/* + * Copyright (C) 2007 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.statusbar; + +import android.os.Parcel; +import android.os.Parcelable; + +import java.io.PrintWriter; + +public class StatusBarIconList implements Parcelable { + private String[] mSlots; + private StatusBarIcon[] mIcons; + + public StatusBarIconList() { + } + + public StatusBarIconList(Parcel in) { + readFromParcel(in); + } + + public void readFromParcel(Parcel in) { + this.mSlots = in.readStringArray(); + final int N = in.readInt(); + if (N < 0) { + mIcons = null; + } else { + mIcons = new StatusBarIcon[N]; + for (int i=0; i<N; i++) { + if (in.readInt() != 0) { + mIcons[i] = new StatusBarIcon(in); + } + } + } + } + + public void writeToParcel(Parcel out, int flags) { + out.writeStringArray(mSlots); + if (mIcons == null) { + out.writeInt(-1); + } else { + final int N = mIcons.length; + out.writeInt(N); + for (int i=0; i<N; i++) { + StatusBarIcon ic = mIcons[i]; + if (ic == null) { + out.writeInt(0); + } else { + out.writeInt(1); + ic.writeToParcel(out, flags); + } + } + } + } + + public int describeContents() { + return 0; + } + + /** + * Parcelable.Creator that instantiates StatusBarIconList objects + */ + public static final Parcelable.Creator<StatusBarIconList> CREATOR + = new Parcelable.Creator<StatusBarIconList>() + { + public StatusBarIconList createFromParcel(Parcel parcel) + { + return new StatusBarIconList(parcel); + } + + public StatusBarIconList[] newArray(int size) + { + return new StatusBarIconList[size]; + } + }; + + public void defineSlots(String[] slots) { + final int N = slots.length; + String[] s = mSlots = new String[N]; + for (int i=0; i<N; i++) { + s[i] = slots[i]; + } + mIcons = new StatusBarIcon[N]; + } + + public int getSlotIndex(String slot) { + final int N = mSlots.length; + for (int i=0; i<N; i++) { + if (slot.equals(mSlots[i])) { + return i; + } + } + return -1; + } + + public int size() { + return mSlots.length; + } + + public void setIcon(int index, StatusBarIcon icon) { + mIcons[index] = icon.clone(); + } + + public void removeIcon(int index) { + mIcons[index] = null; + } + + public String getSlot(int index) { + return mSlots[index]; + } + + public StatusBarIcon getIcon(int index) { + return mIcons[index]; + } + + public int getViewIndex(int index) { + int count = 0; + for (int i=0; i<index; i++) { + if (mIcons[i] != null) { + count++; + } + } + return count; + } + + public void copyFrom(StatusBarIconList that) { + if (that.mSlots == null) { + this.mSlots = null; + this.mIcons = null; + } else { + final int N = that.mSlots.length; + this.mSlots = new String[N]; + this.mIcons = new StatusBarIcon[N]; + for (int i=0; i<N; i++) { + this.mSlots[i] = that.mSlots[i]; + this.mIcons[i] = that.mIcons[i] != null ? that.mIcons[i].clone() : null; + } + } + } + + public void dump(PrintWriter pw) { + 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); + } + } + } +} |