Skip to content

Commit

Permalink
feat: Add a helper method to enable/disable bluetooth (#737)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach committed May 7, 2024
1 parent c57d18b commit 71c0d84
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/tools/adb-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,20 @@ methods.setAirplaneMode = async function setAirplaneMode (on) {
await this.shell(['cmd', 'connectivity', 'airplane-mode', on ? 'enable' : 'disable']);
};

/**
* Change the state of the bluetooth service on the device under test.
*
* @this {import('../adb.js').ADB}
* @param {boolean} on - True to enable bluetooth service and false to disable it.
*/
methods.setBluetoothOn = async function setBluetoothOn (on) {
if (await this.getApiLevel() < 30) {
throw new Error('Changing of the bluetooth state is not supported on your device');
}

await this.shell(['cmd', 'bluetooth_manager', on ? 'enable' : 'disable']);
};

/**
* Broadcast the state of Airplane mode on the device under test.
* This method should be called after {@link #setAirplaneMode}, otherwise
Expand Down

0 comments on commit 71c0d84

Please sign in to comment.