adolfintel / OpenPods

The Free and Open Source app for monitoring your AirPods on Android
https://fdossena.com/?p=openPods/index.frag
GNU General Public License v3.0
932 stars 161 forks source link

Android 11 compatibility #106

Closed adolfintel closed 3 years ago

adolfintel commented 3 years ago

There have been reports of OpenPods having issues with Android 11 (API 30), namely excessive battery usage due to intense BLE scanning.

I don't have a device with Android 11 yet, and I wasn't able to trace the issue so I decided to open this issue so that Android 11 users can provide feedback.

Possibly related issues: #88, #27

Electric1447 commented 3 years ago

Can confirm the app is functioning abnormally on my OnePlus 8 Pro running Android 11

Electric1447 commented 3 years ago

This might be worth a read: https://developer.android.com/about/versions/11/privacy/foreground-services

Tanddant commented 3 years ago

I've cloned and installed the fix - will report back.

Tanddant commented 3 years ago

15 minutes in and 15 minutes of Bluetooth wakelocks.

kghost commented 3 years ago

Pixel4 with Android 11, not only battery consuming problem, but also random system freeze, system process unresponsive, literal unable to use. Verified by install the app and uninstall several time. Always have problem when installed.

adolfintel commented 3 years ago

Well, looks like we have a proof of concept for a denial of service attack on our hands :joy:

Seriously, Google's ability to break their own shit will never cease to amaze me

quot commented 3 years ago

I'm having almost the exact same issues @kghost is having on my Pixel 5. The freezing seems to mostly happen when waking the device, which makes it difficult to unlock.

If you need any help testing a fix, I'd be glad to install it on my Pixel and upload any logs you'd need.

mkeedlinger commented 3 years ago

+1 I am having the exact same behaviour as @kghost on a Pixel 3a with Android 11. Also took the same debugging measures to ensure it was this app.

BTW I love this app! Can't wait to have this issue resolved :smile:

PablosCorner commented 3 years ago

I had been scratching my head for weeks figuring out why my phone was bugging out with the lock screen and system UI, and now I finally figured it out, after seeing this page. Hopefully this gets fixed soon.

kghost commented 3 years ago

The problem may not coming from bluetooth part.

You may using remote view for the systray notifications, it used to be very buggy with the remote view, if the application doesn't response (due to background CPU usage limitations), it can freeze the widget, if it is used inside the notifications, to can freeze the system process.

If you can make a temporary build which doesn't use the notification, but an activity, I can try it to check if the problem still exists.

Tanddant commented 3 years ago

The problem may not coming from bluetooth part.

The fact that there are hundreds of bluetooth scans a minute from the second you turn on bluetooth would indicate otherwise.

image

Electric1447 commented 3 years ago

I've reverted target api back to 29. Will need to see if it even changes anything.

Kurun-pan commented 3 years ago

After updating to the latest android 11 OS on Pixel 3XL, this app doesn't work at all. onScanResult seems be not called. Do you have any idea?

Tanddant commented 3 years ago

I Just saw your comment @Electric1447

Issue is still pressent it seems:

` 2-18 23:53:28.535 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472014

2021-02-18 23:53:28.545 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472024

2021-02-18 23:53:28.558 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472037

2021-02-18 23:53:28.569 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472048

2021-02-18 23:53:28.580 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472060

2021-02-18 23:53:28.593 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472072

2021-02-18 23:53:28.608 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472087

2021-02-18 23:53:28.625 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472104

2021-02-18 23:53:28.638 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472118

2021-02-18 23:53:28.653 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472133

2021-02-18 23:53:28.665 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472144

2021-02-18 23:53:28.676 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472155

2021-02-18 23:53:28.689 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472169

2021-02-18 23:53:28.703 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472182

2021-02-18 23:53:28.713 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472192

2021-02-18 23:53:28.724 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472203

2021-02-18 23:53:28.735 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472215

2021-02-18 23:53:28.747 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472226

2021-02-18 23:53:28.757 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472237

2021-02-18 23:53:28.771 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472250

2021-02-18 23:53:28.783 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472262

2021-02-18 23:53:28.795 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472274

2021-02-18 23:53:28.806 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472285

2021-02-18 23:53:28.813 12341-12700/com.dosse.airpods D/AirPods: Left: 9$ Right: 9$ Case: 15 Model: airpodspro

2021-02-18 23:53:28.817 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472297

2021-02-18 23:53:28.826 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472306

2021-02-18 23:53:28.836 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472316

2021-02-18 23:53:28.848 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472327

2021-02-18 23:53:28.858 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472337

2021-02-18 23:53:28.870 1782-1782/? D/BtGatt.ScanManager: awakened up at time 472349 `

ghost commented 3 years ago

Updated OnePlus 7T Pro (hotdog) to Android 11 with microg4lineageos and found OpenPods not functioning with my AirPods Pro even on v1.5.1, thought I get a logcat to see if the issue can be fixed.

woolmonkey commented 3 years ago

Just wondering any update on this?

Electric1447 commented 3 years ago

Nope

adolfintel commented 3 years ago

I don't have my airpods anymore so I can't test it. I didn't get any complaints though so maaaaybe it works?

Electric1447 commented 3 years ago

We need to look into this: https://developer.android.com/guide/topics/connectivity/companion-device-pairing#java

Electric1447 commented 3 years ago

@adolfintel Managed to fix android 11 compatibility. However, this solution is kinda fucked up and might destroy battery life.

adolfintel commented 3 years ago

It's better than nothing, can I see your code?

Electric1447 commented 3 years ago

I'll need to clean it a bit first and then I will push a commit.

adolfintel commented 3 years ago

Alright. If you think it's bad for battery life, you should probably only enable that code if SDK>=30

Electric1447 commented 3 years ago

That should fix android 11 compatibility. Took exactly 7 months to fix what google broke.

adolfintel commented 3 years ago

So basically you're using a foreground service instead of a background service. A lot of messaging apps are doing this to run on degoogled phones, it's not really a problem battery-wise.

Electric1447 commented 3 years ago

But this also requires having Location Access all the time

Electric1447 commented 3 years ago

debug apk for anyone who want to test it out on their device

app-debug.zip

kghost commented 3 years ago

Can you make the app as an activity which only works when I open it instead of consistent working in the background.

woolmonkey commented 3 years ago

IF your running 11 that is how it is working now. Shouldn’t be but you can’t give it location access permanently so you have to run the app then connect your headphones for it to work. At least that is how I have had to do it.

Electric1447 commented 3 years ago

Fixed in release 1.6

ghost commented 3 years ago

Thought I try to see if v1.6 fixed my problem and it doesn't show up for me for some reason. logcat.txt

Electric1447 commented 3 years ago

What is your phone, android version, android rom ect?

adolfintel commented 3 years ago

Found this in the log [ 06-16 20:02:36.687 1494: 1724 W/BroadcastQueue ] Background execution not allowed: receiving Intent { act=android.intent.action.PACKAGE_RESTARTED dat=package:com.dosse.airpods flg=0x10 (has extras) } to com.google.android.gms/org.microg.nlp.service.PackageChangedReceiver

ghost commented 3 years ago

It's a Pixel 4a with android 11 by LineageOS.

Electric1447 commented 3 years ago

Weird as I also using LineageOS 18.1 and everything works fine. I really do not understand what is written in the log

ghost commented 3 years ago

Should I get another log? I'm not sure why it doesn't work despite me enabling all the permissions it needs.

Electric1447 commented 3 years ago

I don't know as I am not really great with logs. Is it an offical or unofficial lineage build?

Electric1447 commented 3 years ago

If you can use adb and read verbose logs from the app it might help

Electric1447 commented 3 years ago

As if you would see transmissions from the airpods we'll know the problem is with the notification part

ghost commented 3 years ago

It is official, https://wiki.lineageos.org/devices/sunfish. I'll try to get that.

ghost commented 3 years ago

I tried doing that, not sure if this one helps or not. Always happy to get more logs though. logcat.txt

mkeedlinger commented 3 years ago

Just to +1, I have a Pixel 4a, stock Android 11 (up-to-date), and I am experiencing the same thing as @lurkingaroundagain (being that the notification does not seem to detect my airpods).

Thanks for all the work that's being done to fix this!