1/* 2 * Copyright (C) 2008 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.os.Binder; 25import android.os.IBinder; 26import android.os.IPowerManager; 27import android.widget.ListView; 28import android.content.Intent; 29import android.app.Notification; 30import android.app.NotificationManager; 31import android.app.StatusBarManager; 32import android.os.RemoteException; 33import android.os.Vibrator; 34import android.os.Bundle; 35import android.os.Handler; 36import android.os.LocalPowerManager; 37import android.os.ServiceManager; 38import android.util.Log; 39import android.net.Uri; 40import android.os.SystemClock; 41import android.widget.RemoteViews; 42import android.widget.Toast; 43import android.os.PowerManager; 44 45public class PowerTest extends TestActivity 46{ 47 private final static String TAG = "PowerTest"; 48 IPowerManager mPowerManager; 49 int mPokeState = 0; 50 IBinder mPokeToken = new Binder(); 51 Handler mHandler = new Handler(); 52 53 @Override 54 protected String tag() { 55 return TAG; 56 } 57 58 @Override 59 protected Test[] tests() { 60 mPowerManager = IPowerManager.Stub.asInterface(ServiceManager.getService("power")); 61 62 return mTests; 63 } 64 private Test[] mTests = new Test[] { 65 new Test("Cheek events don't poke") { 66 public void run() { 67 mPokeState |= LocalPowerManager.POKE_LOCK_IGNORE_CHEEK_EVENTS; 68 try { 69 mPowerManager.setPokeLock(mPokeState, mPokeToken, TAG); 70 } catch (RemoteException e) { 71 throw new RuntimeException(e); 72 } 73 } 74 }, 75 new Test("Cheek events poke") { 76 public void run() { 77 mPokeState &= ~LocalPowerManager.POKE_LOCK_IGNORE_CHEEK_EVENTS; 78 try { 79 mPowerManager.setPokeLock(mPokeState, mPokeToken, TAG); 80 } catch (RemoteException e) { 81 throw new RuntimeException(e); 82 } 83 } 84 }, 85 new Test("Touch and Cheek events don't poke") { 86 public void run() { 87 mPokeState |= LocalPowerManager.POKE_LOCK_IGNORE_TOUCH_AND_CHEEK_EVENTS; 88 try { 89 mPowerManager.setPokeLock(mPokeState, mPokeToken, TAG); 90 } catch (RemoteException e) { 91 throw new RuntimeException(e); 92 } 93 } 94 }, 95 new Test("Touch and Cheek events poke") { 96 public void run() { 97 mPokeState &= ~LocalPowerManager.POKE_LOCK_IGNORE_TOUCH_AND_CHEEK_EVENTS; 98 try { 99 mPowerManager.setPokeLock(mPokeState, mPokeToken, TAG); 100 } catch (RemoteException e) { 101 throw new RuntimeException(e); 102 } 103 } 104 }, 105 new Test("Short timeout") { 106 public void run() { 107 mPokeState &= ~LocalPowerManager.POKE_LOCK_TIMEOUT_MASK; 108 mPokeState |= LocalPowerManager.POKE_LOCK_SHORT_TIMEOUT; 109 try { 110 mPowerManager.setPokeLock(mPokeState, mPokeToken, TAG); 111 } catch (RemoteException e) { 112 throw new RuntimeException(e); 113 } 114 } 115 }, 116 new Test("Medium timeout") { 117 public void run() { 118 mPokeState &= ~LocalPowerManager.POKE_LOCK_TIMEOUT_MASK; 119 mPokeState |= LocalPowerManager.POKE_LOCK_MEDIUM_TIMEOUT; 120 try { 121 mPowerManager.setPokeLock(mPokeState, mPokeToken, TAG); 122 } catch (RemoteException e) { 123 throw new RuntimeException(e); 124 } 125 } 126 }, 127 new Test("Normal timeout") { 128 public void run() { 129 mPokeState &= ~LocalPowerManager.POKE_LOCK_TIMEOUT_MASK; 130 try { 131 mPowerManager.setPokeLock(mPokeState, mPokeToken, TAG); 132 } catch (RemoteException e) { 133 throw new RuntimeException(e); 134 } 135 } 136 }, 137 new Test("Illegal timeout") { 138 public void run() { 139 mPokeState |= LocalPowerManager.POKE_LOCK_SHORT_TIMEOUT 140 | LocalPowerManager.POKE_LOCK_MEDIUM_TIMEOUT; 141 try { 142 mPowerManager.setPokeLock(mPokeState, mPokeToken, TAG); 143 } catch (RemoteException e) { 144 throw new RuntimeException(e); 145 } 146 } 147 }, 148 }; 149} 150