def _checkProvidedApk(self, pathToApk): ''' This methods validates the provided apk file. Raises: ApkIsNotValidException: if the provided apk file is not correct ''' (valid, error) = apk_utils.checkInputApkFile(pathToApk) if not valid: logger.error("Path %s points to the invalid apk file! ERROR:%s" % (pathToApk, error)) return valid return valid
def initAlreadyInstrApkEnv(self, pathToInstrApk, resultsDir, pathToInstrManifestFile=None): if not apk_utils.checkInputApkFile(pathToInstrApk): logger.error("Provided file [%s] is not a valid apk file!" % pathToInstrApk) return if not os.path.isdir(resultsDir): logger.error("Provided path to results dir [%s] do not point to dir!" % resultsDir) return coverageMetadataFolderPath = os.path.join(resultsDir, self.config.getCoverageMetadataRelativeDir()) if not os.path.isdir(coverageMetadataFolderPath): logger.error("In the results dir [%s] there is no folder with coverage metadata!" % resultsDir) return self.coverageMetadataFolder = coverageMetadataFolderPath if self.config.getCoverageMetadataFilename() not in os.listdir(coverageMetadataFolderPath): logger.error("Cannot find metadata filename in the coverage metadata folder: %s!" % self.coverageMetadataFolder) return self.coverageMetadataFile = os.path.join(self.coverageMetadataFolder, self.config.getCoverageMetadataFilename()) #by default trying to look for a file in the if pathToInstrManifestFile: androidManifestPath = pathToInstrManifestFile else: androidManifestPath = os.path.join(resultsDir, "AndroidManifest.xml") if not os.path.isfile(androidManifestPath): logger.warning("Path [%s] is not pointing to a real file! Leaving pointer to AndroidManifest.xml empty!" % androidManifestPath) return self.instrumentedApk = pathToInstrApk self.apkResultsDir = resultsDir self.runtimeReportsRootDir = self._createDir(resultsDir, self.config.getRuntimeReportsRelativeDir(), False, False) self.androidManifestFile = androidManifestPath self.androidManifest = AndroidManifest(self.androidManifestFile) self.packageName = self.androidManifest.getInstrumentationTargetPackage() self.runnerName = self.androidManifest.getInstrumentationRunnerName() self._bboxStateMachine.start(STATE_VALID_SETTINGS_PROVIDED)
def initAlreadyInstrApkEnv(self, pathToInstrApk, resultsDir, pathToInstrManifestFile=None): if not apk_utils.checkInputApkFile(pathToInstrApk): logger.error("Provided file [%s] is not a valid apk file!" % pathToInstrApk) return if not os.path.isdir(resultsDir): logger.error( "Provided path to results dir [%s] do not point to dir!" % resultsDir) return coverageMetadataFolderPath = os.path.join( resultsDir, self.config.getCoverageMetadataRelativeDir()) if not os.path.isdir(coverageMetadataFolderPath): logger.error( "In the results dir [%s] there is no folder with coverage metadata!" % resultsDir) return self.coverageMetadataFolder = coverageMetadataFolderPath if self.config.getCoverageMetadataFilename() not in os.listdir( coverageMetadataFolderPath): logger.error( "Cannot find metadata filename in the coverage metadata folder: %s!" % self.coverageMetadataFolder) return self.coverageMetadataFile = os.path.join( self.coverageMetadataFolder, self.config.getCoverageMetadataFilename()) #by default trying to look for a file in the if pathToInstrManifestFile: androidManifestPath = pathToInstrManifestFile else: androidManifestPath = os.path.join(resultsDir, "AndroidManifest.xml") if not os.path.isfile(androidManifestPath): logger.warning( "Path [%s] is not pointing to a real file! Leaving pointer to AndroidManifest.xml empty!" % androidManifestPath) return self.instrumentedApk = pathToInstrApk self.apkResultsDir = resultsDir self.runtimeReportsRootDir = self._createDir( resultsDir, self.config.getRuntimeReportsRelativeDir(), False, False) self.androidManifestFile = androidManifestPath self.androidManifest = AndroidManifest(self.androidManifestFile) self.packageName = self.androidManifest.getInstrumentationTargetPackage( ) self.runnerName = self.androidManifest.getInstrumentationRunnerName() self._bboxStateMachine.start(STATE_VALID_SETTINGS_PROVIDED)