Home | History | Annotate | Download | only in remote
      1 /*
      2  * Copyright (C) 2014 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 
     17 package com.android.tradefed.command.remote;
     18 
     19 import java.util.List;
     20 
     21 /**
     22  * Interface for sending remote TradeFederation commands.
     23  */
     24 public interface IRemoteClient {
     25 
     26     /**
     27      * Send a 'list devices' request to remote TF
     28      *
     29      * @return a list of device serials and their state.
     30      * @throws RemoteException if command failed
     31      */
     32     public List<DeviceDescriptor> sendListDevices() throws RemoteException;
     33 
     34     /**
     35      * Send an 'allocate device' request to remote TF.
     36      *
     37      * @param serial
     38      * @throws RemoteException
     39      */
     40     public void sendAllocateDevice(String serial) throws RemoteException;
     41 
     42     /**
     43      * Send a 'free previously allocated device' request to remote TF
     44      *
     45      * @param serial
     46      * @throws RemoteException
     47      */
     48     public void sendFreeDevice(String serial) throws RemoteException;
     49 
     50     /**
     51      * Send an 'add command' request to remote TF. This will add the command to the queue of
     52      * commands waiting for devices, essentially scheduling it for future execution at some point in
     53      * time. There is no way for a client to get the result of a command added via this API.
     54      *
     55      * @see {@link ICommandScheduler#addCommand(String[], long)}
     56      * @param elapsedTimeMs the total time in ms that the command has been executing for. Used for
     57      *            scheduling prioritization, and will typically only be non-zero in handover
     58      *            situations.
     59      * @param commandArgs the command arguments, in [configname] [option] format
     60      * @throws RemoteException
     61      */
     62     public void sendAddCommand(long elapsedTimeMs, String... commandArgs) throws RemoteException;
     63 
     64     /**
     65      * Send an 'add command file' request to remote TF.
     66      *
     67      * @see {@link ICommandScheduler#addCommandFile()}
     68      * @param commandFile the file system path to the command file
     69      * @param extraArgs the list of extra arguments to add to every command parsed from file
     70      * @throws RemoteException
     71      */
     72     void sendAddCommandFile(String commandFile, List<String> extraArgs) throws RemoteException;
     73 
     74     /**
     75      * Send a 'execute this command on given device' request to remote TF.
     76      * <p/>
     77      * Unlike {@link #sendAddCommand(long, String...)}, this is used in cases where the remote
     78      * client caller is doing their own device allocation, and is instructing TF to directly
     79      * execute the command on a given device, instead of just scheduling the command for future
     80      * execution.
     81      * <p/>
     82      * {@link #sendGetLastCommandResult(String, ICommandResultHandler)} can be used to get the
     83      * command result.
     84      *
     85      * @param serial the device serial to execute on. Must have already been allocated
     86      * @param commandArgs the command arguments, in [configname] [option] format
     87      * @throws RemoteException
     88      */
     89     public void sendExecCommand(String serial, String[] commandArgs) throws RemoteException;
     90 
     91     /**
     92      * Poll the remote TF for the last command result on executed given device.
     93      *
     94      * @param serial the device serial to execute on. Must have already been allocated
     95      * @param handler the {@link ICommandResultHandler} to communicate results to
     96      * @throws RemoteException
     97      */
     98     public void sendGetLastCommandResult(String serial, ICommandResultHandler handler)
     99             throws RemoteException;
    100 
    101     /**
    102      * Send a 'close' request to remote TF.
    103      * <p/>
    104      * This requests shut down of the remote TF's connection, and it will stop
    105      * listening for remote requests.
    106      *
    107      * @deprecated will be removed in future. Except for handover cases, it should not be possible
    108      * for a client to shutdown TF's remote manager.
    109      * @throws RemoteException
    110      */
    111     @Deprecated
    112     public void sendClose() throws RemoteException;
    113 
    114     /**
    115      * Request to start a handover sequence to another TF.
    116      *
    117      * @param port the port of the remote TF to hand over to
    118      * @throws RemoteException
    119      */
    120     public void sendStartHandover(int port) throws RemoteException;
    121 
    122     /**
    123      * Inform remote TF that handover initiation is complete. Old TF has send all info about devices
    124      * and commands in use.
    125      *
    126      * @throws RemoteException
    127      */
    128     public void sendHandoverInitComplete() throws RemoteException;
    129 
    130     /**
    131      * Inform remote TF that handover sequence is now complete. Old TF has freed all devices and is
    132      * shutting down.
    133      *
    134      * @throws RemoteException
    135      */
    136     public void sendHandoverComplete() throws RemoteException;
    137 
    138     /**
    139      * Close the connection to the {@link RemoteManager}.
    140      */
    141     public void close();
    142 
    143 }
    144