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
970 stars 164 forks source link

AirPods 2 are not detected. #35

Closed f0s3 closed 4 years ago

f0s3 commented 4 years ago

Hi. I've downloaded your app using the direct link provided in the readme, and opened my Airpods 2 case when they are connected to the bluetooth and gps is turned on(just in case it is needed), allowed all the app wanted me to, yet there is no notification while I have your app opened on my Xiaomi Redmi 6. I am a developer myself, so if any additional info needed (data from android studio or anything else that might show why the app doesn't seem to detect the pods even though the music is playing through them), please let me know. IPhone 8 shows the firmware version as 2A364, were 1A661 before iphone has auto updated them.

adolfintel commented 4 years ago

Were they detected before the firmware update?

f0s3 commented 4 years ago

I'm not sure about this one, but I tried different apps from play market and none seemed to display battery status neither before firmware update nor after it.

f0s3 commented 4 years ago

Note that I have connected my phone to my laptop (ThinkPad x220 if it matters), and can now debug your application. I will leave the logs from the application below:

11/02 15:41:13: Launching 'app' on Xiaomi Redmi 6.
$ adb shell am start -n "com.dosse.airpods/com.dosse.airpods.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Waiting for application to come online: com.dosse.airpods | com.dosse.airpods.test
Waiting for application to come online: com.dosse.airpods | com.dosse.airpods.test
Connecting to com.dosse.airpods
Connected to the target VM, address: 'localhost:8600', transport: 'socket'
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/m.dosse.airpod: Late-enabling -Xcheck:jni
W/re-initialized>: type=1400 audit(0.0:6363): avc: denied { read } for name="u:object_r:mtk_amslog_prop:s0" dev="tmpfs" ino=175 scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:object_r:mtk_amslog_prop:s0 tclass=file permissive=0
E/libc: Access denied finding property "persist.vendor.sys.activitylog"
W/ActivityThread: Application com.dosse.airpods is waiting for the debugger on port 8100...
I/System.out: Sending WAIT chunk
I/System.out: Debugger has connected
    waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: debugger has settled (1376)
I/m.dosse.airpod: The ClassLoaderContext is a special shared library.
E/BoostFramework: BoostFramework() : Exception_1 = java.lang.ClassNotFoundException: com.qualcomm.qti.Performance
E/BoostFramework: BoostFramework() Ux Perf: Exception = java.lang.ClassNotFoundException: com.qualcomm.qti.UxPerformance
E/BoostFramework: BoostFramework() : Exception_1 = java.lang.ClassNotFoundException: com.qualcomm.qti.Performance
E/BoostFramework: BoostFramework() Ux Perf: Exception = java.lang.ClassNotFoundException: com.qualcomm.qti.UxPerformance
W/m.dosse.airpod: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection)
W/m.dosse.airpod: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection)
D/skia_mt: canRunInCoworker = true
I/Timeline: Timeline: Activity_launch_request time:16617015
W/Activity: Slow Operation: Activity com.dosse.airpods/.MainActivity onCreate took 1069ms
W/Looper: Slow Looper main: Activity com.dosse.airpods/.MainActivity is 3885ms late (wall=1320ms running=0ms ClientTransaction{ callbacks=[android.app.servertransaction.LaunchActivityItem] lifecycleRequest=android.app.servertransaction.ResumeActivityItem }) because of 1 msg, msg 1 took 3984ms (late=2ms h=android.app.ActivityThread$H w=110)
W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@488374c
I/SurfaceFactory: [static] sSurfaceFactory = com.mediatek.view.impl.SurfaceFactoryImpl@e0017ba
D/ViewRootImpl[IntroActivity]: hardware acceleration = true , fakeHwAccelerated = false, sRendererDisabled = false, forceHwAccelerated = false, sSystemRendererDisabled = false
V/PhoneWindow: DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl@4538661, this = DecorView@a87f586[IntroActivity]
D/Surface: Surface::allocateBuffers(this=0xa7598000)
W/RenderThread: type=1400 audit(0.0:6380): avc: denied { search } for name="clients" dev="debugfs" ino=6544 scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:object_r:debugfs_ion:s0 tclass=dir permissive=0
I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Swap behavior 2
D/Surface: Surface::connect(this=0xa7598000,api=1)
I/libEGL: [MTK Game SDK] low_latency_mode(0) pid(-1) property(-1)
E/ion: ioctl c0044901 failed with code -1: Invalid argument
I/m.dosse.airpod: ProcessProfilingInfo new_methods=588 is saved saved_to_disk=1 resolve_classes_delay=8000
I/Timeline: Timeline: Activity_launch_request time:16636808
V/PhoneWindow: DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl@4538661, this = DecorView@a87f586[IntroActivity]
I/Timeline: Timeline: Activity_launch_request time:16645541
W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@efe362f
E/BoostFramework: BoostFramework() : Exception_1 = java.lang.ClassNotFoundException: com.qualcomm.qti.Performance
E/BoostFramework: BoostFramework() Ux Perf: Exception = java.lang.ClassNotFoundException: com.qualcomm.qti.UxPerformance
E/BoostFramework: BoostFramework() : Exception_1 = java.lang.ClassNotFoundException: com.qualcomm.qti.Performance
E/BoostFramework: BoostFramework() Ux Perf: Exception = java.lang.ClassNotFoundException: com.qualcomm.qti.UxPerformance
W/m.dosse.airpod: Verification of void com.dosse.airpods.Starter.restartPodsService(android.content.Context) took 158.310ms
W/Activity: Slow Operation: Activity com.dosse.airpods/.MainActivity onCreate took 576ms
V/PhoneWindow: DecorView setVisiblity: visibility = 4, Parent = null, this = DecorView@e22fd17[]
D/ViewRootImpl[MainActivity]: hardware acceleration = true , fakeHwAccelerated = false, sRendererDisabled = false, forceHwAccelerated = false, sSystemRendererDisabled = false
V/PhoneWindow: DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl@bd8fd22, this = DecorView@e22fd17[MainActivity]
D/BluetoothHeadset: Proxy object connected
D/AirPods: START SCANNER
D/BluetoothAdapter: isLeEnabled(): ON
D/BluetoothLeScanner: onScannerRegistered() - status=0 scannerId=7 mScannerId=0
W/InputEventReceiver: Slow Input: 92665ms so far, now at dispatchInputEvent (MotionEvent: event_seq=4, seq=146033, action=ACTION_DOWN)
W/InputEventReceiver: Slow Input: 92440ms so far, now at dispatchInputEvent (MotionEvent: event_seq=5, seq=146077, action=ACTION_MOVE)
W/InputEventReceiver: Slow Input: 92450ms so far, now at dispatchInputEvent (MotionEvent: event_seq=6, seq=146079, action=ACTION_UP)
I/Choreographer: Skipped 8255 frames!  The application may be doing too much work on its main thread.
D/Surface: Surface::allocateBuffers(this=0x95a48800)
D/Surface: Surface::connect(this=0x95a48800,api=1)
I/libEGL: [MTK Game SDK] low_latency_mode(0) pid(-1) property(-1)
W/Looper: Slow Looper main: doFrame is 136006ms late because of 10 msg, msg 1 took 753ms (late=1ms h=android.app.ActivityThread$H w=159), msg 8 took 135806ms (late=132ms h=android.app.ActivityThread$H w=114)
D/AirPods: BT PROXY SERVICE CONNECTED
D/AirPods: BT PROXY: AIRPODS ALREADY CONNECTED
D/Surface: Surface::disconnect(this=0xa7598000,api=1)
W/Looper: Slow Looper main: doFrame is 377ms late because of 14 msg, msg 1 took 137ms (late=1ms h=android.view.Choreographer$FrameHandler c=android.view.Choreographer$FrameDisplayEventReceiver), msg 12 took 162ms (late=611ms h=android.view.ViewRootImpl$ViewRootHandler c=android.support.v7.app.AppCompatDelegateImpl$2)
V/PhoneWindow: DecorView setVisiblity: visibility = 4, Parent = android.view.ViewRootImpl@4538661, this = DecorView@a87f586[IntroActivity]
D/View: [Warning] assignParent to null: this = DecorView@a87f586[IntroActivity]
f0s3 commented 4 years ago

After a bit of debugging I've found out that this if has both maybeConnected and !(leftStatus==15&&rightStatus==15&&caseStatus==15) in it, thus the notification is not shown. Here is the file:line I am talking about. https://github.com/adolfintel/OpenPods/blob/ffd9bdcf89af5bed8de50a19aaadf0468438ff4e/OpenPods/app/src/main/java/com/dosse/airpods/PodsService.java#L257

As I am trying to trace down the reason, I have found that h.getConnectedDevices() in the line below has an empty list of items. https://github.com/adolfintel/OpenPods/blob/ffd9bdcf89af5bed8de50a19aaadf0468438ff4e/OpenPods/app/src/main/java/com/dosse/airpods/PodsService.java#L399

I have probably found the reason. In the line below, the expression is false. https://github.com/adolfintel/OpenPods/blob/ffd9bdcf89af5bed8de50a19aaadf0468438ff4e/OpenPods/app/src/main/java/com/dosse/airpods/PodsService.java#L376

By the way, if evaluating this expression and changing ACTION_ACL_CONNECTED to ACTION_ACL_DISCONNECTED, it still shows false, so what is ACL anyway?

Also please note that all ACTIONs are showing up false.

What I managed to get is maybeConnected is true somehow. Though the second condition about leftStatus, rightStatus and caseStatus is not passing, so I am debugging this one now.

adolfintel commented 4 years ago

That is very strange, keep me posted on this ;)

f0s3 commented 4 years ago

Maybe we can meet in skype and reverse-engineer together? It's difficult to read PodsService because it's way to much code in one file, so I'll refactor it once I get this working. I also think that it might be nice to lint the project according to the Java codestyle, and maybe some unit tests (if you want it to happen, of course). Though its a topic for another issue. Anyways, my skype is dima_kovpak.

adolfintel commented 4 years ago

Sure, if you have some time to spare and want to improve the codebase, feel free to do it and send a PR. I should point out that you're the only person to have reported this issue with airpods 2, in fact a guy reported the app to be working with the new airpods pro.

f0s3 commented 4 years ago

Could we meet in skype? I have a blue background on my profile photo and black "f0s3" written on the foreground.

f0s3 commented 4 years ago

I will try to get my friends' airpods 2 today to make sure it is my android and not my pods. I also have two more phones except my main one, maybe it is worth testing on them.

adolfintel commented 4 years ago

I normally don't use skype, but I can use it as a last resort. If you need to contact me directly, I prefer to use telegram, dosse91

f0s3 commented 4 years ago

Ok, let it be telegram. I don't use it either as it's a microsoft product and I also use it as a last resort. I just wanted to share my screen with you so we can debug that together. What I have found out that when connecting my pods to Xiaomi Redmi Note 5, AirBattery from play market, it detects my pods and shows percentages of case and each of the pods right away. I will try to use Redmi Note 5 with OpenPods and debug the correct behaviour to know what to expect from my phone (what should happen on my Redmi 6). Also note that I tried my friends' airpods 2 and they seem to have same problem on my phone (Redmi 6).

f0s3 commented 4 years ago

I will write about the progress of this issue briefly to keep the log of the work been made and the results. I have tried flashing Lineage OS 16.0 on my Redmi 6 and it bootlooped two times I tried, that's why I rolled back to the stock MIUI. There is no official support for my phone from any ROMs, except for the stock one, of course. It seems to be a ROM issue as it starts and then stops listening the data immediately after the start. I might wanna try to flash a miui with android 8.1 (one MIUI version before my current (10.4.4) - it's 10.3.6), as I have some other problems after updating, so it would fix them as well as (supposedly) bluetooth issues. I'm not sure if I will flash the 10.3.6 though, but I might give it a try one day I think. And of course, @adolfintel, I'm extremely grateful f or your help and guidance on flashing the ROMs. You've taught me very valuable things. I will reopen this if it ever gets solved by flashing the MIUI 10.3.6 or any other way.

f0s3 commented 4 years ago

@adolfintel I have flashed the 10.3.6, and even though airbattery started working on my phone and shows battery status of my pods but not the case, openpods doesn't show any notification. I recon it's because there is an if clause which looks on the case as well as both pods, and as airbattery doesn't show my case battery status, that's why the notification doesn't show up. I will debug why can't I get the case status but maybe we should add a fallback variant to show at least what we can and not when all of the battery levels are known. I will debug it later as I'm at work now.

f0s3 commented 4 years ago

    START SCANNER
D/BluetoothAdapter: isLeEnabled(): ON
D/BluetoothLeScanner: onScannerRegistered() - status=0 scannerId=5 mScannerId=0
D/BluetoothHeadset: Proxy object connected
D/AirPods: BT PROXY SERVICE CONNECTED
D/AirPods: ACL CONNECTED```

Here is what I have now. Still no notification as all statuses are at 15.
adolfintel commented 4 years ago

Didn't we already determine that it was a ROM bug?

f0s3 commented 4 years ago

Yes, but I flashed the MIUI 10.3.6 (Previous version, on which sometimes it works somehow), and now the logs are different.

f0s3 commented 4 years ago

I flashed the lineageos 16.0 (android 9), and it doesn't work. seems to be an issue with android 9 on my device(redmi 6). I will flash the lineageos 15.0 based on android 8.1 and it should work. Posting here just for future reference.