Add a direct reference to HfaLogic in HfaService

The reason HFA Activation wouldn't complete is because HfaLogic was
trying to bounce the radio power. It turns the radio power off, waits
for it to go off and then turn radio power back on. The problem was that
it never go notified that the radio power was successfully turned off
thus HfaLogic never turned it back on and activation never finishes.

I added debug and eventually found that PhoneBase#notifyServiceStateChanged
was not sending a notification to HfaLogic even though I saw that it was
registering. Turns out that RegistrantList uses a WeakReference and that
HfaService did not have a reference to HfaLogic and this caused the
HfaLogic to be garbage collected. I'm not exactly sure when the collection
happens because as I added more debug the bug disappeared. But I do see the
WeakReference going to null which can only happen because HfaLogic was
garbage collected.

My solution is to have HfaService reference HfaLogic. Another solution
was to change the WeakReference to a direct reference. But the
WeakReference is how its always been and jsh pointed out the
WeakReference reduces memory leaks if entities that register but fail
to unregister can still be garbage collected if the only reference is
the WeakReference.

Bug: 10905304
Change-Id: Iec07c6aa5e0de2340d4922bb0ee67f8bd9f3c95d
diff --git a/src/com/android/phone/HfaService.java b/src/com/android/phone/HfaService.java
index 3aeed4d..d5c92b8 100644
--- a/src/com/android/phone/HfaService.java
+++ b/src/com/android/phone/HfaService.java
@@ -28,6 +28,8 @@
 public class HfaService extends Service {
     private static final String TAG = HfaService.class.getSimpleName();
 
+    private HfaLogic mHfaLogic;
+
     @Override
     public void onCreate() {
         Log.i(TAG, "service started");
@@ -38,7 +40,7 @@
         final PendingIntent otaResponseIntent = intent.getParcelableExtra(
                 OtaUtils.EXTRA_OTASP_RESULT_CODE_PENDING_INTENT);
 
-        new HfaLogic(this, new HfaLogic.HfaLogicCallback() {
+        mHfaLogic = new HfaLogic(this, new HfaLogic.HfaLogicCallback() {
             @Override
             public void onSuccess() {
                 Log.i(TAG, "onSuccess");
@@ -52,7 +54,8 @@
                 // we do the same thing...finish.
                 onComplete();
             }
-        }, otaResponseIntent).start();
+        }, otaResponseIntent);
+        mHfaLogic.start();
 
         return START_STICKY;
     }