Add config: Don't start HFA if outside of setup wizard.

Bug: 17910549
Change-Id: I7e91d56302740145d086f65a1fe49a16f5a61c8f
diff --git a/res/values/config.xml b/res/values/config.xml
index 3daf89a..5d59aec 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -141,4 +141,7 @@
 
     <!-- Show APN Settings for some CDMA carriers -->
     <bool name="config_show_apn_setting_cdma">false</bool>
+
+    <!-- Allows the telephony HFA logic to run even if we're not in setup wizard. -->
+    <bool name="config_allow_hfa_outside_of_setup_wizard">true</bool>
 </resources>
diff --git a/src/com/android/phone/InCallScreenShowActivation.java b/src/com/android/phone/InCallScreenShowActivation.java
index fd202db..10f315c 100644
--- a/src/com/android/phone/InCallScreenShowActivation.java
+++ b/src/com/android/phone/InCallScreenShowActivation.java
@@ -180,28 +180,34 @@
      * Starts the HFA provisioning process by bringing up the HFA Activity.
      */
     private void startHfa() {
-        final Intent intent = new Intent();
+        boolean isWizardRunning = isWizardRunning(this);
+        // We always run our HFA logic if we're in setup wizard, but if we're outside of setup
+        // wizard then we have to check a config to see if we should still run HFA.
+        if (isWizardRunning ||
+                getResources().getBoolean(R.bool.config_allow_hfa_outside_of_setup_wizard)) {
 
-        final PendingIntent otaResponseIntent = getIntent().getParcelableExtra(
-                OtaUtils.EXTRA_OTASP_RESULT_CODE_PENDING_INTENT);
+            final Intent intent = new Intent();
 
-        final boolean showUi = !isWizardRunning(this);
+            final PendingIntent otaResponseIntent = getIntent().getParcelableExtra(
+                    OtaUtils.EXTRA_OTASP_RESULT_CODE_PENDING_INTENT);
 
-        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+            final boolean showUi = !isWizardRunning;
+            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 
-        if (otaResponseIntent != null) {
-            intent.putExtra(OtaUtils.EXTRA_OTASP_RESULT_CODE_PENDING_INTENT, otaResponseIntent);
+            if (otaResponseIntent != null) {
+                intent.putExtra(OtaUtils.EXTRA_OTASP_RESULT_CODE_PENDING_INTENT, otaResponseIntent);
+            }
+
+            Log.v(LOG_TAG, "Starting hfa activation activity");
+            if (showUi) {
+                intent.setClassName(this, HfaActivity.class.getName());
+                startActivity(intent);
+            } else {
+                intent.setClassName(this, HfaService.class.getName());
+                startService(intent);
+            }
+
         }
-
-        Log.v(LOG_TAG, "Starting hfa activation activity");
-        if (showUi) {
-            intent.setClassName(this, HfaActivity.class.getName());
-            startActivity(intent);
-        } else {
-            intent.setClassName(this, HfaService.class.getName());
-            startService(intent);
-        }
-
         setResult(RESULT_OK);
     }
 }