mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-20 21:05:18 +02:00
Implement enable/disable bluetooth of device (#754)
Signed-off-by: Jussi Vatjus-Anttila <jussiva@gmail.com>
This commit is contained in:
committed by
GitHub
parent
63ad4f138e
commit
e958a599cb
@@ -1,5 +1,7 @@
|
||||
module.exports = function DeviceSettingsCtrl($scope, $timeout) {
|
||||
$scope.wifiEnabled = true
|
||||
$scope.bluetoothEnabled = true
|
||||
$scope.bluetoothPending = false
|
||||
|
||||
function getWifiStatus() {
|
||||
if ($scope.control) {
|
||||
@@ -19,6 +21,35 @@ module.exports = function DeviceSettingsCtrl($scope, $timeout) {
|
||||
}
|
||||
}
|
||||
|
||||
function getBluetoothStatus() {
|
||||
if ($scope.control) {
|
||||
$scope.bluetoothPending = true
|
||||
$scope.control.getBluetoothStatus()
|
||||
.then(function(result) {
|
||||
$scope.$apply(function() {
|
||||
$scope.bluetoothEnabled = (result.lastData === 'bluetooth_enabled')
|
||||
})
|
||||
})
|
||||
.finally(function() {
|
||||
$scope.bluetoothPending = false
|
||||
})
|
||||
}
|
||||
}
|
||||
getBluetoothStatus()
|
||||
|
||||
$scope.toggleBluetooth = function(enable) {
|
||||
if ($scope.control) {
|
||||
$scope.bluetoothPending = true
|
||||
$scope.control.setBluetoothEnabled(enable)
|
||||
.then(function() {
|
||||
$scope.bluetoothEnabled = enable
|
||||
})
|
||||
.finally(function() {
|
||||
$scope.bluetoothPending = false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
$scope.$watch('ringerMode', function(newValue, oldValue) {
|
||||
if (oldValue) {
|
||||
if ($scope.control) {
|
||||
|
||||
Reference in New Issue
Block a user