Search in sources :

Example 1 with ExternalProcessRunnerImpl

use of com.att.aro.core.commandline.impl.ExternalProcessRunnerImpl in project VideoOptimzer by attdevsupport.

the class ARODataCollectorMenu method chooseDevice.

private IAroDevice chooseDevice(IAroDevices aroDevices, List<IDataCollector> collectors) {
    ArrayList<IAroDevice> deviceList = aroDevices.getDeviceList();
    IAroDevice device = null;
    int delayTimeDL = 0;
    int throttleDL = 0;
    int throttleUL = 0;
    boolean throttleDLEnable = false;
    boolean throttleULEnable = false;
    boolean profileBoolean = false;
    String traceFolderName = "";
    String profileLocation = "";
    if (((MainFrame) parent).getPreviousOptions() != null) {
        previousOptions = ((MainFrame) parent).getPreviousOptions();
    }
    metaDataModel = new MetaDataModel();
    DataCollectorSelectNStartDialog dialog = new DataCollectorSelectNStartDialog(((MainFrame) parent).getJFrame(), parent, deviceList, traceFolderName, collectors, true, previousOptions, metaDataModel);
    if (dialog.getResponse()) {
        device = dialog.getDevice();
        traceFolderName = dialog.getTraceFolder();
        device.setCollector(dialog.getCollectorOption());
        /*debug purpose*/
        delayTimeDL = dialog.getDeviceOptionPanel().getAttenuatorModel().getDelayDS();
        dialog.getDeviceOptionPanel().getAttenuatorModel().getDelayUS();
        throttleDL = dialog.getDeviceOptionPanel().getAttenuatorModel().getThrottleDL();
        throttleUL = dialog.getDeviceOptionPanel().getAttenuatorModel().getThrottleUL();
        throttleDLEnable = dialog.getDeviceOptionPanel().getAttenuatorModel().isThrottleDLEnabled();
        throttleULEnable = dialog.getDeviceOptionPanel().getAttenuatorModel().isThrottleULEnabled();
        profileLocation = dialog.getDeviceOptionPanel().getAttenuatorModel().getLocalPath();
        profileBoolean = dialog.getDeviceOptionPanel().getAttenuatorModel().isLoadProfile();
        LOG.info("set U delay: " + delayTimeDL + ", set D delay: " + delayTimeDL + ", set U throttle: " + throttleUL + ", set D throttle: " + throttleDL + ", set profile: " + profileBoolean + ", set profileLocation: " + profileLocation);
        if (device.isPlatform(IAroDevice.Platform.iOS)) {
            IDataCollector iosCollector = findIOSCollector(collectors);
            if ((throttleDLEnable || throttleULEnable) && !NetworkUtil.isNetworkUp(SharedNetIF)) {
                MessageDialogFactory.getInstance().showInformationDialog(((MainFrame) parent).getJFrame(), ResourceBundleHelper.getMessageString("dlog.collector.option.attenuator.attenuation.finalwarning"), ResourceBundleHelper.getMessageString("dlog.collector.option.attenuator.attenuation.noshared"));
                return null;
            }
            if (!checkSetSuPassword(iosCollector)) {
                return null;
            } else {
                LOG.info("pw validated");
            }
        }
        String traceFolderPath = (device.getPlatform().equals(IAroDevice.Platform.Android)) ? Util.getAROTraceDirAndroid() + System.getProperty("file.separator") + traceFolderName : Util.getAROTraceDirIOS() + System.getProperty("file.separator") + traceFolderName;
        String currentPath = ((MainFrame) parent).getTracePath();
        if (fileManager.directoryExistAndNotEmpty(traceFolderPath)) {
            int result = folderExistsDialog();
            if (result == JOptionPane.OK_OPTION) {
                if (traceFolderPath.equals(currentPath)) {
                    new MessageDialogFactory().showErrorDialog(null, ResourceBundleHelper.getMessageString("viewer.contentUnwritable"));
                    return null;
                }
                File mountPoint = fileManager.createFile(traceFolderPath, IOSCollectorImpl.IOSAPP_MOUNT);
                if (fileManager.createFile(traceFolderPath, IOSCollectorImpl.IOSAPP_MOUNT).exists() && device.getPlatform().equals(IAroDevice.Platform.iOS)) {
                    IExternalProcessRunner runner = new ExternalProcessRunnerImpl();
                    String results = runner.executeCmd(String.format("umount %s;rmdir %s", mountPoint, mountPoint));
                    if (!results.isEmpty()) {
                        new MessageDialogFactory().showErrorDialog(null, traceFolderPath + "/" + IOSCollectorImpl.IOSAPP_MOUNT + " is BUSY");
                        return null;
                    } else {
                        int count = 0;
                        while (fileManager.directoryExistAndNotEmpty(mountPoint.toString())) {
                            if (++count > 5) {
                                new MessageDialogFactory().showErrorDialog(null, traceFolderPath + "/" + IOSCollectorImpl.IOSAPP_MOUNT + " will not release, please detach the iOS device and delete the foldere manually");
                                return null;
                            }
                            try {
                                Thread.sleep(1000);
                            } catch (InterruptedException e) {
                                Log.error("sleep interrupted");
                            }
                        }
                    }
                }
                fileManager.deleteFolderContents(traceFolderPath);
            } else {
                return null;
            }
        }
        Hashtable<String, Object> extras = prepareStartCollectorExtras(device, traceFolderName, dialog);
        updateMetaData(device, traceFolderName, dialog);
        extras.put("DIALOG_SIZE", dialog.getBaseSize());
        if (dialog.getDeviceOptionPanel().getLabeledExpandedOptionFields().isVisible()) {
            extras.put("MetaDataExpanded", true);
        }
        ((MainFrame) parent).startCollector(device, traceFolderName, extras, metaDataModel);
    } else {
        traceFolderName = null;
    }
    dialog.dispose();
    return device;
}
Also used : MetaDataModel(com.att.aro.core.tracemetadata.pojo.MetaDataModel) MainFrame(com.att.aro.ui.view.MainFrame) IExternalProcessRunner(com.att.aro.core.commandline.IExternalProcessRunner) IAroDevice(com.att.aro.core.mobiledevice.pojo.IAroDevice) DataCollectorSelectNStartDialog(com.att.aro.ui.commonui.DataCollectorSelectNStartDialog) MessageDialogFactory(com.att.aro.ui.commonui.MessageDialogFactory) IDataCollector(com.att.aro.core.datacollector.IDataCollector) File(java.io.File) ExternalProcessRunnerImpl(com.att.aro.core.commandline.impl.ExternalProcessRunnerImpl)

Aggregations

IExternalProcessRunner (com.att.aro.core.commandline.IExternalProcessRunner)1 ExternalProcessRunnerImpl (com.att.aro.core.commandline.impl.ExternalProcessRunnerImpl)1 IDataCollector (com.att.aro.core.datacollector.IDataCollector)1 IAroDevice (com.att.aro.core.mobiledevice.pojo.IAroDevice)1 MetaDataModel (com.att.aro.core.tracemetadata.pojo.MetaDataModel)1 DataCollectorSelectNStartDialog (com.att.aro.ui.commonui.DataCollectorSelectNStartDialog)1 MessageDialogFactory (com.att.aro.ui.commonui.MessageDialogFactory)1 MainFrame (com.att.aro.ui.view.MainFrame)1 File (java.io.File)1