From a08f50e155e60774a974214b264535e543be969c Mon Sep 17 00:00:00 2001 From: Simo Kinnunen Date: Tue, 25 Aug 2015 18:17:53 +0900 Subject: [PATCH] Lock rotation when devices are being used if --lock-rotation is given. --- lib/cli.js | 11 ++++++++++- lib/units/device/plugins/group.js | 1 + lib/units/device/plugins/service.js | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index 3fc921a5..9b0ed5c9 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -70,6 +70,8 @@ program , '${publicIp}:${publicPort}') .option('--mute-master' , 'whether to mute master volume when devices are being used') + .option('--lock-rotation' + , 'whether to lock rotation when devices are being used') .action(function() { var serials = cliutil.allUnknownArgs(arguments) , options = cliutil.lastArg(arguments) @@ -110,7 +112,8 @@ program , '--connect-url-pattern', options.connectUrlPattern , '--heartbeat-interval', options.heartbeatInterval ] - .concat(options.muteMaster ? ['--mute-master'] : [])) + .concat(options.muteMaster ? ['--mute-master'] : []) + .concat(options.lockRotation ? ['--lock-rotation'] : [])) } , endpoints: { sub: options.connectSub @@ -172,6 +175,8 @@ program , 10000) .option('--mute-master' , 'whether to mute master volume when devices are being used') + .option('--lock-rotation' + , 'whether to lock rotation when devices are being used') .action(function(serial, options) { if (!options.connectSub) { this.missingArgument('--connect-sub') @@ -210,6 +215,7 @@ program , connectPort: options.connectPort , heartbeatInterval: options.heartbeatInterval , muteMaster: options.muteMaster + , lockRotation: options.lockRotation }) }) @@ -942,6 +948,8 @@ program , String) .option('--mute-master' , 'whether to mute master volume when devices are being used') + .option('--lock-rotation' + , 'whether to lock rotation when devices are being used') .action(function() { var log = logger.createLogger('cli:local') , args = arguments @@ -1008,6 +1016,7 @@ program ] .concat(options.allowRemote ? ['--allow-remote'] : []) .concat(options.muteMaster ? ['--mute-master'] : []) + .concat(options.lockRotation ? ['--lock-rotation'] : []) .concat(cliutil.allUnknownArgs(args))) // auth diff --git a/lib/units/device/plugins/group.js b/lib/units/device/plugins/group.js index 883a8653..c69b0e78 100644 --- a/lib/units/device/plugins/group.js +++ b/lib/units/device/plugins/group.js @@ -104,6 +104,7 @@ module.exports = syrup.serial() plugin.on('leave', function() { service.pressKey('home') + service.thawRotation() service.releaseWakeLock() }) diff --git a/lib/units/device/plugins/service.js b/lib/units/device/plugins/service.js index 5f8ce68f..91b3a32a 100644 --- a/lib/units/device/plugins/service.js +++ b/lib/units/device/plugins/service.js @@ -365,7 +365,7 @@ module.exports = syrup.serial() plugin.rotate = function(rotation) { return runAgentCommand( apk.wire.MessageType.SET_ROTATION - , new apk.wire.SetRotationRequest(rotation, false) + , new apk.wire.SetRotationRequest(rotation, options.lockRotation || false) ) }