@Test public void gotLocalAPK_pushApk() throws Exception { when(device.getSyncService()).thenThrow(new IOException()); when(filemanager.fileExist(any(String.class))).thenReturn(true); boolean testResult = rootedAndroidCollectorImpl.pushApk(device); assertEquals(true, testResult); }
boolean pushApk(IDevice device) { String filepath = getAROCollectorLocation(); boolean gotLocalAPK = true; if (!filemanager.fileExist(filepath)) { ClassLoader loader = RootedAndroidCollectorImpl.class.getClassLoader(); if (!extractor.extractFiles(filepath, ROOTEDCOLLECTOR_APKNAME, loader)) { gotLocalAPK = false; } } if (gotLocalAPK) { try { device.installPackage(filepath, true); log.debug("installed apk in device"); filemanager.deleteFile(filepath); } catch (InstallException e) { log.error(e.getMessage()); return false; } } else { return false; } return true; }
RootedAndroidCollectorImpl implements IDataCollector, IVideoImageSubscriber { boolean pushApk(IDevice device) { String filepath = getAROCollectorLocation(); boolean gotLocalAPK = true; if (!filemanager.fileExist(filepath)) { ClassLoader loader = RootedAndroidCollectorImpl.class.getClassLoader(); if (!extractor.extractFiles(filepath, ROOTEDCOLLECTOR_APKNAME, loader)) { gotLocalAPK = false; } } if (gotLocalAPK) { try { device.installPackage(filepath, true); log.debug("installed apk in device"); filemanager.deleteFile(filepath); } catch (InstallException e) { log.error(e.getMessage()); return false; } } else { return false; } return true; } }
RootedAndroidCollectorImpl implements IDataCollector, IVideoImageSubscriber { boolean pushApk(IDevice device) { String filepath = getAROCollectorLocation(); boolean gotLocalAPK = true; if (!filemanager.fileExist(filepath)) { ClassLoader loader = RootedAndroidCollectorImpl.class.getClassLoader(); if (!extractor.extractFiles(filepath, ROOTEDCOLLECTOR_APKNAME, loader)) { gotLocalAPK = false; } } if (gotLocalAPK) { try { device.installPackage(filepath, true); log.debug("installed apk in device"); filemanager.deleteFile(filepath); } catch (InstallException e) { log.error(e.getMessage()); return false; } } else { return false; } return true; }  }
RootedAndroidCollectorImpl implements IDataCollector, IVideoImageSubscriber { boolean pushApk(IDevice device) { String filepath = getAROCollectorLocation(); boolean gotLocalAPK = true; if (!filemanager.fileExist(filepath)) { ClassLoader loader = RootedAndroidCollectorImpl.class.getClassLoader(); if (!extractor.extractFiles(filepath, ROOTEDCOLLECTOR_APKNAME, loader)) { gotLocalAPK = false; } } if (gotLocalAPK) { try { device.installPackage(filepath, true); log.debug("installed apk in device"); filemanager.deleteFile(filepath); } catch (InstallException e) { log.error(e.getMessage()); return false; } } else { return false; } return true; }  int getMilliSecondsForTimeout(); @Override String getName(); @Override void addDeviceStatusSubscriber(IDeviceStatus devicestatus); @Override void addVideoImageSubscriber(IVideoImageSubscriber subscriber); @Override int getMajorVersion(); @Override String getMinorVersion(); @Override DataCollectorType getType(); @Override boolean isRunning(); @Override String[] getLog(); @Override StatusResult startCollector(boolean isCommandLine, String folderToSaveTrace, VideoOption videoOption_old, String password); @Override StatusResult startCollector(boolean isCommandLine, String folderToSaveTrace, VideoOption videoOption_old, boolean isLiveViewVideo, String deviceId, Hashtable<String, Object> extraParams, String password); @Override void timeOutShutdown(); @Override void haltCollectorInDevice(); @Override boolean isTrafficCaptureRunning(int seconds); void startVideoCapture(); @Override StatusResult stopCollector(); @Override void receiveImage(BufferedImage videoimage); @Override String getPassword(); @Override boolean setPassword(String requestPassword); @Override String[] getDeviceSerialNumber(StatusResult status); @Override IAroDevice[] getDevices(StatusResult status); @Override boolean isDeviceDataPulled(); }
RootedAndroidCollectorImpl implements IDataCollector, IVideoImageSubscriber { boolean pushApk(IDevice device) { String filepath = getAROCollectorLocation(); boolean gotLocalAPK = true; if (!filemanager.fileExist(filepath)) { ClassLoader loader = RootedAndroidCollectorImpl.class.getClassLoader(); if (!extractor.extractFiles(filepath, ROOTEDCOLLECTOR_APKNAME, loader)) { gotLocalAPK = false; } } if (gotLocalAPK) { try { device.installPackage(filepath, true); log.debug("installed apk in device"); filemanager.deleteFile(filepath); } catch (InstallException e) { log.error(e.getMessage()); return false; } } else { return false; } return true; }  int getMilliSecondsForTimeout(); @Override String getName(); @Override void addDeviceStatusSubscriber(IDeviceStatus devicestatus); @Override void addVideoImageSubscriber(IVideoImageSubscriber subscriber); @Override int getMajorVersion(); @Override String getMinorVersion(); @Override DataCollectorType getType(); @Override boolean isRunning(); @Override String[] getLog(); @Override StatusResult startCollector(boolean isCommandLine, String folderToSaveTrace, VideoOption videoOption_old, String password); @Override StatusResult startCollector(boolean isCommandLine, String folderToSaveTrace, VideoOption videoOption_old, boolean isLiveViewVideo, String deviceId, Hashtable<String, Object> extraParams, String password); @Override void timeOutShutdown(); @Override void haltCollectorInDevice(); @Override boolean isTrafficCaptureRunning(int seconds); void startVideoCapture(); @Override StatusResult stopCollector(); @Override void receiveImage(BufferedImage videoimage); @Override String getPassword(); @Override boolean setPassword(String requestPassword); @Override String[] getDeviceSerialNumber(StatusResult status); @Override IAroDevice[] getDevices(StatusResult status); @Override boolean isDeviceDataPulled();  }