StatusBarTest.java revision 91e1d0cddaaec5e077ca689744463901f9d5d580
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 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; 26import android.app.Notification; 27import android.app.NotificationManager; 28import android.app.StatusBarManager; 29import android.os.Vibrator; 30import android.os.Bundle; 31import android.os.Handler; 32import android.util.Log; 33import android.net.Uri; 34import android.os.SystemClock; 35import android.widget.RemoteViews; 36import android.widget.Toast; 37import android.os.PowerManager; 38 39public class StatusBarTest extends TestActivity 40{ 41 private final static String TAG = "StatusBarTest"; 42 StatusBarManager mStatusBarManager; 43 NotificationManager mNotificationManager; 44 Handler mHandler = new Handler(); 45 46 @Override 47 protected String tag() { 48 return TAG; 49 } 50 51 @Override 52 protected Test[] tests() { 53 mStatusBarManager = (StatusBarManager)getSystemService(STATUS_BAR_SERVICE); 54 mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); 55 56 return mTests; 57 } 58 59 private Test[] mTests = new Test[] { 60 new Test("Disable Alerts") { 61 public void run() { 62 mStatusBarManager.disable(StatusBarManager.DISABLE_NOTIFICATION_ALERTS); 63 } 64 }, 65 new Test("Disable Ticker") { 66 public void run() { 67 mStatusBarManager.disable(StatusBarManager.DISABLE_NOTIFICATION_TICKER); 68 } 69 }, 70 new Test("Disable Expand in 3 sec.") { 71 public void run() { 72 mHandler.postDelayed(new Runnable() { 73 public void run() { 74 mStatusBarManager.disable(StatusBarManager.DISABLE_EXPAND); 75 } 76 }, 3000); 77 } 78 }, 79 new Test("Disable Notifications in 3 sec.") { 80 public void run() { 81 mHandler.postDelayed(new Runnable() { 82 public void run() { 83 mStatusBarManager.disable(StatusBarManager.DISABLE_NOTIFICATION_ICONS); 84 } 85 }, 3000); 86 } 87 }, 88 new Test("Disable Expand + Notifications in 3 sec.") { 89 public void run() { 90 mHandler.postDelayed(new Runnable() { 91 public void run() { 92 mStatusBarManager.disable(StatusBarManager.DISABLE_EXPAND 93 | StatusBarManager.DISABLE_NOTIFICATION_ICONS); 94 } 95 }, 3000); 96 } 97 }, 98 new Test("Enable everything") { 99 public void run() { 100 mStatusBarManager.disable(0); 101 } 102 }, 103 new Test("Enable everything in 3 sec.") { 104 public void run() { 105 mHandler.postDelayed(new Runnable() { 106 public void run() { 107 mStatusBarManager.disable(0); 108 } 109 }, 3000); 110 } 111 }, 112 new Test("Notify in 3 sec.") { 113 public void run() { 114 mHandler.postDelayed(new Runnable() { 115 public void run() { 116 mNotificationManager.notify(1, 117 new Notification(StatusBarTest.this, 118 R.drawable.ic_statusbar_missedcall, 119 "tick tick tick", 120 System.currentTimeMillis()-(1000*60*60*24), 121 "(453) 123-2328", 122 "", null 123 )); 124 } 125 }, 3000); 126 } 127 }, 128 new Test("Cancel Notification in 3 sec.") { 129 public void run() { 130 mHandler.postDelayed(new Runnable() { 131 public void run() { 132 mNotificationManager.cancel(1); 133 } 134 }, 3000); 135 } 136 }, 137 new Test("Expand in 3 sec.") { 138 public void run() { 139 mHandler.postDelayed(new Runnable() { 140 public void run() { 141 mStatusBarManager.expand(); 142 } 143 }, 3000); 144 } 145 }, 146 new Test("Expand in 3 sec.") { 147 public void run() { 148 mHandler.postDelayed(new Runnable() { 149 public void run() { 150 mStatusBarManager.expand(); 151 } 152 }, 3000); 153 } 154 }, 155 new Test("Collapse in 3 sec.") { 156 public void run() { 157 mHandler.postDelayed(new Runnable() { 158 public void run() { 159 mStatusBarManager.collapse(); 160 } 161 }, 3000); 162 } 163 }, 164 new Test("Toggle in 3 sec.") { 165 public void run() { 166 mHandler.postDelayed(new Runnable() { 167 public void run() { 168 mStatusBarManager.toggle(); 169 } 170 }, 3000); 171 } 172 }, 173 }; 174} 175