Search in sources :

Example 6 with IAroDevice

use of com.att.aro.core.mobiledevice.pojo.IAroDevice in project VideoOptimzer by attdevsupport.

the class AROController method startCollector.

/**
 * Extract parameters from an AROCollectorActionEvent event. Initiate a
 * collection on Android and iOS devices
 *
 * @param event
 * @param actionCommand
 *                          - "startCollector" or "startCollectorIos"
 */
private void startCollector(ActionEvent event, String actionCommand) {
    StatusResult result;
    this.theView.updateCollectorStatus(CollectorStatus.STARTING, null);
    // reset so that a failure will be true
    this.theView.setDeviceDataPulled(true);
    if (event instanceof AROCollectorActionEvent) {
        IAroDevice device = ((AROCollectorActionEvent) event).getDevice();
        String traceName = ((AROCollectorActionEvent) event).getTrace();
        extraParams = ((AROCollectorActionEvent) event).getExtraParams();
        result = startCollector(device, traceName, extraParams);
        LOG.info("---------- result: " + result.toString());
        if (!result.isSuccess()) {
            // report failure
            if (result.getError().getCode() == 206) {
                try {
                    (new File(traceFolderPath)).delete();
                } catch (Exception e) {
                    LOG.warn("failed to delete trace folder :" + traceFolderPath);
                }
                this.theView.updateCollectorStatus(CollectorStatus.CANCELLED, result);
            } else {
                this.theView.updateCollectorStatus(null, result);
            }
        } else {
            // apk has launched and been activated
            if (!getVideoOption().equals(VideoOption.NONE) && "startCollector".equals(actionCommand)) {
                this.theView.liveVideoDisplay(collector);
            }
            this.theView.updateCollectorStatus(CollectorStatus.STARTED, result);
        }
        if (device.getPlatform().equals(IAroDevice.Platform.iOS)) {
            for (int i = 0; i < 30; i++) {
                try {
                    if (!result.isSuccess() && result.getError().getCode() == 529) {
                        this.theView.updateCollectorStatus(CollectorStatus.CANCELLED, result);
                        this.theView.stopCollector();
                        break;
                    } else {
                        Thread.sleep(1000);
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
Also used : IAroDevice(com.att.aro.core.mobiledevice.pojo.IAroDevice) StatusResult(com.att.aro.core.datacollector.pojo.StatusResult) File(java.io.File) IOException(java.io.IOException)

Example 7 with IAroDevice

use of com.att.aro.core.mobiledevice.pojo.IAroDevice in project VideoOptimzer by attdevsupport.

the class AROController method getDevices.

private int getDevices(IAroDevices aroDevices, List<IDataCollector> collectors, DataCollectorType collectorType) {
    int count = 0;
    for (IDataCollector iDataCollector : collectors) {
        if (iDataCollector.getType().equals(collectorType) && aroDevices != null) {
            if (Util.isMacOS() && iDataCollector.getType().equals(DataCollectorType.IOS)) {
                StatusResult status = new StatusResult();
                IAroDevice[] aroDeviceArray = iDataCollector.getDevices(status);
                aroDevices.addDeviceArray(aroDeviceArray);
                count = aroDeviceArray == null ? 0 : aroDeviceArray.length;
            } else {
                IDevice[] androidDevices = getConnectedDevices();
                if (androidDevices != null && androidDevices.length > 0) {
                    aroDevices.addDeviceArray(androidDevices);
                }
                count = androidDevices == null ? 0 : androidDevices.length;
            }
        }
    }
    return count;
}
Also used : IAroDevice(com.att.aro.core.mobiledevice.pojo.IAroDevice) StatusResult(com.att.aro.core.datacollector.pojo.StatusResult) IDevice(com.android.ddmlib.IDevice) IDataCollector(com.att.aro.core.datacollector.IDataCollector)

Example 8 with IAroDevice

use of com.att.aro.core.mobiledevice.pojo.IAroDevice in project VideoOptimzer by attdevsupport.

the class DeviceTablePanel method getContentTable.

/**
 * Initializes and returns the RequestResponseTable.
 */
public DataTable<IAroDevice> getContentTable() {
    if (contentTable == null) {
        contentTable = new DataTable<IAroDevice>(tableModel);
        contentTable.setName(ResourceBundleHelper.getMessageString("collector.device.list.tableName"));
        contentTable.setAutoCreateRowSorter(true);
        contentTable.setGridColor(Color.LIGHT_GRAY);
        contentTable.setRowHeight(ROW_HEIGHT);
        contentTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
        contentTable.addMouseListener(this);
        DataTablePopupMenu popupMenu = (DataTablePopupMenu) contentTable.getPopup();
        popupMenu.initialize();
    }
    return contentTable;
}
Also used : IAroDevice(com.att.aro.core.mobiledevice.pojo.IAroDevice) DataTablePopupMenu(com.att.aro.ui.model.DataTablePopupMenu)

Example 9 with IAroDevice

use of com.att.aro.core.mobiledevice.pojo.IAroDevice in project VideoOptimzer by attdevsupport.

the class ARODataCollectorMenu method actionPerformed.

@Override
public void actionPerformed(ActionEvent aEvent) {
    if (aEvent.getActionCommand().equalsIgnoreCase(menuItemDatacollectorStart)) {
        Object event = aEvent.getSource();
        if (event instanceof JMenuItem) {
            List<IDataCollector> collectors = parent.getAvailableCollectors();
            if (collectors == null || collectors.isEmpty()) {
                MessageDialogFactory.showMessageDialog(((MainFrame) parent).getJFrame(), ResourceBundleHelper.getMessageString("collector.nocollectors"), ResourceBundleHelper.getMessageString("menu.error.title"), JOptionPane.ERROR_MESSAGE);
                return;
            }
            LOG.info("collector count:" + collectors.size());
            for (IDataCollector collector : collectors) {
                LOG.info(collector.getName());
            }
            IAroDevices aroDevices = parent.getAroDevices();
            IAroDevice device = null;
            if (aroDevices.size() != 0) {
                device = chooseDevice(aroDevices, collectors);
            } else {
                MessageDialogFactory.showMessageDialog(((MainFrame) parent).getJFrame(), ResourceBundleHelper.getMessageString("collector.nodevices"), ResourceBundleHelper.getMessageString("menu.error.title"), JOptionPane.INFORMATION_MESSAGE);
                return;
            }
            if (device == null) {
                MessageDialogFactory.showMessageDialog(((MainFrame) parent).getJFrame(), ResourceBundleHelper.getMessageString("collector.cancelled"), ResourceBundleHelper.getMessageString("menu.info.title"), JOptionPane.INFORMATION_MESSAGE);
                return;
            }
        }
    } else if (aEvent.getActionCommand().equalsIgnoreCase(menuItemDatacollectorStop)) {
        ((MainFrame) parent).stopCollector();
        setStartMenuItem(true);
    }
}
Also used : IAroDevice(com.att.aro.core.mobiledevice.pojo.IAroDevice) IAroDevices(com.att.aro.core.mobiledevice.pojo.IAroDevices) JMenuItem(javax.swing.JMenuItem) IDataCollector(com.att.aro.core.datacollector.IDataCollector)

Example 10 with IAroDevice

use of com.att.aro.core.mobiledevice.pojo.IAroDevice in project VideoOptimzer by attdevsupport.

the class Application method selectDevice.

private void selectDevice(ApplicationContext context, OutSave outSave) {
    aroDevices = showDevices(context, cmds);
    int selection = 0;
    IAroDevice device = null;
    // String selected = aroDevices.getId(3);
    if (aroDevices.size() > 1) {
        selection = -1;
        do {
            String range = "0-" + (aroDevices.size() - 1);
            String message = "Select a device, q to quit :" + range;
            String sValue = null;
            try {
                sValue = input(outSave, message, Pattern.compile("[" + range + "q]"));
                if (sValue.contains("q")) {
                    restoreSystemOut(outSave);
                    System.exit(0);
                }
                selection = Integer.valueOf(sValue);
            } catch (NumberFormatException e) {
                outln("Illegal entry, unable to parse \"" + sValue + "\"");
            }
        } while (selection < 0 || selection >= aroDevices.size());
    } else if (aroDevices.size() == 1 && aroDevices.getDevice(0).getState().equals(AroDeviceState.Available)) {
        selection = 0;
    } else {
        errln("No devices available");
        restoreSystemOut(outSave);
        System.exit(0);
    }
    // have a selected device
    device = aroDevices.getDevice(selection);
    cmds.setDeviceid(device.getId());
    // prepare collector choice
    String requestCollector = cmds.getAsk();
    if (cmds.getStartcollector() != null) {
        requestCollector = cmds.getStartcollector();
    }
    if (!collectorCompatibility(requestCollector, device)) {
        outln("Error :Incompatible collector for device:" + device.getPlatform() + ", collector:" + requestCollector);
        System.exit(0);
    }
    String deviceCollector = collectorSanityCheck(requestCollector, device);
    if (deviceCollector.startsWith("Error")) {
        outln(deviceCollector);
        System.exit(0);
    }
    if ("auto".equals(requestCollector)) {
        // store the auto selection
        cmds.setStartcollector(deviceCollector);
    } else if (!requestCollector.equalsIgnoreCase(deviceCollector)) {
        if (device.isRooted()) {
            // run rooted or vpn on rooted
            cmds.setStartcollector(requestCollector);
        } else if (!device.isRooted() && !requestCollector.equals("vpn_collector")) {
            // only run vpn on non-rooted
            cmds.setStartcollector(requestCollector);
        } else {
            outln("Error: incompatable collector for chosen device");
            System.exit(0);
        }
    } else {
        // allow the asked collector
        cmds.setStartcollector(requestCollector);
    }
}
Also used : IAroDevice(com.att.aro.core.mobiledevice.pojo.IAroDevice)

Aggregations

IAroDevice (com.att.aro.core.mobiledevice.pojo.IAroDevice)10 IDevice (com.android.ddmlib.IDevice)3 IDataCollector (com.att.aro.core.datacollector.IDataCollector)3 StatusResult (com.att.aro.core.datacollector.pojo.StatusResult)3 IOException (java.io.IOException)3 File (java.io.File)2 AdbCommandRejectedException (com.android.ddmlib.AdbCommandRejectedException)1 InstallException (com.android.ddmlib.InstallException)1 SyncException (com.android.ddmlib.SyncException)1 TimeoutException (com.android.ddmlib.TimeoutException)1 BaseTest (com.att.aro.core.BaseTest)1 IExternalProcessRunner (com.att.aro.core.commandline.IExternalProcessRunner)1 ExternalProcessRunnerImpl (com.att.aro.core.commandline.impl.ExternalProcessRunnerImpl)1 AROAndroidDevice (com.att.aro.core.mobiledevice.pojo.AROAndroidDevice)1 IAroDevices (com.att.aro.core.mobiledevice.pojo.IAroDevices)1 MetaDataModel (com.att.aro.core.tracemetadata.pojo.MetaDataModel)1 VideoOption (com.att.aro.core.video.pojo.VideoOption)1 IOSDevice (com.att.aro.datacollector.ioscollector.IOSDevice)1 DataCollectorSelectNStartDialog (com.att.aro.ui.commonui.DataCollectorSelectNStartDialog)1 MessageDialogFactory (com.att.aro.ui.commonui.MessageDialogFactory)1