Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7c1cf5a2 authored by Ricardo Cerqueira's avatar Ricardo Cerqueira Committed by Ricardo Cerqueira
Browse files

MobileData: Don't let wait-for-radio trample wait-for-data

Both waiting for radio and waiting for data used "is the progress
bar visible" as the "allow to continue" clause. If radio service
state changes arrived while the wait-for-data was ongoing, this'd
terminate the progress bar and make it wait forever.

Additionally, if wifi is connected, don't wait for data at all

Ref CYNGNOS-3126

Change-Id: I81792ac8be00c6a6746af88a62220c727cddc6d8
parent 3ebea2fb
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -142,7 +142,7 @@ public class MobileDataPage extends SetupPage {
                boolean checked = !mEnableMobileData.isChecked();
                SetupWizardUtils.setMobileDataEnabled(getActivity(), checked);
                mEnableMobileData.setChecked(checked);
                if (checked) {
                if (checked && !SetupWizardUtils.isWifiConnected(mContext)) {
                    waitForData();
                } else {
                    onDataStateReady();
@@ -205,12 +205,16 @@ public class MobileDataPage extends SetupPage {
                if (mTitleView != null) {
                    mTitleView.setText(mPage.getTitleResId());
                }
                // Something else, like data enablement, may have grabbed
                // the "hold" status. Kill it only if "Next" is active
                if (mNextButton.isEnabled()) {
                    mProgressBar.setVisibility(View.INVISIBLE);
                    mPageView.setVisibility(View.VISIBLE);
                    mPageView.startAnimation(
                            AnimationUtils.loadAnimation(getActivity(), R.anim.translucent_enter));
                }
            }
        }

        private void waitForData() {
            if (getUserVisibleHint() && !mProgressBar.isShown()) {
@@ -225,7 +229,8 @@ public class MobileDataPage extends SetupPage {

        private void onDataStateReady() {
            mHandler.removeCallbacks(mDataConnectionReadyRunnable);
            if (getUserVisibleHint() && mProgressBar.isShown()) {
            if ((getUserVisibleHint() && mProgressBar.isShown()) ||
                  !mNextButton.isEnabled()) {
                mProgressBar.startAnimation(
                        AnimationUtils.loadAnimation(getActivity(), R.anim.translucent_exit));
                mProgressBar.setVisibility(View.INVISIBLE);