Search in sources :

Example 1 with IDataCollector

use of com.att.aro.core.datacollector.IDataCollector in project VideoOptimzer by attdevsupport.

the class DataCollectorManagerImplTest method test1.

@Test
public void test1() {
    // IDataCollector ios = Mockito.mock(IDataCollector.class);
    // Mockito.when(ios.getType()).thenReturn(DataCollectorType.IOS);
    List<IDataCollector> collist = new ArrayList<IDataCollector>();
    IDataCollector defaultCollector = Mockito.mock(IDataCollector.class);
    Mockito.when(defaultCollector.getType()).thenReturn(DataCollectorType.DEFAULT);
    collist.add(defaultCollector);
    IDataCollector iosCollector = Mockito.mock(IDataCollector.class);
    Mockito.when(iosCollector.getType()).thenReturn(DataCollectorType.IOS);
    collist.add(iosCollector);
    IDataCollector rootedCollector = Mockito.mock(IDataCollector.class);
    Mockito.when(rootedCollector.getType()).thenReturn(DataCollectorType.ROOTED_ANDROID);
    collist.add(rootedCollector);
    IDataCollector nonRootedCollector = Mockito.mock(IDataCollector.class);
    Mockito.when(nonRootedCollector.getType()).thenReturn(DataCollectorType.NON_ROOTED_ANDROID);
    collist.add(nonRootedCollector);
    cmg = (DataCollectorManagerImpl) context.getBean(IDataCollectorManager.class);
    ApplicationContext context = Mockito.mock(ApplicationContext.class);
    String[] arr = { "ios", "default", "rooted", "nonrooted" };
    Mockito.when(context.getBeanNamesForType((Class<?>) Mockito.any())).thenReturn(arr);
    Mockito.when(context.getBean("ios")).thenReturn(iosCollector);
    Mockito.when(context.getBean("default")).thenReturn(defaultCollector);
    Mockito.when(context.getBean("rooted")).thenReturn(rootedCollector);
    Mockito.when(context.getBean("nonrooted")).thenReturn(nonRootedCollector);
    List<IDataCollector> collectors = cmg.getAvailableCollectors(context);
    IDataCollector res = cmg.getIOSCollector();
    assertNotNull(res);
    IDataCollector res1 = cmg.getNorootedDataCollector();
    assertNotNull(res1);
    IDataCollector res2 = cmg.getRootedDataCollector();
    assertNotNull(res2);
    assertEquals(3, collectors.size());
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) ArrayList(java.util.ArrayList) IDataCollector(com.att.aro.core.datacollector.IDataCollector) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 2 with IDataCollector

use of com.att.aro.core.datacollector.IDataCollector 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)

Example 3 with IDataCollector

use of com.att.aro.core.datacollector.IDataCollector in project VideoOptimzer by attdevsupport.

the class AROController method getAroDevices.

/**
 * Builds a list of IAroDevices
 *
 * @return a list of IAroDevices
 */
public IAroDevices getAroDevices() {
    // IDevice[] androidDevices = null;
    IAroDevices aroDevices = new AroDevices();
    List<IDataCollector> collectors = getAvailableCollectors();
    if (Util.isMacOS()) {
        getDevices(aroDevices, collectors, DataCollectorType.IOS);
    }
    if (getDevices(aroDevices, collectors, DataCollectorType.ROOTED_ANDROID) == 0) {
        getDevices(aroDevices, collectors, DataCollectorType.NON_ROOTED_ANDROID);
    }
    return aroDevices;
}
Also used : IAroDevices(com.att.aro.core.mobiledevice.pojo.IAroDevices) IDataCollector(com.att.aro.core.datacollector.IDataCollector) IAroDevices(com.att.aro.core.mobiledevice.pojo.IAroDevices) AroDevices(com.att.aro.core.mobiledevice.pojo.AroDevices)

Example 4 with IDataCollector

use of com.att.aro.core.datacollector.IDataCollector 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 5 with IDataCollector

use of com.att.aro.core.datacollector.IDataCollector in project VideoOptimzer by attdevsupport.

the class AROController method loadCollector.

/**
 * Loads the appropriate collector for an IAroDevice
 *
 * @param device an IAroDevice
 * @return collector associated with the device
 */
private IDataCollector loadCollector(IAroDevice device) {
    IDataCollector collector = null;
    if (device.isPlatform(IAroDevice.Platform.Android)) {
        if (device.isRooted()) {
            LOG.debug("rooted device");
            isRooted = true;
            collector = context.getBean(IDataCollectorManager.class).getRootedDataCollector();
        } else {
            LOG.debug("non-rooted device");
            collector = context.getBean(IDataCollectorManager.class).getNorootedDataCollector();
        }
    } else if (device.isPlatform(IAroDevice.Platform.iOS)) {
        LOG.debug("iOS device");
        collector = context.getBean(IDataCollectorManager.class).getIOSCollector();
    }
    return collector;
}
Also used : IDataCollectorManager(com.att.aro.core.datacollector.IDataCollectorManager) IDataCollector(com.att.aro.core.datacollector.IDataCollector)

Aggregations

IDataCollector (com.att.aro.core.datacollector.IDataCollector)8 IAroDevice (com.att.aro.core.mobiledevice.pojo.IAroDevice)3 BaseTest (com.att.aro.core.BaseTest)2 IDataCollectorManager (com.att.aro.core.datacollector.IDataCollectorManager)2 StatusResult (com.att.aro.core.datacollector.pojo.StatusResult)2 IAroDevices (com.att.aro.core.mobiledevice.pojo.IAroDevices)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 ApplicationContext (org.springframework.context.ApplicationContext)2 IDevice (com.android.ddmlib.IDevice)1 OutSave (com.att.aro.console.printstreamutils.OutSave)1 IExternalProcessRunner (com.att.aro.core.commandline.IExternalProcessRunner)1 ExternalProcessRunnerImpl (com.att.aro.core.commandline.impl.ExternalProcessRunnerImpl)1 IFileManager (com.att.aro.core.fileio.IFileManager)1 AroDevices (com.att.aro.core.mobiledevice.pojo.AroDevices)1 AttenuatorModel (com.att.aro.core.peripheral.pojo.AttenuatorModel)1 MetaDataModel (com.att.aro.core.tracemetadata.pojo.MetaDataModel)1 Orientation (com.att.aro.core.video.pojo.Orientation)1 DataCollectorSelectNStartDialog (com.att.aro.ui.commonui.DataCollectorSelectNStartDialog)1 MessageDialogFactory (com.att.aro.ui.commonui.MessageDialogFactory)1