Charging flag is not working if device charged with PC

Hi,

I wrote a battery widget but realized for myself (as well as some customer complaint) that the widget does not recoginize if the watch is charged with PC. I got a message from a user with a vivoactive 3 and I own a 945. This means it's not device specific. 

Now I have to write a workaround in the background service which drains more power as if the flag would work as expected. Is ths a known bug?

  • Couple things here - when you plug into a PC, CIQ doesn't run - you just get the charging screen.  Even with native things, like say you start a "run" activity and plug it in - that activity stops. So the charging flag and background are really only useful if you''re plugged into an external power source - not a PC.

    You could look at the battery level, and if it's risen, and based on that determine the watch has been charged.

  • Hi Jim,

    thanks for the reply. But a couple of things to your suggestion: This would be possible but:

    Sometimes (not often) the battery level rises even if the watch is not plugged into anything. I don't know why this happens but I have observed this since my battery widget monitors the history a bit.

    Next to get that reliable I have to track more than once whether the battery level rises, this means every 5 minutes (the minimum time the background service can run). Saying that, if someone starts the widget during charging at the PC, the background service will loose all it's data, this means the history how often the battery has increased. OK, maybe the risk that someone does this during charging at the PC is low.

    This brings me to the next point: how to detect an increase before setting a pseudo charging flag. My FR945 increases (round about) 1 % per minute during charging. This means every 5 minutes it increases 5 %. I have no clue how other watches behave. OK, let's assume, I check every 5 minute an increase of 2 %. If this happens 3 times in a row, the background service sets a pseudo charging flag. This means, one has to have the watch at leaset 15 minutes + x charging at the PC., where x < 5 minutes depending on when the background service is triggered. In my opinion this would be fine. 

    I would like again discuss what happens if the user starts the widget in this 15 minutes. Is there a way to transfer data back to the background service?

    If I implement this in the background service, the service has to do much more as before. Maybe it's not a big deal, but I want to have this critical part as slim as possible...

  • The unexplained up/down of battery level can probably be explained by temperature.  Imagine the watch is on the table and acclimated, then you put it on.  It gets warmer, and you'll probably see the battery level rise a bit.

    When you're plugged into a pc/mac, your widget wont run in most cases, so there could be say a 20 minute gap.  This would be the same if you ran a ciq device app for 20 minutes, where the background doesn't run during that time.  And with "charge on the go", you could be using something like a cell phone charger while that ciq-device app is running and your background would never see it.

  • Another issue popped up during implementing this:

    How can I handle the unplug time. If the watch is charged 100 percent and the next time the background service is again 100 %, what does that mean? Is the watch still plugged or is it unplugged now? Currently I have this in the background service but disconnect at the PC is not handled, yet:

    function onTemporalEvent() {
           	var data = Background.getBackgroundData();
    		if (data == null) {
    			data = {};
    		}
            var stats = Sys.getSystemStats();
            var curBat = stats.battery;
            
            if (data["batIncreasing"] == null) {
                data.put("batIncreasing", 0);    
            }
            
           	if (stats.charging && data["batIncreasing"] > 2) {
           		data.put("batAtUnplug", curBat);
           		data.put("timeAtUnplug", getTimestamp());
      			data.put("isCharging", true);
           	} else {
           		if (data["batLastTime"] != null) {
           			if (curBat - 2 > data["batLastTime"]) {
           				data.put("batIncreasing", data["batIncreasing"]++);
           			}
           		}
           		data.put("batLastTime", curBat);
           	}
    
            
            Background.exit(data);
        }

    Furthermore the number of compares and maths did rise to factor 3-4 in comparison to the simple question if the charging variable is set. Originally I had the intention to keep the background process as simple as possible....

  • Have you tried something really simple, like just adding a println with the time stamp, battery level, and changing status, and then run that in various conditions and looking at the log to see what's what?

    when the background runs when charging with a pc, with a wall power supply, when running a CIQ device app, etc..  With the charging, flag, that's really "external power connected", as it will stay true even when the battery is at 100% and not really charging any more, for example.

    It might help you with what logic you need or don't need.

  • Is ths a known bug?

    No.

    All devices use the same facilities to determine if the device is 'charging' (connected to an external power source). As far as I can tell, this routine should not care if it is connected to USB that is power only, high power, low power, or power and data; so it surprises me that it would be reporting incorrect results for one case like this.

    I'll have to do some testing to verify that this is actually broken.

  • Ah interesting. So, your recommendation is to revert back the code changes and wait for a fix? I mean, things are really much more complicate in the background service...

  • There is nothing broken that needs to be fixed.  I put together a simple widget with a background process to show what's happening.  I added notes to the log about when things occur, with the time, the battery level and charging state.  The thing to note here, is when you are plugged into a PC and see the charging screen, the background doesn't run (by design), so there's a gap of about 30 minutes where the background can't even check the charging status.  Repeated this will a wall power supply, and there you can see the background runs, the battery level increases, and the charging flag is true.

    There's another case where the background doesn't run (by design) and that's when running a CIQ device app.  I started one, let the battery get down to the low 90's, then plugged in to external power while the app continued to run, until it got to 97%, but with a CIQ device app, you can't see anything happening from the background, as it doesn't run.

    in the CIQ device app I was using, the charging state is displayed, so I could see that changing.

    =============================>Watch face running, no external power
    background exit at 3:10 battery=86 charging=false
    background exit at 3:15 battery=85 charging=false
    background exit at 3:20 battery=84 charging=false
    background exit at 3:25 battery=83 charging=false
    =============================>Plugged into a PC here and charged (charging screen displayed)
    background exit at 3:58 battery=100 charging=false
    background exit at 4:03 battery=100 charging=false
    background exit at 4:08 battery=99 charging=false
    background exit at 4:13 battery=98 charging=false
    background exit at 4:18 battery=98 charging=false
    background exit at 4:23 battery=97 charging=false
    background exit at 4:28 battery=97 charging=false
    =============================>Plugged into to wall power here and charged with watch face running
    background exit at 4:33 battery=98 charging=true
    background exit at 4:38 battery=100 charging=true
    background exit at 4:43 battery=100 charging=true
    background exit at 4:48 battery=100 charging=true
    background exit at 4:53 battery=100 charging=true
    background exit at 4:58 battery=100 charging=true
    =============================>disconnect external power - Watch face running
    background exit at 5:03 battery=100 charging=false
    background exit at 5:08 battery=100 charging=false
    background exit at 5:13 battery=100 charging=false
    =============================>Start CIQ device app, let battery get to the low 90's, then
    =============================>plug in exteranl power until it gets back to 96%, remove external power 
    =============================>and then exit the app and return to watch face, no 
    =============================>external power
    background exit at 6:03 battery=96 charging=false
    background exit at 6:08 battery=96 charging=false
    background exit at 6:13 battery=96 charging=false

    vsbgwid.zip

  • There is actually a way to see the charging status when plugged into a pc, but it's not that common, and adds a step when trying to sync when using a pc/mac.

    That's setting the USB Mode on the device to be "garmin".  The default is MTP or mass store, but can be changed. (I doubt many people do)

    The extra step is when you plug in, the user must answer if you want MTP/mass store mode, and it's possible to miss/ignore

  • Hi Jim  thanks for  looking into it. Why is the battery level falling in case of charging by PC ? If you are right that the background service is not running at all in that case why do we get values anyway (from line 6 on)? And why do you think that this is by design? 

    If your conclusion is correct that bg is not running I need a different concept.