Refactor powerd preference changing to use bind mounts

I need to write a test that needs to change powerd prefs and would like
to reuse existing code in power_utils. However, the existing
set_power_prefs method has a few problems... it does not correctly work
with prefs that do not exist in /var/lib (e.g. because they only rely on
the /usr/share defaults), and if autotest crashes or gets killed, or the
DUT suddenly reboots, the prefs do not get restored correctly.

Bind mounts provide a much saver way to do the same thing... they are
guaranteed to not persist across reboots no matter what happens on the
DUT. This patch changes the implementation to that effect and also
refactors the interface to a PowerPrefChanger class, which sets and
restores the settings in an RAII fashion through its constructor and
destructor, allowing it to be used as a fire-and-forget one-liner in
most use cases.

BUG=None
TEST=Run the affected tests (power_AudioDetector, power_VideoDetector
and power_BacklightControl), make sure they still work.

Change-Id: I5fa968217934aea1d1009a1f430eb8db33d6a554
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/42811
Reviewed-by: Daniel Erat <derat@chromium.org>
5 files changed