mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 08:03:30 +02:00
Implement APK uploads using the new storage system. Installation from URL still does not work, and dropping the file on the screen may not work either.
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
var stream = require('stream')
|
||||
var url = require('url')
|
||||
var util = require('util')
|
||||
|
||||
var syrup = require('syrup')
|
||||
var request = require('request')
|
||||
@@ -17,7 +19,7 @@ module.exports = syrup.serial()
|
||||
var log = logger.createLogger('device:plugins:install')
|
||||
|
||||
router.on(wire.InstallMessage, function(channel, message) {
|
||||
log.info('Installing "%s"', message.url)
|
||||
log.info('Installing "%s"', message.href)
|
||||
|
||||
var reply = wireutil.reply(options.serial)
|
||||
|
||||
@@ -30,7 +32,7 @@ module.exports = syrup.serial()
|
||||
|
||||
function pushApp() {
|
||||
var req = request({
|
||||
url: message.url
|
||||
url: url.resolve(options.storageUrl, message.href)
|
||||
})
|
||||
|
||||
// We need to catch the Content-Length on the fly or we risk
|
||||
@@ -104,16 +106,30 @@ module.exports = syrup.serial()
|
||||
.timeout(30000)
|
||||
})
|
||||
.then(function() {
|
||||
if (message.launchActivity) {
|
||||
log.info(
|
||||
'Launching activity with action "%s" on component "%s"'
|
||||
, message.launchActivity.action
|
||||
, message.launchActivity.component
|
||||
)
|
||||
// Progress 90%
|
||||
sendProgress('launching_app', 90)
|
||||
return adb.startActivity(options.serial, message.launchActivity)
|
||||
.timeout(15000)
|
||||
if (message.launch) {
|
||||
var manifest = JSON.parse(message.manifest)
|
||||
if (manifest.application.launcherActivities.length) {
|
||||
var launchActivity = {
|
||||
action: 'android.intent.action.MAIN'
|
||||
, component: util.format(
|
||||
'%s/%s'
|
||||
, manifest.package
|
||||
, manifest.application.launcherActivities[0].name
|
||||
)
|
||||
, category: ['android.intent.category.LAUNCHER']
|
||||
, flags: 0x10200000
|
||||
}
|
||||
|
||||
log.info(
|
||||
'Launching activity with action "%s" on component "%s"'
|
||||
, launchActivity.action
|
||||
, launchActivity.component
|
||||
)
|
||||
// Progress 90%
|
||||
sendProgress('launching_app', 90)
|
||||
return adb.startActivity(options.serial, launchActivity)
|
||||
.timeout(15000)
|
||||
}
|
||||
}
|
||||
})
|
||||
.then(function() {
|
||||
|
||||
Reference in New Issue
Block a user