SetupWizard: don't access SubscriptionController directly

SubscriptionController exists in the telephony process and cannot
be accessed by SetupWizard.

getInstance() will always return null.

Change-Id: I017682d3aad539e1954348664b1c1fec7f76009d
This commit is contained in:
Pawit Pornkitprasan 2015-04-18 11:40:43 +07:00 committed by cretin45
parent 317a6cb891
commit dd500a1f42
3 changed files with 17 additions and 26 deletions

View File

@ -17,9 +17,6 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
play \ play \
libphonenumber libphonenumber
LOCAL_JAVA_LIBRARIES := \
telephony-common
# Include res dir from chips # Include res dir from chips
google_play_dir := ../../../external/google/google_play_services/libproject/google-play-services_lib/res google_play_dir := ../../../external/google/google_play_services/libproject/google-play-services_lib/res
res_dir := $(google_play_dir) res res_dir := $(google_play_dir) res

View File

@ -38,8 +38,6 @@ import android.widget.ImageView;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import com.android.internal.telephony.SubscriptionController;
import com.cyanogenmod.setupwizard.R; import com.cyanogenmod.setupwizard.R;
import com.cyanogenmod.setupwizard.SetupWizardApp; import com.cyanogenmod.setupwizard.SetupWizardApp;
import com.cyanogenmod.setupwizard.cmstats.SetupStats; import com.cyanogenmod.setupwizard.cmstats.SetupStats;
@ -52,11 +50,8 @@ public class ChooseDataSimPage extends SetupPage {
public static final String TAG = "ChooseDataSimPage"; public static final String TAG = "ChooseDataSimPage";
private SubscriptionManager mSubscriptionManager;
public ChooseDataSimPage(Context context, SetupDataCallbacks callbacks) { public ChooseDataSimPage(Context context, SetupDataCallbacks callbacks) {
super(context, callbacks); super(context, callbacks);
mSubscriptionManager = SubscriptionManager.from(context);
} }
@Override @Override
@ -100,6 +95,7 @@ public class ChooseDataSimPage extends SetupPage {
private boolean mIsAttached = false; private boolean mIsAttached = false;
private Context mContext; private Context mContext;
private SubscriptionManager mSubscriptionManager;
private final Handler mHandler = new Handler(); private final Handler mHandler = new Handler();
@ -115,8 +111,7 @@ public class ChooseDataSimPage extends SetupPage {
public void onClick(View view) { public void onClick(View view) {
SubscriptionInfo subInfoRecord = (SubscriptionInfo)view.getTag(); SubscriptionInfo subInfoRecord = (SubscriptionInfo)view.getTag();
if (subInfoRecord != null) { if (subInfoRecord != null) {
SubscriptionController.getInstance() mSubscriptionManager.setDefaultDataSubId(subInfoRecord.getSubscriptionId());
.setDefaultDataSubId(subInfoRecord.getSubscriptionId());
setDataSubChecked(subInfoRecord); setDataSubChecked(subInfoRecord);
} }
} }
@ -126,8 +121,7 @@ public class ChooseDataSimPage extends SetupPage {
protected void initializePage() { protected void initializePage() {
mPageView = (ViewGroup)mRootView.findViewById(R.id.page_view); mPageView = (ViewGroup)mRootView.findViewById(R.id.page_view);
mProgressBar = (ProgressBar) mRootView.findViewById(R.id.progress); mProgressBar = (ProgressBar) mRootView.findViewById(R.id.progress);
List<SubscriptionInfo> subInfoRecords = SubscriptionController List<SubscriptionInfo> subInfoRecords = mSubscriptionManager.getActiveSubscriptionInfoList();
.getInstance().getActiveSubscriptionInfoList();
int simCount = subInfoRecords.size(); int simCount = subInfoRecords.size();
mSubInfoRecords = new SparseArray<SubscriptionInfo>(simCount); mSubInfoRecords = new SparseArray<SubscriptionInfo>(simCount);
for (int i = 0; i < simCount; i++) { for (int i = 0; i < simCount; i++) {
@ -162,11 +156,17 @@ public class ChooseDataSimPage extends SetupPage {
return R.layout.choose_data_sim_page; return R.layout.choose_data_sim_page;
} }
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContext = getActivity().getApplicationContext();
mSubscriptionManager = SubscriptionManager.from(mContext);
}
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
mIsAttached = true; mIsAttached = true;
mContext = getActivity().getApplicationContext();
mPhone = (TelephonyManager)getActivity().getSystemService(Context.TELEPHONY_SERVICE); mPhone = (TelephonyManager)getActivity().getSystemService(Context.TELEPHONY_SERVICE);
for (int i = 0; i < mPhoneStateListeners.size(); i++) { for (int i = 0; i < mPhoneStateListeners.size(); i++) {
mPhone.listen(mPhoneStateListeners.get(i), mPhone.listen(mPhoneStateListeners.get(i),
@ -253,9 +253,8 @@ public class ChooseDataSimPage extends SetupPage {
if (mIsAttached) { if (mIsAttached) {
for (int i = 0; i < mSubInfoRecords.size(); i++) { for (int i = 0; i < mSubInfoRecords.size(); i++) {
SubscriptionInfo subInfoRecord = mSubInfoRecords.get(i); SubscriptionInfo subInfoRecord = mSubInfoRecords.get(i);
mCheckBoxes.get(i).setChecked(SubscriptionManager.getDefaultDataSubId() mCheckBoxes.get(i).setChecked(mSubscriptionManager.getDefaultDataPhoneId()
== subInfoRecord.getSimSlotIndex()); == subInfoRecord.getSimSlotIndex());
} }
} }
} }

View File

@ -32,8 +32,6 @@ import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.util.Log; import android.util.Log;
import com.android.internal.telephony.SubscriptionController;
import com.cyanogenmod.setupwizard.SetupWizardApp; import com.cyanogenmod.setupwizard.SetupWizardApp;
import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.ConnectionResult;
@ -115,15 +113,12 @@ public class SetupWizardUtils {
public static boolean isSimMissing(Context context) { public static boolean isSimMissing(Context context) {
TelephonyManager tm = TelephonyManager tm =
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
SubscriptionController subscriptionController = SubscriptionController.getInstance(); int simCount = SubscriptionManager.from(context).getDefaultDataPhoneId();
if (subscriptionController != null) { for (int i = 0; i < simCount; i++) {
int simCount = subscriptionController.getActiveSubInfoCount(); int simState = tm.getSimState(i);
for (int i = 0; i < simCount; i++) { if (simState != TelephonyManager.SIM_STATE_ABSENT &&
int simState = tm.getSimState(i); simState != TelephonyManager.SIM_STATE_UNKNOWN) {
if (simState != TelephonyManager.SIM_STATE_ABSENT && return false;
simState != TelephonyManager.SIM_STATE_UNKNOWN) {
return false;
}
} }
} }
return true; return true;