Search in sources :

Example 6 with TelephonyManager

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

Example 7 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 8 with TelephonyManager

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;
}
Also used : TelephonyManager(android.telephony.TelephonyManager) State(com.android.internal.telephony.IccCardConstants.State) ServiceState(android.telephony.ServiceState) Fingerprint(android.hardware.fingerprint.Fingerprint)

Example 9 with TelephonyManager

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

Example 10 with TelephonyManager

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

Aggregations

TelephonyManager (android.telephony.TelephonyManager)679 SubscriptionInfo (android.telephony.SubscriptionInfo)64 ConnectivityManager (android.net.ConnectivityManager)59 SubscriptionManager (android.telephony.SubscriptionManager)53 Context (android.content.Context)42 Method (java.lang.reflect.Method)40 Intent (android.content.Intent)34 IOException (java.io.IOException)30 SuppressLint (android.annotation.SuppressLint)29 ArrayList (java.util.ArrayList)26 PhoneAccountHandle (android.telecom.PhoneAccountHandle)24 NetworkTemplate (android.net.NetworkTemplate)22 NetworkPolicyManager.uidRulesToString (android.net.NetworkPolicyManager.uidRulesToString)20 PhoneAccount (android.telecom.PhoneAccount)19 Test (org.junit.Test)18 Preference (android.support.v7.preference.Preference)17 TelecomManager (android.telecom.TelecomManager)17 View (android.view.View)17 DialogInterface (android.content.DialogInterface)16 Resources (android.content.res.Resources)16