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; |
| 43 | public static final int DISABLE_NAVIGATION = View.STATUS_BAR_DISABLE_NAVIGATION; |
Joe Onorato | 6478adc | 2011-01-27 21:15:01 -0800 | [diff] [blame] | 44 | public static final int DISABLE_BACK = View.STATUS_BAR_DISABLE_BACK; |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 45 | 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] | 46 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 47 | public static final int DISABLE_NONE = 0x00000000; |
| 48 | |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 49 | public static final int DISABLE_MASK = DISABLE_EXPAND | DISABLE_NOTIFICATION_ICONS |
| 50 | | DISABLE_NOTIFICATION_ALERTS | DISABLE_NOTIFICATION_TICKER |
Joe Onorato | 6478adc | 2011-01-27 21:15:01 -0800 | [diff] [blame] | 51 | | DISABLE_SYSTEM_INFO| DISABLE_NAVIGATION | DISABLE_BACK | DISABLE_CLOCK; |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 52 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | private Context mContext; |
Joe Onorato | 25f95f9 | 2010-04-08 18:37:10 -0500 | [diff] [blame] | 54 | private IStatusBarService mService; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | private IBinder mToken = new Binder(); |
| 56 | |
| 57 | StatusBarManager(Context context) { |
| 58 | mContext = context; |
Joe Onorato | 25f95f9 | 2010-04-08 18:37:10 -0500 | [diff] [blame] | 59 | mService = IStatusBarService.Stub.asInterface( |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 60 | ServiceManager.getService(Context.STATUS_BAR_SERVICE)); |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Disable some features in the status bar. Pass the bitwise-or of the DISABLE_* flags. |
| 65 | * To re-enable everything, pass {@link #DISABLE_NONE}. |
| 66 | */ |
| 67 | public void disable(int what) { |
| 68 | try { |
| 69 | mService.disable(what, mToken, mContext.getPackageName()); |
| 70 | } catch (RemoteException ex) { |
| 71 | // system process is dead anyway. |
| 72 | throw new RuntimeException(ex); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Expand the status bar. |
| 78 | */ |
| 79 | public void expand() { |
| 80 | try { |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 81 | mService.expand(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 82 | } catch (RemoteException ex) { |
| 83 | // system process is dead anyway. |
| 84 | throw new RuntimeException(ex); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Collapse the status bar. |
| 90 | */ |
| 91 | public void collapse() { |
| 92 | try { |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 93 | mService.collapse(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 94 | } catch (RemoteException ex) { |
| 95 | // system process is dead anyway. |
| 96 | throw new RuntimeException(ex); |
| 97 | } |
| 98 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 99 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 100 | public void setIcon(String slot, int iconId, int iconLevel) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 101 | try { |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 102 | mService.setIcon(slot, mContext.getPackageName(), iconId, iconLevel); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 103 | } catch (RemoteException ex) { |
| 104 | // system process is dead anyway. |
| 105 | throw new RuntimeException(ex); |
| 106 | } |
| 107 | } |
| 108 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 109 | public void removeIcon(String slot) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 110 | try { |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 111 | mService.removeIcon(slot); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 112 | } catch (RemoteException ex) { |
| 113 | // system process is dead anyway. |
| 114 | throw new RuntimeException(ex); |
| 115 | } |
| 116 | } |
Joe Onorato | 798ac4c | 2010-05-27 16:39:00 -0400 | [diff] [blame] | 117 | |
| 118 | public void setIconVisibility(String slot, boolean visible) { |
| 119 | try { |
| 120 | mService.setIconVisibility(slot, visible); |
| 121 | } catch (RemoteException ex) { |
| 122 | // system process is dead anyway. |
| 123 | throw new RuntimeException(ex); |
| 124 | } |
| 125 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 126 | } |