use of android.telephony.TelephonyManager in project android_frameworks_base by ParanoidAndroid.
the class MobileDataStateTracker method getTcpBufferSizesPropName.
/**
* Return the system properties name associated with the tcp buffer sizes
* for this network.
*/
public String getTcpBufferSizesPropName() {
String networkTypeStr = "unknown";
TelephonyManager tm = new TelephonyManager(mContext);
//TODO We have to edit the parameter for getNetworkType regarding CDMA
switch(tm.getNetworkType()) {
case TelephonyManager.NETWORK_TYPE_GPRS:
networkTypeStr = "gprs";
break;
case TelephonyManager.NETWORK_TYPE_EDGE:
networkTypeStr = "edge";
break;
case TelephonyManager.NETWORK_TYPE_UMTS:
networkTypeStr = "umts";
break;
case TelephonyManager.NETWORK_TYPE_HSDPA:
networkTypeStr = "hsdpa";
break;
case TelephonyManager.NETWORK_TYPE_HSUPA:
networkTypeStr = "hsupa";
break;
case TelephonyManager.NETWORK_TYPE_HSPA:
networkTypeStr = "hspa";
break;
case TelephonyManager.NETWORK_TYPE_HSPAP:
networkTypeStr = "hspap";
break;
case TelephonyManager.NETWORK_TYPE_DCHSPAP:
networkTypeStr = "hspap";
break;
case TelephonyManager.NETWORK_TYPE_CDMA:
networkTypeStr = "cdma";
break;
case TelephonyManager.NETWORK_TYPE_1xRTT:
networkTypeStr = "1xrtt";
break;
case TelephonyManager.NETWORK_TYPE_EVDO_0:
networkTypeStr = "evdo";
break;
case TelephonyManager.NETWORK_TYPE_EVDO_A:
networkTypeStr = "evdo";
break;
case TelephonyManager.NETWORK_TYPE_EVDO_B:
networkTypeStr = "evdo";
break;
case TelephonyManager.NETWORK_TYPE_IDEN:
networkTypeStr = "iden";
break;
case TelephonyManager.NETWORK_TYPE_LTE:
networkTypeStr = "lte";
break;
case TelephonyManager.NETWORK_TYPE_EHRPD:
networkTypeStr = "ehrpd";
break;
default:
loge("unknown network type: " + tm.getNetworkType());
}
return "net.tcp.buffersize." + networkTypeStr;
}
use of android.telephony.TelephonyManager in project XobotOS by xamarin.
the class DefaultPhoneNotifier method doNotifyDataConnection.
private void doNotifyDataConnection(Phone sender, String reason, String apnType, Phone.DataState state) {
// TODO
// use apnType as the key to which connection we're talking about.
// pass apnType back up to fetch particular for this one.
TelephonyManager telephony = TelephonyManager.getDefault();
LinkProperties linkProperties = null;
LinkCapabilities linkCapabilities = null;
boolean roaming = false;
if (state == Phone.DataState.CONNECTED) {
linkProperties = sender.getLinkProperties(apnType);
linkCapabilities = sender.getLinkCapabilities(apnType);
}
ServiceState ss = sender.getServiceState();
if (ss != null)
roaming = ss.getRoaming();
try {
mRegistry.notifyDataConnection(convertDataState(state), sender.isDataConnectivityPossible(apnType), reason, sender.getActiveApnHost(apnType), apnType, linkProperties, linkCapabilities, ((telephony != null) ? telephony.getNetworkType() : TelephonyManager.NETWORK_TYPE_UNKNOWN), roaming);
} catch (RemoteException ex) {
// system process is dead
}
}
use of android.telephony.TelephonyManager in project android_frameworks_base by ResurrectionRemix.
the class KeyguardUpdateMonitor method refreshSimState.
/**
* @return true if and only if the state has changed for the specified {@code slotId}
*/
private boolean refreshSimState(int subId, int slotId) {
// This is awful. It exists because there are two APIs for getting the SIM status
// that don't return the complete set of values and have different types. In Keyguard we
// need IccCardConstants, but TelephonyManager would only give us
// TelephonyManager.SIM_STATE*, so we retrieve it manually.
final TelephonyManager tele = TelephonyManager.from(mContext);
int simState = tele.getSimState(slotId);
State state;
try {
state = State.intToState(simState);
} catch (IllegalArgumentException ex) {
Log.w(TAG, "Unknown sim state: " + simState);
state = State.UNKNOWN;
}
SimData data = mSimDatas.get(subId);
final boolean changed;
if (data == null) {
data = new SimData(state, slotId, subId);
mSimDatas.put(subId, data);
// no data yet; force update
changed = true;
} else {
changed = data.simState != state;
data.simState = state;
}
return changed;
}
use of android.telephony.TelephonyManager in project android_frameworks_base by ResurrectionRemix.
the class UsageStatsService method fetchCarrierPrivilegedAppsLocked.
private void fetchCarrierPrivilegedAppsLocked() {
TelephonyManager telephonyManager = getContext().getSystemService(TelephonyManager.class);
mCarrierPrivilegedApps = telephonyManager.getPackagesWithCarrierPrivileges();
mHaveCarrierPrivilegedApps = true;
if (DEBUG) {
Slog.d(TAG, "apps with carrier privilege " + mCarrierPrivilegedApps);
}
}
use of android.telephony.TelephonyManager in project android_frameworks_base by ResurrectionRemix.
the class DeviceInfoUtils method getFormattedPhoneNumbers.
public static String getFormattedPhoneNumbers(Context context, List<SubscriptionInfo> subscriptionInfo) {
StringBuilder sb = new StringBuilder();
if (subscriptionInfo != null) {
final TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(TELEPHONY_SERVICE);
final int count = subscriptionInfo.size();
for (int i = 0; i < count; i++) {
final String rawNumber = telephonyManager.getLine1Number(subscriptionInfo.get(i).getSubscriptionId());
if (!TextUtils.isEmpty(rawNumber)) {
sb.append(PhoneNumberUtils.formatNumber(rawNumber));
if (i < count - 1) {
sb.append("\n");
}
}
}
}
return sb.toString();
}
Aggregations