use of android.telephony.SubscriptionInfo in project android_frameworks_base by crdroidandroid.
the class NetworkControllerBaseTest method setSubscriptions.
protected void setSubscriptions(int... subIds) {
List<SubscriptionInfo> subs = new ArrayList<SubscriptionInfo>();
for (int subId : subIds) {
SubscriptionInfo subscription = mock(SubscriptionInfo.class);
when(subscription.getSubscriptionId()).thenReturn(subId);
subs.add(subscription);
}
when(mMockSm.getActiveSubscriptionInfoList()).thenReturn(subs);
mNetworkController.doUpdateMobileControllers();
}
use of android.telephony.SubscriptionInfo in project android_frameworks_base by crdroidandroid.
the class KeyguardUpdateMonitor method getNextSubIdForState.
/**
* Find the next SubscriptionId for a SIM in the given state, favoring lower slot numbers first.
* @param state
* @return subid or {@link SubscriptionManager#INVALID_SUBSCRIPTION_ID} if none found
*/
public int getNextSubIdForState(State state) {
List<SubscriptionInfo> list = getSubscriptionInfo(false);
int resultId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
// Favor lowest slot first
int bestSlotId = Integer.MAX_VALUE;
for (int i = 0; i < list.size(); i++) {
final SubscriptionInfo info = list.get(i);
final int id = info.getSubscriptionId();
int slotId = SubscriptionManager.getSlotId(id);
if (state == getSimState(id) && bestSlotId > slotId) {
resultId = id;
bestSlotId = slotId;
}
}
return resultId;
}
use of android.telephony.SubscriptionInfo in project android_frameworks_base by crdroidandroid.
the class GlobalActions method setupAirplaneModeListeners.
/**
* Since there are two ways of handling airplane mode (with telephony, we depend on the internal
* device telephony state), and MSIM devices do not report phone state for missing SIMs, we
* need to dynamically setup listeners based on subscription changes.
*
* So if there is _any_ active SIM in the device, we can depend on the phone state,
* otherwise fall back to {@link Settings.Global#AIRPLANE_MODE_ON}.
*/
private void setupAirplaneModeListeners() {
TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
for (PhoneStateListener listener : mPhoneStateListeners) {
telephonyManager.listen(listener, PhoneStateListener.LISTEN_NONE);
}
mPhoneStateListeners.clear();
final List<SubscriptionInfo> subInfoList = SubscriptionManager.from(mContext).getActiveSubscriptionInfoList();
if (subInfoList != null) {
mHasTelephony = true;
mAirplaneModeBits = new BitSet(subInfoList.size());
for (int i = 0; i < subInfoList.size(); i++) {
final int finalI = i;
PhoneStateListener subListener = new PhoneStateListener(subInfoList.get(finalI).getSubscriptionId()) {
@Override
public void onServiceStateChanged(ServiceState serviceState) {
final boolean inAirplaneMode = serviceState.getState() == ServiceState.STATE_POWER_OFF;
mAirplaneModeBits.set(finalI, inAirplaneMode);
// we're in airplane mode if _any_ of the subscriptions say we are
mAirplaneState = mAirplaneModeBits.cardinality() > 0 ? ToggleAction.State.On : ToggleAction.State.Off;
mAirplaneModeOn.updateState(mAirplaneState);
if (mAdapter != null) {
mAdapter.notifyDataSetChanged();
}
}
};
mPhoneStateListeners.add(subListener);
telephonyManager.listen(subListener, PhoneStateListener.LISTEN_SERVICE_STATE);
}
} else {
mHasTelephony = false;
}
// Set the initial status of airplane mode toggle
mAirplaneState = getUpdatedAirplaneToggleState();
}
use of android.telephony.SubscriptionInfo in project android_frameworks_base by crdroidandroid.
the class EmergencyAffordanceService method handleUpdateSimSubscriptionInfo.
private boolean handleUpdateSimSubscriptionInfo() {
boolean neededBefore = simNeededAffordanceBefore();
boolean neededNow = neededBefore;
List<SubscriptionInfo> activeSubscriptionInfoList = mSubscriptionManager.getActiveSubscriptionInfoList();
if (activeSubscriptionInfoList == null) {
return neededNow;
}
for (SubscriptionInfo info : activeSubscriptionInfoList) {
int mcc = info.getMcc();
if (mccRequiresEmergencyAffordance(mcc)) {
neededNow = true;
break;
} else if (mcc != 0 && mcc != Integer.MAX_VALUE) {
// a Sim with a different mcc code was found
neededNow = false;
}
String simOperator = mTelephonyManager.getSimOperator(info.getSubscriptionId());
mcc = 0;
if (simOperator != null && simOperator.length() >= 3) {
mcc = Integer.parseInt(simOperator.substring(0, 3));
}
if (mcc != 0) {
if (mccRequiresEmergencyAffordance(mcc)) {
neededNow = true;
break;
} else {
// a Sim with a different mcc code was found
neededNow = false;
}
}
}
setSimNeedsEmergencyAffordance(neededNow);
return neededNow;
}
use of android.telephony.SubscriptionInfo in project android_frameworks_base by AOSPA.
the class KeyguardSimPinView method showDefaultMessage.
private void showDefaultMessage() {
if (mRemainingAttempts >= 0) {
if (mResult != PhoneConstants.PIN_RESULT_SUCCESS)
mSecurityMessageDisplay.setMessage(getPinPasswordErrorMessage(mRemainingAttempts, true), true);
return;
}
mSlotId = SubscriptionManager.getSlotId(mSubId) + 1;
int count = TelephonyManager.getDefault().getSimCount();
Resources rez = getResources();
final String msg;
int color = Color.WHITE;
if (count < 2) {
msg = rez.getString(R.string.kg_sim_pin_instructions);
} else {
SubscriptionInfo info = KeyguardUpdateMonitor.getInstance(mContext).getSubscriptionInfoForSubId(mSubId);
// don't crash
CharSequence displayName = info != null ? info.getDisplayName() : "";
msg = rez.getString(R.string.kg_sim_pin_instructions_multi, displayName);
if (info != null) {
color = info.getIconTint();
}
}
mSecurityMessageDisplay.setMessage(msg, true);
mSimImageView.setImageTintList(ColorStateList.valueOf(color));
new CheckSimPin("", mSubId) {
void onSimCheckResponse(final int result, final int attemptsRemaining) {
Log.d(LOG_TAG, "onSimCheckResponse " + " dummy One result" + result + " attemptsRemaining=" + attemptsRemaining);
if (attemptsRemaining >= 0) {
mRemainingAttempts = attemptsRemaining;
mResult = result;
mSecurityMessageDisplay.setMessage(getPinPasswordErrorMessage(attemptsRemaining, true), true);
}
}
}.start();
}
Aggregations