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