apmanager: expose service state through DBus

Update AP service state based on the input from hostapd monitor.
We assume hostapd failed to start when the hostapd control interface
does not get created within a reasonable time, and it is started
once the control interface is detected.

While there, update the HostapdMonitor to use WeakPtr for the tasks
that it will post, so those tasks won't run after HostapdMonitor is
destructed.

BUG=chromium:454863
TEST=Run apmanager_CheckAPProcesses
Manual Test:
1. Start an AP service
2. Verify AP service is in "Started" state using dbus-send command.
3. Stop the AP service, verify it is in "Idle" state using dbus-send
   command.

Change-Id: Id6e22e9e15cd8ef815cc81ef6ae8a00e066b958b
Reviewed-on: https://chromium-review.googlesource.com/245830
Tested-by: Zeping Qiu <zqiu@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Zeping Qiu <zqiu@chromium.org>
5 files changed