mirror of
https://github.com/adelphes/android-dev-ext.git
synced 2025-12-22 17:39:19 +00:00
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:
@@ -52,7 +52,13 @@ The following settings are used to configure the debugger:
|
|||||||
"staleBuild": "warn",
|
"staleBuild": "warn",
|
||||||
|
|
||||||
// Fully qualified path to the AndroidManifest.xml file compiled in the APK. Default: appSrcRoot/AndroidManifest.xml
|
// Fully qualified path to the AndroidManifest.xml file compiled in the APK. Default: appSrcRoot/AndroidManifest.xml
|
||||||
"manifestFile": "${workspaceRoot}/app/src/main/AndroidManifest.xml"
|
"manifestFile": "${workspaceRoot}/app/src/main/AndroidManifest.xml",
|
||||||
|
|
||||||
|
// APK install arguments passed to the Android package manager. Run 'adb shell pm' to show valid arguments. Default: ["-r"]
|
||||||
|
"pmInstallArgs": ["-r"],
|
||||||
|
|
||||||
|
// Manually specify the activity to run when the app is started.
|
||||||
|
"launchActivity": ".MainActivity"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
12
package.json
12
package.json
@@ -79,6 +79,11 @@
|
|||||||
"description": "Number of entries to display in call stack views (for locations outside of the project source). 0 shows the entire call stack. Default: 1",
|
"description": "Number of entries to display in call stack views (for locations outside of the project source). 0 shows the entire call stack. Default: 1",
|
||||||
"default": 1
|
"default": 1
|
||||||
},
|
},
|
||||||
|
"launchActivity": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Manually specify the activity to run when the app is started.",
|
||||||
|
"default": ""
|
||||||
|
},
|
||||||
"logcatPort": {
|
"logcatPort": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"description": "Port number to use for the internal logcat websocket link. Changes to this value only apply when the extension is restarted. Default: 7038",
|
"description": "Port number to use for the internal logcat websocket link. Changes to this value only apply when the extension is restarted. Default: 7038",
|
||||||
@@ -89,6 +94,11 @@
|
|||||||
"description": "Overrides the default location of AndroidManifest.xml",
|
"description": "Overrides the default location of AndroidManifest.xml",
|
||||||
"default": "${workspaceRoot}/app/src/main/AndroidManifest.xml"
|
"default": "${workspaceRoot}/app/src/main/AndroidManifest.xml"
|
||||||
},
|
},
|
||||||
|
"pmInstallArgs": {
|
||||||
|
"type": "array",
|
||||||
|
"description":"APK install arguments passed to the Android package manager. Run 'adb shell pm' to show valid arguments. Default: [\"-r\"]",
|
||||||
|
"default": ["-r"]
|
||||||
|
},
|
||||||
"staleBuild": {
|
"staleBuild": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Launch behaviour if source files have been saved after the APK was built. One of: [\"ignore\" \"warn\" \"stop\"]. Default: \"warn\"",
|
"description": "Launch behaviour if source files have been saved after the APK was built. One of: [\"ignore\" \"warn\" \"stop\"]. Default: \"warn\"",
|
||||||
@@ -102,7 +112,7 @@
|
|||||||
"trace": {
|
"trace": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Set to true to output debugging logs for diagnostics",
|
"description": "Set to true to output debugging logs for diagnostics",
|
||||||
"default": "false"
|
"default": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -245,6 +245,7 @@ class AndroidDebugSession extends DebugSession {
|
|||||||
this.app_src_root = ensure_path_end_slash(args.appSrcRoot);
|
this.app_src_root = ensure_path_end_slash(args.appSrcRoot);
|
||||||
this.apk_fpn = args.apkFile;
|
this.apk_fpn = args.apkFile;
|
||||||
this.manifest_fpn = args.manifestFile;
|
this.manifest_fpn = args.manifestFile;
|
||||||
|
this.pmInstallArgs = args.pmInstallArgs;
|
||||||
if (typeof args.callStackDisplaySize === 'number' && args.callStackDisplaySize >= 0)
|
if (typeof args.callStackDisplaySize === 'number' && args.callStackDisplaySize >= 0)
|
||||||
this.callStackDisplaySize = args.callStackDisplaySize|0;
|
this.callStackDisplaySize = args.callStackDisplaySize|0;
|
||||||
|
|
||||||
@@ -397,16 +398,19 @@ class AndroidDebugSession extends DebugSession {
|
|||||||
copyAndInstallAPK() {
|
copyAndInstallAPK() {
|
||||||
// copy the file to the device
|
// copy the file to the device
|
||||||
this.LOG('Deploying current build...');
|
this.LOG('Deploying current build...');
|
||||||
|
const device_apk_fpn = '/data/local/tmp/debug.apk';
|
||||||
return this._device.adbclient.push_file({
|
return this._device.adbclient.push_file({
|
||||||
filepathname:'/data/local/tmp/debug.apk',
|
filepathname:device_apk_fpn,
|
||||||
filedata:this._apk_file_data,
|
filedata:this._apk_file_data,
|
||||||
filemtime:new Date().getTime(),
|
filemtime:new Date().getTime(),
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// send the install command
|
// send the install command
|
||||||
this.LOG('Installing...');
|
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({
|
return this._device.adbclient.shell_cmd({
|
||||||
command:'pm install -r /data/local/tmp/debug.apk',
|
command,
|
||||||
untilclosed:true,
|
untilclosed:true,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -418,6 +422,12 @@ class AndroidDebugSession extends DebugSession {
|
|||||||
if (m) {
|
if (m) {
|
||||||
return $.Deferred().rejectWith(this, [new Error('Installation failed. ' + m[0])]);
|
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])]);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user