Page 1 of 2
Trigger/condition for pixel stand?
Posted: 16 Jun 2019 14:26
by Gen
Hi,
I have a Google pixel 3 xl and a pixel stand which I use in the bedroom. I also have another wireless charging device in the car. I want to activate different flows depending on whether my phone is charging via the pixel stand or the wireless charger in the car.
They both activate using the "power source: wireless" trigger but I noticed that the stand is somehow identified as a different device by the OS as you can see "Pixel Stand" under the connected devices in settings.
So my question is how can I make automagic reliably determine whether my phone is being charged by the pixel stand or by a regular wireless charger?
The closest I got was to use a condition and check for an app task running called "Pixel Stand" but the problem is this only evaluates to true when the screen is off as it starts to run the dreamliner. I also need it to evaluate to true if the screen is already on when I place the phone on charge.
Any help appreciated!
Thanks,
Gen.
Re: Trigger/condition for pixel stand?
Posted: 16 Jun 2019 14:39
by Martin
Hi,
Condition Dock State might be able to detect the pixel stand but I've not tested this with a pixel stand so I'm not sure if a pixel stand is considered by the system as a desk dock or not.
Regards,
Martin
Re: Trigger/condition for pixel stand?
Posted: 16 Jun 2019 14:56
by Gen
Tried dock state with all the options, false on the pixel stand
likely not but maybe it'll be true on the car charger then I can differentiate it that way.
Might there be some root command I can run to check whether the stand device is connected?
Re: Trigger/condition for pixel stand?
Posted: 16 Jun 2019 17:08
by Desmanto
Try to use logcat to check for any broadcast intent sent when the pixel stand is detected. You can use General Broadcast later to react to the broadcast intent.
Re: Trigger/condition for pixel stand?
Posted: 17 Jun 2019 18:30
by Gen
logcat shows these lines when the pixel stand is connected:
06-17 19:23:37.134 1136 1152 I ActivityManager: Start proc 6788:com.google.android.apps.dreamliner/u0a209 for service com.google.android.apps.dreamliner/.DreamlinerControlService 06-17 19:23:37.255 1136 4848 W ActivityManager: Receiver with filter android.content.IntentFilter@b3328ea already registered for pid 6788, callerPackage is com.google.android.apps.dreamliner
This only seems to be the case on the first instance though. If I take my phone off the stand and replace, new lines don't get logged.
A second time I tried it, I got this log entry:
06-17 19:25:27.155 1136 1152 I ActivityManager: Start proc 7361:com.google.android.partnersetup/u0a20 for content provider com.google.android.partnersetup/.RlzAppProvider
Is there anything here we can work with?
Re: Trigger/condition for pixel stand?
Posted: 18 Jun 2019 18:31
by Desmanto
It seems you can't use that broadcast too. Maybe try another method, try to check the write secure setting. Pixel maybe write something to the system setting when changing that state. Use my secure setting logger flow to detect it :
viewtopic.php?f=3&t=7931
Re: Trigger/condition for pixel stand?
Posted: 19 Jun 2019 17:46
by Gen
No setting changes before using the stand and while phone is on stand
Awesome flow by the way - thanks!
Regarding the previous post - why do you say we can't use that broadcast? I'm not that familiar with broadcasts.
This is harder to achieve then it seems - there must be some kind of system change that we can tap into which takes place during the pixel stand and doesn't take place during the normal wireless charging.
Re: Trigger/condition for pixel stand?
Posted: 23 Jun 2019 14:54
by Desmanto
Because the broadcast doesn't consistently giving the same event for the trigger. The system must be storing the value somewhere else. If you have root, try to look at /data/system and look for any file modification when the stand is connected/disconnected. It maybe stored in some other type of database or xml.
Re: Trigger/condition for pixel stand?
Posted: 25 Jun 2019 18:58
by Gen
No consistent changes in any data/system files during placing the phone on the stand.
I had more of a play around with logcat and I noticed some consistent logs that come up everytime the phone is placed on the stand and not when it's placed on the normal charger:
Code: Select all
06-25 19:47:18.331 1201 2902 D ConditionProviders: Enabling component com.google.android.apps.dreamliner/.dnd.DockConditionProviderService
06-25 19:47:18.331 1201 2902 V ConditionProviders: binding: Intent { act=android.service.notification.ConditionProviderService cmp=com.google.android.apps.dreamliner/.dnd.DockConditionProviderService (has extras) }
06-25 19:47:19.493 1201 4679 D ConditionProviders: Disabling component com.google.android.apps.dreamliner/.dnd.DockConditionProviderService
-----------------
Code: Select all
06-25 19:47:47.457 1201 2018 D ConditionProviders: Enabling component com.google.android.apps.dreamliner/.dnd.DockConditionProviderService
06-25 19:47:47.457 1201 2018 V ConditionProviders: binding: Intent { act=android.service.notification.ConditionProviderService cmp=com.google.android.apps.dreamliner/.dnd.DockConditionProviderService (has extras) }
06-25 19:47:48.631 1201 1694 D ConditionProviders: Disabling component com.google.android.apps.dreamliner/.dnd.DockConditionProviderService
Maybe we can use this?
Re: Trigger/condition for pixel stand?
Posted: 26 Jun 2019 06:49
by Desmanto
If you have consistent line that show up in logcat everytime only when you use pixel stand, then you can use logcat, find that line using regex. I will just use the intent line, since that seems to be unique for that event. If found, then you know it is pixel stand.
You can use the same trigger Power source. Then use script
Code: Select all
start = triggertime - 3000;
time = "{start,dateformat,MM-dd HH:mm:ss.SSS}";
cmd = "logcat -t '" + time + "'";
This prepare the command to logcat only the last 3 seconds (should be more than enough to have that line).
Use Execute root command with the command {cmd}
Then after the root command, use expression
Code: Select all
isEmpty(findAll(stdout, 'ConditionProviders: binding: Intent \\{ act=android.service.notification.ConditionProviderService cmp=com.google.android.apps.dreamliner/.dnd.DockConditionProviderService \\(has extras\\) \\}'))
If the result is empty, means pixel stand logcat line not found, condition ends with true, this is regular wireless charger.
If result is not empty, condition ends with false, this is pixel stand.
PS : The extra double backslash is to escape the special char for braces and parenthesis. You can escape the dot too, but it seems to be not necessary.