summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/settings/sim/SimSettings.java580
1 files changed, 574 insertions, 6 deletions
diff --git a/src/com/android/settings/sim/SimSettings.java b/src/com/android/settings/sim/SimSettings.java
index 23e6275..6299b55 100644
--- a/src/com/android/settings/sim/SimSettings.java
+++ b/src/com/android/settings/sim/SimSettings.java
@@ -16,14 +16,26 @@
package com.android.settings.sim;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.ProgressDialog;
+import android.content.BroadcastReceiver;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
+import android.content.IntentFilter;
import android.content.res.Resources;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.os.RemoteException;
+import android.os.ServiceManager;
import android.preference.Preference;
import android.preference.PreferenceScreen;
+import android.preference.PreferenceCategory;
import android.provider.SearchIndexableResource;
+import android.provider.Settings;
import android.telephony.PhoneStateListener;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
@@ -31,14 +43,23 @@ import android.telephony.TelephonyManager;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.text.TextUtils;
+import android.util.AttributeSet;
import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.CompoundButton;
+import android.widget.CompoundButton.OnCheckedChangeListener;
+
import com.android.internal.logging.MetricsLogger;
+import com.android.internal.telephony.PhoneConstants;
import com.android.settings.RestrictedSettingsFragment;
import com.android.settings.Utils;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.R;
import android.os.SystemProperties;
+import com.android.internal.telephony.IExtTelephony;
import com.android.internal.telephony.TelephonyProperties;
import java.util.ArrayList;
@@ -64,11 +85,15 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
private List<SubscriptionInfo> mAvailableSubInfos = null;
private List<SubscriptionInfo> mSubInfoList = null;
private List<SubscriptionInfo> mSelectableSubInfos = null;
- private PreferenceScreen mSimCards = null;
+ private PreferenceCategory mSimCards = null;
private SubscriptionManager mSubscriptionManager;
private int mNumSlots;
private Context mContext;
+ private static AlertDialog sAlertDialog = null;
+ private static ProgressDialog sProgressDialog = null;
+ private boolean needUpdate = false;
+
public SimSettings() {
super(DISALLOW_CONFIG_SIM);
}
@@ -89,12 +114,25 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
addPreferencesFromResource(R.xml.sim_settings);
mNumSlots = tm.getSimCount();
- mSimCards = (PreferenceScreen)findPreference(SIM_CARD_CATEGORY);
+ mSimCards = (PreferenceCategory)findPreference(SIM_CARD_CATEGORY);
mAvailableSubInfos = new ArrayList<SubscriptionInfo>(mNumSlots);
mSelectableSubInfos = new ArrayList<SubscriptionInfo>();
SimSelectNotification.cancelNotification(getActivity());
}
+ @Override
+ public void onDestroy() {
+ for (int i = 0; i < mSimCards.getPreferenceCount(); ++i) {
+ Preference pref = mSimCards.getPreference(i);
+ if (pref instanceof SimEnablerPreference) {
+ // Calling destroy() here to unregister all intent listeners.
+ ((SimEnablerPreference)pref).destroy();
+ }
+ }
+ Log.d(TAG,"on onDestroy");
+ super.onDestroy();
+ }
+
private final SubscriptionManager.OnSubscriptionsChangedListener mOnSubscriptionsChangeListener
= new SubscriptionManager.OnSubscriptionsChangedListener() {
@Override
@@ -111,6 +149,10 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
if (pref instanceof SimPreference) {
mSimCards.removePreference(pref);
}
+ if (pref instanceof SimEnablerPreference) {
+ // Calling destroy() here to unregister all intent listeners.
+ ((SimEnablerPreference)pref).destroy();
+ }
}
mAvailableSubInfos.clear();
mSelectableSubInfos.clear();
@@ -118,7 +160,7 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
for (int i = 0; i < mNumSlots; ++i) {
final SubscriptionInfo sir = mSubscriptionManager
.getActiveSubscriptionInfoForSimSlotIndex(i);
- SimPreference simPreference = new SimPreference(mContext, sir, i);
+ SimPreference simPreference = new SimEnablerPreference(mContext, sir, i);
simPreference.setOrder(i-mNumSlots);
mSimCards.addPreference(simPreference);
mAvailableSubInfos.add(sir);
@@ -209,6 +251,14 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
mSubscriptionManager.removeOnSubscriptionsChangedListener(mOnSubscriptionsChangeListener);
final TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
+
+ for (int i = 0; i < mSimCards.getPreferenceCount(); ++i) {
+ Preference pref = mSimCards.getPreference(i);
+ if (pref instanceof SimEnablerPreference) {
+ // Calling cleanUp() here to dismiss/cleanup any pending dialog exists.
+ ((SimEnablerPreference)pref).cleanUpPendingDialogs();
+ }
+ }
}
private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
@@ -253,11 +303,18 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
return true;
}
+ private void simEnablerUpdate() {
+ if (isAdded()) {
+ updateAllOptions();
+ } else {
+ needUpdate = true;
+ }
+ }
+
private class SimPreference extends Preference {
- private SubscriptionInfo mSubInfoRecord;
- private int mSlotId;
+ SubscriptionInfo mSubInfoRecord;
+ int mSlotId;
Context mContext;
-
public SimPreference(Context context, SubscriptionInfo subInfoRecord, int slotId) {
super(context);
@@ -267,6 +324,9 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
setKey("sim" + mSlotId);
update();
}
+ public SimPreference (Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
public void update() {
final Resources res = mContext.getResources();
@@ -292,6 +352,514 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
private int getSlotId() {
return mSlotId;
}
+
+ @Override
+ protected void onAttachedToActivity() {
+ super.onAttachedToActivity();
+ if (needUpdate) {
+ needUpdate = false;
+ updateAllOptions();
+ }
+ }
+ }
+
+ // This is to show SIM Enable options on/off on UI for user selection.
+ // User can activate/de-activate through SIM on/off options.
+ private class SimEnablerPreference extends SimPreference implements OnCheckedChangeListener {
+
+ private String TAG = "SimEnablerPreference";
+ private static final boolean DBG = true;
+
+ private static final int EVT_UPDATE = 1;
+ private static final int EVT_SHOW_RESULT_DLG = 2;
+ private static final int EVT_SHOW_PROGRESS_DLG = 3;
+ private static final int EVT_PROGRESS_DLG_TIME_OUT = 4;
+
+ private static final int CONFIRM_ALERT_DLG_ID = 1;
+ private static final int ERROR_ALERT_DLG_ID = 2;
+ private static final int RESULT_ALERT_DLG_ID = 3;
+
+ private static final int REQUEST_SUCCESS = 0;
+ private static final int GENERIC_FAILURE = -1;
+ private static final int INVALID_INPUT = -2;
+ private static final int REQUEST_IN_PROGRESS = -3;
+
+ // These are the list of possible values that
+ // IExtTelephony.getCurrentUiccCardProvisioningStatus() can return
+ static final int PROVISIONED = 1;
+ static final int NOT_PROVISIONED = 0;
+ static final int INVALID_STATE = -1;
+ static final int CARD_NOT_PRESENT = -2;
+
+ static final String ACTION_UICC_MANUAL_PROVISION_STATUS_CHANGED =
+ "org.codeaurora.intent.action.ACTION_UICC_MANUAL_PROVISION_STATUS_CHANGED";
+ static final String EXTRA_NEW_PROVISION_STATE = "newProvisionState";
+
+ private static final String DISPLAY_NUMBERS_TYPE = "display_numbers_type";
+
+ private SubscriptionInfo mSir;
+ private boolean mCurrentUiccProvisionState;
+ private boolean mIsChecked;
+
+ private boolean mCmdInProgress = false;
+ private int mSwitchVisibility = View.VISIBLE;
+ private CompoundButton mSwitch;
+ //Delay for progress dialog to dismiss
+ private static final int PROGRESS_DLG_TIME_OUT = 30000;
+ private static final int MSG_DELAY_TIME = 2000;
+
+ private int mPhoneCount = TelephonyManager.getDefault().getPhoneCount();
+ int[] mUiccProvisionStatus = new int[mPhoneCount];
+ private IExtTelephony mExtTelephony;
+
+
+ public SimEnablerPreference(Context context, SubscriptionInfo sir, int slotId) {
+ super(context, (AttributeSet)null,
+ com.android.internal.R.attr.checkBoxPreferenceStyle);
+ logd("Contructor..Enter");
+ mContext = context;
+ mSlotId = slotId;
+ mSir = sir;
+ mSubInfoRecord = sir;
+ if (mContext.getResources().getBoolean(R.bool.config_custom_multi_sim_checkbox)) {
+ setWidgetLayoutResource(R.layout.custom_sim_checkbox);
+ } else {
+ setWidgetLayoutResource(R.layout.custom_sim_switch);
+ }
+
+ mExtTelephony = IExtTelephony.Stub.asInterface(ServiceManager.getService("extphone"));
+
+ setSwitchVisibility(View.VISIBLE);
+ setKey("sim" + mSlotId);
+ update();
+ IntentFilter intentFilter = new IntentFilter(
+ ACTION_UICC_MANUAL_PROVISION_STATUS_CHANGED);
+ mContext.registerReceiver(mReceiver, intentFilter);
+ }
+
+ private void sendMessage(int event, Handler handler, int delay) {
+ Message message = handler.obtainMessage(event);
+ handler.sendMessageDelayed(message, delay);
+ }
+
+ private void sendMessage(int event, Handler handler, int delay, int arg1, int arg2) {
+ Message message = handler.obtainMessage(event, arg1, arg2);
+ handler.sendMessageDelayed(message, delay);
+ }
+
+ private boolean hasCard() {
+ return TelephonyManager.getDefault().hasIccCard(mSlotId);
+ }
+
+ private boolean isAirplaneModeOn() {
+ return (Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.AIRPLANE_MODE_ON, 0) != 0);
+ }
+
+ private int getProvisionStatus(int slotId) {
+ return mUiccProvisionStatus[slotId];
+ }
+
+ @Override
+ protected void onBindView(View view) {
+ super.onBindView(view);
+ logd("onBindView....");
+ mSwitch = (CompoundButton) view.findViewById(R.id.sub_switch_widget);
+ mSwitch.setOnCheckedChangeListener(this);
+ update();
+ // now use other config screen to active/deactive sim card\
+ mSwitch.setVisibility(mSwitchVisibility);
+ }
+
+ @Override
+ public void update() {
+ final Resources res = mContext.getResources();
+ logd("update()" + mSir);
+ try {
+ //get current provision state of the SIM.
+ mUiccProvisionStatus[mSlotId] =
+ mExtTelephony.getCurrentUiccCardProvisioningStatus(mSlotId);
+ } catch (RemoteException ex) {
+ mUiccProvisionStatus[mSlotId] = INVALID_STATE;
+ loge("Failed to get pref, slotId: "+ mSlotId +" Exception: " + ex);
+ } catch (NullPointerException ex) {
+ mUiccProvisionStatus[mSlotId] = INVALID_STATE;
+ loge("Failed to get pref, slotId: "+ mSlotId +" Exception: " + ex);
+ }
+
+ boolean isSubValid = isCurrentSubValid();
+ setEnabled(isSubValid);
+
+ logd("update: isSubValid " + isSubValid + " provision status["
+ + mSlotId + "] = " + mUiccProvisionStatus[mSlotId]);
+ setTitle(res.getString(R.string.sim_card_number_title, mSlotId + 1));
+ if (isSubValid) {
+ updateSummary();
+ setIcon(new BitmapDrawable(res, (mSir.createIconBitmap(mContext))));
+ } else {
+ setSummary(res.getString(R.string.sim_slot_empty));
+ }
+ }
+
+ // This method returns true if SubScription record corresponds to this
+ // Preference screen has a valid SIM and slot index/SubId.
+ private boolean isCurrentSubValid() {
+ boolean isSubValid = false;
+ if (!isAirplaneModeOn() && hasCard()) {
+ List<SubscriptionInfo> sirList =
+ mSubscriptionManager.getActiveSubscriptionInfoList();
+ if (sirList != null ) {
+ for (SubscriptionInfo sir : sirList) {
+ if (sir != null && mSlotId == sir.getSimSlotIndex()) {
+ mSir = sir;
+ break;
+ }
+ }
+ if (mSir != null &&
+ SubscriptionManager.isValidSubscriptionId(mSir.getSubscriptionId()) &&
+ mSir.getSimSlotIndex() >= 0 &&
+ getProvisionStatus(mSir.getSimSlotIndex()) >= 0) {
+ isSubValid = true;
+ }
+ }
+ }
+ return isSubValid;
+ }
+
+ public void setSwitchVisibility (int visibility) {
+ mSwitchVisibility = visibility;
+ }
+
+ // Based on the received SIM provision state this method
+ // sets the check box on Sim Preference UI and updates new
+ // state to mCurrentUiccProvisionState.
+ private void setChecked(boolean uiccProvisionState) {
+ logd("setChecked: uiccProvisionState " + uiccProvisionState + "sir:" + mSir);
+ if (mSwitch != null) {
+ mSwitch.setOnCheckedChangeListener(null);
+ // Do not update update checkstatus again in progress
+ if (!mCmdInProgress) {
+ mSwitch.setChecked(uiccProvisionState);
+ }
+ mSwitch.setOnCheckedChangeListener(this);
+ mCurrentUiccProvisionState = uiccProvisionState;
+ }
+ }
+
+ private void updateSummary() {
+ Resources res = mContext.getResources();
+ String summary;
+ boolean isActivated = (getProvisionStatus(mSir.getSimSlotIndex()) == PROVISIONED);
+ logd("updateSummary: subId " + mSir.getSubscriptionId() + " isActivated = "
+ + isActivated + " slot id = " + mSlotId);
+
+ String displayName = mSir == null ? "SIM" : (String)mSir.getDisplayName();
+ if (isActivated) {
+ summary = displayName;
+ if (!TextUtils.isEmpty(mSir.getNumber())) {
+ summary = displayName + " - " + mSir.getNumber();
+ }
+ } else {
+ summary = displayName + mContext.getString(R.string.sim_enabler_summary,
+ res.getString(hasCard() ? R.string.sim_disabled : R.string.sim_missing));
+ }
+
+ setSummary(summary);
+ setChecked(isActivated);
+ }
+
+
+ /**
+ * get number of Subs provisioned on the device
+ * @param context
+ * @return
+ */
+ public int getNumOfSubsProvisioned() {
+ int activeSubInfoCount = 0;
+ List<SubscriptionInfo> subInfoLists =
+ mSubscriptionManager.getActiveSubscriptionInfoList();
+ if (subInfoLists != null) {
+ for (SubscriptionInfo subInfo : subInfoLists) {
+ if (getProvisionStatus(mSir.getSimSlotIndex())
+ == PROVISIONED) activeSubInfoCount++;
+ }
+ }
+ return activeSubInfoCount;
+ }
+
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ mIsChecked = isChecked;
+ logd("onClick: " + isChecked);
+
+ handleUserRequest();
+ }
+
+ // This internal method called when user changes preference from UI
+ // 1. For activation/deactivation request from User, if device in APM mode
+ // OR if voice call active on any SIM it dispay error dialog and returns.
+ // 2. For deactivation request it returns error dialog if only one SUB in
+ // active state.
+ // 3. In other cases it sends user request to framework.
+ synchronized private void handleUserRequest() {
+ if (isAirplaneModeOn()) {
+ // do nothing but warning
+ logd("APM is on, EXIT!");
+ showAlertDialog(ERROR_ALERT_DLG_ID, R.string.sim_enabler_airplane_on);
+ return;
+ }
+ for (int i = 0; i < mPhoneCount; i++) {
+ int[] subId = SubscriptionManager.getSubId(i);
+ //when voice call in progress, subscription can't be activate/deactivate.
+ if (TelephonyManager.getDefault().getCallState(subId[0])
+ != TelephonyManager.CALL_STATE_IDLE) {
+ logd("Call state for phoneId: " + i + " is not idle, EXIT!");
+ showAlertDialog(ERROR_ALERT_DLG_ID, R.string.sim_enabler_in_call);
+ return;
+ }
+ }
+
+ if (!mIsChecked) {
+ if (getNumOfSubsProvisioned() > 1) {
+ logd("More than one sub is active, Deactivation possible.");
+ showAlertDialog(CONFIRM_ALERT_DLG_ID, 0);
+ } else {
+ logd("Only one sub is active. Deactivation not possible.");
+ showAlertDialog(ERROR_ALERT_DLG_ID, R.string.sim_enabler_both_inactive);
+ return;
+ }
+ } else {
+ logd("Activate the sub");
+ sendUiccProvisioningRequest();
+ }
+ }
+
+ private void sendUiccProvisioningRequest() {
+ if (!mSwitch.isEnabled()) {
+ return;
+ }
+ int result = -1;
+ int newProvisionedState = NOT_PROVISIONED;
+ mCmdInProgress = true;
+
+ showProgressDialog();
+ setEnabled(false);
+ try {
+ if (mIsChecked) {
+ result = mExtTelephony.activateUiccCard(mSir.getSimSlotIndex());
+ newProvisionedState = PROVISIONED;
+ } else {
+ result = mExtTelephony.deactivateUiccCard(mSir.getSimSlotIndex());
+ }
+ } catch (RemoteException ex) {
+ loge("Activate sub failed " + result + " phoneId " + mSir.getSimSlotIndex());
+ } catch (NullPointerException ex) {
+ loge("Failed to activate sub Exception: " + ex);
+ }
+
+ processSetUiccDone(result, newProvisionedState);
+ }
+
+ private void processSetUiccDone(int result, int newProvisionedState) {
+ sendMessage(EVT_UPDATE, mHandler, MSG_DELAY_TIME);
+ sendMessage(EVT_SHOW_RESULT_DLG, mHandler, MSG_DELAY_TIME, result, newProvisionedState);
+ mCmdInProgress = false;
+ }
+
+ private void showAlertDialog(int dialogId, int msgId) {
+
+ String title = mSir == null ? "SUB" : mSir.getDisplayName().toString();
+ // Confirm only one AlertDialog instance to show.
+ dismissDialog(sAlertDialog);
+ dismissDialog(sProgressDialog);
+ AlertDialog.Builder builder = new AlertDialog.Builder(mContext)
+ .setIcon(android.R.drawable.ic_dialog_alert)
+ .setTitle(title);
+
+ switch(dialogId) {
+ case CONFIRM_ALERT_DLG_ID:
+ String message;
+ if (mContext.getResources().getBoolean(
+ R.bool.confirm_to_switch_data_service)) {
+ if (SubscriptionManager.getDefaultDataSubId() ==
+ mSir.getSubscriptionId()) {
+ message = mContext.getString(
+ R.string.sim_enabler_need_switch_data_service,
+ getProvisionedSlotId(mContext));
+ } else {
+ message = mContext.getString(R.string.sim_enabler_need_disable_sim);
+ }
+ builder.setTitle(R.string.sim_enabler_will_disable_sim_title);
+ } else {
+ message = mContext.getString(R.string.sim_enabler_need_disable_sim);
+ }
+ builder.setMessage(message);
+ builder.setPositiveButton(android.R.string.ok, mDialogClickListener);
+ builder.setNegativeButton(android.R.string.no, mDialogClickListener);
+ builder.setOnCancelListener(mDialogCanceListener);
+ break;
+
+ case ERROR_ALERT_DLG_ID:
+ builder.setMessage(mContext.getString(msgId));
+ builder.setNeutralButton(android.R.string.ok, mDialogClickListener);
+ builder.setCancelable(false);
+ break;
+
+ case RESULT_ALERT_DLG_ID:
+ String msg = mCurrentUiccProvisionState ?
+ mContext.getString(R.string.sub_activate_success) :
+ mContext.getString(R.string.sub_deactivate_success);
+ builder.setMessage(msg);
+ builder.setNeutralButton(android.R.string.ok, null);
+ break;
+ default:
+ break;
+ }
+
+ sAlertDialog = builder.create();
+ sAlertDialog.setCanceledOnTouchOutside(false);
+ sAlertDialog.show();
+ }
+
+ private int getProvisionedSlotId(Context context) {
+ int activeSlotId = -1;
+ List<SubscriptionInfo> subInfoLists =
+ mSubscriptionManager.getActiveSubscriptionInfoList();
+ if (subInfoLists != null) {
+ for (SubscriptionInfo subInfo : subInfoLists) {
+ if (getProvisionStatus(subInfo.getSimSlotIndex()) == PROVISIONED
+ && subInfo.getSubscriptionId() != mSir.getSubscriptionId())
+ activeSlotId = subInfo.getSimSlotIndex() + 1;
+ }
+ }
+ return activeSlotId;
+ }
+
+ private void showProgressDialog() {
+ String title = mSir == null ? "SUB" : mSir.getDisplayName().toString();
+
+ String msg = mContext.getString(mIsChecked ? R.string.sim_enabler_enabling
+ : R.string.sim_enabler_disabling);
+ dismissDialog(sProgressDialog);
+ sProgressDialog = new ProgressDialog(mContext);
+ sProgressDialog.setIndeterminate(true);
+ sProgressDialog.setTitle(title);
+ sProgressDialog.setMessage(msg);
+ sProgressDialog.setCancelable(false);
+ sProgressDialog.setCanceledOnTouchOutside(false);
+ sProgressDialog.show();
+
+ sendMessage(EVT_PROGRESS_DLG_TIME_OUT, mHandler, PROGRESS_DLG_TIME_OUT);
+ }
+
+ private void dismissDialog(Dialog dialog) {
+ if((dialog != null) && (dialog.isShowing())) {
+ dialog.dismiss();
+ dialog = null;
+ }
+ }
+
+ public void cleanUpPendingDialogs() {
+ dismissDialog(sProgressDialog);
+ dismissDialog(sAlertDialog);
+ }
+
+ private DialogInterface.OnClickListener mDialogClickListener = new DialogInterface
+ .OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ if (which == DialogInterface.BUTTON_POSITIVE) {
+ sendUiccProvisioningRequest();
+ } else if (which == DialogInterface.BUTTON_NEGATIVE) {
+ update();
+ } else if (which == DialogInterface.BUTTON_NEUTRAL) {
+ update();
+ }
+ }
+ };
+
+ private DialogInterface.OnCancelListener mDialogCanceListener = new DialogInterface
+ .OnCancelListener() {
+ public void onCancel(DialogInterface dialog) {
+ update();
+ }
+ };
+
+ private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ logd("Intent received: " + action);
+ if (ACTION_UICC_MANUAL_PROVISION_STATUS_CHANGED.equals(action)) {
+ int phoneId = intent.getIntExtra(PhoneConstants.PHONE_KEY,
+ SubscriptionManager.INVALID_SUBSCRIPTION_ID);
+ int newProvisionedState = intent.getIntExtra(EXTRA_NEW_PROVISION_STATE,
+ NOT_PROVISIONED);
+ update();
+
+ logd("Received ACTION_UICC_MANUAL_PROVISION_STATUS_CHANGED on phoneId: "
+ + phoneId + " new sub state " + newProvisionedState);
+ }
+ }
+ };
+
+ private Handler mHandler = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+
+ switch(msg.what) {
+ case EVT_UPDATE:
+ simEnablerUpdate();
+
+ case EVT_SHOW_RESULT_DLG:
+ int result = msg.arg1;
+ int newProvisionedState = msg.arg2;
+ logd("EVT_SHOW_RESULT_DLG result: " + result +
+ " new provisioned state " + newProvisionedState);
+ update();
+ if (result != REQUEST_SUCCESS) {
+ int msgId = (newProvisionedState == PROVISIONED) ?
+ R.string.sub_activate_failed :
+ R.string.sub_deactivate_failed;
+ showAlertDialog(ERROR_ALERT_DLG_ID, msgId);
+ } else {
+ showAlertDialog(RESULT_ALERT_DLG_ID, 0);
+ }
+ mHandler.removeMessages(EVT_PROGRESS_DLG_TIME_OUT);
+ break;
+
+ case EVT_SHOW_PROGRESS_DLG:
+ logd("EVT_SHOW_PROGRESS_DLG");
+ showProgressDialog();
+ break;
+
+ case EVT_PROGRESS_DLG_TIME_OUT:
+ logd("EVT_PROGRESS_DLG_TIME_OUT");
+ dismissDialog(sProgressDialog);
+ // Must update UI when time out
+ update();
+ break;
+
+ default:
+ break;
+ }
+ }
+ };
+
+ public void destroy() {
+ try {
+ mContext.unregisterReceiver(mReceiver);
+ } catch (IllegalArgumentException e) {
+ // May receive Receiver not registered error
+ logd(e.getMessage());
+ }
+ }
+
+ private void logd(String msg) {
+ if (DBG) Log.d(TAG + "(" + mSlotId + ")", msg);
+ }
+
+ private void loge(String msg) {
+ if (DBG) Log.e(TAG + "(" + mSlotId + ")", msg);
+ }
}
// Returns the line1Number. Line1number should always be read from TelephonyManager since it can