Home | History | Annotate | Download | only in device
      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 
     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      */
     49     public void setIDevice(IDevice device);
     50 
     51     /**
     52      * Update the device's state.
     53      *
     54      * @param deviceState the {@link TestDeviceState}
     55      */
     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      */
     64     public void setFastbootEnabled(boolean fastbootEnabled);
     65 
     66     /**
     67      * Return if fastboot is available for the device.
     68      */
     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      */
     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      */
     81     public String getFastbootPath();
     82 
     83     /**
     84      * Invoke recovery on the device.
     85      *
     86      * @throws DeviceNotAvailableException if recovery was not successful
     87      */
     88     public void recoverDevice() throws DeviceNotAvailableException;
     89 
     90     /**
     91      * Sets the {@link Process}, when this device is an emulator.
     92      */
     93     public void setEmulatorProcess(Process p);
     94 
     95     /**
     96      * Return the {@link Process} corresponding to this emulator.
     97      *
     98      * @return the {@link Process} or <code>null</code>
     99      */
    100     public Process getEmulatorProcess();
    101 
    102     /**
    103      * Return the current allocation state of device
    104      */
    105     public DeviceAllocationState getAllocationState();
    106 
    107     /**
    108      * Process the given {@link com.android.tradefed.device.DeviceEvent}. May transition device
    109      * to new state. Will inform the {@link IDeviceMonitor} of any state transitions.
    110      */
    111     public DeviceEventResponse handleAllocationEvent(DeviceEvent event);
    112 
    113     /**
    114      * Return the {@link IDeviceStateMonitor} associated with device.
    115      */
    116     public IDeviceStateMonitor getMonitor();
    117 
    118     /**
    119      * Returns the MAC address of the device, null if it fails to query from the device.
    120      */
    121     public String getMacAddress();
    122 
    123     /** Return the SIM card state or null if device is not available. */
    124     public String getSimState();
    125 
    126     /** Return the SIM card operator or null if device is not available. */
    127     public String getSimOperator();
    128 }
    129