本文整理汇总了Java中android.telecom.TelecomManager类的典型用法代码示例。如果您正苦于以下问题:Java TelecomManager类的具体用法?Java TelecomManager怎么用?Java TelecomManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TelecomManager类属于android.telecom包,在下文中一共展示了TelecomManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDefaultVoiceSubscriptionSimSlot
import android.telecom.TelecomManager; //导入依赖的package包/类
private int getDefaultVoiceSubscriptionSimSlot() {
try {
final TelecomManager telecomManager =
(TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
final TelephonyManager telephonyManager =
(TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
PhoneAccountHandle pah = (PhoneAccountHandle) XposedHelpers.callMethod(telecomManager,
"getUserSelectedOutgoingPhoneAccount");
if (pah != null) {
PhoneAccount pa = telecomManager.getPhoneAccount(pah);
int subId = getSubIdForPhoneAccount(telephonyManager, pa);
SubscriptionInfo si = mSubMgr.getActiveSubscriptionInfo(subId);
if (si != null) {
return si.getSimSlotIndex();
}
}
return -1;
} catch (Throwable t) {
XposedBridge.log(t);
return -1;
}
}
示例2: onHandleIntent
import android.telecom.TelecomManager; //导入依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
log.d("onHandleIntent");
//SubscriptionManager 该类主要包含了所有sim卡的信息
SubscriptionManager mSubscriptionManager = SubscriptionManager.from(this);
int simcnt = mSubscriptionManager.getActiveSubscriptionInfoCount();
List<SubscriptionInfo> lstSim = mSubscriptionManager.getActiveSubscriptionInfoList();
for (int i = 0; i < lstSim.size(); i++) {
SubscriptionInfo si = lstSim.get(i);
if (si != null)
log.d(si.toString());
}
TelecomManager telecomManager = (TelecomManager) getSystemService(Context.TELECOM_SERVICE);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) {
List<PhoneAccountHandle> lstPA=telecomManager.getCallCapablePhoneAccounts();
int accoutSum =lstPA.size();
for(int i=0;i<accoutSum;i++)
log.d("accountSum: " + accoutSum +lstPA.get(i) );
}
}
示例3: initialize
import android.telecom.TelecomManager; //导入依赖的package包/类
@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
cordovaInterface = cordova;
super.initialize(cordova, webView);
appName = getApplicationName(this.cordova.getActivity().getApplicationContext());
handle = new PhoneAccountHandle(new ComponentName(this.cordova.getActivity().getApplicationContext(),MyConnectionService.class),appName);
tm = (TelecomManager)this.cordova.getActivity().getApplicationContext().getSystemService(this.cordova.getActivity().getApplicationContext().TELECOM_SERVICE);
phoneAccount = new PhoneAccount.Builder(handle, appName)
.setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER)
.build();
callbackContextMap.put("answer",new ArrayList<CallbackContext>());
callbackContextMap.put("reject",new ArrayList<CallbackContext>());
callbackContextMap.put("hangup",new ArrayList<CallbackContext>());
callbackContextMap.put("sendCall",new ArrayList<CallbackContext>());
callbackContextMap.put("receiveCall",new ArrayList<CallbackContext>());
}
示例4: receiveCall
import android.telecom.TelecomManager; //导入依赖的package包/类
private void receiveCall() {
if(permissionCounter >= 1) {
try {
Bundle callInfo = new Bundle();
callInfo.putString("from",from);
tm.addNewIncomingCall(handle, callInfo);
permissionCounter = 0;
this.callbackContext.success("Incoming call successful");
} catch(Exception e) {
if(permissionCounter == 2) {
tm.registerPhoneAccount(phoneAccount);
Intent phoneIntent = new Intent(TelecomManager.ACTION_CHANGE_PHONE_ACCOUNTS);
this.cordova.getActivity().getApplicationContext().startActivity(phoneIntent);
} else {
this.callbackContext.error("You need to accept phone account permissions in order to receive calls");
}
}
}
permissionCounter--;
}
示例5: onCreateIncomingConnection
import android.telecom.TelecomManager; //导入依赖的package包/类
@Override
public Connection onCreateIncomingConnection(PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request) {
Log.d(TAG, "onCreateIncomingConnection: called.");
if (request.getExtras() == null) {
return Connection.createFailedConnection(new DisconnectCause(DisconnectCause.ERROR, "No extras on request."));
}
Intent sipIntent = request.getExtras().getParcelable(EXTRA_INCOMING_CALL_INTENT);
if (sipIntent == null) {
return Connection.createFailedConnection(new DisconnectCause(DisconnectCause.ERROR, "No SIP intent."));
}
try {
SipAudioCall audioCall = PhonySipUtil.getSipManager(this).takeAudioCall(sipIntent, null);
PhonyConnection connection = new PhonyConnection(audioCall);
connection.setAddress(Uri.parse(audioCall.getPeerProfile().getUriString()), TelecomManager.PRESENTATION_ALLOWED);
connection.setInitialized();
return connection;
} catch (SipException e) {
e.printStackTrace();
return Connection.createFailedConnection(new DisconnectCause(DisconnectCause.ERROR, "SipExecption", "Check the stack trace for more information.", e.getLocalizedMessage()));
}
}
示例6: onCreateOutgoingConnection
import android.telecom.TelecomManager; //导入依赖的package包/类
@Override
public Connection onCreateOutgoingConnection(PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request) {
Log.d(TAG, "onCreateOutgoingConnection: called.");
try {
SipAudioCall audioCall = PhonySipUtil.getSipManager(this).makeAudioCall(connectionManagerPhoneAccount.getId(), Uri.decode(request.getAddress().toString()), null, PhonySipUtil.EXPIRY_TIME);
PhonyConnection connection = new PhonyConnection(audioCall);
connection.setAddress(request.getAddress(), TelecomManager.PRESENTATION_ALLOWED);
connection.setInitialized();
return connection;
} catch (SipException e) {
e.printStackTrace();
return Connection.createFailedConnection(new DisconnectCause(DisconnectCause.ERROR, "SipExecption", "Check the stack trace for more information.", e.getLocalizedMessage()));
}
}
示例7: registerNewPhoneAccount
import android.telecom.TelecomManager; //导入依赖的package包/类
/**
* Create a new {@link PhoneAccount} and register it with the system.
*
* @param context The context to use for finding the services and resources.
* @param accountName The name of the account to add - must be an international phonenumber.
*/
public static void registerNewPhoneAccount(Context context, String accountName) {
PhoneAccountHandle accountHandle = createPhoneAccountHandle(context, accountName);
PhoneAccount phone = PhoneAccount.builder(accountHandle, context.getResources().getString(R.string.app_name))
.setIcon(Icon.createWithResource(context, R.mipmap.ic_launcher_round))
.setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER)
.addSupportedUriScheme(PhoneAccount.SCHEME_SIP)
.setAddress(Uri.parse("sip:" + accountName))
.build();
TelecomManager telecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
telecomManager.registerPhoneAccount(phone);
// Let the user enable our phone account
// TODO Show toast so the user knows what is happening
context.startActivity(new Intent(TelecomManager.ACTION_CHANGE_PHONE_ACCOUNTS));
}
示例8: getSubItemList
import android.telecom.TelecomManager; //导入依赖的package包/类
private List<IIconListAdapterItem> getSubItemList(final SubType subType) {
List<IIconListAdapterItem> list = new ArrayList<>();
if (subType == SubType.VOICE) {
list.add(new SubListItem(null));
final TelecomManager telecomManager =
(TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
final TelephonyManager telephonyManager =
(TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
final Iterator<PhoneAccountHandle> phoneAccounts =
telecomManager.getCallCapablePhoneAccounts().listIterator();
while (phoneAccounts.hasNext()) {
final PhoneAccount phoneAccount =
telecomManager.getPhoneAccount(phoneAccounts.next());
int subId = getSubIdForPhoneAccount(telephonyManager, phoneAccount);
if (subId != -1) {
list.add(new SubListItem(mSubMgr.getActiveSubscriptionInfo(subId)));
}
}
} else {
for (SubscriptionInfo si : mSubMgr.getActiveSubscriptionInfoList())
if (si != null)
list.add(new SubListItem(si));
}
return list;
}
示例9: subscriptionToPhoneAccountHandle
import android.telecom.TelecomManager; //导入依赖的package包/类
private PhoneAccountHandle subscriptionToPhoneAccountHandle(final SubscriptionInfo subInfo) {
if (subInfo == null)
return null;
final TelecomManager telecomManager =
(TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
final TelephonyManager telephonyManager =
(TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
final Iterator<PhoneAccountHandle> phoneAccounts =
telecomManager.getCallCapablePhoneAccounts().listIterator();
while (phoneAccounts.hasNext()) {
final PhoneAccountHandle phoneAccountHandle = phoneAccounts.next();
final PhoneAccount phoneAccount = telecomManager.getPhoneAccount(phoneAccountHandle);
if (subInfo.getSubscriptionId() == getSubIdForPhoneAccount(telephonyManager, phoneAccount)) {
return phoneAccountHandle;
}
}
return null;
}
示例10: getSimColor
import android.telecom.TelecomManager; //导入依赖的package包/类
public static int getSimColor(Context context, int id) {
int highlightColor = 0;
TelecomManager telecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
if (telecomManager != null) {
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return -1;
}
List<PhoneAccountHandle> phoneAccountHandleList = telecomManager.getCallCapablePhoneAccounts();
PhoneAccount phoneAccount = telecomManager.getPhoneAccount(phoneAccountHandleList.get(id));
if (phoneAccount != null) {
highlightColor = phoneAccount.getHighlightColor();
}
}
return highlightColor;
}
示例11: onReceive
import android.telecom.TelecomManager; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "onReceive: called.");
PhoneAccountHandle phoneAccount = PhonyUtil.createPhoneAccountHandle(context, intent.getStringExtra(PhonyConnectionService.EXTRA_PHONE_ACCOUNT));
Bundle bundle = new Bundle();
bundle.putParcelable(PhonyConnectionService.EXTRA_INCOMING_CALL_INTENT, intent);
TelecomManager telecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
telecomManager.addNewIncomingCall(phoneAccount, bundle);
}
示例12: silenceRinger
import android.telecom.TelecomManager; //导入依赖的package包/类
private void silenceRinger() {
try {
TelecomManager tm = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
tm.silenceRinger();
} catch(Throwable t) {
XposedBridge.log(t);
}
}
示例13: setDefaultVoiceSubscription
import android.telecom.TelecomManager; //导入依赖的package包/类
private boolean setDefaultVoiceSubscription(final SubscriptionInfo subInfo) {
try {
final TelecomManager telecomManager =
(TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
XposedHelpers.callMethod(telecomManager,
"setUserSelectedOutgoingPhoneAccount",
subscriptionToPhoneAccountHandle(subInfo));
return true;
} catch (Throwable t) {
XposedBridge.log(t);
return false;
}
}
示例14: getDefaultDialerPackageName
import android.telecom.TelecomManager; //导入依赖的package包/类
public static String getDefaultDialerPackageName(Context ctx) {
if (mDefaultDialerPkgName == null) {
try {
TelecomManager tm = (TelecomManager) ctx.getSystemService(Context.TELECOM_SERVICE);
mDefaultDialerPkgName = tm.getDefaultDialerPackage();
} catch (Throwable t) {
t.printStackTrace();
}
}
return mDefaultDialerPkgName;
}
示例15: answerNativelyOreo
import android.telecom.TelecomManager; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.O)
private void answerNativelyOreo() {
TelecomManager telecomManager
= (TelecomManager) getCallModule().getService().getSystemService(Context.TELECOM_SERVICE);
Timber.d("Answering natively with Oreo.");
try {
telecomManager.acceptRingingCall();
} catch (SecurityException e) {
Timber.e("No accept call permission!");
}
}