Skip to content

Fix to get the bluetooth name as device name #1641

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 35 additions & 27 deletions src/device-managers/AndroidDeviceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -631,35 +631,43 @@ export default class AndroidDeviceManager implements IDeviceManager {
isRealDevice: boolean,
): Promise<string | undefined> => {
const props = isRealDevice
? ['ro.vendor.oplus.market.name', 'ro.display.series', 'ro.product.name']
: ['ro.kernel.qemu.avd_name', 'ro.boot.qemu.avd_name'];
? ['ro.vendor.oplus.market.name', 'ro.display.series', 'ro.product.name']
: ['ro.kernel.qemu.avd_name', 'ro.boot.qemu.avd_name'];

let deviceName;

deviceName = await (
await adbInstance
).adbExec([
'-s',
udid,
'shell',
'dumpsys',
'bluetooth_manager',
'|',
'grep',
'name:',
'|',
'cut',
'-c9-',
'|',
'head',
'-n',
'1',
]);


if (!deviceName || (deviceName && deviceName.trim() === '')) {
// If the device name is null or empty, try to get it from the product name.
for (const prop of props) {
deviceName = await this.getDeviceProperty(adbInstance, udid, prop);
if (deviceName && deviceName.trim() !== '') {
break;
}
}
}

let deviceName;

for (const prop of props) {
deviceName = await this.getDeviceProperty(adbInstance, udid, prop);
if (deviceName && deviceName.trim() !== '') {
break;
}
}
if (!deviceName || (deviceName && deviceName.trim() === '')) {
// If the device name is null or empty, try to get it from the Bluetooth manager.
deviceName = await (
await adbInstance
).adbExec([
'-s',
udid,
'shell',
'dumpsys',
'bluetooth_manager',
'|',
'grep',
'name:',
'|',
'cut',
'-c9-',
]);
}
return deviceName;
};
}
Loading