power: Try to avoid reusing suspend attempt and delay IDs.

To reduce the likelihood of clients that have registered
suspend delays stepping on each others' toes when powerd is
restarted, choose starting suspend attempt and delay IDs
that are based on powerd's PID.

Some specific potential issues that are made less likely by
this change:

- If a buggy client doesn't reregister its suspend delay
  when powerd restarts, it could otherwise accidentally
  report suspend readiness on behalf of another client.

- If a client registers a suspend delay just before or after
  powerd restarts, the client may see the ownership of
  powerd's D-Bus name change but not know whether its
  request was handled by the old or new powerd process. With
  this change, it can just unregister the old delay
  (harmless if it was generated by the old process) and
  register a new one.

BUG=none
TEST=manual: verified that suspend/resume still works

Change-Id: I6dd64a8fa90faae8f056671eb424074fd549c3ce
Reviewed-on: https://chromium-review.googlesource.com/196838
Tested-by: Daniel Erat <derat@chromium.org>
Reviewed-by: Prathmesh Prabhu <pprabhu@chromium.org>
Commit-Queue: Daniel Erat <derat@chromium.org>
7 files changed