Low battery handling during boot

Registered by Oliver Grawert on 2013-11-07

There are cases with the phone where the battery power is not sufficient to boot (1% and lower) . Android very agressively blocks the boot process showing a charge animation. We want to do something similar (to prevent teh battery from being damaged) but easier to override (there is no need to block booting if you already have 5% battery and are connected to the charger for example) and a lot less agressive. this function needs to live in our initrd.

Blueprint information

Status:
Not started
Approver:
Michael Frey
Priority:
Undefined
Drafter:
Oliver Grawert
Direction:
Approved
Assignee:
Oliver Grawert
Definition:
New
Series goal:
Accepted for trusty
Implementation:
Unknown
Milestone target:
None

Related branches

Sprints

Whiteboard

UDS notes from the session:
There are cases with the phone where the battery power is not sufficient to boot (1% and lower) . Android very agressively blocks the boot process showing a charge animation. We want to do something similar (to prevent the battery from being damaged) but easier to override (there is no need to block booting if you already have 5% battery and are connected to the charger for example) and a lot less agressive. this function needs to live in our initrd.
* Detect the battery status from initrd (how do we get that info generically, upower inside the initrd ?)
  * There seems to be a capacity file in android that we could make use of to determine the data
* Hand over a specific boot arg to upstart to intercept it from emitting the startup event (much like the desktop recovery mode does)
  * We just need to change /usr/share/initramfs-tools/init to pass the custom startup event see last line of that file (see the last two lines)
* Have an upstart job that specifically holds back the boot until at i.e. 2%, shows an animation via plymouth and
  once the threshold is reached, emits "startup" to move on with the boot
* Design needs to create some graphical feedback for the user when

* Note that we already have percentage support in plymouth for fsck: https://wiki.ubuntu.com/Plymouth#Special_FSCK_messages

(?)

Work Items

Work items:
[ogra] check on non nexus devices if /sys/class/power_supply actually provides consistent data: TODO
[ogra] include the necessary pieces in the initrd to hand the right bits to upstart on boot (see /etc/init/friendly-recovery.conf on a desktop machine): TODO
[ogra] create an upstart job to intercept the boot and show an animation (jodh happy to help with this): TODO
[ogra] contact design for a "charging" animation for plymouth (*): TODO

This blueprint contains Public information 
Everyone can see this information.