BimmerGestalt / AAIdrive

Implementations of some Android Auto features as unofficial IDrive apps
MIT License
541 stars 90 forks source link

AAI Lose control to Library Spotify API #254

Closed Kamil2398 closed 3 years ago

Kamil2398 commented 3 years ago

Screenshot_20210419-163728_AndroidAutoIdrive

Spotify loses API access control, below is a screenshot. It usually occurs when I leave work (second connection with the car during the day). I can not grant control again (I will post a video showing this situation) to fix this you need to close the Spotify connection in the Android application settings. Link to video https://youtu.be/iCkgkWzvric I described this problem in #239 as well, whether I use Connected or My Bmw the problem is the same. If you have any questions, I will be happy to help you, I would like the application to be as stable and popular as possible soon to reward your work Huffman :)

hufman commented 3 years ago

Thank you very much for bringing this problem out to a separate issue for tracking, and providing the video showing the problem! Do you know what version of Spotify you see this one? I saw that you were trying an older version, is this version still installed or did it auto-upgrade to the latest? During the work day, do you see the Spotify Connection popup from #217? I wonder if this old connection is preventing the new connection from the drive home. I think I'm close to a fix on it, and if this is related, I will bump the priority up!

Kamil2398 commented 3 years ago

Thank you very much for bringing this problem out to a separate issue for tracking, and providing the video showing the problem! Do you know what version of Spotify you see this one? I saw that you were trying an older version, is this version still installed or did it auto-upgrade to the latest? During the work day, do you see the Spotify Connection popup from #217? I wonder if this old connection is preventing the new connection from the drive home. I think I'm close to a fix on it, and if this is related, I will bump the priority up!

I decided to return to the newest one available on Google Play with the thought that it makes the most sense for an app test. So during the day it always shows that the Spotify application is connected. On the first connection after killing the Spotify connection everything is fine so I think it may be related.

Interestingly, when I run Spotify (without a car) via AAI, the connection closes properly, see the video 😊 link : https://youtu.be/kLZ-W8C-AMw

See also this second video, when I finished the song manually (probably that's what idrive6 does), the Spotify connection notification has not disappeared. It only disappeared when I restarted the song with AAI and stopped . Second link : https://youtu.be/aPvj3aEOAjw

LACNR commented 3 years ago

What happens if you connect to the car but never open AAI and simply open Spotify in phone only (e.g. to select a song right away) and/or directly from the car only?

I noticed that once in a awhile the Spotify Connection pop-up notification does remain for me too, but only very rarely I assume that's because I almost never open the AAI when connected to the car, but then I do this might be the only time then the Spotify Connection notification locks up. I'm also not sure if it even says Spotify Connection when I didn't open AAI, maybe it only appears when you actually open AAI (and maybe additionally select Spotify from the app)

Kamil2398 commented 3 years ago

Honestly, I never really started AAI until everything was fine. Now I have forced the application to stop and we will see what happens tomorrow when I am in the car.From what it seems to me this morning when I started Spotify I did it directly from idrive selecting Spotify source. Then when I got to work the Spotify connection was still active.When I left work a few hours later, the aforementioned problem occurred

LACNR commented 3 years ago

I didn't think about it much because it happened rarely and didn't give me trouble that I would notice. I will keep an eye on it tomorrow if the popup appears and remains and if it will prevent me from connecting the next time by.

fabssor commented 3 years ago

Since some time I also noticed some more issues with spotify. After the second connection (often when I leave work) and the spotify notification (as described in #217 and here) is still present the connection seems to be broken. Audio will play but I cannot control the media via IDrive. Also the cover art does not show up. After force closing and restarting spotify, AAiD and MyBMW it works again.

I will post a video when I use my car the next time!

hufman commented 3 years ago

I believe the latest version has a fix for the Spotify Connections, please check if it also fixes this!

LACNR commented 3 years ago

Thank you hufman!

I have not updated yet but as thought yesterday, Spotify Connection didn't show up for me and didn't appear after disconnecting either, eventually because I didn't open AAI itself, but selected Spotify from the iDrive.

I will see what it will do after work.

Kamil2398 commented 3 years ago

Unfortunately, my problem is still the latest version of AAI and Spotify, everything is fine with the first connection. Screenshot_20210420-175916_One UI Home I tried different combinations, I cleared the cache in every application. I restarted the phone unfortunately the problem is the same as the previous AAI release

fabssor commented 3 years ago

So also teseted it. It did not work from the beginning. I removed the "do not optimize battery" option for spotify in the Android settings and swicht back to intelligent mode just for spotify. After that it started to work and the connection was closed to spotify.

Kamil2398 commented 3 years ago

So also teseted it. It did not work from the beginning. I removed the "do not optimize battery" option for spotify in the Android settings and swicht back to intelligent mode just for spotify. After that it started to work and the connection was closed to spotify.

How to swicht back to intelligent mode for Spotify? When will I click to back optimalize again battery, will I achieve the desired effect?

LACNR commented 3 years ago

I still haven't updated but everything works fine for me, doesn't matter what I do, even if the Spotify Connection PopUp appears it does and stays, it disappears everytime when I disconnect the phone, even when I controlled Spotify via the AAiD app during connection, no noticeable restrictions for me.

I'm using a slightly older build, maybe that helps to track down the cause for you? Build Version: 1.2.2-405-7e7d2d1 07.04.2021

Edit: Although working fine apparently after controlling Spotify via the app (only a guess) during the connection, it seems I can not properly control Spotify in Spotify when I'm no longer connected.

I can select any track it will play and use the shuffle Button it will shuffle the playlist, but it will not show me the current played song nor progress and the shuffle button has no text. Everything is back to normal after force shut Spotify.

https://i.postimg.cc/MpRjdRMm/Screenshot-20210420-200800-Spotify.jpg

Kamil2398 commented 3 years ago

For me, even after restoring the default settings and reinstalling Spotify, the connection is still open. I also removed the connection on the Spotify website in the applications and then granted AAI access again. Unfortunately, nothing helped and the problem persists, so it's not Huffman yet

engbibi commented 3 years ago

For me, even after restoring the default settings and reinstalling Spotify, the connection is still open. I also removed the connection on the Spotify website in the applications and then granted AAI access again. Unfortunately, nothing helped and the problem persists, so it's not Huffman yet

Same for me, no aforementioned solution works: after disconnection, the subsequent connections will not work for searching.

hufman commented 3 years ago

I did experience this once yesterday, which means I have a better chance to figure out what's going wrong!

Kamil2398 commented 3 years ago

Huffman, until you fix the closing of the connection, will continue to have the problem that I reported. When the connection is not closed and we try to start music from spotify by connecting to the car or selecting spotify from the AAI interface, it loses control to the api. Overall, there was also a problem with Spotify connected on the side of Spotify producers, it was just not visible sometimes what is being played, but they have already fixed it.We are waiting for a repair with AAI and thank you again for your application :)

Edit:I closed accidentally

Edit2: I will ask again, you already know what's going on and we can expect a fairly quick repair or do you have to be patient?

LACNR commented 3 years ago

@hufman Strangely it works fine for me except the Spotify App displaying malfunction I mentioned before but could have been Spotify itself. Otherwise this morning and evening I didn't even saw the Spotify Connection message at all. And yesterday it disappared properly whenever I disconnected from the car - as said I didn't come across to update to the latest nightlies yet. It seems it is not a consistant problem at least for me I only expierenced once that the Spotify Connection popup didn't disappeared itself.

For everyone my Spotify version: 8.5.68.904

Marc2480 commented 3 years ago

Hi all, let me first express my "thanks a lot" for this amazing tool! I only found it last week while seriously looking a solution for loosing the Spotify connectivity in my X3 G01 (from early 2018 with ID6).

I have been trying certain combo's of CD, SP and AAI, now running MyBMW 1.3.4 (6706 EU), Spotify 8.6.20.1063 and AAI build 419. Must say works almost perfect, can get in and out of the car restarting everything and most of time (>+ 95%) without any hick-ups, I do have my phone mostly unlocked before starting the car (no idea if this can have an impact).

So far only a few times I also experienced this lost of access to the library browsing (as shown by the threat starter), Spotify still continues playing whatever was playing. Trying to re-connect doesn't really help (too many tries required, not safe while driving ;)), so my quick fix here is then to restart the phone and reconnect ...

So overall I am very impressed and happy with AAI. One small improvement would be ideal for me ... when browsing the SP library, the list is not shown alphabetically, so sometimes difficult to find the entry you are looking for as shown here ...

20210423_124553

Is this a Spotify issue/setting or could this be facilitated in AAI ?

thanks again for the amazing work! Marc2480

LACNR commented 3 years ago

@Marc2480

The default order by Spotify itself is that the first song you (or other user, Spotify itself) added to the playlist will be on top of the list and the last song at the bottom, while you can change in what order the song in the playlist should be displayed in the Spotify App for the individual device in the individual app (Last Added First, First added First, Alphabetic..) the hardcoded default order is always First to Last Added. This means external devices always display it by the "hardcoded" spotify default setting regardless the individual Spotify app setting.

About your problem, if you expierence it force killing Spotify from your device's app manager should work, so you don't need to restart your phone.

Marc2480 commented 3 years ago

@LACNR

thx for the info and suggestion, will give it a try the next time it happens. Maybe this alphabetic order display can become a minor feature request ??

Kamil2398 commented 3 years ago

@hufman how's the work going? When can you expect to fix this problem so that I don't have to constantly kill the application to reconnect to the car after work?

hufman commented 3 years ago

I haven't found time to focus on this, I apologize.

LACNR commented 3 years ago

@hufman I don't think there's the need apologize, you did so much amazing work and still take on ideas for the future, I'm also sure you have enough other things going on so puttin some kind of pressure on you is not right.

@Kamil2398 Give him some time, and having to kill the application isn't killing anyone. It might be kinda annoying doing it on the long run but its a thing of a few seconds. Whats strange though that it seems I don't expierence the problem.

@Marc2480 Maybe, if Spotify allows that external systems can adjust the displaying order when app running in the iDrive.

bpowder1966 commented 3 years ago

@LACNR I have been experiencing the same issue @Kamil2398 reported for a few months now. To see if it made a difference, I am using the my bmw app but it happened on bmw connected also. I am also using the latest nightly build of AAI.

LACNR commented 3 years ago

What if it is a problem with ID6 and/or a certain Spotify Version because it seems only people with ID6 report this it seems, I'm having ID4++ using a Spotify Build from Sepember 2020 and I had the reported issue only once, but no matter what I do a cannot replicate the problem.

Marc2480 commented 3 years ago

Screenshot_20210426-072958_AndroidAutoIdrive

Something I noticed earlier. Shouldn't AAI say ID6 for my G01 (not ID5) ??

LACNR commented 3 years ago

If you activate Enhanced Options it show you more details and also the iDrive Level maybe it does say HMiType: ID6 there.

QuickInfo:

Apparently the MyBMW app has been removed from the PlayStore for devices such as the Galaxy S8 with the notice it is not compatible anymore. I can still use the installed app as of now.

Marc2480 commented 3 years ago

@LACNR

you were correct, hmi.type is ID6L, hmi.version is ID5, a bit confusing ...

Screenshot_20210427-082119_AndroidAutoIdrive

LACNR commented 3 years ago

I guess it says ID5 because ID6 is based on the widget system ID5 introduced so basically ID6 is an overhauled ID5 so that why the build itself probably contains ID5 in the internal version text

Kamil2398 commented 3 years ago

I found that it is enough to kill the AAI applications to terminate the Spotify connection notification. Previously, I thought Spotify should be killed to terminate Spotify connection. Huffman, wouldn't the solution be to make the application automatically kill itself after unconnect from the car?

Video showing this: https://youtu.be/E-IW0MAI1tQ

I also experienced that once in maybe 10 connections without my intervention, everything disconnected correctly and there was no Spotify connection notification

I am using the latest version Spotify and AAI

hufman commented 3 years ago

Thank you for the lead to investigate! I really feel bad for the delay, I've been trying to work on the remaining few UI features scheduled in this (too long delayed) release to give the translators time to work on the new text while I focus on hard bugs. I appreciate your patience.

Do you have AAI set to be Battery Optimized? It should be fine to let Android kill it, I feel AAI has pretty good autostart functionality when the car connects. That might help while I figure out the root problem.

I fully intend AAI to be able to shut down fully between car connections. When it hears the Car Disconnected announcement, it shuts down its MainService and all the associated app modules. My hopeful fix 9783bb2 was meant to properly shut down the app modules (including disconnecting the music app connections) even if the connection to the car breaks sooner than expected. It seems there is something else happening too, so I will need to puzzle it out.

Kamil2398 commented 3 years ago

Sure, nothing happened. So, for some time now I have switched each application to optimization, after this setting the application sometimes closes properly (as I mentioned earlier, it is not very often but it started to occur).

Screen bartery settings Screenshot_20210429-193806_Settings

DominikS66 commented 3 years ago

@LACNR which exact version of Spotify App are you using ? @hufman I've tested https://github.com/hufman/AndroidAutoIdrive/commit/9783bb27e6fad93474e5129a4107a2a602c466d7 and I think I've found a reproducible failure that might have a relation to this commit, look issue #244

LACNR commented 3 years ago

@DominikS66 I am using 8.5.68.904 which is from September 2020 I believe, that last update I did after realizing Spotify removed their compatibility framework with BMW pre-iDrive 7 using an Android phone.

Marc2480 commented 3 years ago

@LACNR @DominikS66 I am using latest Spotify 8.6.20.1063, MyBMW just updated overnight to 1.3.4 (6707) ... and build 429 of AAi, don't think the older Spotify builds make a difference when using AAi (with the exception that one of the old 8.4.xx or 8.5.xx builds sorted the lists alphabetically if I remember well).

LACNR commented 3 years ago

Maybe because I'm still using an slightly older AAi build.

Apparently BMW does plan to add Calendar and other apps support in the future to MyBMW, this information is taken from the PlayStore where the BMW Group responded to critics by a user.

hufman commented 3 years ago

I just pushed a probable fix, try it out!

bpowder1966 commented 3 years ago

Where do we go to get the latest nightly build??

On Fri, May 14, 2021, 4:14 PM Walter Huf @.***> wrote:

I just pushed a probable fix, try it out!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hufman/AndroidAutoIdrive/issues/254#issuecomment-841477717, or unsubscribe https://github.com/notifications/unsubscribe-auth/AT2SGM46NUKAPMEOOVN2AO3TNWACRANCNFSM43F7ICZQ .

hufman commented 3 years ago

I pushed this fix right to the master branch, which you can download from the link on the main page

DominikS66 commented 3 years ago

@hufman I hate to tell you...the issue just happened again after second connection to car. I'm using actual build 1.2.2-444 from today, so your fixes are included. Same behavior as described by @Kamil2398 at beginning of issue.

bpowder1966 commented 3 years ago

I also had the issue happen again this morning in the latest nightly build.

On Sat, May 15, 2021, 7:25 AM DominikS66 @.***> wrote:

@hufman https://github.com/hufman I hate to tell you...the issue just happened again after second connection to car. I'm using actual build 1.2.2-444 from today, so your fixes are included. Same behavior as described by @Kamil2398 https://github.com/Kamil2398 at beginning of issue.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hufman/AndroidAutoIdrive/issues/254#issuecomment-841643042, or unsubscribe https://github.com/notifications/unsubscribe-auth/AT2SGM7NJTP2KPE2N3PISBLTNZK4BANCNFSM43F7ICZQ .

LACNR commented 3 years ago

Is it absolutely out of range that maybe MyBMW is causing it? Officially it is not meant to support Apps and the connection, it is however apparently planned in the future.

I have to try out the new build but it would be an explaination why I am not expierencing the issue because my own BMW doesn't support Bluetooth Apps which means the existing (bluetooth-) tunnel created by MyBMW is useless for me therefore it never connects although it does tell me it is connected the tunnel isn't functional for me at least not that I would notice.

Kamil2398 commented 3 years ago

Is it absolutely out of range that maybe MyBMW is causing it? Officially it is not meant to support Apps and the connection, it is however apparently planned in the future.

I have to try out the new build but it would be an explaination why I am not expierencing the issue because my own BMW doesn't support Bluetooth Apps which means the existing (bluetooth-) tunnel created by MyBMW is useless for me therefore it never connects although it does tell me it is connected the tunnel isn't functional for me at least not that I would notice.

In Connected app this problem also occurs so it is independent of the application that is used to connect

LACNR commented 3 years ago

Is it absolutely out of range that maybe MyBMW is causing it? Officially it is not meant to support Apps and the connection, it is however apparently planned in the future. I have to try out the new build but it would be an explaination why I am not expierencing the issue because my own BMW doesn't support Bluetooth Apps which means the existing (bluetooth-) tunnel created by MyBMW is useless for me therefore it never connects although it does tell me it is connected the tunnel isn't functional for me at least not that I would notice.

In Connected app this problem also occurs so it is independent of the application that is used to connect

Ohh... even if MyBMW is removed completely? Did anyone of you tried to go back to an older version of AAI problem did not occur?

HaivanJV commented 3 years ago

Hi @hufman. I installed the nightly build after the last commit that you referenced for this issue. This is for me now resolving the main issue of taking back control over Spotify when connecting back to the car: I can now have full access to my library and pick anything from there.

As a side effect, when not in the car all of previously opened music apps Notifications keep popping up on the phone. They can be closed by sliding them off the screen, but they keep coming back over and over again. I also noticed that if I force stop AAID, it will still autostart in the background after a few seconds, still without active car connection (I am not in the car).

hufman commented 3 years ago

I'm glad to hear it helped! Could you explain more about the "previously opened music apps Notifications"? Perhaps post a picture or video of it. AndroidAutoIdrive will run in the background if you've enabled Notification Access, there isn't a way to run the notification listener only when needed. If you disable the Notification Access permission, it should stay shut-down until you next connect to the car.

HaivanJV commented 3 years ago

I realised after I made the video that it can actually be a MIUI bug. After clearing the notifications and locking the phone screen, at next screen unlock they come up again. Somehow I lost the video after recording it, but if I still suspect some involvement I will try to be more precise. Thanks for fixing the main issue btw!

hufman commented 3 years ago

Could you try out this test branch build, this branch upgrades the Spotify SDK and seemed to help for me. You could also test out this other branch, this branch changes the app to use a single Spotify client, but it didn't seem to help as much in my quick tests. Let me know what you find!

hufman commented 3 years ago

I've been running the upgraded Spotify SDK version on the master branch for a few weeks and haven't run into this problem again, is this good to close?

HaivanJV commented 3 years ago

hi @hufman sorry if I missed a few updates here. I'd like to test this. Shall I test the 1st branched build above or the latest master build?

I will start with the one linked here