Skip to content

Commit

Permalink
Revert all adbkit upgrades (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
koral-- authored Mar 10, 2021
1 parent 84bf212 commit 53acc92
Show file tree
Hide file tree
Showing 25 changed files with 60 additions and 105 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

### Enhancements

- Update dependency versions, including adbkit rewritten in TypeScript
- Update dependency versions

## 3.5.0 (2020-10-18)

Expand Down
6 changes: 2 additions & 4 deletions lib/units/device/plugins/account.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var syrup = require('@devicefarmer/stf-syrup')
var DeviceClient = require('@devicefarmer/adbkit/dist/src/adb/DeviceClient').default

var logger = require('../../../util/logger')
var wire = require('../../../wire')
Expand All @@ -13,7 +12,6 @@ module.exports = syrup.serial()
.dependency(require('../support/push'))
.dependency(require('../support/adb'))
.define(function(options, service, identity, touch, router, push, adb) {
var deviceClient = new DeviceClient(adb, options.serial)
var log = logger.createLogger('device:plugins:account')

function checkAccount(type, account) {
Expand Down Expand Up @@ -283,11 +281,11 @@ module.exports = syrup.serial()
])
})
.catch(function() {
return deviceClient.clear('com.google.android.gsf.login')
return adb.clear(options.serial, 'com.google.android.gsf.login')
.catch(function() {
// The package name is different in 2.3, so let's try the old name
// if the new name fails.
return deviceClient.clear('com.google.android.gsf')
return adb.clear(options.serial, 'com.google.android.gsf')
})
.then(function() {
return service.addAccountMenu()
Expand Down
6 changes: 2 additions & 4 deletions lib/units/device/plugins/browser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
var syrup = require('@devicefarmer/stf-syrup')

var browsers = require('@devicefarmer/stf-browser-db')
var DeviceClient = require('@devicefarmer/adbkit/dist/src/adb/DeviceClient').default

var logger = require('../../../util/logger')
var wire = require('../../../wire')
Expand All @@ -24,7 +23,6 @@ module.exports = syrup.serial()
.dependency(require('../support/adb'))
.dependency(require('./service'))
.define(function(options, router, push, adb, service) {
var deviceClient = new DeviceClient(adb, options.serial)
var log = logger.createLogger('device:plugins:browser')

function pkg(component) {
Expand Down Expand Up @@ -105,7 +103,7 @@ module.exports = syrup.serial()
}

var reply = wireutil.reply(options.serial)
deviceClient.startActivity({
adb.startActivity(options.serial, {
action: 'android.intent.action.VIEW'
, component: message.browser
, data: message.url
Expand Down Expand Up @@ -138,7 +136,7 @@ module.exports = syrup.serial()
router.on(wire.BrowserClearMessage, function(channel, message) {
log.info('Clearing "%s"', message.browser)
var reply = wireutil.reply(options.serial)
deviceClient.clear(pkg(message.browser))
adb.clear(options.serial, pkg(message.browser))
.then(function() {
push.send([
channel
Expand Down
6 changes: 2 additions & 4 deletions lib/units/device/plugins/cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ var Promise = require('bluebird')
var _ = require('lodash')

var logger = require('../../../util/logger')
var DeviceClient = require('@devicefarmer/adbkit/dist/src/adb/DeviceClient').default

module.exports = syrup.serial()
.dependency(require('../support/adb'))
.dependency(require('../resources/service'))
.dependency(require('./group'))
.define(function(options, adb, service, group) {
var deviceClient = new DeviceClient(adb, options.serial)
var log = logger.createLogger('device:plugins:cleanup')
var plugin = Object.create(null)

Expand All @@ -19,12 +17,12 @@ module.exports = syrup.serial()
}

function listPackages() {
return deviceClient.getPackages()
return adb.getPackages(options.serial)
}

function uninstallPackage(pkg) {
log.info('Cleaning up package "%s"', pkg)
return deviceClient.uninstall(pkg)
return adb.uninstall(options.serial, pkg)
.catch(function(err) {
log.warn('Unable to clean up package "%s"', pkg, err)
return true
Expand Down
4 changes: 1 addition & 3 deletions lib/units/device/plugins/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var util = require('util')

var syrup = require('@devicefarmer/stf-syrup')
var Promise = require('bluebird')
var DeviceClient = require('@devicefarmer/adbkit/dist/src/adb/DeviceClient').default

var logger = require('../../../util/logger')
var grouputil = require('../../../util/grouputil')
Expand All @@ -23,7 +22,6 @@ module.exports = syrup.serial()
.dependency(require('./util/urlformat'))
.define(function(options, adb, router, push, group, solo, urlformat) {
var log = logger.createLogger('device:plugins:connect')
var deviceClient = new DeviceClient(adb, options.serial)
var plugin = Object.create(null)
var activeServer = null

Expand All @@ -36,7 +34,7 @@ module.exports = syrup.serial()
return resolve(plugin.url)
}

var server = deviceClient.createTcpUsbBridge({
var server = adb.createTcpUsbBridge(options.serial, {
auth: function(key) {
var resolver = Promise.defer()

Expand Down
8 changes: 3 additions & 5 deletions lib/units/device/plugins/filesystem.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
var syrup = require('@devicefarmer/stf-syrup')
var path = require('path')

var DeviceClient = require('@devicefarmer/adbkit/dist/src/adb/DeviceClient').default
var logger = require('../../../util/logger')
var wire = require('../../../wire')
var wireutil = require('../../../wire/util')
Expand All @@ -12,16 +11,15 @@ module.exports = syrup.serial()
.dependency(require('../support/push'))
.dependency(require('../support/storage'))
.define(function(options, adb, router, push, storage) {
var deviceClient = new DeviceClient(adb, options.serial)
var log = logger.createLogger('device:plugins:filesystem')
var plugin = Object.create(null)

plugin.retrieve = function(file) {
log.info('Retrieving file "%s"', file)

return deviceClient.stat(file)
return adb.stat(options.serial, file)
.then(function(stats) {
return deviceClient.pull(file)
return adb.pull(options.serial, file)
.then(function(transfer) {
// We may have add new storage plugins for various file types
// in the future, and add proper detection for the mimetype.
Expand Down Expand Up @@ -56,7 +54,7 @@ module.exports = syrup.serial()

router.on(wire.FileSystemListMessage, function(channel, message) {
var reply = wireutil.reply(options.serial)
deviceClient.readdir(message.dir)
adb.readdir(options.serial, message.dir)
.then(function(files) {
push.send([
channel
Expand Down
6 changes: 2 additions & 4 deletions lib/units/device/plugins/forward/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ var logger = require('../../../../util/logger')
var lifecycle = require('../../../../util/lifecycle')
var streamutil = require('../../../../util/streamutil')
var wireutil = require('../../../../wire/util')
var DeviceClient = require('@devicefarmer/adbkit/dist/src/adb/DeviceClient').default

var ForwardManager = require('./util/manager')

Expand All @@ -20,14 +19,13 @@ module.exports = syrup.serial()
.dependency(require('../../resources/minirev'))
.dependency(require('../group'))
.define(function(options, adb, router, push, minirev, group) {
var deviceClient = new DeviceClient(adb, options.serial)
var log = logger.createLogger('device:plugins:forward')
var plugin = Object.create(null)
var manager = new ForwardManager()

function startService() {
log.info('Launching reverse port forwarding service')
return deviceClient.shell([
return adb.shell(options.serial, [
'exec'
, minirev.bin
])
Expand All @@ -40,7 +38,7 @@ module.exports = syrup.serial()

function connectService(times) {
function tryConnect(times, delay) {
return deviceClient.openLocal('localabstract:minirev')
return adb.openLocal(options.serial, 'localabstract:minirev')
.timeout(10000)
.catch(function(err) {
if (/closed/.test(err.message) && times > 1) {
Expand Down
14 changes: 6 additions & 8 deletions lib/units/device/plugins/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ var stream = require('stream')
var url = require('url')
var util = require('util')

var DeviceClient = require('@devicefarmer/adbkit/dist/src/adb/DeviceClient').default
var syrup = require('@devicefarmer/stf-syrup')
var request = require('request')
var Promise = require('bluebird')
Expand All @@ -24,7 +23,6 @@ module.exports = syrup.serial()
.dependency(require('../support/router'))
.dependency(require('../support/push'))
.define(function(options, adb, router, push) {
var deviceClient = new DeviceClient(adb, options.serial)
var log = logger.createLogger('device:plugins:install')

router.on(wire.InstallMessage, function(channel, message) {
Expand Down Expand Up @@ -57,7 +55,7 @@ module.exports = syrup.serial()
var source = new stream.Readable().wrap(req)
var target = '/data/local/tmp/_app.apk'

return deviceClient.push(source, target)
return adb.push(options.serial, source, target)
.timeout(10000)
.then(function(transfer) {
var resolver = Promise.defer()
Expand Down Expand Up @@ -105,7 +103,7 @@ module.exports = syrup.serial()

sendProgress('installing_app', guesstimate)
return promiseutil.periodicNotify(
deviceClient.installRemote(apk)
adb.installRemote(options.serial, apk)
.timeout(60000 * 5)
.catch(function(err) {
switch (err.code) {
Expand All @@ -115,10 +113,10 @@ module.exports = syrup.serial()
'Uninstalling "%s" first due to inconsistent certificates'
, pkg
)
return deviceClient.uninstall(pkg)
return adb.uninstall(options.serial, pkg)
.timeout(15000)
.then(function() {
return deviceClient.installRemote(apk)
return adb.installRemote(options.serial, apk)
.timeout(60000 * 5)
})
default:
Expand Down Expand Up @@ -164,7 +162,7 @@ module.exports = syrup.serial()
)
// Progress 90%
sendProgress('launching_app', 90)
return deviceClient.startActivity(launchActivity)
return adb.startActivity(options.serial, launchActivity)
.timeout(30000)
}
}
Expand Down Expand Up @@ -207,7 +205,7 @@ module.exports = syrup.serial()

var reply = wireutil.reply(options.serial)

deviceClient.uninstall(message.packageName)
adb.uninstall(options.serial, message.packageName)
.then(function() {
push.send([
channel
Expand Down
4 changes: 1 addition & 3 deletions lib/units/device/plugins/logcat.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ var logger = require('../../../util/logger')
var wire = require('../../../wire')
var wireutil = require('../../../wire/util')
var lifecycle = require('../../../util/lifecycle')
var DeviceClient = require('@devicefarmer/adbkit/dist/src/adb/DeviceClient').default

module.exports = syrup.serial()
.dependency(require('../support/adb'))
Expand All @@ -14,7 +13,6 @@ module.exports = syrup.serial()
.dependency(require('./group'))
.define(function(options, adb, router, push, group) {
var log = logger.createLogger('device:plugins:logcat')
var deviceClient = new DeviceClient(adb, options.serial)
var plugin = Object.create(null)
var activeLogcat = null

Expand All @@ -24,7 +22,7 @@ module.exports = syrup.serial()
return plugin.stop()
.then(function() {
log.info('Starting logcat')
return deviceClient.openLogcat({
return adb.openLogcat(options.serial, {
clear: true
})
})
Expand Down
4 changes: 1 addition & 3 deletions lib/units/device/plugins/reboot.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@ var syrup = require('@devicefarmer/stf-syrup')
var logger = require('../../../util/logger')
var wire = require('../../../wire')
var wireutil = require('../../../wire/util')
var DeviceClient = require('@devicefarmer/adbkit/dist/src/adb/DeviceClient').default

module.exports = syrup.serial()
.dependency(require('../support/adb'))
.dependency(require('../support/router'))
.dependency(require('../support/push'))
.define(function(options, adb, router, push) {
var log = logger.createLogger('device:plugins:reboot')
var deviceClient = new DeviceClient(adb, options.serial)

router.on(wire.RebootMessage, function(channel) {
var reply = wireutil.reply(options.serial)

log.important('Rebooting')

deviceClient.reboot()
adb.reboot(options.serial)
.timeout(30000)
.then(function() {
push.send([
Expand Down
8 changes: 3 additions & 5 deletions lib/units/device/plugins/screen/capture.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var adbkit = require('@devicefarmer/adbkit')
var logger = require('../../../../util/logger')
var wire = require('../../../../wire')
var wireutil = require('../../../../wire/util')
var DeviceClient = require('@devicefarmer/adbkit/dist/src/adb/DeviceClient').default

module.exports = syrup.serial()
.dependency(require('../../support/adb'))
Expand All @@ -16,7 +15,6 @@ module.exports = syrup.serial()
.dependency(require('../../resources/minicap'))
.dependency(require('../util/display'))
.define(function(options, adb, router, push, storage, minicap, display) {
var deviceClient = new DeviceClient(adb, options.serial)
var log = logger.createLogger('device:plugins:screen:capture')
var plugin = Object.create(null)

Expand All @@ -39,14 +37,14 @@ module.exports = syrup.serial()
'-P %s -s >%s', projectionFormat(), file))
.then(adbkit.util.readAll)
.then(function() {
return deviceClient.stat(file)
return adb.stat(options.serial, file)
})
.then(function(stats) {
if (stats.size === 0) {
throw new Error('Empty screenshot; possibly secure screen?')
}

return deviceClient.pull(file)
return adb.pull(options.serial, file)
.then(function(transfer) {
return storage.store('image', transfer, {
filename: util.format('%s.jpg', options.serial)
Expand All @@ -56,7 +54,7 @@ module.exports = syrup.serial()
})
})
.finally(function() {
return deviceClient.shell(['rm', '-f', file])
return adb.shell(options.serial, ['rm', '-f', file])
.then(adbkit.util.readAll)
})
}
Expand Down
6 changes: 2 additions & 4 deletions lib/units/device/plugins/screen/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ var BroadcastSet = require('./util/broadcastset')
var StateQueue = require('../../../../util/statequeue')
var RiskyStream = require('../../../../util/riskystream')
var FailCounter = require('../../../../util/failcounter')
var DeviceClient = require('@devicefarmer/adbkit/dist/src/adb/DeviceClient').default

module.exports = syrup.serial()
.dependency(require('../../support/adb'))
.dependency(require('../../resources/minicap'))
.dependency(require('../util/display'))
.dependency(require('./options'))
.define(function(options, adb, minicap, display, screenOptions) {
var deviceClient = new DeviceClient(adb, options.serial)
var log = logger.createLogger('device:plugins:screen:stream')

function FrameProducer(config) {
Expand Down Expand Up @@ -278,7 +276,7 @@ module.exports = syrup.serial()

FrameProducer.prototype._connectService = function() {
function tryConnect(times, delay) {
return deviceClient.openLocal('localabstract:minicap')
return adb.openLocal(options.serial, 'localabstract:minicap')
.timeout(10000)
.then(function(out) {
return out
Expand Down Expand Up @@ -369,7 +367,7 @@ module.exports = syrup.serial()
log.info('Sending %s to minicap', signal)
return Promise.all([
output.waitForEnd()
, deviceClient.shell(['kill', signum, pid])
, adb.shell(options.serial, ['kill', signum, pid])
.then(adbkit.util.readAll)
.return(true)
])
Expand Down
Loading

0 comments on commit 53acc92

Please sign in to comment.