summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRicardo Cerqueira <ricardo@cyngn.com>2016-07-12 15:13:28 +0100
committerGerrit Code Review <gerrit@cyanogenmod.org>2016-07-14 04:03:45 -0700
commit3ebea2fb6de5e6037255f97b5bf190a6e0b02c94 (patch)
tree0db14610ba07a7a2e3ec5d6dfaa0134e6a170629
parent07c44c446762820d8080bd97f566de8fcea8b6f6 (diff)
downloadpackages_apps_SetupWizard-3ebea2fb6de5e6037255f97b5bf190a6e0b02c94.zip
packages_apps_SetupWizard-3ebea2fb6de5e6037255f97b5bf190a6e0b02c94.tar.gz
packages_apps_SetupWizard-3ebea2fb6de5e6037255f97b5bf190a6e0b02c94.tar.bz2
ChooseDataSim: Use the extra data from the intent to validate the sub
Instead of waiting for the telephony stack to catch up to the default, take advantage of the fact that the intent already carries the ID as an extra. Also, we were using slotId and phoneId interchangeably, and they're not the same thing. While it's likely they'll match on a freshly reset phone, don't assume that. Index everything to subId for consistency. Ref CYNGNOS-3126 Change-Id: Ibcd767d0124b05d669886190f5d9a98f1a6e5bd7
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/ChooseDataSimPage.java45
1 files changed, 22 insertions, 23 deletions
diff --git a/src/com/cyanogenmod/setupwizard/setup/ChooseDataSimPage.java b/src/com/cyanogenmod/setupwizard/setup/ChooseDataSimPage.java
index a0a4312..adca459 100644
--- a/src/com/cyanogenmod/setupwizard/setup/ChooseDataSimPage.java
+++ b/src/com/cyanogenmod/setupwizard/setup/ChooseDataSimPage.java
@@ -43,6 +43,7 @@ import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
+import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.cyanogenmod.setupwizard.R;
@@ -107,12 +108,12 @@ public class ChooseDataSimPage extends SetupPage {
private Context mContext;
private SubscriptionManager mSubscriptionManager;
- private int mCurrentDataPhoneId;
+ private int mCurrentDataSubId;
// This is static because a user can click back mid operation.
// We want to persist what the user was changing to because of the
// async callback can sometimes take a long time.
- private static int sChangingToDataPhoneId = -1;
+ private static int sChangingToDataSubId = -1;
private boolean mDisabledForSwitch = false;
@@ -133,8 +134,7 @@ public class ChooseDataSimPage extends SetupPage {
@Override
public void onClick(View view) {
SubscriptionInfo subInfoRecord = (SubscriptionInfo)view.getTag();
- if (subInfoRecord != null &&
- subInfoRecord.getSimSlotIndex() != mCurrentDataPhoneId) {
+ if (subInfoRecord != null) {
changeDataSub(subInfoRecord);
}
}
@@ -188,9 +188,9 @@ public class ChooseDataSimPage extends SetupPage {
super.onCreate(savedInstanceState);
mContext = getActivity().getApplicationContext();
mSubscriptionManager = SubscriptionManager.from(mContext);
- mCurrentDataPhoneId = mSubscriptionManager.getDefaultDataPhoneId();
- if (sChangingToDataPhoneId == -1) {
- sChangingToDataPhoneId = mCurrentDataPhoneId;
+ mCurrentDataSubId = mSubscriptionManager.getDefaultDataSubId();
+ if (sChangingToDataSubId == -1) {
+ sChangingToDataSubId = mCurrentDataSubId;
}
}
@@ -230,9 +230,8 @@ public class ChooseDataSimPage extends SetupPage {
getActivity().unregisterReceiver(mIntentReceiver);
}
- private void ddsHasChanged() {
- mCurrentDataPhoneId = mSubscriptionManager.getDefaultDataPhoneId();
- if (mCurrentDataPhoneId == sChangingToDataPhoneId) {
+ private void ddsHasChanged(int subId) {
+ if (subId == sChangingToDataSubId) {
hideProgress();
enableViews(true);
}
@@ -257,16 +256,16 @@ public class ChooseDataSimPage extends SetupPage {
@Override
public void onDataConnectionStateChanged(int state) {
- final int dataPhoneId = mSubscriptionManager.getDefaultDataPhoneId();
+ final int dataSubId = mSubscriptionManager.getDefaultDataSubId();
// In case the default sub changes from elsewhere. This shouldn't happen,
// but testcases can induce this.
- if (dataPhoneId != mCurrentDataPhoneId &&
- dataPhoneId != sChangingToDataPhoneId) {
- sChangingToDataPhoneId = dataPhoneId;
+ if (dataSubId != mCurrentDataSubId &&
+ dataSubId != sChangingToDataSubId) {
+ sChangingToDataSubId = dataSubId;
updateCurrentDataSub();
}
- if (mCurrentDataPhoneId != dataPhoneId) {
- mCurrentDataPhoneId = dataPhoneId;
+ if (mCurrentDataSubId != dataSubId) {
+ mCurrentDataSubId = dataSubId;
updateCurrentDataSub();
}
checkSimChangingState();
@@ -331,9 +330,9 @@ public class ChooseDataSimPage extends SetupPage {
}
private void changeDataSub(SubscriptionInfo subInfoRecord) {
- if (sChangingToDataPhoneId != subInfoRecord.getSimSlotIndex()) {
- sChangingToDataPhoneId = subInfoRecord.getSimSlotIndex();
- mSubscriptionManager.setDefaultDataSubId(subInfoRecord.getSubscriptionId());
+ if (sChangingToDataSubId != subInfoRecord.getSubscriptionId()) {
+ sChangingToDataSubId = subInfoRecord.getSubscriptionId();
+ mSubscriptionManager.setDefaultDataSubId(sChangingToDataSubId);
setDataSubChecked(subInfoRecord);
}
checkSimChangingState();
@@ -341,7 +340,7 @@ public class ChooseDataSimPage extends SetupPage {
private void checkSimChangingState() {
if (mIsAttached && mRadioReady) {
- if (mCurrentDataPhoneId != sChangingToDataPhoneId) {
+ if (mCurrentDataSubId != sChangingToDataSubId) {
showProgress();
enableViews(false);
} else {
@@ -371,8 +370,8 @@ public class ChooseDataSimPage extends SetupPage {
if (mIsAttached) {
for (int i = 0; i < mSubInfoRecords.size(); i++) {
SubscriptionInfo subInfoRecord = mSubInfoRecords.valueAt(i);
- mCheckBoxes.get(i).setChecked(mSubscriptionManager.getDefaultDataPhoneId()
- == subInfoRecord.getSimSlotIndex());
+ mCheckBoxes.get(i).setChecked(mSubscriptionManager.getDefaultDataSubId()
+ == subInfoRecord.getSubscriptionId());
}
}
}
@@ -487,7 +486,7 @@ public class ChooseDataSimPage extends SetupPage {
public void onReceive(Context context, Intent intent) {
final Activity activity = getActivity();
if (activity != null) {
- ddsHasChanged();
+ ddsHasChanged(intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY, -1));
}
}
};