Integrated Agrabren's libhardware_legacy fixes.