The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 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 | |
| 18 | package android.app; |
| 19 | |
| 20 | import android.content.Context; |
| 21 | import android.os.Binder; |
| 22 | import android.os.RemoteException; |
| 23 | import android.os.IBinder; |
| 24 | import android.os.ServiceManager; |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 25 | import android.view.View; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 27 | import com.android.internal.statusbar.IStatusBarService; |
| 28 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 | /** |
| 30 | * Allows an app to control the status bar. |
| 31 | * |
| 32 | * @hide |
| 33 | */ |
| 34 | public class StatusBarManager { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 35 | |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 36 | public static final int DISABLE_EXPAND = View.STATUS_BAR_DISABLE_EXPAND; |
| 37 | public static final int DISABLE_NOTIFICATION_ICONS = View.STATUS_BAR_DISABLE_NOTIFICATION_ICONS; |
| 38 | public static final int DISABLE_NOTIFICATION_ALERTS |
| 39 | = View.STATUS_BAR_DISABLE_NOTIFICATION_ALERTS; |
| 40 | public static final int DISABLE_NOTIFICATION_TICKER |
| 41 | = View.STATUS_BAR_DISABLE_NOTIFICATION_TICKER; |
| 42 | public static final int DISABLE_SYSTEM_INFO = View.STATUS_BAR_DISABLE_SYSTEM_INFO; |
Daniel Sandler | dba9356 | 2011-10-06 16:39:58 -0400 | [diff] [blame^] | 43 | public static final int DISABLE_HOME = View.STATUS_BAR_DISABLE_HOME; |
| 44 | public static final int DISABLE_RECENT = View.STATUS_BAR_DISABLE_RECENT; |
Joe Onorato | 6478adc | 2011-01-27 21:15:01 -0800 | [diff] [blame] | 45 | public static final int DISABLE_BACK = View.STATUS_BAR_DISABLE_BACK; |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 46 | public static final int DISABLE_CLOCK = View.STATUS_BAR_DISABLE_CLOCK; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 47 | |
Daniel Sandler | dba9356 | 2011-10-06 16:39:58 -0400 | [diff] [blame^] | 48 | @Deprecated |
| 49 | public static final int DISABLE_NAVIGATION = |
| 50 | View.STATUS_BAR_DISABLE_HOME | View.STATUS_BAR_DISABLE_RECENT; |
| 51 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 52 | public static final int DISABLE_NONE = 0x00000000; |
| 53 | |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 54 | public static final int DISABLE_MASK = DISABLE_EXPAND | DISABLE_NOTIFICATION_ICONS |
| 55 | | DISABLE_NOTIFICATION_ALERTS | DISABLE_NOTIFICATION_TICKER |
Daniel Sandler | dba9356 | 2011-10-06 16:39:58 -0400 | [diff] [blame^] | 56 | | DISABLE_SYSTEM_INFO | DISABLE_RECENT | DISABLE_HOME | DISABLE_BACK | DISABLE_CLOCK; |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 57 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 58 | private Context mContext; |
Joe Onorato | 25f95f9 | 2010-04-08 18:37:10 -0500 | [diff] [blame] | 59 | private IStatusBarService mService; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 60 | private IBinder mToken = new Binder(); |
| 61 | |
| 62 | StatusBarManager(Context context) { |
| 63 | mContext = context; |
Joe Onorato | 25f95f9 | 2010-04-08 18:37:10 -0500 | [diff] [blame] | 64 | mService = IStatusBarService.Stub.asInterface( |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 65 | ServiceManager.getService(Context.STATUS_BAR_SERVICE)); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Disable some features in the status bar. Pass the bitwise-or of the DISABLE_* flags. |
| 70 | * To re-enable everything, pass {@link #DISABLE_NONE}. |
| 71 | */ |
| 72 | public void disable(int what) { |
| 73 | try { |
| 74 | mService.disable(what, mToken, mContext.getPackageName()); |
| 75 | } catch (RemoteException ex) { |
| 76 | // system process is dead anyway. |
| 77 | throw new RuntimeException(ex); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Expand the status bar. |
| 83 | */ |
| 84 | public void expand() { |
| 85 | try { |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 86 | mService.expand(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 87 | } catch (RemoteException ex) { |
| 88 | // system process is dead anyway. |
| 89 | throw new RuntimeException(ex); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Collapse the status bar. |
| 95 | */ |
| 96 | public void collapse() { |
| 97 | try { |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 98 | mService.collapse(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 99 | } catch (RemoteException ex) { |
| 100 | // system process is dead anyway. |
| 101 | throw new RuntimeException(ex); |
| 102 | } |
| 103 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 104 | |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 105 | public void setIcon(String slot, int iconId, int iconLevel, String contentDescription) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 106 | try { |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 107 | mService.setIcon(slot, mContext.getPackageName(), iconId, iconLevel, |
| 108 | contentDescription); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 109 | } catch (RemoteException ex) { |
| 110 | // system process is dead anyway. |
| 111 | throw new RuntimeException(ex); |
| 112 | } |
| 113 | } |
| 114 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 115 | public void removeIcon(String slot) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 116 | try { |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 117 | mService.removeIcon(slot); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 118 | } catch (RemoteException ex) { |
| 119 | // system process is dead anyway. |
| 120 | throw new RuntimeException(ex); |
| 121 | } |
| 122 | } |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 123 | |
| 124 | public void setIconVisibility(String slot, boolean visible) { |
| 125 | try { |
| 126 | mService.setIconVisibility(slot, visible); |
| 127 | } catch (RemoteException ex) { |
| 128 | // system process is dead anyway. |
| 129 | throw new RuntimeException(ex); |
| 130 | } |
| 131 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 132 | } |