SetupWizard: Don't wait for data connection to present the data toggle

We can proceed to the data enablement screen as soon as the device
confirms the requested slot is active. Waiting for an actual data
connection kinda breaks the point of that screen :)

Addresses CYNGNOS-660 and CRACKLING-503

Change-Id: I975508852b37c0e4b112612ac10aacb71ded97b3
This commit is contained in:
Ricardo Cerqueira 2015-08-20 16:01:51 +01:00 committed by cretin45
parent 4ef509ac48
commit 7e1a0aaffa

View File

@ -16,9 +16,13 @@
package com.cyanogenmod.setupwizard.setup;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.telephony.PhoneStateListener;
@ -39,6 +43,8 @@ import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.android.internal.telephony.TelephonyIntents;
import com.cyanogenmod.setupwizard.R;
import com.cyanogenmod.setupwizard.SetupWizardApp;
import com.cyanogenmod.setupwizard.cmstats.SetupStats;
@ -207,6 +213,11 @@ public class ChooseDataSimPage extends SetupPage {
if (mRadioReady) {
checkSimChangingState();
}
// Register for DDS changes
IntentFilter filter = new IntentFilter();
filter.addAction(TelephonyIntents.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
getActivity().registerReceiver(mIntentReceiver, filter, null, null);
}
@Override
@ -216,6 +227,15 @@ public class ChooseDataSimPage extends SetupPage {
for (int i = 0; i < mPhoneStateListeners.size(); i++) {
mPhone.listen(mPhoneStateListeners.valueAt(i), PhoneStateListener.LISTEN_NONE);
}
getActivity().unregisterReceiver(mIntentReceiver);
}
private void ddsHasChanged() {
mCurrentDataPhoneId = mSubscriptionManager.getDefaultDataPhoneId();
if (mCurrentDataPhoneId == sChangingToDataPhoneId) {
hideProgress();
enableViews(true);
}
}
private PhoneStateListener createPhoneStateListener(final SubscriptionInfo subInfoRecord) {
@ -458,6 +478,17 @@ public class ChooseDataSimPage extends SetupPage {
}
return retVal;
}
private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final Activity activity = getActivity();
if (activity != null) {
ddsHasChanged();
}
}
};
}
}