summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcretin45 <cretin45@gmail.com>2016-04-08 11:39:44 -0700
committercretin45 <cretin45@gmail.com>2016-04-08 11:40:20 -0700
commit763af1265c4ddba9d010362a1d449ac51f5945d4 (patch)
tree36f38f3abbd804497c86193d394d62cc85997bc7
parentac93a6765db36760995f102cc590435bac36f4d0 (diff)
downloadpackages_apps_SetupWizard-763af1265c4ddba9d010362a1d449ac51f5945d4.zip
packages_apps_SetupWizard-763af1265c4ddba9d010362a1d449ac51f5945d4.tar.gz
packages_apps_SetupWizard-763af1265c4ddba9d010362a1d449ac51f5945d4.tar.bz2
SetupWizard: Wait for data connection
Issue-id: CRACKLING-786 Change-Id: I54ef75ffa8da87d829ce7ce45a7f42ca1ce54732
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/MobileDataPage.java51
1 files changed, 49 insertions, 2 deletions
diff --git a/src/com/cyanogenmod/setupwizard/setup/MobileDataPage.java b/src/com/cyanogenmod/setupwizard/setup/MobileDataPage.java
index caffc41..8940fd3 100644
--- a/src/com/cyanogenmod/setupwizard/setup/MobileDataPage.java
+++ b/src/com/cyanogenmod/setupwizard/setup/MobileDataPage.java
@@ -30,6 +30,7 @@ import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
+import android.widget.Button;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.Switch;
@@ -45,6 +46,8 @@ public class MobileDataPage extends SetupPage {
public static final String TAG = "MobileDataPage";
+ private static final int DC_READY_TIMEOUT = 20 * 1000;
+
public MobileDataPage(Context context, SetupDataCallbacks callbacks) {
super(context, callbacks);
}
@@ -80,6 +83,7 @@ public class MobileDataPage extends SetupPage {
private Switch mEnableMobileData;
private ImageView mSignalView;
private TextView mNameView;
+ private Button mNextButton;
private TelephonyManager mPhone;
private SignalStrength mSignalStrength;
@@ -98,6 +102,13 @@ public class MobileDataPage extends SetupPage {
}
};
+ private final Runnable mDataConnectionReadyRunnable = new Runnable() {
+ @Override
+ public void run() {
+ onDataStateReady();
+ }
+ };
+
private PhoneStateListener mPhoneStateListener =
new PhoneStateListener(SubscriptionManager.getDefaultDataSubId()) {
@@ -116,6 +127,13 @@ public class MobileDataPage extends SetupPage {
updateSignalStrength();
}
+ @Override
+ public void onDataConnectionStateChanged(int state) {
+ if (state == TelephonyManager.DATA_CONNECTED) {
+ onDataStateReady();
+ }
+ }
+
};
private View.OnClickListener mEnableDataClickListener = new View.OnClickListener() {
@@ -124,6 +142,11 @@ public class MobileDataPage extends SetupPage {
boolean checked = !mEnableMobileData.isChecked();
SetupWizardUtils.setMobileDataEnabled(getActivity(), checked);
mEnableMobileData.setChecked(checked);
+ if (checked) {
+ waitForData();
+ } else {
+ onDataStateReady();
+ }
SetupStats.addEvent(SetupStats.Categories.SETTING_CHANGED,
SetupStats.Action.ENABLE_MOBILE_DATA,
SetupStats.Label.CHECKED, String.valueOf(checked));
@@ -139,6 +162,7 @@ public class MobileDataPage extends SetupPage {
mEnableMobileData = (Switch) mRootView.findViewById(R.id.data_switch);
mSignalView = (ImageView) mRootView.findViewById(R.id.signal);
mNameView = (TextView) mRootView.findViewById(R.id.enable_data_title);
+ mNextButton = (Button) getActivity().findViewById(R.id.next_button);
updateDataConnectionStatus();
updateSignalStrength();
}
@@ -156,7 +180,8 @@ public class MobileDataPage extends SetupPage {
mPhone = (TelephonyManager)getActivity().getSystemService(Context.TELEPHONY_SERVICE);
mPhone.listen(mPhoneStateListener,
PhoneStateListener.LISTEN_SERVICE_STATE
- | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
+ | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
+ | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE);
updateDataConnectionStatus();
updateSignalStrength();
if (SetupWizardUtils.isRadioReady(mContext, null)) {
@@ -180,13 +205,35 @@ public class MobileDataPage extends SetupPage {
if (mTitleView != null) {
mTitleView.setText(mPage.getTitleResId());
}
- mProgressBar.setVisibility(View.GONE);
+ mProgressBar.setVisibility(View.INVISIBLE);
mPageView.setVisibility(View.VISIBLE);
mPageView.startAnimation(
AnimationUtils.loadAnimation(getActivity(), R.anim.translucent_enter));
}
}
+ private void waitForData() {
+ if (getUserVisibleHint() && !mProgressBar.isShown()) {
+ mProgressBar.setVisibility(View.VISIBLE);
+ mProgressBar.startAnimation(
+ AnimationUtils.loadAnimation(getActivity(), R.anim.translucent_enter));
+ mEnableDataRow.setEnabled(false);
+ mNextButton.setEnabled(false);
+ mHandler.postDelayed(mDataConnectionReadyRunnable, DC_READY_TIMEOUT);
+ }
+ }
+
+ private void onDataStateReady() {
+ mHandler.removeCallbacks(mDataConnectionReadyRunnable);
+ if (getUserVisibleHint() && mProgressBar.isShown()) {
+ mProgressBar.startAnimation(
+ AnimationUtils.loadAnimation(getActivity(), R.anim.translucent_exit));
+ mProgressBar.setVisibility(View.INVISIBLE);
+ mEnableDataRow.setEnabled(true);
+ mNextButton.setEnabled(true);
+ }
+ }
+
private void updateCarrierText() {
if (mIsAttached) {
String name =