blob: 46285d4c1de94c69e52251f98f0a0fb0740066a5 [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 /**
52 * Waits for the device to be responsive and available for testing.
53 *
54 * @param waitTime the time in ms to wait
Brett Chabotac3a79e2010-05-26 13:46:36 -070055 * @return the {@link IDevice} if device becomes online before time expires. <code>null</code>
56 * otherwise.
Brett Chabot4e54a1f2010-05-10 19:46:36 -070057 */
Brett Chabotac3a79e2010-05-26 13:46:36 -070058 public IDevice waitForDeviceAvailable(final long waitTime);
Brett Chabot4e54a1f2010-05-10 19:46:36 -070059
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 Chabotac3a79e2010-05-26 13:46:36 -070066 * @return the {@link IDevice} if device becomes online before time expires. <code>null</code>
67 * otherwise.
Brett Chabot4e54a1f2010-05-10 19:46:36 -070068 */
Brett Chabotac3a79e2010-05-26 13:46:36 -070069 public IDevice waitForDeviceAvailable();
Brett Chabot4e54a1f2010-05-10 19:46:36 -070070
71 /**
72 * Waits for the device to be in bootloader.
73 *
Brett Chabot93e07822010-05-12 16:52:18 -070074 * @param waitTime the maximum time in ms to wait
Brett Chabot4e54a1f2010-05-10 19:46:36 -070075 *
76 * @return <code>true</code> if device is in bootloader before time expires
77 */
Brett Chabot93e07822010-05-12 16:52:18 -070078 public boolean waitForDeviceBootloader(long waitTime);
Brett Chabot4e54a1f2010-05-10 19:46:36 -070079
80 /**
Brett Chabot467ac2b2010-07-30 16:44:47 -070081 * Waits for device bootloader state to be refreshed
82 */
83 public void waitForDeviceBootloaderStateUpdate();
84
85 /**
Brett Chabot4e54a1f2010-05-10 19:46:36 -070086 * Waits for the device to be not available
87 *
Brett Chabot93e07822010-05-12 16:52:18 -070088 * @param waitTime the maximum time in ms to wait
Brett Chabot4e54a1f2010-05-10 19:46:36 -070089 *
90 * @return <code>true</code> if device becomes unavailable
91 */
Brett Chabot93e07822010-05-12 16:52:18 -070092 public boolean waitForDeviceNotAvailable(long waitTime);
Brett Chabot4e54a1f2010-05-10 19:46:36 -070093
Brett Chabotac3a79e2010-05-26 13:46:36 -070094 /**
95 * Gets the serial number of the device.
96 */
97 public String getSerialNumber();
Brett Chabot4e54a1f2010-05-10 19:46:36 -070098
99 /**
100 * Gets the device state.
101 *
102 * @return the {@link TestDeviceState} of device
103 */
104 public TestDeviceState getDeviceState();
Brett Chabotac3a79e2010-05-26 13:46:36 -0700105
106 /**
Brett Chabot3759c852010-07-13 17:36:31 -0700107 * Sets the device current state.
108 *
Brett Chabotac3a79e2010-05-26 13:46:36 -0700109 * @param deviceState
110 */
111 public void setState(TestDeviceState deviceState);
Brett Chabot3759c852010-07-13 17:36:31 -0700112
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 Chabot467ac2b2010-07-30 16:44:47 -0700125
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 Chabot4e54a1f2010-05-10 19:46:36 -0700134}