use of android.telephony.TelephonyManager in project android_frameworks_base by ResurrectionRemix.
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.TelephonyManager in project android_frameworks_base by ResurrectionRemix.
the class DataUsageController method getActiveSubscriberId.
private static String getActiveSubscriberId(Context context) {
final TelephonyManager tele = TelephonyManager.from(context);
final String actualSubscriberId = tele.getSubscriberId(SubscriptionManager.getDefaultDataSubscriptionId());
return actualSubscriberId;
}
use of android.telephony.TelephonyManager in project android_frameworks_base by ResurrectionRemix.
the class TwoGToggle method getScreenOffAction.
protected Runnable getScreenOffAction() {
return new Runnable() {
@Override
public void run() {
TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
Log.d(TAG, "2G = true");
tm.toggle2G(true);
}
};
}
use of android.telephony.TelephonyManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SimSettings method onCreate.
@Override
public void onCreate(final Bundle bundle) {
super.onCreate(bundle);
mContext = getActivity();
mSubscriptionManager = SubscriptionManager.from(getActivity());
final TelephonyManager tm = (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
mExtTelephony = IExtTelephony.Stub.asInterface(ServiceManager.getService("extphone"));
addPreferencesFromResource(R.xml.sim_settings);
mNoSims = (SwitchPreference) findPreference(SIM_EMPTY_SWITCH);
mNumSlots = tm.getSimCount();
mSimCards = (PreferenceCategory) findPreference(SIM_CARD_CATEGORY);
mMobileNetwork = (PreferenceCategory) findPreference(MOBILE_NETWORK_CATEGORY);
mAvailableSubInfos = new ArrayList<SubscriptionInfo>(mNumSlots);
mSelectableSubInfos = new ArrayList<SubscriptionInfo>();
SimSelectNotification.cancelNotification(getActivity());
IntentFilter intentFilter = new IntentFilter(ACTION_UICC_MANUAL_PROVISION_STATUS_CHANGED);
mContext.registerReceiver(mReceiver, intentFilter);
}
use of android.telephony.TelephonyManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SimSettings method onPause.
@Override
public void onPause() {
super.onPause();
mSubscriptionManager.removeOnSubscriptionsChangedListener(mOnSubscriptionsChangeListener);
final TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
for (int i = 0; i < mPhoneCount; i++) {
if (mPhoneStateListener[i] != null) {
tm.listen(mPhoneStateListener[i], PhoneStateListener.LISTEN_NONE);
mPhoneStateListener[i] = null;
}
}
for (int i = 0; i < mSimCards.getPreferenceCount(); ++i) {
Preference pref = mSimCards.getPreference(i);
if (pref instanceof SimEnablerPreference) {
// Calling cleanUp() here to dismiss/cleanup any pending dialog exists.
((SimEnablerPreference) pref).cleanUpPendingDialogs();
}
}
}
Aggregations