NotificationTestList.java revision 373a9983742b3d2370c36183aca3cde4614e6185
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.Notification;
20import android.app.NotificationManager;
21import android.app.PendingIntent;
22import android.content.Context;
23import android.content.ContentResolver;
24import android.content.Intent;
25import android.graphics.Bitmap;
26import android.graphics.drawable.BitmapDrawable;
27import android.os.Environment;
28import android.os.Vibrator;
29import android.os.Handler;
30import android.util.Log;
31import android.net.Uri;
32import android.os.SystemClock;
33import android.widget.RemoteViews;
34import android.widget.TextView;
35import android.widget.ProgressBar;
36import android.os.PowerManager;
37
38public class NotificationTestList extends TestActivity
39{
40    private final static String TAG = "NotificationTestList";
41
42    NotificationManager mNM;
43    Vibrator mVibrator = new Vibrator();
44    Handler mHandler = new Handler();
45
46    long mActivityCreateTime = System.currentTimeMillis();
47    long mChronometerBase = 0;
48
49    boolean mProgressDone = true;
50
51    final int[] kNumberedIconResIDs = {
52        R.drawable.notification0,
53        R.drawable.notification1,
54        R.drawable.notification2,
55        R.drawable.notification3,
56        R.drawable.notification4,
57        R.drawable.notification5,
58        R.drawable.notification6,
59        R.drawable.notification7,
60        R.drawable.notification8,
61        R.drawable.notification9
62    };
63    final int kUnnumberedIconResID = R.drawable.notificationx;
64
65    @Override
66    protected String tag() {
67        return TAG;
68    }
69
70    @Override
71    protected Test[] tests() {
72        mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
73
74        return mTests;
75    }
76
77    private Test[] mTests = new Test[] {
78        new Test("Off and sound") {
79            public void run() {
80                PowerManager pm = (PowerManager)NotificationTestList.this.getSystemService(Context.POWER_SERVICE);
81                PowerManager.WakeLock wl =
82                            pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "sound");
83                wl.acquire();
84
85                pm.goToSleep(SystemClock.uptimeMillis());
86
87                Notification n = new Notification();
88                n.sound = Uri.parse("file://" + Environment.getExternalStorageDirectory() +
89                        "/virtual-void.mp3");
90                Log.d(TAG, "n.sound=" + n.sound);
91
92                mNM.notify(1, n);
93
94                Log.d(TAG, "releasing wake lock");
95                wl.release();
96                Log.d(TAG, "released wake lock");
97            }
98        },
99
100        new Test("Cancel #1") {
101            public void run()
102            {
103                mNM.cancel(1);
104            }
105        },
106
107        new Test("Button") {
108            public void run() {
109                Notification n = new Notification(R.drawable.icon1, null,
110                        mActivityCreateTime);
111                n.contentView = new RemoteViews(getPackageName(), R.layout.button_notification);
112                n.flags |= Notification.FLAG_ONGOING_EVENT;
113                n.contentIntent = makeIntent();
114                n.contentView.setOnClickPendingIntent(R.id.button, makeIntent2());
115
116                mNM.notify(1, n);
117            }
118        },
119
120        new Test("custom intent on text view") {
121            public void run() {
122                Notification n = new Notification(R.drawable.icon1, null,
123                        mActivityCreateTime);
124                n.setLatestEventInfo(NotificationTestList.this, "Persistent #1",
125                            "This is a notification!!!", null);
126                n.contentView.setOnClickPendingIntent(com.android.internal.R.id.text,
127                        makeIntent2());
128                mNM.notify(1, n);
129            }
130        },
131
132        new Test("Ticker 1 line") {
133            public void run() {
134                Notification n = new Notification(R.drawable.icon1, "tick tick tick",
135                        mActivityCreateTime);
136                n.setLatestEventInfo(NotificationTestList.this, "Persistent #1",
137                            "This is a notification!!!", makeIntent());
138                mNM.notify(1, n);
139            }
140        },
141
142        new Test("No view") {
143            public void run() {
144                Notification n = new Notification(R.drawable.icon1, "No view",
145                        System.currentTimeMillis());
146                mNM.notify(1, n);
147            }
148        },
149
150        new Test("No intent") {
151            public void run() {
152                Notification n = new Notification(R.drawable.icon1, "No intent",
153                        System.currentTimeMillis());
154                n.setLatestEventInfo(NotificationTestList.this, "No intent",
155                            "No intent", null);
156                mNM.notify(1, n);
157            }
158        },
159
160        new Test("Layout") {
161            public void run()
162            {
163                Notification n;
164
165                n = new Notification(NotificationTestList.this,
166                            R.drawable.ic_statusbar_missedcall,
167                            null, System.currentTimeMillis()-(1000*60*60*24),
168                            "(453) 123-2328",
169                            "", null);
170                n.flags |= Notification.FLAG_ONGOING_EVENT;
171
172                mNM.notify(1, n);
173
174                mNM.notify(2, new Notification(NotificationTestList.this,
175                            R.drawable.ic_statusbar_email,
176                            null, System.currentTimeMillis(),
177                            "Mark Willem, Me (2)",
178                            "Re: Didn't you get the memo?", null));
179
180                mNM.notify(3, new Notification(NotificationTestList.this,
181                            R.drawable.ic_statusbar_chat,
182                            null, System.currentTimeMillis()+(1000*60*60*24),
183                            "Sophia Winterlanden",
184                            "Lorem ipsum dolor sit amet.", null));
185            }
186        },
187
188        new Test("Bad Icon #1 (when=create)") {
189            public void run() {
190                Notification n = new Notification(R.layout.chrono_notification /* not an icon */,
191                        null, mActivityCreateTime);
192                n.setLatestEventInfo(NotificationTestList.this, "Persistent #1",
193                            "This is the same notification!!!", makeIntent());
194                mNM.notify(1, n);
195            }
196        },
197
198        new Test("Bad Icon #1 (when=now)") {
199            public void run() {
200                Notification n = new Notification(R.layout.chrono_notification /* not an icon */,
201                        null, System.currentTimeMillis());
202                n.setLatestEventInfo(NotificationTestList.this, "Persistent #1",
203                            "This is the same notification!!!", makeIntent());
204                mNM.notify(1, n);
205            }
206        },
207
208        new Test("Bad resource #1 (when=create)") {
209            public void run() {
210                Notification n = new Notification(R.drawable.icon2,
211                        null, mActivityCreateTime);
212                n.setLatestEventInfo(NotificationTestList.this, "Persistent #1",
213                            "This is the same notification!!!", makeIntent());
214                n.contentView.setInt(1 /*bogus*/, "bogus method", 666);
215                mNM.notify(1, n);
216            }
217        },
218
219        new Test("Bad resource #1 (when=now)") {
220            public void run() {
221                Notification n = new Notification(R.drawable.icon2,
222                        null, System.currentTimeMillis());
223                n.setLatestEventInfo(NotificationTestList.this, "Persistent #1",
224                            "This is the same notification!!!", makeIntent());
225                n.contentView.setInt(1 /*bogus*/, "bogus method", 666);
226                mNM.notify(1, n);
227            }
228        },
229
230
231        new Test("Bad resource #3") {
232            public void run()
233            {
234                Notification n = new Notification(NotificationTestList.this,
235                            R.drawable.ic_statusbar_missedcall,
236                            null, System.currentTimeMillis()-(1000*60*60*24),
237                            "(453) 123-2328",
238                            "", null);
239                n.contentView.setInt(1 /*bogus*/, "bogus method", 666);
240                mNM.notify(3, n);
241            }
242        },
243
244        new Test("Times") {
245            public void run()
246            {
247                long now = System.currentTimeMillis();
248
249                timeNotification(7, "24 hours from now", now+(1000*60*60*24));
250                timeNotification(6, "12:01:00 from now", now+(1000*60*60*12)+(60*1000));
251                timeNotification(5, "12 hours from now", now+(1000*60*60*12));
252                timeNotification(4, "now", now);
253                timeNotification(3, "11:59:00 ago", now-((1000*60*60*12)-(60*1000)));
254                timeNotification(2, "12 hours ago", now-(1000*60*60*12));
255                timeNotification(1, "24 hours ago", now-(1000*60*60*24));
256            }
257        },
258        new StateStress("Stress - Ongoing / Latest", 100, 100, new Runnable[] {
259                new Runnable() {
260                    public void run() {
261                        Log.d(TAG, "Stress - Ongoing/Latest 0");
262                        Notification n = new Notification(NotificationTestList.this,
263                                R.drawable.icon3,
264                                null, System.currentTimeMillis(), "Stress - Ongoing",
265                                "Notify me!!!", null);
266                        n.flags |= Notification.FLAG_ONGOING_EVENT;
267                        mNM.notify(1, n);
268                    }
269                },
270                new Runnable() {
271                    public void run() {
272                        Log.d(TAG, "Stress - Ongoing/Latest 1");
273                        Notification n = new Notification(NotificationTestList.this,
274                                R.drawable.icon4,
275                                null, System.currentTimeMillis(), "Stress - Latest",
276                                "Notify me!!!", null);
277                        //n.flags |= Notification.FLAG_ONGOING_EVENT;
278                        mNM.notify(1, n);
279                    }
280                }
281            }),
282
283        new Test("Long") {
284            public void run()
285            {
286                Notification n = new Notification();
287                n.defaults |= Notification.DEFAULT_SOUND ;
288                n.vibrate = new long[] {
289                        300, 400, 300, 400, 300, 400, 300, 400, 300, 400, 300, 400,
290                        300, 400, 300, 400, 300, 400, 300, 400, 300, 400, 300, 400,
291                        300, 400, 300, 400, 300, 400, 300, 400, 300, 400, 300, 400 };
292                mNM.notify(1, n);
293            }
294        },
295
296        new Test("Progress #1") {
297            public void run() {
298                final boolean PROGRESS_UPDATES_WHEN = true;
299                if (!mProgressDone) return;
300                mProgressDone = false;
301                Thread t = new Thread() {
302                    public void run() {
303                        int x = 0;
304                        while (!mProgressDone) {
305                            Notification n = new Notification(R.drawable.icon1, null,
306                                    PROGRESS_UPDATES_WHEN
307                                    ? System.currentTimeMillis()
308                                    : mActivityCreateTime);
309                            RemoteViews v = new RemoteViews(getPackageName(),
310                                    R.layout.progress_notification);
311
312                            v.setProgressBar(R.id.progress_bar, 100, x, false);
313                            v.setTextViewText(R.id.status_text, "Progress: " + x + "%");
314
315                            n.contentView = v;
316                            n.flags |= Notification.FLAG_ONGOING_EVENT;
317
318                            mNM.notify(500, n);
319                            x = (x + 7) % 100;
320
321                            try {
322                                Thread.sleep(1000);
323                            } catch (InterruptedException e) {
324                                break;
325                            }
326                        }
327                    }
328                };
329                t.start();
330            }
331        },
332
333        new Test("Stop Progress") {
334            public void run() {
335                mProgressDone = true;
336                mNM.cancel(500);
337            }
338        },
339
340        new Test("Blue Lights") {
341            public void run()
342            {
343                Notification n = new Notification();
344                n.flags |= Notification.FLAG_SHOW_LIGHTS;
345                n.ledARGB = 0xff0000ff;
346                n.ledOnMS = 1;
347                n.ledOffMS = 0;
348                mNM.notify(1, n);
349            }
350        },
351
352        new Test("Red Lights") {
353            public void run()
354            {
355                Notification n = new Notification();
356                n.flags |= Notification.FLAG_SHOW_LIGHTS;
357                n.ledARGB = 0xffff0000;
358                n.ledOnMS = 1;
359                n.ledOffMS = 0;
360                mNM.notify(1, n);
361            }
362        },
363
364        new Test("Yellow Lights") {
365            public void run()
366            {
367                Notification n = new Notification();
368                n.flags |= Notification.FLAG_SHOW_LIGHTS;
369                n.ledARGB = 0xffffff00;
370                n.ledOnMS = 1;
371                n.ledOffMS = 0;
372                mNM.notify(1, n);
373            }
374        },
375
376        new Test("Lights off") {
377            public void run()
378            {
379                Notification n = new Notification();
380                n.flags |= Notification.FLAG_SHOW_LIGHTS;
381                n.ledARGB = 0x00000000;
382                n.ledOnMS = 0;
383                n.ledOffMS = 0;
384                mNM.notify(1, n);
385            }
386        },
387
388        new Test("Blue Blinking Slow") {
389            public void run()
390            {
391                Notification n = new Notification();
392                n.flags |= Notification.FLAG_SHOW_LIGHTS;
393                n.ledARGB = 0xff0000ff;
394                n.ledOnMS = 1300;
395                n.ledOffMS = 1300;
396                mNM.notify(1, n);
397            }
398        },
399
400        new Test("Blue Blinking Fast") {
401            public void run()
402            {
403                Notification n = new Notification();
404                n.flags |= Notification.FLAG_SHOW_LIGHTS;
405                n.ledARGB = 0xff0000ff;
406                n.ledOnMS = 300;
407                n.ledOffMS = 300;
408                mNM.notify(1, n);
409            }
410        },
411
412        new Test("Default All") {
413            public void run()
414            {
415                Notification n = new Notification();
416                n.defaults |= Notification.DEFAULT_ALL;
417                mNM.notify(1, n);
418            }
419        },
420
421        new Test("Default All, once") {
422            public void run()
423            {
424                Notification n = new Notification();
425                n.defaults |= Notification.DEFAULT_ALL;
426                n.flags |= Notification.FLAG_ONLY_ALERT_ONCE ;
427                mNM.notify(1, n);
428            }
429        },
430
431        new Test("Content Sound") {
432            public void run()
433            {
434                Notification n = new Notification();
435                n.sound = Uri.parse(
436                        "content://media/internal/audio/media/7");
437
438                mNM.notify(1, n);
439            }
440        },
441
442        new Test("Resource Sound") {
443            public void run()
444            {
445                Notification n = new Notification();
446                n.sound = Uri.parse(
447                        ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
448                        getPackageName() + "/raw/ringer");
449                Log.d(TAG, "n.sound=" + n.sound);
450
451                mNM.notify(1, n);
452            }
453        },
454
455        new Test("Sound and Cancel") {
456            public void run()
457            {
458                Notification n = new Notification();
459                n.sound = Uri.parse(
460                            "content://media/internal/audio/media/7");
461
462                mNM.notify(1, n);
463                SystemClock.sleep(200);
464                mNM.cancel(1);
465            }
466        },
467
468        new Test("Vibrate") {
469            public void run()
470            {
471                Notification n = new Notification();
472                    n.vibrate = new long[] { 0, 700, 500, 1000 };
473
474                mNM.notify(1, n);
475            }
476        },
477
478        new Test("Vibrate and cancel") {
479            public void run()
480            {
481                Notification n = new Notification();
482                    n.vibrate = new long[] { 0, 700, 500, 1000 };
483
484                mNM.notify(1, n);
485                SystemClock.sleep(500);
486                mNM.cancel(1);
487            }
488        },
489
490        new Test("Vibrate pattern") {
491            public void run()
492            {
493                mVibrator.vibrate(new long[] { 250, 1000, 500, 2000 }, -1);
494            }
495        },
496
497        new Test("Vibrate pattern repeating") {
498            public void run()
499            {
500                mVibrator.vibrate(new long[] { 250, 1000, 500 }, 1);
501            }
502        },
503
504        new Test("Vibrate 3s") {
505            public void run()
506            {
507                mVibrator.vibrate(3000);
508            }
509        },
510
511        new Test("Vibrate 100s") {
512            public void run()
513            {
514                mVibrator.vibrate(100000);
515            }
516        },
517
518        new Test("Vibrate off") {
519            public void run()
520            {
521                mVibrator.cancel();
522            }
523        },
524
525        new Test("Cancel #1") {
526            public void run() {
527                mNM.cancel(1);
528            }
529        },
530
531        new Test("Cancel #1 in 3 sec") {
532            public void run() {
533                mHandler.postDelayed(new Runnable() {
534                            public void run() {
535                                Log.d(TAG, "Cancelling now...");
536                                mNM.cancel(1);
537                            }
538                        }, 3000);
539            }
540        },
541
542        new Test("Cancel #2") {
543            public void run() {
544                mNM.cancel(2);
545            }
546        },
547
548        new Test("Persistent #1") {
549            public void run() {
550                Notification n = new Notification(R.drawable.icon1, "tick tick tick",
551                        mActivityCreateTime);
552                n.setLatestEventInfo(NotificationTestList.this, "Persistent #1",
553                            "This is a notification!!!", makeIntent());
554                mNM.notify(1, n);
555            }
556        },
557
558        new Test("Persistent #1 in 3 sec") {
559            public void run() {
560                mHandler.postDelayed(new Runnable() {
561                            public void run() {
562                                Notification n = new Notification(R.drawable.icon1,
563                                        "            "
564                                        + "tick tock tick tock\n\nSometimes notifications can "
565                                        + "be really long and wrap to more than one line.\n"
566                                        + "Sometimes."
567                                        + "Ohandwhathappensifwehaveonereallylongstringarewesure"
568                                        + "thatwesegmentitcorrectly?\n",
569                                        System.currentTimeMillis());
570                                n.setLatestEventInfo(NotificationTestList.this,
571                                        "Still Persistent #1",
572                                        "This is still a notification!!!",
573                                        makeIntent());
574                                mNM.notify(1, n);
575                            }
576                        }, 3000);
577            }
578        },
579
580        new Test("Persistent #2") {
581            public void run() {
582                Notification n = new Notification(R.drawable.icon2, "tock tock tock",
583                        System.currentTimeMillis());
584                n.setLatestEventInfo(NotificationTestList.this, "Persistent #2",
585                            "Notify me!!!", makeIntent());
586                mNM.notify(2, n);
587            }
588        },
589
590        new Test("Persistent #3") {
591            public void run() {
592                Notification n = new Notification(R.drawable.icon2, "tock tock tock\nmooooo",
593                        System.currentTimeMillis());
594                n.setLatestEventInfo(NotificationTestList.this, "Persistent #3",
595                            "Notify me!!!", makeIntent());
596                mNM.notify(3, n);
597            }
598        },
599
600        new Test("Persistent #2 Vibrate") {
601            public void run() {
602                Notification n = new Notification(R.drawable.icon2, "tock tock tock",
603                        System.currentTimeMillis());
604                n.setLatestEventInfo(NotificationTestList.this, "Persistent #2",
605                            "Notify me!!!", makeIntent());
606                n.defaults = Notification.DEFAULT_VIBRATE;
607                mNM.notify(2, n);
608            }
609        },
610
611        new Test("Persistent #1 - different icon") {
612            public void run() {
613                Notification n = new Notification(R.drawable.icon2, null,
614                        mActivityCreateTime);
615                n.setLatestEventInfo(NotificationTestList.this, "Persistent #1",
616                            "This is the same notification!!!", makeIntent());
617                mNM.notify(1, n);
618            }
619        },
620
621        new Test("Chronometer Start") {
622            public void run() {
623                Notification n = new Notification(R.drawable.icon2, "me me me me",
624                                                    System.currentTimeMillis());
625                n.contentView = new RemoteViews(getPackageName(), R.layout.chrono_notification);
626                mChronometerBase = SystemClock.elapsedRealtime();
627                n.contentView.setChronometer(R.id.time, mChronometerBase, "Yay! (%s)", true);
628                n.flags |= Notification.FLAG_ONGOING_EVENT;
629                n.contentIntent = makeIntent();
630                mNM.notify(2, n);
631            }
632        },
633
634        new Test("Chronometer Stop") {
635            public void run() {
636                mHandler.postDelayed(new Runnable() {
637                        public void run() {
638                            Log.d(TAG, "Chronometer Stop");
639                            Notification n = new Notification();
640                            n.icon = R.drawable.icon1;
641                            n.contentView = new RemoteViews(getPackageName(),
642                                                             R.layout.chrono_notification);
643                            n.contentView.setChronometer(R.id.time, mChronometerBase, null, false);
644                            n.contentIntent = makeIntent();
645                            mNM.notify(2, n);
646                        }
647                    }, 3000);
648            }
649        },
650
651        new Test("Sequential Persistent") {
652            public void run() {
653                mNM.notify(1, notificationWithNumbers(1));
654                mNM.notify(2, notificationWithNumbers(2));
655            }
656        },
657
658        new Test("Replace Persistent") {
659            public void run() {
660                mNM.notify(1, notificationWithNumbers(1));
661                mNM.notify(1, notificationWithNumbers(1));
662            }
663        },
664
665        new Test("Run and Cancel (n=1)") {
666            public void run() {
667                mNM.notify(1, notificationWithNumbers(1));
668                mNM.cancel(1);
669            }
670        },
671
672        new Test("Run an Cancel (n=2)") {
673            public void run() {
674                mNM.notify(1, notificationWithNumbers(1));
675                mNM.notify(2, notificationWithNumbers(2));
676                mNM.cancel(2);
677            }
678        },
679
680        // Repeatedly notify and cancel -- triggers bug #670627
681        new Test("Bug 670627") {
682            public void run() {
683                for (int i = 0; i < 10; i++) {
684                  Log.d(TAG, "Add two notifications");
685                  mNM.notify(1, notificationWithNumbers(1));
686                  mNM.notify(2, notificationWithNumbers(2));
687                  Log.d(TAG, "Cancel two notifications");
688                  mNM.cancel(1);
689                  mNM.cancel(2);
690                }
691            }
692        },
693
694        new Test("Ten Notifications") {
695            public void run() {
696                for (int i = 0; i < 2; i++) {
697                    Notification n = new Notification(NotificationTestList.this,
698                            kNumberedIconResIDs[i],
699                            null, System.currentTimeMillis(), "Persistent #" + i,
700                            "Notify me!!!" + i, null);
701                    n.flags |= Notification.FLAG_ONGOING_EVENT;
702                    n.number = i;
703                    mNM.notify((i+1)*10, n);
704                }
705                for (int i = 2; i < 10; i++) {
706                    Notification n = new Notification(NotificationTestList.this,
707                            kNumberedIconResIDs[i],
708                            null, System.currentTimeMillis(), "Persistent #" + i,
709                            "Notify me!!!" + i, null);
710                    n.number = i;
711                    mNM.notify((i+1)*10, n);
712                }
713            }
714        },
715
716        new Test("Cancel eight notifications") {
717            public void run() {
718                for (int i = 1; i < 9; i++) {
719                    mNM.cancel((i+1)*10);
720                }
721            }
722        },
723
724        new Test("Cancel the other two notifications") {
725            public void run() {
726                mNM.cancel(10);
727                mNM.cancel(100);
728            }
729        },
730
731        new Test("Persistent with numbers 1") {
732            public void run() {
733                mNM.notify(1, notificationWithNumbers(1));
734            }
735        },
736
737        new Test("Persistent with numbers 22") {
738            public void run() {
739                mNM.notify(1, notificationWithNumbers(22));
740            }
741        },
742
743        new Test("Persistent with numbers 333") {
744            public void run() {
745                mNM.notify(1, notificationWithNumbers(333));
746            }
747        },
748
749        new Test("Persistent with numbers 4444") {
750            public void run() {
751                mNM.notify(1, notificationWithNumbers(4444));
752            }
753        },
754
755        new Test("Crash") {
756            public void run()
757            {
758                PowerManager.WakeLock wl
759                        = ((PowerManager)NotificationTestList.this.getSystemService(Context.POWER_SERVICE))
760                            .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "crasher");
761                wl.acquire();
762                mHandler.postDelayed(new Runnable() {
763                            public void run() {
764                                throw new RuntimeException("Die!");
765                            }
766                        }, 10000);
767
768            }
769        },
770
771    };
772
773    private Notification notificationWithNumbers(int num) {
774        Notification n = new Notification(this,
775                (num >= 0 && num < kNumberedIconResIDs.length)
776                    ? kNumberedIconResIDs[num]
777                    : kUnnumberedIconResID,
778                null,
779                System.currentTimeMillis(),
780                "Notification", "Number=" + num,
781                null);
782        n.number = num;
783        return n;
784    }
785
786    private PendingIntent makeIntent() {
787        Intent intent = new Intent(Intent.ACTION_MAIN);
788        intent.addCategory(Intent.CATEGORY_HOME);
789        return PendingIntent.getActivity(this, 0, intent, 0);
790    }
791
792    private PendingIntent makeIntent2() {
793        Intent intent = new Intent(this, StatusBarTest.class);
794        return PendingIntent.getActivity(this, 0, intent, 0);
795    }
796
797
798    class StateStress extends Test {
799        StateStress(String name, int pause, int iterations, Runnable[] tasks) {
800            super(name);
801            mPause = pause;
802            mTasks = tasks;
803            mIteration = iterations;
804        }
805        Runnable[] mTasks;
806        int mNext;
807        int mIteration;
808        long mPause;
809        Runnable mRunnable = new Runnable() {
810            public void run() {
811                mTasks[mNext].run();
812                mNext++;
813                if (mNext >= mTasks.length) {
814                    mNext = 0;
815                    mIteration--;
816                    if (mIteration <= 0) {
817                        return;
818                    }
819                }
820                mHandler.postDelayed(mRunnable, mPause);
821            }
822        };
823        public void run() {
824            mNext = 0;
825            mHandler.postDelayed(mRunnable, mPause);
826        }
827    }
828
829    void timeNotification(int n, String label, long time) {
830        mNM.notify(n, new Notification(NotificationTestList.this,
831                    R.drawable.ic_statusbar_missedcall, null,
832                    time, label, "" + new java.util.Date(time), null));
833
834    }
835
836    Bitmap loadBitmap(int resId) {
837        BitmapDrawable bd = (BitmapDrawable)getResources().getDrawable(resId);
838        return Bitmap.createBitmap(bd.getBitmap());
839    }
840}
841
842