Search in sources :

Example 81 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 82 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 83 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 84 with TelephonyManager

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

the class SimPreferenceDialog method createEditDialog.

private void createEditDialog(Bundle bundle) {
    final Resources res = mContext.getResources();
    EditText nameText = (EditText) mDialogLayout.findViewById(R.id.sim_name);
    nameText.setText(mSubInfoRecord.getDisplayName());
    final Spinner tintSpinner = (Spinner) mDialogLayout.findViewById(R.id.spinner);
    SelectColorAdapter adapter = new SelectColorAdapter(mContext, R.layout.settings_color_picker_item, mColorStrings);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    tintSpinner.setAdapter(adapter);
    for (int i = 0; i < mTintArr.length; i++) {
        if (mTintArr[i] == mSubInfoRecord.getIconTint()) {
            tintSpinner.setSelection(i);
            mTintSelectorPos = i;
            break;
        }
    }
    tintSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
            tintSpinner.setSelection(pos);
            mTintSelectorPos = pos;
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    final TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
    TextView numberView = (TextView) mDialogLayout.findViewById(R.id.number);
    final String rawNumber = tm.getLine1Number(mSubInfoRecord.getSubscriptionId());
    if (TextUtils.isEmpty(rawNumber)) {
        numberView.setText(res.getString(com.android.internal.R.string.unknownName));
    } else {
        numberView.setText(PhoneNumberUtils.formatNumber(rawNumber));
    }
    String simCarrierName = tm.getSimOperatorName(mSubInfoRecord.getSubscriptionId());
    TextView carrierView = (TextView) mDialogLayout.findViewById(R.id.carrier);
    carrierView.setText(!TextUtils.isEmpty(simCarrierName) ? simCarrierName : mContext.getString(com.android.internal.R.string.unknownName));
    mBuilder.setTitle(String.format(res.getString(R.string.sim_editor_title), (mSubInfoRecord.getSimSlotIndex() + 1)));
    mBuilder.setPositiveButton(R.string.okay, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int whichButton) {
            final EditText nameText = (EditText) mDialogLayout.findViewById(R.id.sim_name);
            String displayName = nameText.getText().toString();
            int subId = mSubInfoRecord.getSubscriptionId();
            mSubInfoRecord.setDisplayName(displayName);
            mSubscriptionManager.setDisplayName(displayName, subId, SubscriptionManager.NAME_SOURCE_USER_INPUT);
            final int tintSelected = tintSpinner.getSelectedItemPosition();
            int subscriptionId = mSubInfoRecord.getSubscriptionId();
            int tint = mTintArr[tintSelected];
            mSubInfoRecord.setIconTint(tint);
            mSubscriptionManager.setIconTint(tint, subscriptionId);
            dialog.dismiss();
        }
    });
    mBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.dismiss();
        }
    });
    mBuilder.setOnDismissListener(new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            finish();
        }
    });
    AlertDialog dialog = mBuilder.show();
    final Button button = dialog.getButton(AlertDialog.BUTTON1);
    if (TextUtils.isEmpty(mSubInfoRecord.getDisplayName()) || TextUtils.getTrimmedLength(mSubInfoRecord.getDisplayName()) == 0) {
        button.setEnabled(false);
    }
    nameText.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            button.setEnabled(TextUtils.getTrimmedLength(s) > 0);
        }

        @Override
        public void afterTextChanged(Editable s) {
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }
    });
}
Also used : EditText(android.widget.EditText) AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Spinner(android.widget.Spinner) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) Paint(android.graphics.Paint) TelephonyManager(android.telephony.TelephonyManager) Button(android.widget.Button) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) Resources(android.content.res.Resources)

Example 85 with TelephonyManager

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

the class SimDialogActivity method subscriptionIdToPhoneAccountHandle.

private PhoneAccountHandle subscriptionIdToPhoneAccountHandle(final int subId) {
    final TelecomManager telecomManager = TelecomManager.from(this);
    final TelephonyManager telephonyManager = TelephonyManager.from(this);
    final Iterator<PhoneAccountHandle> phoneAccounts = telecomManager.getCallCapablePhoneAccounts().listIterator();
    while (phoneAccounts.hasNext()) {
        final PhoneAccountHandle phoneAccountHandle = phoneAccounts.next();
        final PhoneAccount phoneAccount = telecomManager.getPhoneAccount(phoneAccountHandle);
        if (subId == telephonyManager.getSubIdForPhoneAccount(phoneAccount)) {
            return phoneAccountHandle;
        }
    }
    return null;
}
Also used : PhoneAccount(android.telecom.PhoneAccount) PhoneAccountHandle(android.telecom.PhoneAccountHandle) TelephonyManager(android.telephony.TelephonyManager) TelecomManager(android.telecom.TelecomManager)

Aggregations

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