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 \
libphonenumber
LOCAL_JAVA_LIBRARIES := \
telephony-common
# Include res dir from chips
google_play_dir := ../../../external/google/google_play_services/libproject/google-play-services_lib/res
res_dir := $(google_play_dir) res

View File

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

View File

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