remove HFA logics
- those classes were added as to interact with HFA app and communicate
result to SuW
- SprintDM app today don't depend on HFA logics anymore and has been
moved to new API for activation status, thus remove those
intermediate layer.
Bug: 31061369
Test: Manual
Change-Id: Iea629f5c21e68fdeecaf3973cabb465ef20ae347
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index de5e979..755d970 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -571,13 +571,6 @@
android:theme="@style/Empty">
</activity>
- <activity android:name="HfaActivity"
- android:configChanges="orientation|screenSize|keyboardHidden"
- android:launchMode="singleInstance"
- android:theme="@style/Empty"
- android:exported="false">
- </activity>
-
<activity android:name="com.android.phone.settings.PhoneAccountSettingsActivity"
android:label="@string/phone_accounts"
android:theme="@style/DialerSettingsLight">
@@ -602,9 +595,6 @@
</intent-filter>
</activity>
- <!-- service to dump telephony information -->
- <service android:name="HfaService" android:exported="false"/>
-
<!-- Telecom integration -->
<service
android:singleUser="true"
diff --git a/src/com/android/phone/HfaActivity.java b/src/com/android/phone/HfaActivity.java
deleted file mode 100644
index b526d46..0000000
--- a/src/com/android/phone/HfaActivity.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.phone;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.PendingIntent;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.util.Log;
-
-/**
- * Starts and displays status for Hands Free Activation (HFA).
- *
- * This class operates with Hands Free Activation apps. It comes up during activation
- * requests that occur outside of setup wizard and so provides its own UI.
- * It uses {@link HfaLogic} to perform the actual activation and during the process
- * displays a "performing activation..." dialog. This will remain up until the user
- * chooses to skip the activation (still happens in the background) or the activation
- * is successful. Upon failure, the dialog also goes away but a subsequent dialog will
- * ask the user if they would like to try again or cancel.
- */
-public class HfaActivity extends Activity {
- private static final String TAG = HfaActivity.class.getSimpleName();
-
- private AlertDialog mDialog;
- private HfaLogic mHfaLogic;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- Log.i(TAG, "onCreate");
-
- final PendingIntent otaResponseIntent = getIntent().getParcelableExtra(
- OtaUtils.EXTRA_OTASP_RESULT_CODE_PENDING_INTENT);
-
- mHfaLogic = new HfaLogic(this.getApplicationContext(), new HfaLogic.HfaLogicCallback() {
- @Override
- public void onSuccess() {
- onHfaSuccess();
- }
-
- @Override
- public void onError(String error) {
- onHfaError(error);
- }
- }, otaResponseIntent);
-
- startProvisioning();
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
-
- Log.i(TAG, "onDestroy");
-
- if (mDialog != null && mDialog.isShowing()) {
- mDialog.dismiss();
- mDialog = null;
- }
- }
-
- private void startProvisioning() {
- buildAndShowDialog();
- mHfaLogic.start();
- }
-
- private void buildAndShowDialog() {
- mDialog = new AlertDialog.Builder(this, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT)
- .setTitle(R.string.ota_hfa_activation_title)
- .setMessage(R.string.ota_hfa_activation_dialog_message)
- .setPositiveButton(R.string.ota_skip_activation_dialog_skip_label,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface di, int which) {
- onUserSkip();
- }})
- /*.setOnCancelListener(new DialogInterface.OnCancelListener() {
- @Override
- public void onCancel(DialogInterface di) {
- sendFinalResponse(OTASP_USER_SKIPPED);
- }})*/
- .create();
-
- // Do not allow user to dismiss dialog unless they are clicking "skip"
- mDialog.setCanceledOnTouchOutside(false);
- mDialog.setCancelable(false);
-
- Log.i(TAG, "showing dialog");
- mDialog.show();
- }
-
- private void onHfaError(String errorMsg) {
- mDialog.dismiss();
-
- AlertDialog errorDialog = new AlertDialog.Builder(this,
- AlertDialog.THEME_DEVICE_DEFAULT_LIGHT)
- .setMessage(errorMsg)
- .setPositiveButton(R.string.ota_skip_activation_dialog_skip_label,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface di, int which) {
- di.dismiss();
- onUserSkip();
- }
- })
- .setNegativeButton(R.string.ota_try_again,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface di, int which) {
- di.dismiss();
- startProvisioning();
- }
- })
- .create();
-
- errorDialog.show();
- }
-
- private void onHfaSuccess() {
- finish();
- }
-
- private void onUserSkip() {
- finish();
- }
-
-}
diff --git a/src/com/android/phone/HfaLogic.java b/src/com/android/phone/HfaLogic.java
deleted file mode 100644
index b064b18..0000000
--- a/src/com/android/phone/HfaLogic.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.phone;
-
-import android.app.PendingIntent;
-import android.app.PendingIntent.CanceledException;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.os.AsyncResult;
-import android.os.Handler;
-import android.os.Message;
-import android.telephony.ServiceState;
-import android.util.Log;
-
-import com.android.internal.telephony.Phone;
-import com.google.common.base.Preconditions;
-
-/**
- * Starts and displays status for Hands Free Activation (HFA).
- *
- * This class operates with Hands Free Activation apps.
- * It starts by broadcasting the intent com.android.action.START_HFA.
- * An HFA app will pick that up and start the HFA process.
- * If it fails it return ERROR_HFA Intent and upon success returns COMPLETE_HFA.
- *
- * If successful, we bounce the radio so that the service picks up the new number.
- * Once the radio is back on we callback the requestor.
- *
- * If there is an error, we do not bounce the radio but still callback with a failure.
- *
- * TODO(klp): We need system-only permissions for the HFA intents.
- */
-public class HfaLogic {
- private static final String TAG = HfaLogic.class.getSimpleName();
-
- private static final String ACTION_START = "com.android.action.START_HFA";
- private static final String ACTION_ERROR = "com.android.action.ERROR_HFA";
- private static final String ACTION_CANCEL = "com.android.action.CANCEL_HFA";
- private static final String ACTION_COMPLETE = "com.android.action.COMPLETE_HFA";
-
- private static final int SERVICE_STATE_CHANGED = 1;
-
- public static final int NOT_WAITING = 0;
- public static final int WAITING_FOR_RADIO_OFF = 1;
- public static final int WAITING_FOR_RADIO_ON = 2;
-
- public static final int OTASP_UNKNOWN = 0;
- public static final int OTASP_USER_SKIPPED = 1;
- public static final int OTASP_SUCCESS = 2;
- public static final int OTASP_FAILURE = 3;
-
- private int mPhoneMonitorState = NOT_WAITING;
- private BroadcastReceiver mReceiver;
- private HfaLogicCallback mCallback;
- private PendingIntent mResponseIntent;
- private Context mContext;
-
- // No retry at the moment. Increase later if necessary.
- private static final int DEFAULT_RETRY_COUNT = 0;
- private int mRetryCount;
-
- public interface HfaLogicCallback {
- public void onSuccess();
- public void onError(String errorMsg);
- }
-
- public HfaLogic(Context context, HfaLogicCallback callback, PendingIntent intent) {
- mCallback = Preconditions.checkNotNull(callback);
- mContext = Preconditions.checkNotNull(context);
- mResponseIntent = intent;
- }
-
- public void start() {
- Log.i(TAG, "start:");
- mRetryCount = DEFAULT_RETRY_COUNT;
- startHfaIntentReceiver();
- startProvisioning();
- }
-
- private void startProvisioning() {
- Log.i(TAG, "startProvisioning:");
- sendHfaCommand(ACTION_START);
- }
-
- private void sendHfaCommand(String action) {
- Log.i(TAG, "sendHfaCommand: command=" + action);
- mContext.sendBroadcast(new Intent(action));
- }
-
- private void onHfaError(String errorMsg) {
- Log.i(TAG, "onHfaError: call mCallBack.onError errorMsg=" + errorMsg
- + " mRetryCount=" + mRetryCount);
- mRetryCount -= 1;
- if (mRetryCount >= 0) {
- Log.i(TAG, "onHfaError: retry");
- startProvisioning();
- } else {
- Log.i(TAG, "onHfaError: Declare OTASP_FAILURE");
- mRetryCount = 0;
- stopHfaIntentReceiver();
- sendFinalResponse(OTASP_FAILURE, errorMsg);
- mCallback.onError(errorMsg);
- }
- }
-
- private void onHfaSuccess() {
- Log.i(TAG, "onHfaSuccess: NOT bouncing radio call onTotalSuccess");
- stopHfaIntentReceiver();
- // bounceRadio();
- onTotalSuccess();
- }
-
- private void onTotalSuccess() {
- Log.i(TAG, "onTotalSuccess: call mCallBack.onSuccess");
- sendFinalResponse(OTASP_SUCCESS, null);
- mCallback.onSuccess();
- }
-
- private void bounceRadio() {
- final Phone phone = PhoneGlobals.getInstance().getPhone();
- phone.registerForServiceStateChanged(mHandler, SERVICE_STATE_CHANGED, null);
-
- mPhoneMonitorState = WAITING_FOR_RADIO_OFF;
- phone.setRadioPower(false);
- onServiceStateChange(phone.getServiceState());
- }
-
- private void onServiceStateChange(ServiceState state) {
- final boolean radioIsOff = state.getVoiceRegState() == ServiceState.STATE_POWER_OFF;
- final Phone phone = PhoneGlobals.getInstance().getPhone();
-
- Log.i(TAG, "Radio is on: " + !radioIsOff);
-
- if (mPhoneMonitorState == WAITING_FOR_RADIO_OFF) {
- if (radioIsOff) {
- mPhoneMonitorState = WAITING_FOR_RADIO_ON;
- phone.setRadioPower(true);
- }
- } else if (mPhoneMonitorState == WAITING_FOR_RADIO_ON) {
- if (!radioIsOff) {
- mPhoneMonitorState = NOT_WAITING;
- phone.unregisterForServiceStateChanged(mHandler);
-
- onTotalSuccess();
- }
- }
- }
-
- private void startHfaIntentReceiver() {
- final IntentFilter filter = new IntentFilter(ACTION_COMPLETE);
- filter.addAction(ACTION_ERROR);
-
- mReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- final String action = intent.getAction();
- if (action.equals(ACTION_ERROR)) {
- onHfaError(intent.getStringExtra("errorCode"));
- } else if (action.equals(ACTION_COMPLETE)) {
- Log.i(TAG, "Hfa Successful");
- onHfaSuccess();
- }
- }
- };
-
- mContext.registerReceiver(mReceiver, filter);
- }
-
- private void stopHfaIntentReceiver() {
- if (mReceiver != null) {
- mContext.unregisterReceiver(mReceiver);
- mReceiver = null;
- }
- }
-
- private void sendFinalResponse(int responseCode, String errorCode) {
- if (mResponseIntent != null) {
- final Intent extraStuff = new Intent();
- extraStuff.putExtra(OtaUtils.EXTRA_OTASP_RESULT_CODE, responseCode);
-
- if (responseCode == OTASP_FAILURE && errorCode != null) {
- extraStuff.putExtra(OtaUtils.EXTRA_OTASP_ERROR_CODE, errorCode);
- }
-
- try {
- Log.i(TAG, "Sending OTASP confirmation with result code: "
- + responseCode);
- mResponseIntent.send(mContext, 0 /* resultCode (not used) */, extraStuff);
- } catch (CanceledException e) {
- Log.e(TAG, "Pending Intent canceled");
- }
- }
- }
-
- private Handler mHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case SERVICE_STATE_CHANGED:
- ServiceState state = (ServiceState) ((AsyncResult) msg.obj).result;
- onServiceStateChange(state);
- break;
- default:
- break;
- }
- }
- };
-
-}
diff --git a/src/com/android/phone/HfaService.java b/src/com/android/phone/HfaService.java
deleted file mode 100644
index bc07453..0000000
--- a/src/com/android/phone/HfaService.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.phone;
-
-import android.app.PendingIntent;
-import android.app.Service;
-import android.content.Intent;
-import android.os.IBinder;
-import android.util.Log;
-
-/**
- * Service for performing HfaActivation without any UI.
- */
-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");
- }
-
- @Override
- public int onStartCommand(Intent intent, int flags, int startId) {
- final PendingIntent otaResponseIntent = intent.getParcelableExtra(
- OtaUtils.EXTRA_OTASP_RESULT_CODE_PENDING_INTENT);
-
- mHfaLogic = new HfaLogic(this, new HfaLogic.HfaLogicCallback() {
- @Override
- public void onSuccess() {
- Log.i(TAG, "onSuccess");
- onComplete();
- }
-
- @Override
- public void onError(String msg) {
- Log.i(TAG, "onError: " + msg);
- // We do not respond from this service. On success or failure
- // we do the same thing...finish.
- onComplete();
- }
- }, otaResponseIntent);
- mHfaLogic.start();
-
- return START_REDELIVER_INTENT;
- }
-
- @Override
- public IBinder onBind(Intent intent) {
- return null;
- }
-
- private void onComplete() {
- stopSelf();
- }
-}
diff --git a/src/com/android/phone/InCallScreenShowActivation.java b/src/com/android/phone/InCallScreenShowActivation.java
index 9d35442..78cc20b 100644
--- a/src/com/android/phone/InCallScreenShowActivation.java
+++ b/src/com/android/phone/InCallScreenShowActivation.java
@@ -18,14 +18,10 @@
import android.app.Activity;
import android.app.PendingIntent;
-import android.content.Context;
import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.os.SystemProperties;
-import android.provider.Settings;
import android.telephony.CarrierConfigManager;
import android.util.Log;
@@ -92,14 +88,6 @@
if (intent.getAction().equals(OtaUtils.ACTION_PERFORM_CDMA_PROVISIONING)) {
PersistableBundle carrierConfig = app.getCarrierConfig();
- boolean usesHfa = carrierConfig.getBoolean(
- CarrierConfigManager.KEY_USE_HFA_FOR_PROVISIONING_BOOL);
- if (usesHfa) {
- Log.i(LOG_TAG, "Starting Hfa from ACTION_PERFORM_CDMA_PROVISIONING");
- startHfa();
- finish();
- return;
- }
boolean usesOtasp = carrierConfig.getBoolean(
CarrierConfigManager.KEY_USE_OTASP_FOR_PROVISIONING_BOOL);
@@ -179,65 +167,4 @@
finish();
}
-
- /**
- * On devices that provide a phone initialization wizard (such as Google Setup Wizard),
- * the wizard displays it's own activation UI. The Hfa activation started by this class
- * will show a UI or not depending on the status of the setup wizard. If the setup wizard
- * is running, do not show a UI, otherwise show our own UI since setup wizard will not.
- *
- * The method checks two properties:
- * 1. Does the device require a setup wizard (ro.setupwizard.mode == (REQUIRED|OPTIONAL))
- * 2. Is device_provisioned set to non-zero--a property that setup wizard sets at completion.
- * @return true if wizard is running, false otherwise.
- */
- private boolean isWizardRunning(Context context) {
- Intent intent = new Intent("android.intent.action.DEVICE_INITIALIZATION_WIZARD");
- ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(intent,
- PackageManager.MATCH_DEFAULT_ONLY);
- boolean provisioned = Settings.Global.getInt(context.getContentResolver(),
- Settings.Global.DEVICE_PROVISIONED, 0) != 0;
- String mode = SystemProperties.get("ro.setupwizard.mode", "REQUIRED");
- boolean runningSetupWizard = "REQUIRED".equals(mode) || "OPTIONAL".equals(mode);
- if (DBG) {
- Log.v(LOG_TAG, "resolvInfo = " + resolveInfo + ", provisioned = " + provisioned
- + ", runningSetupWizard = " + runningSetupWizard);
- }
- return resolveInfo != null && !provisioned && runningSetupWizard;
- }
-
- /**
- * Starts the HFA provisioning process by bringing up the HFA Activity.
- */
- private void startHfa() {
- 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 Intent intent = new Intent();
-
- final PendingIntent otaResponseIntent = getIntent().getParcelableExtra(
- OtaUtils.EXTRA_OTASP_RESULT_CODE_PENDING_INTENT);
-
- final boolean showUi = !isWizardRunning;
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-
- 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);
- }
-
- }
- setResult(RESULT_OK);
- }
}