Skip to content
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

Can't detect headphones whose name has been changed #6

Open
byf3332 opened this issue May 24, 2023 · 8 comments
Open

Can't detect headphones whose name has been changed #6

byf3332 opened this issue May 24, 2023 · 8 comments

Comments

@byf3332
Copy link

byf3332 commented May 24, 2023

The headphones' name can be changed via setting on a HUAWEI phone. After the change Freebuddy cannot detect the headphones.
Maybe you can try detect through MAC address that belongs to HUAWEI.
System:Havoc OS on Android Q
Screenshot_20230524-095105
Screenshot_20230524-095111

@TheLastGimbus
Copy link
Owner

TheLastGimbus commented May 29, 2023

Ah damn. On my LineageOS, this changes the device.alias property, and I even use it in the app as their name!

Your mac is 10:5D:DC:8D:E8:1F, right? i'll try to find matching parts with mine...

System:Havoc OS

Wait, so you have huawei or havoc custom rom?

@byf3332
Copy link
Author

byf3332 commented May 29, 2023

Your mac is 10:5D:DC:8D:E8:1F, right?

Yes, that's my headphones' mac address

System:Havoc OS
Wait, so you have huawei or havoc custom rom?

This is another device, not my huawei phone.

(However my huawei phone is also unlocked and rooted on emui 9 though, ready to flash something into it, exploring now)

@TheLastGimbus
Copy link
Owner

So, when you changed their name on huawei device, they changed it permanently?? Interesting... maybe there's some hidden api for that that we could use too 😁

@byf3332
Copy link
Author

byf3332 commented May 30, 2023

So, when you changed their name on huawei device, they changed it permanently??

Yes, requires specified system version of huawei/honor device (requires Magic UI ?, I changed the name on KOZ-AL00 running on Magic UI 4,which is my friend's phone. But I tried EMUI 10 and Harmony OS, none of them changed the device name but only name displayed on the device), and the name change is permanent, you can see it on another device just like Apple Airpods.
However now I don't have emui 10 system so I'm unable to test it now (To root I have to downgrade to emui 9 to unlock bootloader).

@byf3332
Copy link
Author

byf3332 commented Jun 2, 2023

Can you tell me where is the code for detecting headphones? I 'll try to fork and build one using my custom name 🤔

I barely know anything about flutter, but thanks to your actions I can build apks for me.

Also I've found that when I reset my headphones by long press the button for 30s(which resets the name), Freebuddy can detect my headphones. Then I changed the name again, I'm still able to use Freebuddy as I didn't delete my headphones from the list. But if I re-pair the headphones (deleting device first), then I'll be unable to use Freebuddy again.

@byf3332
Copy link
Author

byf3332 commented Jun 3, 2023

Found a temporary solution for rooted device:
Go to/data/misc/bluedroid/,there will be 2 files
bt_config.confandbt_config.bak,which comtains the same thing🤔.
Turn bluetooth off, and use a text editor to open both of the file, change the Name = xxxtoName = HUAWEI FreeBuds 4i which is under your device's MAC in both file, then save. Now You shall see The name in bluetooth devices list has changed to what you set in the file, and Freebuddy should work now.
Screenshot_20230603-204609
Screenshot_20230603-204557

@TheLastGimbus
Copy link
Owner

ll try to fork and build one using my custom name thinking

brave of you! bulding should be straightforward, so shouldn't be a problem - here are the lines:

final otter = devices
.firstWhereOrNull((d) => OtterConst.btDevNameRegex.hasMatch(d.name));

static final btDevNameRegex =
RegExp(r'^(?=(HUAWEI FreeBuds 4i))', caseSensitive: true);

you can just change .firstWhereOrNull((d) => OtterConst.btDevNameRegex.hasMatch(d.name)); to

.firstWhereOrNull((d) => d.mac == 'YOUR:MAC:HERE' );

(something like that)

@TheLastGimbus
Copy link
Owner

In general, i will need to write some nicer algo that would read UUID advertisiments - tho this will require some messing with bluetooth apis (nothing pleasant 🤮 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants