summaryrefslogtreecommitdiffstats
path: root/src/com/cyanogenmod/setupwizard/setup
diff options
context:
space:
mode:
authorcretin45 <cretin45@gmail.com>2015-04-14 17:28:37 -0700
committerMichael Bestas <mikeioannina@gmail.com>2015-04-17 03:44:08 +0300
commitf654deb21764efb32b9c2af0d48c387bb8c733e0 (patch)
tree1231490b2ce42973e27847d28b60aa6a7a31ae0b /src/com/cyanogenmod/setupwizard/setup
parentbfd7ca05454c6f555e228896f1e59223e26eca70 (diff)
downloadpackages_apps_SetupWizard-f654deb21764efb32b9c2af0d48c387bb8c733e0.zip
packages_apps_SetupWizard-f654deb21764efb32b9c2af0d48c387bb8c733e0.tar.gz
packages_apps_SetupWizard-f654deb21764efb32b9c2af0d48c387bb8c733e0.tar.bz2
SetupWizard: Give radio a 10 second chance to come up
Change-Id: Iadd817b200106783dd67edbc5ad03928ce2baa6b
Diffstat (limited to 'src/com/cyanogenmod/setupwizard/setup')
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java43
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/ChooseDataSimPage.java51
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/MobileDataPage.java69
3 files changed, 124 insertions, 39 deletions
diff --git a/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java b/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java
index bb5d846..5070fec 100644
--- a/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java
+++ b/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java
@@ -44,10 +44,12 @@ public class CMSetupWizardData extends AbstractSetupData {
pages.add(new WelcomePage(mContext, this));
pages.add(new WifiSetupPage(mContext, this));
if (SetupWizardUtils.hasTelephony(mContext)) {
- pages.add(new SimCardMissingPage(mContext, this).setHidden(isSimInserted()));
+ pages.add(new SimCardMissingPage(mContext, this)
+ .setHidden(isSimInserted()));
}
if (SetupWizardUtils.isMultiSimDevice(mContext)) {
- pages.add(new ChooseDataSimPage(mContext, this).setHidden(!allSimsInserted()));
+ pages.add(new ChooseDataSimPage(mContext, this)
+ .setHidden(!allSimsInserted()));
}
if (SetupWizardUtils.hasTelephony(mContext)) {
pages.add(new MobileDataPage(mContext, this)
@@ -68,19 +70,8 @@ public class CMSetupWizardData extends AbstractSetupData {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) {
- ChooseDataSimPage chooseDataSimPage =
- (ChooseDataSimPage) getPage(ChooseDataSimPage.TAG);
- if (chooseDataSimPage != null) {
- chooseDataSimPage.setHidden(!allSimsInserted());
- }
- SimCardMissingPage simCardMissingPage =
- (SimCardMissingPage) getPage(SimCardMissingPage.TAG);
- if (simCardMissingPage != null) {
- simCardMissingPage.setHidden(isSimInserted());
- if (isCurrentPage(simCardMissingPage)) {
- onNextPage();
- }
- }
+ showHideDataSimPage();
+ showHideSimMissingPage();
showHideMobileDataPage();
} else if (intent.getAction()
.equals(ConnectivityManager.CONNECTIVITY_ACTION) ||
@@ -116,12 +107,30 @@ public class CMSetupWizardData extends AbstractSetupData {
}
}
+ private void showHideSimMissingPage() {
+ SimCardMissingPage simCardMissingPage =
+ (SimCardMissingPage) getPage(SimCardMissingPage.TAG);
+ if (simCardMissingPage != null && isSimInserted()) {
+ simCardMissingPage.setHidden(true);
+ if (isCurrentPage(simCardMissingPage)) {
+ onNextPage();
+ }
+ }
+ }
+
+ private void showHideDataSimPage() {
+ ChooseDataSimPage chooseDataSimPage =
+ (ChooseDataSimPage) getPage(ChooseDataSimPage.TAG);
+ if (chooseDataSimPage != null) {
+ chooseDataSimPage.setHidden(!isSimInserted());
+ }
+ }
+
private void showHideMobileDataPage() {
MobileDataPage mobileDataPage =
(MobileDataPage) getPage(MobileDataPage.TAG);
if (mobileDataPage != null) {
- mobileDataPage.setHidden(!isSimInserted() ||
- SetupWizardUtils.isMobileDataEnabled(mContext));
+ mobileDataPage.setHidden(!isSimInserted());
}
}
diff --git a/src/com/cyanogenmod/setupwizard/setup/ChooseDataSimPage.java b/src/com/cyanogenmod/setupwizard/setup/ChooseDataSimPage.java
index 7536a5e..c5aedc4 100644
--- a/src/com/cyanogenmod/setupwizard/setup/ChooseDataSimPage.java
+++ b/src/com/cyanogenmod/setupwizard/setup/ChooseDataSimPage.java
@@ -20,6 +20,7 @@ import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Context;
import android.os.Bundle;
+import android.os.Handler;
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
@@ -31,15 +32,19 @@ import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.view.animation.AnimationUtils;
import android.widget.CheckBox;
import android.widget.ImageView;
+import android.widget.ProgressBar;
import android.widget.TextView;
import com.android.internal.telephony.SubscriptionController;
import com.cyanogenmod.setupwizard.R;
+import com.cyanogenmod.setupwizard.SetupWizardApp;
import com.cyanogenmod.setupwizard.cmstats.SetupStats;
import com.cyanogenmod.setupwizard.ui.SetupPageFragment;
+import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
import java.util.List;
@@ -81,6 +86,7 @@ public class ChooseDataSimPage extends SetupPage {
public static class ChooseDataSimFragment extends SetupPageFragment {
private ViewGroup mPageView;
+ private ProgressBar mProgressBar;
private SparseArray<TextView> mNameViews;
private SparseArray<ImageView> mSignalViews;
private SparseArray<CheckBox> mCheckBoxes;
@@ -93,6 +99,17 @@ public class ChooseDataSimPage extends SetupPage {
private boolean mIsAttached = false;
+ private Context mContext;
+
+ private final Handler mHandler = new Handler();
+
+ private final Runnable mRadioReadyRunnable = new Runnable() {
+ @Override
+ public void run() {
+ hideWaitForRadio();
+ }
+ };
+
private View.OnClickListener mSetDataSimClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
@@ -108,6 +125,7 @@ public class ChooseDataSimPage extends SetupPage {
@Override
protected void initializePage() {
mPageView = (ViewGroup)mRootView.findViewById(R.id.page_view);
+ mProgressBar = (ProgressBar) mRootView.findViewById(R.id.progress);
List<SubscriptionInfo> subInfoRecords = SubscriptionController
.getInstance().getActiveSubscriptionInfoList();
int simCount = subInfoRecords.size();
@@ -148,6 +166,7 @@ public class ChooseDataSimPage extends SetupPage {
public void onResume() {
super.onResume();
mIsAttached = true;
+ mContext = getActivity().getApplicationContext();
mPhone = (TelephonyManager)getActivity().getSystemService(Context.TELEPHONY_SERVICE);
for (int i = 0; i < mPhoneStateListeners.size(); i++) {
mPhone.listen(mPhoneStateListeners.get(i),
@@ -156,6 +175,12 @@ public class ChooseDataSimPage extends SetupPage {
}
updateSignalStrengths();
updateCurrentDataSub();
+ if (SetupWizardUtils.isRadioReady(mContext, null)) {
+ hideWaitForRadio();
+ } else if (mTitleView != null) {
+ mTitleView.setText(R.string.loading);
+ mHandler.postDelayed(mRadioReadyRunnable, SetupWizardApp.RADIO_READY_TIMEOUT);
+ }
}
@Override
@@ -172,22 +197,34 @@ public class ChooseDataSimPage extends SetupPage {
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
- if (mIsAttached) {
- mSignalStrengths.put(subInfoRecord.getSimSlotIndex(), signalStrength);
- updateSignalStrength(subInfoRecord);
- }
+ mSignalStrengths.put(subInfoRecord.getSimSlotIndex(), signalStrength);
+ updateSignalStrength(subInfoRecord);
}
@Override
public void onServiceStateChanged(ServiceState state) {
- if (mIsAttached) {
- mServiceStates.put(subInfoRecord.getSimSlotIndex(), state);
- updateSignalStrength(subInfoRecord);
+ if (SetupWizardUtils.isRadioReady(mContext, state)) {
+ hideWaitForRadio();
}
+ mServiceStates.put(subInfoRecord.getSimSlotIndex(), state);
+ updateSignalStrength(subInfoRecord);
}
};
}
+ private void hideWaitForRadio() {
+ if (getUserVisibleHint() && mProgressBar.isShown()) {
+ mHandler.removeCallbacks(mRadioReadyRunnable);
+ if (mTitleView != null) {
+ mTitleView.setText(mPage.getTitleResId());
+ }
+ mProgressBar.setVisibility(View.GONE);
+ mPageView.setVisibility(View.VISIBLE);
+ mPageView.startAnimation(
+ AnimationUtils.loadAnimation(getActivity(), R.anim.translucent_enter));
+ }
+ }
+
private void updateSignalStrengths() {
if (mIsAttached) {
for (int i = 0; i < mSubInfoRecords.size(); i++) {
diff --git a/src/com/cyanogenmod/setupwizard/setup/MobileDataPage.java b/src/com/cyanogenmod/setupwizard/setup/MobileDataPage.java
index 2d4fecb..caffc41 100644
--- a/src/com/cyanogenmod/setupwizard/setup/MobileDataPage.java
+++ b/src/com/cyanogenmod/setupwizard/setup/MobileDataPage.java
@@ -20,6 +20,7 @@ import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Context;
import android.os.Bundle;
+import android.os.Handler;
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
@@ -27,11 +28,15 @@ import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.view.View;
+import android.view.ViewGroup;
+import android.view.animation.AnimationUtils;
import android.widget.ImageView;
+import android.widget.ProgressBar;
import android.widget.Switch;
import android.widget.TextView;
import com.cyanogenmod.setupwizard.R;
+import com.cyanogenmod.setupwizard.SetupWizardApp;
import com.cyanogenmod.setupwizard.cmstats.SetupStats;
import com.cyanogenmod.setupwizard.ui.SetupPageFragment;
import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
@@ -69,6 +74,8 @@ public class MobileDataPage extends SetupPage {
public static class MobileDataFragment extends SetupPageFragment {
+ private ViewGroup mPageView;
+ private ProgressBar mProgressBar;
private View mEnableDataRow;
private Switch mEnableMobileData;
private ImageView mSignalView;
@@ -80,27 +87,37 @@ public class MobileDataPage extends SetupPage {
private boolean mIsAttached = false;
- private PhoneStateListener mPhoneStateListener =
- new PhoneStateListener(SubscriptionManager.getDefaultDataSubId()) {
+ private Context mContext;
- @Override
- public void onSignalStrengthsChanged(SignalStrength signalStrength) {
- if (mIsAttached) {
- mSignalStrength = signalStrength;
- updateSignalStrength();
- }
- }
+ private final Handler mHandler = new Handler();
+ private final Runnable mRadioReadyRunnable = new Runnable() {
@Override
- public void onServiceStateChanged(ServiceState state) {
- if (mIsAttached) {
- mServiceState = state;
- updateSignalStrength();
- }
+ public void run() {
+ hideWaitForRadio();
}
-
};
+ private PhoneStateListener mPhoneStateListener =
+ new PhoneStateListener(SubscriptionManager.getDefaultDataSubId()) {
+
+ @Override
+ public void onSignalStrengthsChanged(SignalStrength signalStrength) {
+ mSignalStrength = signalStrength;
+ updateSignalStrength();
+ }
+
+ @Override
+ public void onServiceStateChanged(ServiceState state) {
+ if (SetupWizardUtils.isRadioReady(mContext, state)) {
+ hideWaitForRadio();
+ }
+ mServiceState = state;
+ updateSignalStrength();
+ }
+
+ };
+
private View.OnClickListener mEnableDataClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
@@ -115,6 +132,8 @@ public class MobileDataPage extends SetupPage {
@Override
protected void initializePage() {
+ mPageView = (ViewGroup)mRootView.findViewById(R.id.page_view);
+ mProgressBar = (ProgressBar) mRootView.findViewById(R.id.progress);
mEnableDataRow = mRootView.findViewById(R.id.data);
mEnableDataRow.setOnClickListener(mEnableDataClickListener);
mEnableMobileData = (Switch) mRootView.findViewById(R.id.data_switch);
@@ -133,12 +152,19 @@ public class MobileDataPage extends SetupPage {
public void onResume() {
super.onResume();
mIsAttached = true;
+ mContext = getActivity().getApplicationContext();
mPhone = (TelephonyManager)getActivity().getSystemService(Context.TELEPHONY_SERVICE);
mPhone.listen(mPhoneStateListener,
PhoneStateListener.LISTEN_SERVICE_STATE
| PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
updateDataConnectionStatus();
updateSignalStrength();
+ if (SetupWizardUtils.isRadioReady(mContext, null)) {
+ hideWaitForRadio();
+ } else if (mTitleView != null) {
+ mTitleView.setText(R.string.loading);
+ mHandler.postDelayed(mRadioReadyRunnable, SetupWizardApp.RADIO_READY_TIMEOUT);
+ }
}
@Override
@@ -148,6 +174,19 @@ public class MobileDataPage extends SetupPage {
mPhone.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
}
+ private void hideWaitForRadio() {
+ if (getUserVisibleHint() && mProgressBar.isShown()) {
+ mHandler.removeCallbacks(mRadioReadyRunnable);
+ if (mTitleView != null) {
+ mTitleView.setText(mPage.getTitleResId());
+ }
+ mProgressBar.setVisibility(View.GONE);
+ mPageView.setVisibility(View.VISIBLE);
+ mPageView.startAnimation(
+ AnimationUtils.loadAnimation(getActivity(), R.anim.translucent_enter));
+ }
+ }
+
private void updateCarrierText() {
if (mIsAttached) {
String name =