use of android.telephony.TelephonyManager in project facebook-android-sdk by facebook.
the class Utility method refreshCarrierName.
/**
* Get and cache the carrier name since this won't change during the lifetime of the app.
* @return The carrier name
*/
private static void refreshCarrierName(Context appContext) {
if (carrierName.equals(noCarrierConstant)) {
try {
TelephonyManager telephonyManager = ((TelephonyManager) appContext.getSystemService(Context.TELEPHONY_SERVICE));
carrierName = telephonyManager.getNetworkOperatorName();
} catch (Exception e) {
}
}
}
use of android.telephony.TelephonyManager in project VitamioBundle by yixia.
the class Device method getIdentifiers.
@SuppressLint("NewApi")
public static String getIdentifiers(Context ctx) {
StringBuilder sb = new StringBuilder();
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO)
sb.append(getPair("serial", Build.SERIAL));
else
sb.append(getPair("serial", "No Serial"));
sb.append(getPair("android_id", Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.ANDROID_ID)));
TelephonyManager tel = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
sb.append(getPair("sim_country_iso", tel.getSimCountryIso()));
sb.append(getPair("network_operator_name", tel.getNetworkOperatorName()));
sb.append(getPair("unique_id", Crypto.md5(sb.toString())));
ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
sb.append(getPair("network_type", cm.getActiveNetworkInfo() == null ? "-1" : String.valueOf(cm.getActiveNetworkInfo().getType())));
return sb.toString();
}
use of android.telephony.TelephonyManager in project ZI by yixia.
the class Device method getIdentifiers.
public static String getIdentifiers(Context ctx) {
StringBuilder sb = new StringBuilder();
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO)
sb.append(getPair("serial", Build.SERIAL));
else
sb.append(getPair("serial", "No Serial"));
sb.append(getPair("android_id", Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.ANDROID_ID)));
TelephonyManager tel = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
sb.append(getPair("sim_country_iso", tel.getSimCountryIso()));
sb.append(getPair("network_operator_name", tel.getNetworkOperatorName()));
sb.append(getPair("unique_id", Crypto.md5(sb.toString())));
ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
sb.append(getPair("network_type", cm.getActiveNetworkInfo() == null ? "-1" : String.valueOf(cm.getActiveNetworkInfo().getType())));
return sb.toString();
}
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 XobotOS by xamarin.
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_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;
}
Aggregations