Search in sources :

Example 36 with TelephonyManager

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

Example 37 with TelephonyManager

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

Example 38 with TelephonyManager

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

Example 39 with TelephonyManager

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

Example 40 with TelephonyManager

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