Use the binder token to reference AutoKI in alarm

This patch uses the binder token represented by the callback
to communicate the identity of the AutoOnOffKeepalive through
the alarm mechanism. This is a lot more robust and easy to
understand.

Addressing this, on top of the robustness and readability
advantages, corrects three bugs.

• The |obj| in the message to CMD_MONITOR_AUTOMATIC_KEEPALIVE
  is now the binder token both on the sender side and the
  receiver side, while the previous code had a Network in the
  sender while the receiver expected AutoOnOffKeepalive,
  crashing the system server with a wrong cast.
• The intent sent in the alarm would have a yet-uninitialized
  value for the slot, so it would not be possible to find the
  auto keepalive when the alarm fires.
• When the slot is reassigned, the alarm continued to fire
  with the same slot value, so the auto keepalive would no
  longer be found after a pause/resume cycle that would
  change the slot.

Test: FrameworksNetTests
Change-Id: Ibdbfcd884e0d3559206cbaae7b6b7a524972c3ca
diff --git a/service/src/com/android/server/ConnectivityService.java b/service/src/com/android/server/ConnectivityService.java
index 330a1da..f1c68cb 100755
--- a/service/src/com/android/server/ConnectivityService.java
+++ b/service/src/com/android/server/ConnectivityService.java
@@ -5547,7 +5547,9 @@
                     break;
                 }
                 case NetworkAgent.CMD_MONITOR_AUTOMATIC_KEEPALIVE: {
-                    final AutomaticOnOffKeepalive ki = (AutomaticOnOffKeepalive) msg.obj;
+                    final AutomaticOnOffKeepalive ki =
+                            mKeepaliveTracker.getKeepaliveForBinder((IBinder) msg.obj);
+                    if (null == ki) return; // The callback was unregistered before the alarm fired
 
                     final Network network = ki.getNetwork();
                     boolean networkFound = false;