appium-adb
Advanced tools
Comparing version 2.0.0-beta4 to 2.0.0-beta5
@@ -6,2 +6,3 @@ import _ from 'lodash'; | ||
const JAR_PATH = path.resolve(rootDir, 'jars'); | ||
const DEFAULTS_OPTS = { | ||
@@ -26,3 +27,3 @@ sdkRoot: null, | ||
jars: {}, | ||
helperJarPath: path.resolve(rootDir, 'jars') | ||
helperJarPath: JAR_PATH | ||
}; | ||
@@ -51,7 +52,6 @@ | ||
for (let jarName of tempJars) { | ||
this.jars[jarName] = path.resolve(__dirname, '../jars', jarName); | ||
this.jars[jarName] = path.resolve(JAR_PATH, jarName); | ||
} | ||
if (!this.javaVersion || parseFloat(this.javaVersion) < 1.7) { | ||
this.jars['appium_apk_tools.jar'] = path.resolve(__dirname, | ||
'../jars', | ||
this.jars['appium_apk_tools.jar'] = path.resolve(JAR_PATH, | ||
'appium_apk_tools_1.6.jar'); | ||
@@ -58,0 +58,0 @@ } |
import { buildStartCmd, getActivityRelativeName } from '../helpers.js'; | ||
import { exec } from 'teen_process'; | ||
import log from '../logger.js'; | ||
import path from 'path'; | ||
import _ from 'lodash'; | ||
import { sleep } from 'asyncbox'; | ||
import { fs } from '../utils'; | ||
@@ -160,2 +163,35 @@ let apkUtilsMethods = {}; | ||
apkUtilsMethods.extractStringsFromApk = async function (apk, language, out) { | ||
log.debug("Extracting strings for language: " + (language || "default")); | ||
let stringsJson = 'strings.json'; | ||
if (!language) { | ||
language = await this.getDeviceLanguage(); | ||
} | ||
let apkTools = this.jars['appium_apk_tools.jar']; | ||
let args = ['-jar', apkTools, 'stringsFromApk', apk, out, language]; | ||
let fileData, apkStrings; | ||
try { | ||
await exec('java', args); | ||
} catch (e) { | ||
log.debug(`No strings.xml for language '${language}', getting default ` + | ||
`strings.xml`); | ||
args.pop(); | ||
await exec('java', args); | ||
} | ||
try { | ||
log.debug("Reading strings from converted strings.json"); | ||
fileData = await fs.readFile(path.join(out, stringsJson), 'utf8'); | ||
apkStrings = JSON.parse(fileData); | ||
} catch (e) { | ||
if (fileData) { | ||
log.debug("Content started with: " + fileData.slice(0, 300)); | ||
} | ||
let msg = `Could not parse strings from strings.json. Original ` + | ||
`error: ${e.message}`; | ||
log.errorAndThrow(msg); | ||
} | ||
return apkStrings; | ||
}; | ||
export default apkUtilsMethods; |
@@ -16,3 +16,4 @@ import _mv from 'mv'; | ||
readdir: B.promisify(_fs.readdir), | ||
writeFile: B.promisify(_fs.writeFile) | ||
writeFile: B.promisify(_fs.writeFile), | ||
readFile: B.promisify(_fs.readFile) | ||
}, | ||
@@ -19,0 +20,0 @@ rootDir = path.resolve(__dirname, process.env.NO_PRECOMPILE ? '..' : '../..'), |
{ | ||
"name": "appium-adb", | ||
"version": "2.0.0-beta4", | ||
"version": "2.0.0-beta5", | ||
"description": "appium-adb", | ||
@@ -5,0 +5,0 @@ "main": "./build/index.js", |
@@ -72,2 +72,6 @@ import chai from 'chai'; | ||
}); | ||
it('extractStringsFromApk should get strings for default language', async () => { | ||
let strings = await adb.extractStringsFromApk(contactManagerPath, null, '/tmp'); | ||
strings.save.should.equal('Save'); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 16 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21800185
65
3120
19