blob: 7863102857eddfd2f361200165b94792a00d4fe8 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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
Jim Miller305c78c2011-10-16 14:54:38 -070017
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080018package android.app;
19
20import android.content.Context;
21import android.os.Binder;
22import android.os.RemoteException;
23import android.os.IBinder;
24import android.os.ServiceManager;
Joe Onorato7bb8eeb2011-01-27 16:00:58 -080025import android.view.View;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080026
Joe Onorato0cbda992010-05-02 16:28:15 -070027import com.android.internal.statusbar.IStatusBarService;
28
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080029/**
30 * Allows an app to control the status bar.
31 *
32 * @hide
33 */
34public class StatusBarManager {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080035
Joe Onorato7bb8eeb2011-01-27 16:00:58 -080036 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 Sandlerdba93562011-10-06 16:39:58 -040043 public static final int DISABLE_HOME = View.STATUS_BAR_DISABLE_HOME;
44 public static final int DISABLE_RECENT = View.STATUS_BAR_DISABLE_RECENT;
Joe Onorato6478adc2011-01-27 21:15:01 -080045 public static final int DISABLE_BACK = View.STATUS_BAR_DISABLE_BACK;
Joe Onorato7bb8eeb2011-01-27 16:00:58 -080046 public static final int DISABLE_CLOCK = View.STATUS_BAR_DISABLE_CLOCK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080047
Daniel Sandlerdba93562011-10-06 16:39:58 -040048 @Deprecated
49 public static final int DISABLE_NAVIGATION =
50 View.STATUS_BAR_DISABLE_HOME | View.STATUS_BAR_DISABLE_RECENT;
51
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080052 public static final int DISABLE_NONE = 0x00000000;
53
Joe Onorato7bb8eeb2011-01-27 16:00:58 -080054 public static final int DISABLE_MASK = DISABLE_EXPAND | DISABLE_NOTIFICATION_ICONS
55 | DISABLE_NOTIFICATION_ALERTS | DISABLE_NOTIFICATION_TICKER
Daniel Sandlerdba93562011-10-06 16:39:58 -040056 | DISABLE_SYSTEM_INFO | DISABLE_RECENT | DISABLE_HOME | DISABLE_BACK | DISABLE_CLOCK;
Joe Onorato7bb8eeb2011-01-27 16:00:58 -080057
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080058 private Context mContext;
Joe Onorato25f95f92010-04-08 18:37:10 -050059 private IStatusBarService mService;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080060 private IBinder mToken = new Binder();
61
62 StatusBarManager(Context context) {
63 mContext = context;
Joe Onorato25f95f92010-04-08 18:37:10 -050064 mService = IStatusBarService.Stub.asInterface(
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080065 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 {
Jim Miller305c78c2011-10-16 14:54:38 -070074 if (mService != null) {
75 mService.disable(what, mToken, mContext.getPackageName());
76 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080077 } catch (RemoteException ex) {
78 // system process is dead anyway.
79 throw new RuntimeException(ex);
80 }
81 }
82
83 /**
84 * Expand the status bar.
85 */
86 public void expand() {
87 try {
Joe Onoratof3f0e052010-05-14 18:49:29 -070088 mService.expand();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080089 } catch (RemoteException ex) {
90 // system process is dead anyway.
91 throw new RuntimeException(ex);
92 }
93 }
94
95 /**
96 * Collapse the status bar.
97 */
98 public void collapse() {
99 try {
Joe Onoratof3f0e052010-05-14 18:49:29 -0700100 mService.collapse();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800101 } catch (RemoteException ex) {
102 // system process is dead anyway.
103 throw new RuntimeException(ex);
104 }
105 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800106
Svetoslav Ganov6179ea32011-06-28 01:12:41 -0700107 public void setIcon(String slot, int iconId, int iconLevel, String contentDescription) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800108 try {
Svetoslav Ganov6179ea32011-06-28 01:12:41 -0700109 mService.setIcon(slot, mContext.getPackageName(), iconId, iconLevel,
110 contentDescription);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800111 } catch (RemoteException ex) {
112 // system process is dead anyway.
113 throw new RuntimeException(ex);
114 }
115 }
116
Joe Onorato0cbda992010-05-02 16:28:15 -0700117 public void removeIcon(String slot) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800118 try {
Joe Onorato0cbda992010-05-02 16:28:15 -0700119 mService.removeIcon(slot);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800120 } catch (RemoteException ex) {
121 // system process is dead anyway.
122 throw new RuntimeException(ex);
123 }
124 }
Joe Onorato798ac4c2010-05-27 16:39:00 -0400125
126 public void setIconVisibility(String slot, boolean visible) {
127 try {
128 mService.setIconVisibility(slot, visible);
129 } catch (RemoteException ex) {
130 // system process is dead anyway.
131 throw new RuntimeException(ex);
132 }
133 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800134}