Brett Chabot | 4e54a1f | 2010-05-10 19:46:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 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 | package com.android.tradefed.device; |
| 17 | |
| 18 | import com.android.ddmlib.IDevice; |
| 19 | |
| 20 | /** |
| 21 | * Provides facilities for monitoring the state of a {@link IDevice}. |
| 22 | */ |
Brett Chabot | 5fecdaf | 2010-06-03 17:01:08 -0700 | [diff] [blame] | 23 | public interface IDeviceStateMonitor { |
Brett Chabot | 4e54a1f | 2010-05-10 19:46:36 -0700 | [diff] [blame] | 24 | |
| 25 | /** |
| 26 | * Waits for device to be online. |
| 27 | * <p/> |
| 28 | * Note: this method will return once device is visible via DDMS. It does not guarantee that the |
| 29 | * device is actually responsive to adb commands - use {@link #waitForDeviceAvailable()} |
| 30 | * instead. |
| 31 | * |
| 32 | * @param time the maximum time in ms to wait |
| 33 | * |
Brett Chabot | ac3a79e | 2010-05-26 13:46:36 -0700 | [diff] [blame] | 34 | * @return the {@link IDevice} if device becomes online before time expires. <code>null</code> |
| 35 | * otherwise. |
Brett Chabot | 4e54a1f | 2010-05-10 19:46:36 -0700 | [diff] [blame] | 36 | */ |
Brett Chabot | ac3a79e | 2010-05-26 13:46:36 -0700 | [diff] [blame] | 37 | public IDevice waitForDeviceOnline(long time); |
Brett Chabot | 93e0782 | 2010-05-12 16:52:18 -0700 | [diff] [blame] | 38 | |
| 39 | /** |
| 40 | * Waits for device to be online using standard boot timeout. |
| 41 | * <p/> |
| 42 | * Note: this method will return once device is visible via DDMS. It does not guarantee that the |
| 43 | * device is actually responsive to adb commands - use {@link #waitForDeviceAvailable()} |
| 44 | * instead. |
| 45 | * |
Brett Chabot | ac3a79e | 2010-05-26 13:46:36 -0700 | [diff] [blame] | 46 | * @return the {@link IDevice} if device becomes online before time expires. <code>null</code> |
| 47 | * otherwise. |
Brett Chabot | 93e0782 | 2010-05-12 16:52:18 -0700 | [diff] [blame] | 48 | */ |
Brett Chabot | ac3a79e | 2010-05-26 13:46:36 -0700 | [diff] [blame] | 49 | public IDevice waitForDeviceOnline(); |
Brett Chabot | 4e54a1f | 2010-05-10 19:46:36 -0700 | [diff] [blame] | 50 | |
| 51 | /** |
| 52 | * Waits for the device to be responsive and available for testing. |
| 53 | * |
| 54 | * @param waitTime the time in ms to wait |
Brett Chabot | ac3a79e | 2010-05-26 13:46:36 -0700 | [diff] [blame] | 55 | * @return the {@link IDevice} if device becomes online before time expires. <code>null</code> |
| 56 | * otherwise. |
Brett Chabot | 4e54a1f | 2010-05-10 19:46:36 -0700 | [diff] [blame] | 57 | */ |
Brett Chabot | ac3a79e | 2010-05-26 13:46:36 -0700 | [diff] [blame] | 58 | public IDevice waitForDeviceAvailable(final long waitTime); |
Brett Chabot | 4e54a1f | 2010-05-10 19:46:36 -0700 | [diff] [blame] | 59 | |
| 60 | /** |
| 61 | * Waits for the device to be responsive and available for testing. |
| 62 | * <p/> |
| 63 | * Equivalent to {@link #waitForDeviceAvailable(long)}, but uses default device |
| 64 | * boot timeout. |
| 65 | * |
Brett Chabot | ac3a79e | 2010-05-26 13:46:36 -0700 | [diff] [blame] | 66 | * @return the {@link IDevice} if device becomes online before time expires. <code>null</code> |
| 67 | * otherwise. |
Brett Chabot | 4e54a1f | 2010-05-10 19:46:36 -0700 | [diff] [blame] | 68 | */ |
Brett Chabot | ac3a79e | 2010-05-26 13:46:36 -0700 | [diff] [blame] | 69 | public IDevice waitForDeviceAvailable(); |
Brett Chabot | 4e54a1f | 2010-05-10 19:46:36 -0700 | [diff] [blame] | 70 | |
| 71 | /** |
| 72 | * Waits for the device to be in bootloader. |
| 73 | * |
Brett Chabot | 93e0782 | 2010-05-12 16:52:18 -0700 | [diff] [blame] | 74 | * @param waitTime the maximum time in ms to wait |
Brett Chabot | 4e54a1f | 2010-05-10 19:46:36 -0700 | [diff] [blame] | 75 | * |
| 76 | * @return <code>true</code> if device is in bootloader before time expires |
| 77 | */ |
Brett Chabot | 93e0782 | 2010-05-12 16:52:18 -0700 | [diff] [blame] | 78 | public boolean waitForDeviceBootloader(long waitTime); |
Brett Chabot | 4e54a1f | 2010-05-10 19:46:36 -0700 | [diff] [blame] | 79 | |
| 80 | /** |
Brett Chabot | 467ac2b | 2010-07-30 16:44:47 -0700 | [diff] [blame^] | 81 | * Waits for device bootloader state to be refreshed |
| 82 | */ |
| 83 | public void waitForDeviceBootloaderStateUpdate(); |
| 84 | |
| 85 | /** |
Brett Chabot | 4e54a1f | 2010-05-10 19:46:36 -0700 | [diff] [blame] | 86 | * Waits for the device to be not available |
| 87 | * |
Brett Chabot | 93e0782 | 2010-05-12 16:52:18 -0700 | [diff] [blame] | 88 | * @param waitTime the maximum time in ms to wait |
Brett Chabot | 4e54a1f | 2010-05-10 19:46:36 -0700 | [diff] [blame] | 89 | * |
| 90 | * @return <code>true</code> if device becomes unavailable |
| 91 | */ |
Brett Chabot | 93e0782 | 2010-05-12 16:52:18 -0700 | [diff] [blame] | 92 | public boolean waitForDeviceNotAvailable(long waitTime); |
Brett Chabot | 4e54a1f | 2010-05-10 19:46:36 -0700 | [diff] [blame] | 93 | |
Brett Chabot | ac3a79e | 2010-05-26 13:46:36 -0700 | [diff] [blame] | 94 | /** |
| 95 | * Gets the serial number of the device. |
| 96 | */ |
| 97 | public String getSerialNumber(); |
Brett Chabot | 4e54a1f | 2010-05-10 19:46:36 -0700 | [diff] [blame] | 98 | |
| 99 | /** |
| 100 | * Gets the device state. |
| 101 | * |
| 102 | * @return the {@link TestDeviceState} of device |
| 103 | */ |
| 104 | public TestDeviceState getDeviceState(); |
Brett Chabot | ac3a79e | 2010-05-26 13:46:36 -0700 | [diff] [blame] | 105 | |
| 106 | /** |
Brett Chabot | 3759c85 | 2010-07-13 17:36:31 -0700 | [diff] [blame] | 107 | * Sets the device current state. |
| 108 | * |
Brett Chabot | ac3a79e | 2010-05-26 13:46:36 -0700 | [diff] [blame] | 109 | * @param deviceState |
| 110 | */ |
| 111 | public void setState(TestDeviceState deviceState); |
Brett Chabot | 3759c85 | 2010-07-13 17:36:31 -0700 | [diff] [blame] | 112 | |
| 113 | /** |
| 114 | * Returns a mount point. |
| 115 | * <p/> |
| 116 | * Queries the device directly if the cached info in {@link IDevice} is not available. |
| 117 | * <p/> |
| 118 | * TODO: move this behavior to {@link IDevice#getMountPoint(String)} |
| 119 | * |
| 120 | * @param mountName the name of the mount point |
| 121 | * @return the mount point or <code>null</code> |
| 122 | * @see {@link IDevice#getMountPoint(String)} |
| 123 | */ |
| 124 | public String getMountPoint(String mountName); |
Brett Chabot | 467ac2b | 2010-07-30 16:44:47 -0700 | [diff] [blame^] | 125 | |
| 126 | /** |
| 127 | * Updates the current IDevice. |
| 128 | * |
| 129 | * @param device |
| 130 | * |
| 131 | * @see {@link IManagedTestDevice#setIDevice(IDevice)} |
| 132 | */ |
| 133 | public void setIDevice(IDevice device); |
Brett Chabot | 4e54a1f | 2010-05-10 19:46:36 -0700 | [diff] [blame] | 134 | } |