Search in sources :

Example 21 with TelephonyManager

use of android.telephony.TelephonyManager in project android_frameworks_base by ResurrectionRemix.

the class OMADMAdapter method isSprint.

private static boolean isSprint(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String simOperator = tm.getSimOperator();
    String imsi = tm.getSubscriberId();
    /* Use MEID for sprint */
    if ("310120".equals(simOperator) || (imsi != null && imsi.startsWith("310120"))) {
        return true;
    } else {
        return false;
    }
}
Also used : TelephonyManager(android.telephony.TelephonyManager)

Example 22 with TelephonyManager

use of android.telephony.TelephonyManager in project android_frameworks_base by ResurrectionRemix.

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 23 with TelephonyManager

use of android.telephony.TelephonyManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SmsDefaultDialog method buildDialog.

private boolean buildDialog(String packageName) {
    TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    if (!tm.isSmsCapable()) {
        // No phone, no SMS
        return false;
    }
    final AlertController.AlertParams p = mAlertParams;
    p.mTitle = getString(R.string.sms_change_default_dialog_title);
    mNewSmsApplicationData = SmsApplication.getSmsApplicationData(packageName, this);
    if (mNewSmsApplicationData != null) {
        // New default SMS app specified, change to that directly after the confirmation
        // dialog.
        SmsApplicationData oldSmsApplicationData = null;
        ComponentName oldSmsComponent = SmsApplication.getDefaultSmsApplication(this, true);
        if (oldSmsComponent != null) {
            oldSmsApplicationData = SmsApplication.getSmsApplicationData(oldSmsComponent.getPackageName(), this);
            if (oldSmsApplicationData.mPackageName.equals(mNewSmsApplicationData.mPackageName)) {
                return false;
            }
        }
        // Compose dialog; get
        if (oldSmsApplicationData != null) {
            p.mMessage = getString(R.string.sms_change_default_dialog_text, mNewSmsApplicationData.getApplicationName(this), oldSmsApplicationData.getApplicationName(this));
        } else {
            p.mMessage = getString(R.string.sms_change_default_no_previous_dialog_text, mNewSmsApplicationData.getApplicationName(this));
        }
        p.mPositiveButtonText = getString(R.string.yes);
        p.mNegativeButtonText = getString(R.string.no);
        p.mPositiveButtonListener = this;
        p.mNegativeButtonListener = this;
    } else {
        // No new default SMS app specified, show a list of all SMS apps and let user to pick
        p.mAdapter = new AppListAdapter();
        p.mOnClickListener = this;
        p.mNegativeButtonText = getString(R.string.cancel);
        p.mNegativeButtonListener = this;
    }
    setupAlert();
    return true;
}
Also used : TelephonyManager(android.telephony.TelephonyManager) ComponentName(android.content.ComponentName) SmsApplicationData(com.android.internal.telephony.SmsApplication.SmsApplicationData) AlertController(com.android.internal.app.AlertController)

Example 24 with TelephonyManager

use of android.telephony.TelephonyManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class CellularDataCondition method onActionClick.

@Override
public void onActionClick(int index) {
    if (index == 0) {
        TelephonyManager telephony = mManager.getContext().getSystemService(TelephonyManager.class);
        telephony.setDataEnabled(true);
        setActive(false);
    } else {
        throw new IllegalArgumentException("Unexpected index " + index);
    }
}
Also used : TelephonyManager(android.telephony.TelephonyManager)

Example 25 with TelephonyManager

use of android.telephony.TelephonyManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class TelephonyUtils method isWorldMode.

private static boolean isWorldMode(Context context) {
    boolean worldModeOn = false;
    final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    Resources phoneResources = getPhoneResources(context);
    if (phoneResources != null) {
        int id = phoneResources.getIdentifier("config_world_mode", "string", "com.android.phone");
        if (id > 0) {
            final String configString = phoneResources.getString(id);
            if (!TextUtils.isEmpty(configString)) {
                String[] configArray = configString.split(";");
                // and SIM GID value is also set and matches to the current SIM GID.
                if (configArray != null && ((configArray.length == 1 && configArray[0].equalsIgnoreCase("true")) || (configArray.length == 2 && !TextUtils.isEmpty(configArray[1]) && tm != null && configArray[1].equalsIgnoreCase(tm.getGroupIdLevel1())))) {
                    worldModeOn = true;
                }
            }
        } else {
            Log.w(TAG, "couldn't find resource of config_world_mode");
        }
    }
    return worldModeOn;
}
Also used : TelephonyManager(android.telephony.TelephonyManager) Resources(android.content.res.Resources)

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