blob: 13665e183559222359b1e29845efe97fa050b205 [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
17package com.android.statusbartest;
18
19import android.app.ListActivity;
20import android.app.Notification;
21import android.app.NotificationManager;
22import android.widget.ArrayAdapter;
23import android.view.View;
24import android.widget.ListView;
25import android.content.Intent;
Daniel Sandler88967832010-06-23 15:29:59 -040026import android.app.PendingIntent;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080027import android.app.Notification;
28import android.app.NotificationManager;
29import android.app.StatusBarManager;
Joe Onorato664644d2011-01-23 17:53:23 -080030import android.content.Context;
31import android.util.AttributeSet;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080032import android.os.Vibrator;
33import android.os.Bundle;
34import android.os.Handler;
35import android.util.Log;
36import android.net.Uri;
37import android.os.SystemClock;
38import android.widget.RemoteViews;
39import android.widget.Toast;
40import android.os.PowerManager;
Joe Onorato664644d2011-01-23 17:53:23 -080041import android.view.View;
Daniel Sandler88967832010-06-23 15:29:59 -040042import android.view.Window;
43import android.view.WindowManager;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080044
45public class StatusBarTest extends TestActivity
46{
47 private final static String TAG = "StatusBarTest";
48 StatusBarManager mStatusBarManager;
49 NotificationManager mNotificationManager;
50 Handler mHandler = new Handler();
51
Joe Onorato664644d2011-01-23 17:53:23 -080052 View.OnSystemUiVisibilityChangeListener mOnSystemUiVisibilityChangeListener
53 = new View.OnSystemUiVisibilityChangeListener() {
54 public void onSystemUiVisibilityChange(int visibility) {
55 Log.d(TAG, "onSystemUiVisibilityChange visibility=" + visibility);
56 }
57 };
58
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080059 @Override
60 protected String tag() {
61 return TAG;
62 }
63
64 @Override
65 protected Test[] tests() {
66 mStatusBarManager = (StatusBarManager)getSystemService(STATUS_BAR_SERVICE);
67 mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
68
69 return mTests;
70 }
71
72 private Test[] mTests = new Test[] {
Joe Onorato7bb8eeb2011-01-27 16:00:58 -080073 new Test("DISABLE_NAVIGATION") {
74 public void run() {
75 View v = findViewById(android.R.id.list);
76 v.setSystemUiVisibility(View.STATUS_BAR_DISABLE_NAVIGATION);
77 }
78 },
Joe Onorato664644d2011-01-23 17:53:23 -080079 new Test("STATUS_BAR_HIDDEN") {
80 public void run() {
81 View v = findViewById(android.R.id.list);
82 v.setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
83 v.setOnSystemUiVisibilityChangeListener(mOnSystemUiVisibilityChangeListener);
84 }
85 },
Joe Onorato7bb8eeb2011-01-27 16:00:58 -080086 new Test("no setSystemUiVisibility") {
Joe Onorato664644d2011-01-23 17:53:23 -080087 public void run() {
88 View v = findViewById(android.R.id.list);
89 v.setSystemUiVisibility(View.STATUS_BAR_VISIBLE);
90 v.setOnSystemUiVisibilityChangeListener(null);
91 }
92 },
Joe Onorato795f2842010-09-27 11:34:46 -070093 new Test("Double Remove") {
94 public void run() {
95 Log.d(TAG, "set 0");
96 mStatusBarManager.setIcon("speakerphone", R.drawable.stat_sys_phone, 0);
97 Log.d(TAG, "remove 1");
98 mStatusBarManager.removeIcon("tty");
99
100 SystemClock.sleep(1000);
101
102 Log.d(TAG, "set 1");
103 mStatusBarManager.setIcon("tty", R.drawable.stat_sys_phone, 0);
104 if (false) {
105 Log.d(TAG, "set 2");
106 mStatusBarManager.setIcon("tty", R.drawable.stat_sys_phone, 0);
107 }
108 Log.d(TAG, "remove 2");
109 mStatusBarManager.removeIcon("tty");
110 Log.d(TAG, "set 3");
111 mStatusBarManager.setIcon("speakerphone", R.drawable.stat_sys_phone, 0);
112 }
113 },
Joe Onorato93056472010-09-10 10:30:46 -0400114 new Test("Hide (FLAG_FULLSCREEN)") {
Daniel Sandler88967832010-06-23 15:29:59 -0400115 public void run() {
116 Window win = getWindow();
Joe Onorato93056472010-09-10 10:30:46 -0400117 win.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
118 WindowManager.LayoutParams.FLAG_FULLSCREEN);
119 Log.d(TAG, "flags=" + Integer.toHexString(win.getAttributes().flags));
Daniel Sandler88967832010-06-23 15:29:59 -0400120 }
121 },
Joe Onorato93056472010-09-10 10:30:46 -0400122 new Test("Show (~FLAG_FULLSCREEN)") {
Daniel Sandler88967832010-06-23 15:29:59 -0400123 public void run() {
124 Window win = getWindow();
Joe Onorato93056472010-09-10 10:30:46 -0400125 win.setFlags(0, WindowManager.LayoutParams.FLAG_FULLSCREEN);
126 Log.d(TAG, "flags=" + Integer.toHexString(win.getAttributes().flags));
Daniel Sandler88967832010-06-23 15:29:59 -0400127 }
128 },
129 new Test("Immersive: Enter") {
130 public void run() {
131 setImmersive(true);
132 }
133 },
134 new Test("Immersive: Exit") {
135 public void run() {
136 setImmersive(false);
137 }
138 },
139 new Test("Priority notification") {
140 public void run() {
141 Notification not = new Notification(StatusBarTest.this,
Daniel Sandlerb59b9442010-06-30 16:25:33 -0400142 R.drawable.stat_sys_phone,
143 "Incoming call from: Imperious Leader",
Daniel Sandler88967832010-06-23 15:29:59 -0400144 System.currentTimeMillis()-(1000*60*60*24),
Daniel Sandlerb59b9442010-06-30 16:25:33 -0400145 "Imperious Leader",
146 "(888) 555-5038",
147 null
Daniel Sandler88967832010-06-23 15:29:59 -0400148 );
149 not.flags |= Notification.FLAG_HIGH_PRIORITY;
150 Intent fullScreenIntent = new Intent(StatusBarTest.this, TestAlertActivity.class);
151 int id = (int)System.currentTimeMillis(); // XXX HAX
152 fullScreenIntent.putExtra("id", id);
153 not.fullScreenIntent = PendingIntent.getActivity(
154 StatusBarTest.this,
155 0,
156 fullScreenIntent,
157 PendingIntent.FLAG_CANCEL_CURRENT);
Daniel Sandler27a8be42010-06-29 15:19:54 -0400158 // if you tap on it you should get the original alert box
159 not.contentIntent = not.fullScreenIntent;
Daniel Sandler88967832010-06-23 15:29:59 -0400160 mNotificationManager.notify(id, not);
161 }
162 },
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800163 new Test("Disable Alerts") {
164 public void run() {
165 mStatusBarManager.disable(StatusBarManager.DISABLE_NOTIFICATION_ALERTS);
166 }
167 },
Daniel Sandler91e1d0c2010-02-04 15:41:20 -0800168 new Test("Disable Ticker") {
169 public void run() {
170 mStatusBarManager.disable(StatusBarManager.DISABLE_NOTIFICATION_TICKER);
171 }
172 },
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800173 new Test("Disable Expand in 3 sec.") {
174 public void run() {
175 mHandler.postDelayed(new Runnable() {
176 public void run() {
177 mStatusBarManager.disable(StatusBarManager.DISABLE_EXPAND);
178 }
179 }, 3000);
180 }
181 },
182 new Test("Disable Notifications in 3 sec.") {
183 public void run() {
184 mHandler.postDelayed(new Runnable() {
185 public void run() {
186 mStatusBarManager.disable(StatusBarManager.DISABLE_NOTIFICATION_ICONS);
187 }
188 }, 3000);
189 }
190 },
Daniel Sandler91e1d0c2010-02-04 15:41:20 -0800191 new Test("Disable Expand + Notifications in 3 sec.") {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800192 public void run() {
193 mHandler.postDelayed(new Runnable() {
194 public void run() {
195 mStatusBarManager.disable(StatusBarManager.DISABLE_EXPAND
196 | StatusBarManager.DISABLE_NOTIFICATION_ICONS);
197 }
198 }, 3000);
199 }
200 },
Joe Onorato091e1b82010-09-26 18:04:44 -0700201 new Test("Disable Navigation") {
202 public void run() {
203 mStatusBarManager.disable(StatusBarManager.DISABLE_NAVIGATION);
204 }
205 },
Daniel Sandler3e8f5a22010-12-03 14:52:10 -0500206 new Test("Disable Clock") {
207 public void run() {
208 mStatusBarManager.disable(StatusBarManager.DISABLE_CLOCK);
209 }
210 },
Daniel Sandler6f6cf3c2010-12-16 12:54:03 -0500211 new Test("Disable System Info") {
212 public void run() {
213 mStatusBarManager.disable(StatusBarManager.DISABLE_SYSTEM_INFO);
214 }
215 },
Joe Onorato091e1b82010-09-26 18:04:44 -0700216 new Test("Disable everything in 3 sec") {
217 public void run() {
218 mHandler.postDelayed(new Runnable() {
219 public void run() {
Daniel Sandler3e8f5a22010-12-03 14:52:10 -0500220 mStatusBarManager.disable(~StatusBarManager.DISABLE_NONE);
Joe Onorato091e1b82010-09-26 18:04:44 -0700221 }
222 }, 3000);
223 }
224 },
Daniel Sandler91e1d0c2010-02-04 15:41:20 -0800225 new Test("Enable everything") {
226 public void run() {
Daniel Sandler3e8f5a22010-12-03 14:52:10 -0500227 mStatusBarManager.disable(StatusBarManager.DISABLE_NONE);
Daniel Sandler91e1d0c2010-02-04 15:41:20 -0800228 }
229 },
230 new Test("Enable everything in 3 sec.") {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800231 public void run() {
232 mHandler.postDelayed(new Runnable() {
233 public void run() {
234 mStatusBarManager.disable(0);
235 }
236 }, 3000);
237 }
238 },
239 new Test("Notify in 3 sec.") {
240 public void run() {
241 mHandler.postDelayed(new Runnable() {
242 public void run() {
243 mNotificationManager.notify(1,
244 new Notification(StatusBarTest.this,
245 R.drawable.ic_statusbar_missedcall,
246 "tick tick tick",
247 System.currentTimeMillis()-(1000*60*60*24),
248 "(453) 123-2328",
249 "", null
250 ));
251 }
252 }, 3000);
253 }
254 },
255 new Test("Cancel Notification in 3 sec.") {
256 public void run() {
257 mHandler.postDelayed(new Runnable() {
258 public void run() {
259 mNotificationManager.cancel(1);
260 }
261 }, 3000);
262 }
263 },
Joe Onorato4762c2d2010-05-17 15:42:59 -0700264 new Test("Expand") {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800265 public void run() {
Joe Onorato4762c2d2010-05-17 15:42:59 -0700266 mStatusBarManager.expand();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800267 }
268 },
269 new Test("Expand in 3 sec.") {
270 public void run() {
271 mHandler.postDelayed(new Runnable() {
272 public void run() {
273 mStatusBarManager.expand();
274 }
275 }, 3000);
276 }
277 },
278 new Test("Collapse in 3 sec.") {
279 public void run() {
280 mHandler.postDelayed(new Runnable() {
281 public void run() {
282 mStatusBarManager.collapse();
283 }
284 }, 3000);
285 }
286 },
Joe Onorato0faeb072010-06-07 12:36:51 -0700287 new Test("More icons") {
288 public void run() {
289 for (String slot: new String[] {
290 "sync_failing",
291 "gps",
292 "bluetooth",
293 "tty",
294 "speakerphone",
295 "mute",
296 "wifi",
297 "alarm_clock",
298 "secure",
299 }) {
300 mStatusBarManager.setIconVisibility(slot, true);
301 }
302 }
303 },
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800304 };
305}