summaryrefslogtreecommitdiffstats
path: root/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java
diff options
context:
space:
mode:
authorcretin45 <cretin45@gmail.com>2015-01-29 17:36:30 -0800
committercretin45 <cretin45@gmail.com>2015-01-29 17:40:05 -0800
commit106a127508aada421485abb70c8b29f6974ba270 (patch)
tree87dd8381485a0797a8c0c7960d1b35e831725af1 /src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java
parentb0167c853fa6940fad4dfb175df2a7667dfa1616 (diff)
downloadpackages_apps_SetupWizard-106a127508aada421485abb70c8b29f6974ba270.zip
packages_apps_SetupWizard-106a127508aada421485abb70c8b29f6974ba270.tar.gz
packages_apps_SetupWizard-106a127508aada421485abb70c8b29f6974ba270.tar.bz2
SetupWizard: Add receivers for sim state and time
Change-Id: I8d44623e898eaa175d69d682c8089caa1a58f287
Diffstat (limited to 'src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java')
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java91
1 files changed, 83 insertions, 8 deletions
diff --git a/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java b/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java
index f4e7153..e5e2fb8 100644
--- a/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java
+++ b/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java
@@ -16,29 +16,47 @@
package com.cyanogenmod.setupwizard.setup;
-import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
-
import android.content.Context;
-import android.telephony.SubscriptionManager;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.telephony.TelephonyManager;
+
+import com.android.internal.telephony.TelephonyIntents;
+import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
import java.util.ArrayList;
public class CMSetupWizardData extends AbstractSetupData {
+ private static final String TAG = CMSetupWizardData.class.getSimpleName();
+
+ private final TelephonyManager mTelephonyManager;
+
+ private boolean mTimeSet = false;
+ private boolean mTimeZoneSet = false;
+
+ private final int mSimSlotCount;
+ private final int[] mSimStates;
+
public CMSetupWizardData(Context context) {
super(context);
+ mTelephonyManager = TelephonyManager.from(context);
+ mSimSlotCount = mTelephonyManager.getPhoneCount();
+ mSimStates = new int[mSimSlotCount];
+ for (int i = 0; i < mSimSlotCount; i++) {
+ mSimStates[i] = TelephonyManager.SIM_STATE_ABSENT;
+ }
}
@Override
protected PageList onNewPageList() {
- ArrayList<SetupPage> pages = new ArrayList<SetupPage>();
+ ArrayList<Page> pages = new ArrayList<Page>();
pages.add(new WelcomePage(mContext, this));
pages.add(new WifiSetupPage(mContext, this));
- if (SetupWizardUtils.isSimMissing(mContext)) {
- pages.add(new SimCardMissingPage(mContext, this));
+ if (TelephonyManager.from(mContext).getSimCount() > 0) {
+ pages.add(new SimCardMissingPage(mContext, this).setHidden(true));
}
- if (SetupWizardUtils.isMultiSimDevice(mContext)
- && SubscriptionManager.getActiveSubInfoCount() > 1) {
+ if (SetupWizardUtils.isMultiSimDevice(mContext)) {
pages.add(new ChooseDataSimPage(mContext, this));
}
if (SetupWizardUtils.hasTelephony(mContext) &&
@@ -57,4 +75,61 @@ public class CMSetupWizardData extends AbstractSetupData {
}
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) {
+ int slot = intent.getIntExtra("slot", -1);
+ if (slot != -1 && mSimStates.length > 0) {
+ mSimStates[slot] = mTelephonyManager.getSimState(slot);
+ }
+ } else if (intent.getAction().equals(Intent.ACTION_TIMEZONE_CHANGED)) {
+ mTimeZoneSet = true;
+ } else if (intent.getAction().equals(Intent.ACTION_TIME_CHANGED)) {
+ mTimeSet = true;
+ }
+ DateTimePage dateTimePage = (DateTimePage) getPage(DateTimePage.TAG);
+ dateTimePage.setHidden(mTimeZoneSet & mTimeSet);
+
+ SimCardMissingPage simCardMissingPage =
+ (SimCardMissingPage) getPage(SimCardMissingPage.TAG);
+ if (simCardMissingPage != null) {
+ simCardMissingPage.setHidden(isSimInserted());
+ }
+
+ ChooseDataSimPage chooseDataSimPage =
+ (ChooseDataSimPage) getPage(ChooseDataSimPage.TAG);
+ if (chooseDataSimPage != null) {
+ chooseDataSimPage.setHidden(!allSimsInserted());
+ }
+ }
+
+ public IntentFilter getIntentFilter() {
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
+ filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
+ filter.addAction(Intent.ACTION_TIME_CHANGED);
+ return filter;
+ }
+
+ // We only care that one sim is inserted
+ private boolean isSimInserted() {
+ for (int state : mSimStates) {
+ if (state != TelephonyManager.SIM_STATE_ABSENT
+ && state != TelephonyManager.SIM_STATE_UNKNOWN) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ // We only care the each slot has a sim
+ private boolean allSimsInserted() {
+ for (int state : mSimStates) {
+ if (state == TelephonyManager.SIM_STATE_ABSENT) {
+ return false;
+ }
+ }
+ return true;
+ }
+
} \ No newline at end of file