blob: 7a166cf975e326bf045c215a8db761404d47e957 [file] [log] [blame]
Brett Chabot4e54a1f2010-05-10 19:46:36 -07001/*
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 */
16package com.android.tradefed.device;
17
18import com.android.ddmlib.IDevice;
19
20/**
21 * Provides facilities for monitoring the state of a {@link IDevice}.
22 */
Brett Chabot5fecdaf2010-06-03 17:01:08 -070023public interface IDeviceStateMonitor {
Brett Chabot4e54a1f2010-05-10 19:46:36 -070024
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 Chabotac3a79e2010-05-26 13:46:36 -070034 * @return the {@link IDevice} if device becomes online before time expires. <code>null</code>
35 * otherwise.
Brett Chabot4e54a1f2010-05-10 19:46:36 -070036 */
Brett Chabotac3a79e2010-05-26 13:46:36 -070037 public IDevice waitForDeviceOnline(long time);
Brett Chabot93e07822010-05-12 16:52:18 -070038
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 Chabotac3a79e2010-05-26 13:46:36 -070046 * @return the {@link IDevice} if device becomes online before time expires. <code>null</code>
47 * otherwise.
Brett Chabot93e07822010-05-12 16:52:18 -070048 */
Brett Chabotac3a79e2010-05-26 13:46:36 -070049 public IDevice waitForDeviceOnline();
Brett Chabot4e54a1f2010-05-10 19:46:36 -070050
51 /**
wsmlbyf0437ea2014-08-22 15:01:11 -070052 * Blocks until the device's boot complete flag is set
53 *
54 * @param waitTime the amount in ms to wait
55 */
56 public boolean waitForBootComplete(final long waitTime);
57
58 /**
Brett Chabot01500902011-07-19 19:27:38 -070059 * Waits for device to be responsive to a basic adb shell command.
60 *
61 * @param waitTime the time in ms to wait
62 * @return <code>true</code> if device becomes responsive before <var>waitTime</var> elapses.
63 */
64 public boolean waitForDeviceShell(final long waitTime);
65
66 /**
Brett Chabot4d180a52011-07-07 17:59:42 -070067 * Waits for the device to be responsive and available for testing. Currently this means that
68 * the package manager and external storage are available.
Brett Chabot4e54a1f2010-05-10 19:46:36 -070069 *
70 * @param waitTime the time in ms to wait
Brett Chabotac3a79e2010-05-26 13:46:36 -070071 * @return the {@link IDevice} if device becomes online before time expires. <code>null</code>
72 * otherwise.
Brett Chabot4e54a1f2010-05-10 19:46:36 -070073 */
Brett Chabotac3a79e2010-05-26 13:46:36 -070074 public IDevice waitForDeviceAvailable(final long waitTime);
Brett Chabot4e54a1f2010-05-10 19:46:36 -070075
76 /**
77 * Waits for the device to be responsive and available for testing.
78 * <p/>
79 * Equivalent to {@link #waitForDeviceAvailable(long)}, but uses default device
80 * boot timeout.
81 *
Brett Chabotac3a79e2010-05-26 13:46:36 -070082 * @return the {@link IDevice} if device becomes online before time expires. <code>null</code>
83 * otherwise.
Brett Chabot4e54a1f2010-05-10 19:46:36 -070084 */
Brett Chabotac3a79e2010-05-26 13:46:36 -070085 public IDevice waitForDeviceAvailable();
Brett Chabot4e54a1f2010-05-10 19:46:36 -070086
87 /**
88 * Waits for the device to be in bootloader.
89 *
Brett Chabot93e07822010-05-12 16:52:18 -070090 * @param waitTime the maximum time in ms to wait
Brett Chabot4e54a1f2010-05-10 19:46:36 -070091 *
92 * @return <code>true</code> if device is in bootloader before time expires
93 */
Brett Chabot93e07822010-05-12 16:52:18 -070094 public boolean waitForDeviceBootloader(long waitTime);
Brett Chabot4e54a1f2010-05-10 19:46:36 -070095
96 /**
Brett Chabot467ac2b2010-07-30 16:44:47 -070097 * Waits for device bootloader state to be refreshed
98 */
99 public void waitForDeviceBootloaderStateUpdate();
100
101 /**
Brett Chabot4e54a1f2010-05-10 19:46:36 -0700102 * Waits for the device to be not available
103 *
Brett Chabot93e07822010-05-12 16:52:18 -0700104 * @param waitTime the maximum time in ms to wait
Brett Chabot4e54a1f2010-05-10 19:46:36 -0700105 *
106 * @return <code>true</code> if device becomes unavailable
107 */
Brett Chabot93e07822010-05-12 16:52:18 -0700108 public boolean waitForDeviceNotAvailable(long waitTime);
Brett Chabot4e54a1f2010-05-10 19:46:36 -0700109
Brett Chabotac3a79e2010-05-26 13:46:36 -0700110 /**
Brett Chabot70ac3fd2011-01-17 13:38:59 -0800111 * Waits for the device to be in the 'adb recovery' state
112 *
113 * @param waitTime the maximum time in ms to wait
Julien Desprezac32e662016-07-05 10:59:32 +0100114 * @return True if the device is in Recovery before the timeout, False otherwise.
Brett Chabot70ac3fd2011-01-17 13:38:59 -0800115 */
116 public boolean waitForDeviceInRecovery(long waitTime);
117
118 /**
Guang Zhuac76f7a2019-05-22 16:46:23 -0700119 * Waits for the device to be in the 'adb sideload' state
120 *
121 * @param waitTime the maximum time in ms to wait
122 * @return True if the device is in sideload before the timeout, False otherwise.
123 */
124 public boolean waitForDeviceInSideload(long waitTime);
125
126 /**
Brett Chabotac3a79e2010-05-26 13:46:36 -0700127 * Gets the serial number of the device.
128 */
129 public String getSerialNumber();
Brett Chabot4e54a1f2010-05-10 19:46:36 -0700130
131 /**
132 * Gets the device state.
133 *
134 * @return the {@link TestDeviceState} of device
135 */
136 public TestDeviceState getDeviceState();
Brett Chabotac3a79e2010-05-26 13:46:36 -0700137
138 /**
Brett Chabot3759c852010-07-13 17:36:31 -0700139 * Sets the device current state.
140 *
Brett Chabotac3a79e2010-05-26 13:46:36 -0700141 * @param deviceState
142 */
143 public void setState(TestDeviceState deviceState);
Brett Chabot3759c852010-07-13 17:36:31 -0700144
145 /**
146 * Returns a mount point.
147 * <p/>
148 * Queries the device directly if the cached info in {@link IDevice} is not available.
149 * <p/>
150 * TODO: move this behavior to {@link IDevice#getMountPoint(String)}
151 *
152 * @param mountName the name of the mount point
153 * @return the mount point or <code>null</code>
Julien Desprezac32e662016-07-05 10:59:32 +0100154 * @see IDevice#getMountPoint(String)
Brett Chabot3759c852010-07-13 17:36:31 -0700155 */
156 public String getMountPoint(String mountName);
Brett Chabot467ac2b2010-07-30 16:44:47 -0700157
158 /**
159 * Updates the current IDevice.
160 *
161 * @param device
162 *
Julien Desprezac32e662016-07-05 10:59:32 +0100163 * @see IManagedTestDevice#setIDevice(IDevice)
Brett Chabot467ac2b2010-07-30 16:44:47 -0700164 */
165 public void setIDevice(IDevice device);
Brett Chabotcb6bf632011-03-17 00:08:13 -0700166
167 /**
168 * @return <code>true</code> if device is connected to adb via tcp
169 */
170 public boolean isAdbTcp();
171
Brett Chabot8b52b9b2012-05-02 11:35:50 -0700172 /**
173 * Set the time in ms to wait for a device to be online in {@link #waitForDeviceOnline()}.
174 */
175 public void setDefaultOnlineTimeout(long timeoutMs);
176
177 /**
178 * Set the time in ms to wait for a device to be available in {@link #waitForDeviceAvailable()}.
179 */
180 public void setDefaultAvailableTimeout(long timeoutMs);
181
Brett Chabot4e54a1f2010-05-10 19:46:36 -0700182}