• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 import com.android.tradefed.util.DeviceInspectionResult;
20 
21 /**
22  * A ITestDevice whose lifecycle is managed.
23  */
24 public interface IManagedTestDevice extends ITestDevice {
25 
26     /**
27      * Container for a response to a {@link IManagedTestDevice#handleAllocationEvent(DeviceEvent)}
28      * call
29      */
30     static class DeviceEventResponse {
31         /** the new state of the device */
32         final DeviceAllocationState allocationState;
33         /** true if state changed as a result of device event */
34         final boolean stateChanged;
35 
DeviceEventResponse(DeviceAllocationState s, boolean b)36         DeviceEventResponse(DeviceAllocationState s, boolean b) {
37             allocationState = s;
38             stateChanged = b;
39         }
40     }
41 
42     /**
43      * Update the IDevice associated with this ITestDevice.
44      * <p/>
45      * The new IDevice must refer the same physical device as the current reference. This method
46      * will be called if DDMS has allocated a new IDevice
47      *
48      * @param device the {@link IDevice}
49      */
setIDevice(IDevice device)50     public void setIDevice(IDevice device);
51 
52     /**
53      * Update the device's state.
54      *
55      * @param deviceState the {@link TestDeviceState}
56      */
setDeviceState(TestDeviceState deviceState)57     public void setDeviceState(TestDeviceState deviceState);
58 
59     /**
60      * Set the fastboot option for the device. Should be set when device is first
61      * allocated.
62      *
63      * @param fastbootEnabled whether fastboot is available for the device or not
64      */
setFastbootEnabled(boolean fastbootEnabled)65     public void setFastbootEnabled(boolean fastbootEnabled);
66 
67     /**
68      * Return if fastboot is available for the device.
69      */
isFastbootEnabled()70     public boolean isFastbootEnabled();
71 
72     /**
73      * Sets the path to the fastboot binary that should be used.
74      * Still requires {@link #isFastbootEnabled()} to be true, to have fastboot functions enabled.
75      */
setFastbootPath(String fastbootPath)76     public void setFastbootPath(String fastbootPath);
77 
78     /**
79      * Returns the path of the fastboot binary being used.
80      * Still requires {@link #isFastbootEnabled()} to be true, to have fastboot functions enabled.
81      */
getFastbootPath()82     public String getFastbootPath();
83 
84     /**
85      * Returns the version string of the fastboot binary being used. Or null if something goes
86      * wrong.
87      */
getFastbootVersion()88     public String getFastbootVersion();
89 
90     /**
91      * Invoke recovery on the device.
92      *
93      * @throws DeviceNotAvailableException if recovery was not successful
94      * @return True if recovery attempted and successful, returns False if recovery was skipped
95      */
recoverDevice()96     public boolean recoverDevice() throws DeviceNotAvailableException;
97 
98     /**
99      * Sets the {@link Process}, when this device is an emulator.
100      */
setEmulatorProcess(Process p)101     public void setEmulatorProcess(Process p);
102 
103     /**
104      * Return the {@link Process} corresponding to this emulator.
105      *
106      * @return the {@link Process} or <code>null</code>
107      */
getEmulatorProcess()108     public Process getEmulatorProcess();
109 
110     /**
111      * Return the current allocation state of device
112      */
getAllocationState()113     public DeviceAllocationState getAllocationState();
114 
115     /**
116      * Process the given {@link com.android.tradefed.device.DeviceEvent}. May transition device
117      * to new state. Will inform the {@link IDeviceMonitor} of any state transitions.
118      */
handleAllocationEvent(DeviceEvent event)119     public DeviceEventResponse handleAllocationEvent(DeviceEvent event);
120 
121     /**
122      * Return the {@link IDeviceStateMonitor} associated with device.
123      */
getMonitor()124     public IDeviceStateMonitor getMonitor();
125 
126     /**
127      * Returns the MAC address of the device, null if it fails to query from the device.
128      */
getMacAddress()129     public String getMacAddress();
130 
131     /** Return the SIM card state or null if not available or device is not available. */
getSimState()132     public String getSimState();
133 
134     /** Return the SIM card operator or null if not available or if device is not available. */
getSimOperator()135     public String getSimOperator();
136 
137     /** Inspect a device and return detailed info when a device becomes unavailable. */
debugDeviceNotAvailable()138     public DeviceInspectionResult debugDeviceNotAvailable();
139 }
140