Re: [battery] add more discussion of sec and priv analysis; split sections (#28)

@anssiko Thanks for the update. 

I hope that I can add to your understanding of, at least, one of the current uses of the Battery Status API. 

I have implemented a Chrome extension based on research that supports keeping a Lithium-ion battery charge between 20 and 80 per cent. The extension creates a notification augmented with audio when the battery charge level is less than or equal to 20% or greater than or equal to 80%. I have included the relevant code below:
+-----------------------------------------------------------------------------------------------+
function batteryStatus(battery) { 
    if (battery.level <= 0.20 && battery.charging == false) {
        chrome.notifications.create({
            type: 'basic',
            iconUrl: 'warning.png',
            title: 'Battery Level: 20%',
            message: 'CONNECT CHARGER NOW!',
            requireInteraction: true,
            priority: 2
        });
        playAudio();
    }
    if (battery.level >= 0.80 && battery.charging == true) {
        chrome.notifications.create({
            type: 'basic',
            iconUrl: 'warning.png',
            title: 'Battery Level: 80%',
            message: 'DISCONNECT CHARGER NOW!',
            requireInteraction: true,
            priority: 2
        });
        playAudio();
    }
    function playAudio() {   
        var audio = new Audio('oneUp.mp3');
        audio.play();
        audio.volume = 0.25;
    }
}
navigator.getBattery().then(function(battery) {
    battery.onlevelchange = () => {
        batteryStatus(battery);
    };    
});
+-------------------------------------------------------------------------------------------------+
As far as "enhancements to the privacy and security considerations", I believe they are already addressed in the current api:

Battery Status API
[W3C Editor's Draft](https://www.w3.org/standards/types#ED) 03 February 2022

3. Security and privacy considerations

"The user agent MAY ask the user for battery status information access, or alternatively, enforce the user permission requirement in its private browsing modes."

"The user agent SHOULD inform the user of the API use by scripts in an unobtrusive manner to aid transparency and to allow the user to revoke the API access."

I believe the final decision should be that of the user aided by the user agent.

Regards, Mike Barrett

-- 
GitHub Notification of comment by m32b64
Please view or discuss this issue at https://github.com/w3c/battery/issues/28#issuecomment-1258870680 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 27 September 2022 02:08:03 UTC