Allow customised install arguments (#75)

* add pmInstallArgs launch config property

* add missing launchActivity description
correct default trace value

* add launchActivity to the README

* add comment describing why we look for IllegalArgumentException
This commit is contained in:
Dave Holoway
2019-08-26 10:48:29 +01:00
committed by GitHub
parent 989de8254a
commit 7e958620a8
3 changed files with 30 additions and 4 deletions

View File

@@ -245,6 +245,7 @@ class AndroidDebugSession extends DebugSession {
this.app_src_root = ensure_path_end_slash(args.appSrcRoot);
this.apk_fpn = args.apkFile;
this.manifest_fpn = args.manifestFile;
this.pmInstallArgs = args.pmInstallArgs;
if (typeof args.callStackDisplaySize === 'number' && args.callStackDisplaySize >= 0)
this.callStackDisplaySize = args.callStackDisplaySize|0;
@@ -397,16 +398,19 @@ class AndroidDebugSession extends DebugSession {
copyAndInstallAPK() {
// copy the file to the device
this.LOG('Deploying current build...');
const device_apk_fpn = '/data/local/tmp/debug.apk';
return this._device.adbclient.push_file({
filepathname:'/data/local/tmp/debug.apk',
filepathname:device_apk_fpn,
filedata:this._apk_file_data,
filemtime:new Date().getTime(),
})
.then(() => {
// send the install command
this.LOG('Installing...');
const command = `pm install ${Array.isArray(this.pmInstallArgs) ? this.pmInstallArgs.join(' ') : '-r'} ${device_apk_fpn}`;
D(command);
return this._device.adbclient.shell_cmd({
command:'pm install -r /data/local/tmp/debug.apk',
command,
untilclosed:true,
})
})
@@ -418,6 +422,12 @@ class AndroidDebugSession extends DebugSession {
if (m) {
return $.Deferred().rejectWith(this, [new Error('Installation failed. ' + m[0])]);
}
// now the 'pm install' command can have user-defined arguments, we must check that the command
// is not rejected because of bad values
m = stdout.match(/^java.lang.IllegalArgumentException:.+/m);
if (m) {
return $.Deferred().rejectWith(this, [new Error('Installation failed. ' + m[0])]);
}
})
}