use of android.telecom.TelecomManager in project platform_frameworks_base by android.
the class PhoneWindowManager method interceptBackKeyUp.
// returns true if the key was handled and should not be passed to the user
private boolean interceptBackKeyUp(KeyEvent event) {
// Cache handled state
boolean handled = mBackKeyHandled;
if (hasPanicPressOnBackBehavior()) {
// Check for back key panic press
++mBackKeyPressCounter;
final long eventTime = event.getDownTime();
if (mBackKeyPressCounter <= PANIC_PRESS_BACK_COUNT) {
// This could be a multi-press. Wait a little bit longer to confirm.
Message msg = mHandler.obtainMessage(MSG_BACK_DELAYED_PRESS, mBackKeyPressCounter, 0, eventTime);
msg.setAsynchronous(true);
mHandler.sendMessageDelayed(msg, ViewConfiguration.getMultiPressTimeout());
}
}
// Reset back long press state
cancelPendingBackKeyAction();
if (mHasFeatureWatch) {
TelecomManager telecomManager = getTelecommService();
if (telecomManager != null) {
if (telecomManager.isRinging()) {
// Pressing back while there's a ringing incoming
// call should silence the ringer.
telecomManager.silenceRinger();
// It should not prevent navigating away
return false;
} else if ((mIncallBackBehavior & Settings.Secure.INCALL_BACK_BUTTON_BEHAVIOR_HANGUP) != 0 && telecomManager.isInCall()) {
// the Back button will hang up any current active call.
return telecomManager.endCall();
}
}
}
return handled;
}
use of android.telecom.TelecomManager in project android_frameworks_base by DirtyUnicorns.
the class TelecomLoaderService method registerDefaultAppProviders.
private void registerDefaultAppProviders() {
final PackageManagerInternal packageManagerInternal = LocalServices.getService(PackageManagerInternal.class);
// Set a callback for the package manager to query the default sms app.
packageManagerInternal.setSmsAppPackagesProvider(new PackageManagerInternal.PackagesProvider() {
@Override
public String[] getPackages(int userId) {
synchronized (mLock) {
if (mServiceConnection == null) {
if (mDefaultSmsAppRequests == null) {
mDefaultSmsAppRequests = new IntArray();
}
mDefaultSmsAppRequests.add(userId);
return null;
}
}
ComponentName smsComponent = SmsApplication.getDefaultSmsApplication(mContext, true);
if (smsComponent != null) {
return new String[] { smsComponent.getPackageName() };
}
return null;
}
});
// Set a callback for the package manager to query the default dialer app.
packageManagerInternal.setDialerAppPackagesProvider(new PackageManagerInternal.PackagesProvider() {
@Override
public String[] getPackages(int userId) {
synchronized (mLock) {
if (mServiceConnection == null) {
if (mDefaultDialerAppRequests == null) {
mDefaultDialerAppRequests = new IntArray();
}
mDefaultDialerAppRequests.add(userId);
return null;
}
}
String packageName = DefaultDialerManager.getDefaultDialerApplication(mContext);
if (packageName != null) {
return new String[] { packageName };
}
return null;
}
});
// Set a callback for the package manager to query the default sim call manager.
packageManagerInternal.setSimCallManagerPackagesProvider(new PackageManagerInternal.PackagesProvider() {
@Override
public String[] getPackages(int userId) {
synchronized (mLock) {
if (mServiceConnection == null) {
if (mDefaultSimCallManagerRequests == null) {
mDefaultSimCallManagerRequests = new IntArray();
}
mDefaultSimCallManagerRequests.add(userId);
return null;
}
}
TelecomManager telecomManager = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
PhoneAccountHandle phoneAccount = telecomManager.getSimCallManager(userId);
if (phoneAccount != null) {
return new String[] { phoneAccount.getComponentName().getPackageName() };
}
return null;
}
});
}
use of android.telecom.TelecomManager in project android_packages_apps_Settings by LineageOS.
the class SimDialogActivity method setUserSelectedOutgoingPhoneAccount.
private void setUserSelectedOutgoingPhoneAccount(PhoneAccountHandle phoneAccount) {
final TelecomManager telecomManager = TelecomManager.from(this);
telecomManager.setUserSelectedOutgoingPhoneAccount(phoneAccount);
}
use of android.telecom.TelecomManager in project android_packages_apps_Settings by LineageOS.
the class SimDialogActivity method createDialog.
public Dialog createDialog(final Context context, final int id) {
final ArrayList<String> list = new ArrayList<String>();
final SubscriptionManager subscriptionManager = SubscriptionManager.from(context);
final List<SubscriptionInfo> subInfoList = subscriptionManager.getActiveSubscriptionInfoList();
final int selectableSubInfoLength = subInfoList == null ? 0 : subInfoList.size();
final DialogInterface.OnClickListener selectionListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int value) {
final SubscriptionInfo sir;
switch(id) {
case DATA_PICK:
sir = subInfoList.get(value);
setDefaultDataSubId(context, sir.getSubscriptionId());
setUserPrefDataSubIdInDb(sir.getSubscriptionId());
break;
case CALLS_PICK:
final TelecomManager telecomManager = TelecomManager.from(context);
final List<PhoneAccountHandle> phoneAccountsList = telecomManager.getCallCapablePhoneAccounts();
setUserSelectedOutgoingPhoneAccount(value < 1 ? null : phoneAccountsList.get(value - 1));
break;
case SMS_PICK:
sir = subInfoList.get(value);
setDefaultSmsSubId(context, sir.getSubscriptionId());
break;
default:
throw new IllegalArgumentException("Invalid dialog type " + id + " in SIM dialog.");
}
finish();
}
};
Dialog.OnKeyListener keyListener = new Dialog.OnKeyListener() {
@Override
public boolean onKey(DialogInterface arg0, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
finish();
}
return true;
}
};
ArrayList<SubscriptionInfo> callsSubInfoList = new ArrayList<SubscriptionInfo>();
if (id == CALLS_PICK) {
final TelecomManager telecomManager = TelecomManager.from(context);
final TelephonyManager telephonyManager = TelephonyManager.from(context);
final Iterator<PhoneAccountHandle> phoneAccounts = telecomManager.getCallCapablePhoneAccounts().listIterator();
list.add(getResources().getString(R.string.sim_calls_ask_first_prefs_title));
callsSubInfoList.add(null);
while (phoneAccounts.hasNext()) {
final PhoneAccount phoneAccount = telecomManager.getPhoneAccount(phoneAccounts.next());
list.add((String) phoneAccount.getLabel());
int subId = telephonyManager.getSubIdForPhoneAccount(phoneAccount);
if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
final SubscriptionInfo sir = SubscriptionManager.from(context).getActiveSubscriptionInfo(subId);
callsSubInfoList.add(sir);
} else {
callsSubInfoList.add(null);
}
}
} else {
for (int i = 0; i < selectableSubInfoLength; ++i) {
final SubscriptionInfo sir = subInfoList.get(i);
CharSequence displayName = sir.getDisplayName();
if (displayName == null) {
displayName = "";
}
list.add(displayName.toString());
}
}
String[] arr = list.toArray(new String[0]);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
ListAdapter adapter = new SelectAccountListAdapter(id == CALLS_PICK ? callsSubInfoList : subInfoList, builder.getContext(), R.layout.select_account_list_item, arr, id);
switch(id) {
case DATA_PICK:
builder.setTitle(R.string.select_sim_for_data);
break;
case CALLS_PICK:
builder.setTitle(R.string.select_sim_for_calls);
break;
case SMS_PICK:
builder.setTitle(R.string.sim_card_select_title);
break;
default:
throw new IllegalArgumentException("Invalid dialog type " + id + " in SIM dialog.");
}
Dialog dialog = builder.setAdapter(adapter, selectionListener).create();
dialog.setOnKeyListener(keyListener);
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
finish();
}
});
return dialog;
}
use of android.telecom.TelecomManager in project android_packages_apps_Settings by LineageOS.
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