Search in sources :

Example 6 with IDataCollector

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

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

the class Application method runDataCollector.

/**
 * Launches a DataCollection. Provides an input prompt for the user to stop the
 * collection by typing "stop"
 *
 * <pre>
 * Note:
 * Do not exit collection by pressing a ctrl-c
 * Doing so will exit ARO.Console but will not stop the trace on the device.
 * </pre>
 *
 * @param context
 * @param cmds
 */
// ignoring incorrect eclipse warning
@SuppressWarnings("null")
void runDataCollector(ApplicationContext context, Commands cmds) {
    if (cmds.getOutput() != null) {
        // LOGGER.info("runDataCollector");
        IDataCollectorManager colmg = context.getBean(IDataCollectorManager.class);
        colmg.getAvailableCollectors(context);
        IDataCollector collector = null;
        switch(cmds.getStartcollector()) {
            case "rooted_android":
                collector = colmg.getRootedDataCollector();
                break;
            case "vpn_android":
                collector = colmg.getNorootedDataCollector();
                break;
            case "ios":
                collector = colmg.getIOSCollector();
                if (cmds.getSudo().isEmpty() || !collector.setPassword(cmds.getSudo())) {
                    printError(ErrorCodeRegistry.getInvalidPasswordError());
                    System.exit(1);
                }
                if ("hd".equals(cmds.getVideo()) || "sd".equals(cmds.getVideo())) {
                    printError(ErrorCodeRegistry.getInvalidiOSArgs());
                    System.exit(1);
                }
                break;
            default:
                printError(ErrorCodeRegistry.getCollectorNotfound());
                System.exit(1);
                break;
        }
        StatusResult result = null;
        if (collector == null) {
            printError(ErrorCodeRegistry.getCollectorNotfound());
            System.exit(1);
        }
        if (cmds.getOverwrite().equalsIgnoreCase("yes")) {
            String traceName = cmds.getOutput();
            IFileManager filemanager = context.getBean(IFileManager.class);
            filemanager.directoryDeleteInnerFiles(traceName);
        }
        OutSave outSave = prepareSystemOut();
        AttenuatorModel model = getAttenuateModel(cmds);
        // If the user want to collect regular iOS collection, they can proceed
        if (DataCollectorType.IOS.equals(collector.getType()) && (model.isThrottleDLEnabled() || model.isThrottleULEnabled())) {
            if (isIOSAttenuationConfirmed() && NetworkUtil.isNetworkUp("bridge100")) {
                model.setConstantThrottle(true);
                println("Collection proceeded.");
            } else {
                System.exit(1);
            }
        }
        videoOption = configureVideoOption(cmds.getVideo());
        try {
            Hashtable<String, Object> extras = new Hashtable<String, Object>();
            Orientation videoOrientation = getOrientation(cmds.getVideoOrientation());
            extras.put("video_option", getVideoOption());
            extras.put("videoOrientation", videoOrientation == null ? Orientation.PORTRAIT : videoOrientation);
            extras.put("AttenuatorModel", model);
            extras.put("assignPermission", false);
            result = runCommand(cmds, collector, cmds.getSudo(), extras);
        } finally {
            restoreSystemOut(outSave);
        }
        if (result.getError() != null) {
            outln("Caught an error:");
            printError(result.getError());
        } else {
            outSave = prepareSystemOut();
            try {
                String input = "";
                print("Data collector is running, enter stop to save trace and quit program");
                print(">");
                do {
                    input = readInput();
                } while (!input.contains("stop"));
            } finally {
                restoreSystemOut(outSave);
            }
            println("stopping collector...");
            try {
                if (collector != null)
                    collector.stopCollector();
            } finally {
                restoreSystemOut(outSave);
            }
            println("collector stopped, trace saved to: " + cmds.getOutput());
            cleanUp(context);
            println("VO exited");
            System.exit(0);
        }
    } else {
        println("No output tracefolder was entered\n");
        usageHelp();
        System.exit(1);
    }
}
Also used : OutSave(com.att.aro.console.printstreamutils.OutSave) Hashtable(java.util.Hashtable) StatusResult(com.att.aro.core.datacollector.pojo.StatusResult) IDataCollectorManager(com.att.aro.core.datacollector.IDataCollectorManager) AttenuatorModel(com.att.aro.core.peripheral.pojo.AttenuatorModel) IDataCollector(com.att.aro.core.datacollector.IDataCollector) Orientation(com.att.aro.core.video.pojo.Orientation) IFileManager(com.att.aro.core.fileio.IFileManager)

Example 8 with IDataCollector

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

the class DataCollectorManagerImplTest method test.

@Test
public void test() {
    IDataCollector ios = Mockito.mock(IDataCollector.class);
    Mockito.when(ios.getType()).thenReturn(DataCollectorType.IOS);
    List<IDataCollector> collist = new ArrayList<IDataCollector>();
    collist.add(ios);
    cmg = (DataCollectorManagerImpl) context.getBean(IDataCollectorManager.class);
    ApplicationContext context = Mockito.mock(ApplicationContext.class);
    String[] arr = { "ios" };
    Mockito.when(context.getBeanNamesForType((Class<?>) Mockito.any())).thenReturn(arr);
    Mockito.when(context.getBean("ios")).thenReturn(ios);
    cmg.getAvailableCollectors(context);
    IDataCollector res = cmg.getIOSCollector();
    assertNotNull(res);
}
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)

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