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);
}
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;
}
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);
}
}
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) {
}
});
}
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;
}
Aggregations