-
Notifications
You must be signed in to change notification settings - Fork 658
added ability to connect to the current DeviceSupport #1172
base: master
Are you sure you want to change the base?
Conversation
Thanks for the PR, but this is most probably not the way to go forward with this. The The normal information flow from a How does this sound? |
sounds good. |
Or maybe some sort of a binder, which is implemented and returned by the DeviceSupport? |
Yes, a broadcast intent. See |
wouldn't it be possible to add a Binder-like system for the DeviceSupports? |
Unless you have some very compelling arguments against the other solution, no. Those instances belong to the service, and should be called though the service. |
I may need some stream-like interaction with my gadget from different activities, and to manage bi-directional communication with different types of messaging, even more when one of those types involves sending continuous Broadcasts seems like a waste of ressources to me. Yet, when your proposed solution is your way to go, i am going to adapt to that whenever it gets implemented. |
Care to elaborate on that? I have no idea what use case(s) that might be. |
For instance, i would want to make the real clock hands make the hand settings on the screen. Also, relying on the delivery of such a message makes it pretty hard to distinguish whether a device is connected or if is the real device. Throughout my whole argumentation i might be a bit one-sided, since i am using the Androids Service-Binder-implementation. A second case i might see that feature handy for is file synchronization. |
|
Alright, i'll try to adapt my code to that concept. |
so...how do i query that GBDevice from an activity? |
You would get the device right from the intent that started the activity. In onCreate(), use
Callers have to ensure that they actually pass the device like that, of course. |
What class does my activity have to extend in order to receive that parcelable? EDIT as far as i understant, all the settings activities get started in |
AFAICS, we have only one SettingsActivity, and indeed it doesn't receive the device. Most of the activities are started from GBDeviceAdapterv2 (where the get the device) and from ControlCenterv2 (where they don't get the device. This should be fixed so that they always get the device. |
so, how to hotfix that problem in the case of ControlCenterv2? how to get the device there for now? |
As a hotfix, you can use this:
Before adding the EXTRA_DEVICE parameter to all activities, we need to determine how this relates to multi-device support (multiple devices connected at the same time). Also devices getting disconnected, etc. |
@cpfeiffer how does your hotfix handle the scenario of multiple devices? |
It should only return the currently connected device (atm there can only be one). |
alright... |
and concerning devices disconnecting, i really think it is on the developers side to register for a corresponding DEVICE_DISCONNECTED broadcast or something... |
well, i'll just go with a hotfix for now... |
so, what is the current state? How can i get access to the device support from the Settings UI? |
By binding the DeviceCommunicationService a binder object can now be acquired,
which then can be used to get a reference to the currently responsible DeviceSupport.
In my example this is done from a random activity to interact with the QHybridSupport class and get the device vibration strength, which is handled here.
I tried to come up with a way of communicating with the DeviceSupport from basically any point in the app, and this is the best i could come up with.
Please enlighten me if there is another method of archieving the same, in my case to call that getVibrationStrength() method.