merge powerlost function from openatv, thanks to atv