use of android.telephony.TelephonyManager in project android_frameworks_base by DirtyUnicorns.
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 DirtyUnicorns.
the class DataConnectionStats method startMonitoring.
public void startMonitoring() {
TelephonyManager phone = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
phone.listen(mPhoneStateListener, PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE | PhoneStateListener.LISTEN_DATA_ACTIVITY);
IntentFilter filter = new IntentFilter();
filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
filter.addAction(ConnectivityManager.INET_CONDITION_ACTION);
mContext.registerReceiver(this, filter);
}
use of android.telephony.TelephonyManager in project android_frameworks_base by DirtyUnicorns.
the class Tethering method checkDunRequired.
private void checkDunRequired() {
int secureSetting = 2;
TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
if (tm != null) {
secureSetting = tm.getTetherApnRequired();
}
// Allow override of TETHER_DUN_REQUIRED via prop
int prop = SystemProperties.getInt("persist.sys.dun.override", -1);
secureSetting = ((prop < 3) && (prop >= 0)) ? prop : secureSetting;
synchronized (mPublicSync) {
// 2 = not set, 0 = DUN not required, 1 = DUN required
if (secureSetting != 2) {
int requiredApn = (secureSetting == 1 ? ConnectivityManager.TYPE_MOBILE_DUN : ConnectivityManager.TYPE_MOBILE_HIPRI);
if (requiredApn == ConnectivityManager.TYPE_MOBILE_DUN) {
while (mUpstreamIfaceTypes.contains(MOBILE_TYPE)) {
mUpstreamIfaceTypes.remove(MOBILE_TYPE);
}
while (mUpstreamIfaceTypes.contains(HIPRI_TYPE)) {
mUpstreamIfaceTypes.remove(HIPRI_TYPE);
}
if (mUpstreamIfaceTypes.contains(DUN_TYPE) == false) {
mUpstreamIfaceTypes.add(DUN_TYPE);
}
} else {
while (mUpstreamIfaceTypes.contains(DUN_TYPE)) {
mUpstreamIfaceTypes.remove(DUN_TYPE);
}
if (mUpstreamIfaceTypes.contains(MOBILE_TYPE) == false) {
mUpstreamIfaceTypes.add(MOBILE_TYPE);
}
if (mUpstreamIfaceTypes.contains(HIPRI_TYPE) == false) {
mUpstreamIfaceTypes.add(HIPRI_TYPE);
}
}
}
if (mUpstreamIfaceTypes.contains(DUN_TYPE)) {
mPreferredUpstreamMobileApn = ConnectivityManager.TYPE_MOBILE_DUN;
} else {
mPreferredUpstreamMobileApn = ConnectivityManager.TYPE_MOBILE_HIPRI;
}
}
}
use of android.telephony.TelephonyManager in project android_frameworks_base by DirtyUnicorns.
the class GnssLocationProvider method requestSetID.
/**
* Called from native code to request set id info.
* We should be careful about receiving null string from the TelephonyManager,
* because sending null String to JNI function would cause a crash.
*/
private void requestSetID(int flags) {
TelephonyManager phone = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
int type = AGPS_SETID_TYPE_NONE;
String data = "";
if ((flags & AGPS_RIL_REQUEST_SETID_IMSI) == AGPS_RIL_REQUEST_SETID_IMSI) {
String data_temp = phone.getSubscriberId();
if (data_temp == null) {
// This means the framework does not have the SIM card ready.
} else {
// This means the framework has the SIM card.
data = data_temp;
type = AGPS_SETID_TYPE_IMSI;
}
} else if ((flags & AGPS_RIL_REQUEST_SETID_MSISDN) == AGPS_RIL_REQUEST_SETID_MSISDN) {
String data_temp = phone.getLine1Number();
if (data_temp == null) {
// This means the framework does not have the SIM card ready.
} else {
// This means the framework has the SIM card.
data = data_temp;
type = AGPS_SETID_TYPE_MSISDN;
}
}
native_agps_set_id(type, data);
}
use of android.telephony.TelephonyManager in project android_frameworks_base by DirtyUnicorns.
the class PowerManagerService method runWithProximityCheck.
private void runWithProximityCheck(final Runnable r) {
if (mHandler.hasMessages(MSG_WAKE_UP)) {
// A message is already queued
return;
}
final TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
final boolean hasIncomingCall = tm.getCallState() == TelephonyManager.CALL_STATE_RINGING;
if (mProximityWakeSupported && mProximityWakeEnabled && mProximitySensor != null && !hasIncomingCall) {
final Message msg = mHandler.obtainMessage(MSG_WAKE_UP);
msg.obj = r;
mHandler.sendMessageDelayed(msg, mProximityTimeOut);
runPostProximityCheck(r);
} else {
r.run();
}
}
Aggregations