Search in sources :

Example 56 with TelephonyManager

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) {
        }
    }
}
Also used : TelephonyManager(android.telephony.TelephonyManager) JSONException(org.json.JSONException) InvocationTargetException(java.lang.reflect.InvocationTargetException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) FacebookException(com.facebook.FacebookException) IOException(java.io.IOException)

Example 57 with TelephonyManager

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();
}
Also used : TelephonyManager(android.telephony.TelephonyManager) ConnectivityManager(android.net.ConnectivityManager) SuppressLint(android.annotation.SuppressLint)

Example 58 with TelephonyManager

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();
}
Also used : TelephonyManager(android.telephony.TelephonyManager) ConnectivityManager(android.net.ConnectivityManager)

Example 59 with TelephonyManager

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
    }
}
Also used : ServiceState(android.telephony.ServiceState) TelephonyManager(android.telephony.TelephonyManager) RemoteException(android.os.RemoteException) LinkProperties(android.net.LinkProperties) LinkCapabilities(android.net.LinkCapabilities)

Example 60 with TelephonyManager

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;
}
Also used : TelephonyManager(android.telephony.TelephonyManager)

Aggregations

TelephonyManager (android.telephony.TelephonyManager)285 NetworkPolicyManager.uidRulesToString (android.net.NetworkPolicyManager.uidRulesToString)20 SubscriptionManager (android.telephony.SubscriptionManager)20 ConnectivityManager (android.net.ConnectivityManager)13 Test (org.junit.Test)13 Intent (android.content.Intent)11 NetworkIdentity (android.net.NetworkIdentity)11 Method (java.lang.reflect.Method)11 GsmCellLocation (android.telephony.gsm.GsmCellLocation)10 Context (android.content.Context)9 SubscriptionInfo (android.telephony.SubscriptionInfo)9 IntentFilter (android.content.IntentFilter)8 IOException (java.io.IOException)8 ServiceState (android.telephony.ServiceState)7 PackageManager (android.content.pm.PackageManager)6 NetworkPolicy (android.net.NetworkPolicy)6 DevicePolicyManagerInternal (android.app.admin.DevicePolicyManagerInternal)5 SharedPreferences (android.content.SharedPreferences)5 NetworkStats (android.net.NetworkStats)5 WifiManager (android.net.wifi.WifiManager)5