Tim Malseed
Tim Malseed

Reputation: 6373

Android app automatically casting without user interaction (CastCompanionLibrary)

I have an Android app using the CastCompanionLibrary v2.9.1, modified to use play-services-cast:10.0.1 (just a simple change to the gradle dependencies).

Short version: The app is attempting to automatically connect to the ChromeCast device, without user interaction.

Long version:

Since updating the CCL library to use play services 10.0.1, I've had several users mention that the app is automatically connecting/casting to ChromeCast without user interaction.

Some users have said they're not using the app, then they connect to WiFi, and the app automatically attempts to cast. Others have said they are using the app, they don't press the ChromeCast button, and the app begins casting.

--

I'm having trouble figuring out where to look for potential changes to the ChromeCast APIs which might explain what's going on. I'm also not sure whether this issue is only occurring for my app, or for many other ChromeCast enabled apps. Lastly, I'm not able to reproduce this issue on my own ChromeCast device.

Any help would be appreciated.

Upvotes: 0

Views: 2211

Answers (2)

Tim Malseed
Tim Malseed

Reputation: 6373

So it turns out there's a bug in Android Support Library 25.1.0 which was causing this issue.

https://code.google.com/p/google-cast-sdk/issues/detail?id=1105

Which is now marked as 'fixed internally'.

Also related: https://code.google.com/p/android/issues/detail?id=232326

Upvotes: 0

Ali Naddaf
Ali Naddaf

Reputation: 19084

I had not seen or heard this before, so here are some pointers for you to do further investigation to see what can be the cause. CCL has a (sticky) service called ReconnectionService that is responsible to perform reconnection attempts when you lose wifi and later gain it back. The wifi scenario you had mentioned resembles this so I would suggest to start from there. In order to only reconnect when it makes sense, it gets the time length of the content that is playing and only makes such attempts for that period of time; i.e. if you start playing a content that is for 1 hr and then you leave your phone on the table and pick it up after 2 hrs, it notices that the last movie before it fell sleep was for 1 hr so it won't make any attempt to reconnect (see handleTermination() in that same class). For live-stream that doesn't have a clear content duration, CCL uses a default of 2hrs but allows apps to modify that by calling VideoCastManager.setLiveStreamDuration(duration_in_seconds) method. Finally, the whole reconnection relies on a few factors: it saves the route-id of the last connection, along with the session ID. So if needed, you can clear any of these and then it won't try to reconnect for that particular session (in case you want to keep reconnection for some and disable on some other). Hope these help to troubleshoot the issue.

Upvotes: 2

Related Questions