Java Code Examples for android.telecom.TelecomManager

The following examples show how to use android.telecom.TelecomManager. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: android_9.0.0_r45   Source File: LockTaskController.java    License: Apache License 2.0 6 votes vote down vote up
private boolean isEmergencyCallTask(TaskRecord task) {
    final Intent intent = task.intent;
    if (intent == null) {
        return false;
    }

    // 1. The emergency keypad activity launched on top of the keyguard
    if (EMERGENCY_DIALER_COMPONENT.equals(intent.getComponent())) {
        return true;
    }

    // 2. The intent sent by the keypad, which is handled by Telephony
    if (ACTION_CALL_EMERGENCY.equals(intent.getAction())) {
        return true;
    }

    // 3. Telephony then starts the default package for making the call
    final TelecomManager tm = getTelecomManager();
    final String dialerPackage = tm != null ? tm.getSystemDialerPackage() : null;
    if (dialerPackage != null && dialerPackage.equals(intent.getComponent().getPackageName())) {
        return true;
    }

    return false;
}
 
Example 2
Source Project: TelePlus-Android   Source File: VoIPService.java    License: GNU General Public License v2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.O)
@Override
public CallConnection getConnectionAndStartCall(){
	if(systemCallConnection==null){
		if(BuildVars.LOGS_ENABLED)
			FileLog.d("creating call connection");
		systemCallConnection=new CallConnection();
		systemCallConnection.setInitializing();
		if(isOutgoing){
			delayedStartOutgoingCall=new Runnable(){
				@Override
				public void run(){
					delayedStartOutgoingCall=null;
					startOutgoingCall();
				}
			};
			AndroidUtilities.runOnUIThread(delayedStartOutgoingCall, 2000);
		}
		systemCallConnection.setCallerDisplayName(ContactsController.formatName(user.first_name, user.last_name), TelecomManager.PRESENTATION_ALLOWED);
	}
	return systemCallConnection;
}
 
Example 3
Source Project: BaldPhone   Source File: DialerActivity.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressLint("NewApi")
public static void call(final CharSequence number, final Context context, SubscriptionInfo subscriptionInfo) {
    try {
        if (subscriptionInfo == null) {
            context.startActivity(new Intent(Intent.ACTION_CALL).setData(Uri.parse(("tel:" + number).replace("#", Uri.encode("#")))));
        } else {
            final TelecomManager telecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
            final List<PhoneAccountHandle> list = telecomManager.getCallCapablePhoneAccounts();
            for (final PhoneAccountHandle phoneAccountHandle : list) {
                if (phoneAccountHandle.getId().contains(subscriptionInfo.getIccId())) {
                    context.startActivity(new Intent(Intent.ACTION_CALL).setData(Uri.parse(("tel:" + number).replace("#", Uri.encode("#"))))
                            .putExtra("android.telecom.extra.PHONE_ACCOUNT_HANDLE", (Parcelable) phoneAccountHandle));
                    return;
                }
            }
            BaldToast.error(context);

        }
    } catch (SecurityException e) {
        Log.e(TAG, e.getMessage());
        e.printStackTrace();
        throw new RuntimeException(e);
    }

}
 
Example 4
Source Project: react-native-callkeep   Source File: RNCallKeepModule.java    License: ISC License 6 votes vote down vote up
@ReactMethod
public void displayIncomingCall(String uuid, String number, String callerName) {
    if (!isConnectionServiceAvailable() || !hasPhoneAccount()) {
        return;
    }

    Log.d(TAG, "displayIncomingCall number: " + number + ", callerName: " + callerName);

    Bundle extras = new Bundle();
    Uri uri = Uri.fromParts(PhoneAccount.SCHEME_TEL, number, null);

    extras.putParcelable(TelecomManager.EXTRA_INCOMING_CALL_ADDRESS, uri);
    extras.putString(EXTRA_CALLER_NAME, callerName);
    extras.putString(EXTRA_CALL_UUID, uuid);

    telecomManager.addNewIncomingCall(handle, extras);
}
 
Example 5
Source Project: react-native-callkeep   Source File: RNCallKeepModule.java    License: ISC License 6 votes vote down vote up
@ReactMethod
public void startCall(String uuid, String number, String callerName) {
    if (!isConnectionServiceAvailable() || !hasPhoneAccount() || !hasPermissions() || number == null) {
        return;
    }

    Log.d(TAG, "startCall number: " + number + ", callerName: " + callerName);

    Bundle extras = new Bundle();
    Uri uri = Uri.fromParts(PhoneAccount.SCHEME_TEL, number, null);

    Bundle callExtras = new Bundle();
    callExtras.putString(EXTRA_CALLER_NAME, callerName);
    callExtras.putString(EXTRA_CALL_UUID, uuid);
    callExtras.putString(EXTRA_CALL_NUMBER, number);

    extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, handle);
    extras.putParcelable(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS, callExtras);

    telecomManager.placeCall(uri, extras);
}
 
Example 6
Source Project: react-native-callkeep   Source File: RNCallKeepModule.java    License: ISC License 6 votes vote down vote up
private void registerPhoneAccount(Context appContext) {
    if (!isConnectionServiceAvailable()) {
        return;
    }

    ComponentName cName = new ComponentName(this.getAppContext(), VoiceConnectionService.class);
    String appName = this.getApplicationName(appContext);

    handle = new PhoneAccountHandle(cName, appName);

    PhoneAccount.Builder builder = new PhoneAccount.Builder(handle, appName)
            .setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER);

    if (_settings != null && _settings.hasKey("imageName")) {
        int identifier = appContext.getResources().getIdentifier(_settings.getString("imageName"), "drawable", appContext.getPackageName());
        Icon icon = Icon.createWithResource(appContext, identifier);
        builder.setIcon(icon);
    }

    PhoneAccount account = builder.build();

    telephonyManager = (TelephonyManager) this.getAppContext().getSystemService(Context.TELEPHONY_SERVICE);
    telecomManager = (TelecomManager) this.getAppContext().getSystemService(Context.TELECOM_SERVICE);

    telecomManager.registerPhoneAccount(account);
}
 
Example 7
Source Project: call_manage   Source File: Utilities.java    License: MIT License 6 votes vote down vote up
/**
 * Check if koler is set as the default dialer app
 *
 * @param activity
 * @return boolean
 */
public static boolean checkDefaultDialer(FragmentActivity activity) {
    String packageName = activity.getApplication().getPackageName();
    try {
        if (!activity.getSystemService(TelecomManager.class).getDefaultDialerPackage().equals(packageName)) {
            // Prompt the user with a dialog to select this app to be the default phone app
            Intent intent = new Intent(TelecomManager.ACTION_CHANGE_DEFAULT_DIALER)
                    .putExtra(TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME, packageName);
            activity.startActivityForResult(intent, DEFAULT_DIALER_RC);
            return false;
        }
        return true;
    } catch (Exception e) {
        return false;
    }
}
 
Example 8
Source Project: TelePlus-Android   Source File: VoIPService.java    License: GNU General Public License v2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.O)
@Override
public CallConnection getConnectionAndStartCall(){
	if(systemCallConnection==null){
		if(BuildVars.LOGS_ENABLED)
			FileLog.d("creating call connection");
		systemCallConnection=new CallConnection();
		systemCallConnection.setInitializing();
		if(isOutgoing){
			delayedStartOutgoingCall=new Runnable(){
				@Override
				public void run(){
					delayedStartOutgoingCall=null;
					startOutgoingCall();
				}
			};
			AndroidUtilities.runOnUIThread(delayedStartOutgoingCall, 2000);
		}
		systemCallConnection.setCallerDisplayName(ContactsController.formatName(user.first_name, user.last_name), TelecomManager.PRESENTATION_ALLOWED);
	}
	return systemCallConnection;
}
 
Example 9
Source Project: GravityBox   Source File: SubscriptionManager.java    License: Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 10
Source Project: GravityBox   Source File: SubscriptionManager.java    License: Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 11
Source Project: GravityBox   Source File: SubscriptionManager.java    License: Apache License 2.0 6 votes vote down vote up
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;
    }
}
 
Example 12
Source Project: Telegram-FOSS   Source File: VoIPService.java    License: GNU General Public License v2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.O)
@Override
public CallConnection getConnectionAndStartCall(){
	if(systemCallConnection==null){
		if(BuildVars.LOGS_ENABLED)
			FileLog.d("creating call connection");
		systemCallConnection=new CallConnection();
		systemCallConnection.setInitializing();
		if(isOutgoing){
			delayedStartOutgoingCall=new Runnable(){
				@Override
				public void run(){
					delayedStartOutgoingCall=null;
					startOutgoingCall();
				}
			};
			AndroidUtilities.runOnUIThread(delayedStartOutgoingCall, 2000);
		}
		systemCallConnection.setAddress(Uri.fromParts("tel", "+99084"+user.id, null), TelecomManager.PRESENTATION_ALLOWED);
		systemCallConnection.setCallerDisplayName(ContactsController.formatName(user.first_name, user.last_name), TelecomManager.PRESENTATION_ALLOWED);
	}
	return systemCallConnection;
}
 
Example 13
Source Project: Telegram   Source File: VoIPService.java    License: GNU General Public License v2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.O)
@Override
public CallConnection getConnectionAndStartCall(){
	if(systemCallConnection==null){
		if(BuildVars.LOGS_ENABLED)
			FileLog.d("creating call connection");
		systemCallConnection=new CallConnection();
		systemCallConnection.setInitializing();
		if(isOutgoing){
			delayedStartOutgoingCall=new Runnable(){
				@Override
				public void run(){
					delayedStartOutgoingCall=null;
					startOutgoingCall();
				}
			};
			AndroidUtilities.runOnUIThread(delayedStartOutgoingCall, 2000);
		}
		systemCallConnection.setAddress(Uri.fromParts("tel", "+99084"+user.id, null), TelecomManager.PRESENTATION_ALLOWED);
		systemCallConnection.setCallerDisplayName(ContactsController.formatName(user.first_name, user.last_name), TelecomManager.PRESENTATION_ALLOWED);
	}
	return systemCallConnection;
}
 
Example 14
Source Project: android_9.0.0_r45   Source File: TelecomLoaderService.java    License: Apache License 2.0 5 votes vote down vote up
private void updateSimCallManagerPermissions(PackageManagerInternal packageManagerInternal,
        int userId) {
    TelecomManager telecomManager =
        (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
    PhoneAccountHandle phoneAccount = telecomManager.getSimCallManager(userId);
    if (phoneAccount != null) {
        Slog.i(TAG, "updating sim call manager permissions for userId:" + userId);
        String packageName = phoneAccount.getComponentName().getPackageName();
        packageManagerInternal.grantDefaultPermissionsToDefaultSimCallManager(
            packageName, userId);
    }
}
 
Example 15
Source Project: android_9.0.0_r45   Source File: NotificationComparator.java    License: Apache License 2.0 5 votes vote down vote up
private boolean isDefaultPhoneApp(String pkg) {
    if (mDefaultPhoneApp == null) {
        final TelecomManager telecomm =
                (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
        mDefaultPhoneApp = telecomm != null ? telecomm.getDefaultDialerPackage() : null;
    }
    return Objects.equals(pkg, mDefaultPhoneApp);
}
 
Example 16
Source Project: android_9.0.0_r45   Source File: ZenModeFiltering.java    License: Apache License 2.0 5 votes vote down vote up
private boolean isDefaultPhoneApp(String pkg) {
    if (mDefaultPhoneApp == null) {
        final TelecomManager telecomm =
                (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
        mDefaultPhoneApp = telecomm != null ? telecomm.getDefaultPhoneApp() : null;
        if (DEBUG) Slog.d(TAG, "Default phone app: " + mDefaultPhoneApp);
    }
    return pkg != null && mDefaultPhoneApp != null
            && pkg.equals(mDefaultPhoneApp.getPackageName());
}
 
Example 17
Source Project: android_9.0.0_r45   Source File: LockTaskController.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable
private TelecomManager getTelecomManager() {
    if (mTelecomManager == null) {
        // We don't preserve the TelecomManager object to save memory
        return mContext.getSystemService(TelecomManager.class);
    }
    return mTelecomManager;
}
 
Example 18
@TargetApi(Build.VERSION_CODES.O)
protected PhoneAccountHandle addAccountToTelecomManager(){
	TelecomManager tm=(TelecomManager) getSystemService(TELECOM_SERVICE);
	TLRPC.User self=UserConfig.getInstance(currentAccount).getCurrentUser();
	PhoneAccountHandle handle=new PhoneAccountHandle(new ComponentName(this, TelegramConnectionService.class), ""+self.id);
	PhoneAccount account=new PhoneAccount.Builder(handle, ContactsController.formatName(self.first_name, self.last_name))
			.setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED)
			.setIcon(Icon.createWithResource(this, R.drawable.ic_launcher))
			.setHighlightColor(0xff2ca5e0)
			.addSupportedUriScheme("sip")
			.build();
	tm.registerPhoneAccount(account);
	return handle;
}
 
Example 19
Source Project: VoIpUSSD   Source File: USSDController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * get action call Intent
 *
 * @param uri     parsed uri to call
 * @param simSlot simSlot number to use
 */
@SuppressLint("MissingPermission")
private Intent getActionCallIntent(Uri uri, int simSlot) {
    // https://stackoverflow.com/questions/25524476/make-call-using-a-specified-sim-in-a-dual-sim-device
    final String simSlotName[] = {
            "extra_asus_dial_use_dualsim",
            "com.android.phone.extra.slot",
            "slot",
            "simslot",
            "sim_slot",
            "subscription",
            "Subscription",
            "phone",
            "com.android.phone.DialingMode",
            "simSlot",
            "slot_id",
            "simId",
            "simnum",
            "phone_type",
            "slotId",
            "slotIdx"
    };

    Intent intent = new Intent(Intent.ACTION_CALL, uri);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra("com.android.phone.force.slot", true);
    intent.putExtra("Cdma_Supp", true);

    for (String s : simSlotName)
        intent.putExtra(s, simSlot);

    TelecomManager telecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
    if (telecomManager != null) {
        List<PhoneAccountHandle> phoneAccountHandleList = telecomManager.getCallCapablePhoneAccounts();
        if (phoneAccountHandleList != null && phoneAccountHandleList.size() > simSlot)
            intent.putExtra("android.telecom.extra.PHONE_ACCOUNT_HANDLE", phoneAccountHandleList.get(simSlot));
    }

    return intent;
}
 
Example 20
Source Project: react-native-callkeep   Source File: VoiceConnection.java    License: ISC License 5 votes vote down vote up
VoiceConnection(Context context, HashMap<String, String> handle) {
    super();
    this.handle = handle;
    this.context = context;

    String number = handle.get(EXTRA_CALL_NUMBER);
    String name = handle.get(EXTRA_CALLER_NAME);

    if (number != null) {
        setAddress(Uri.parse(number), TelecomManager.PRESENTATION_ALLOWED);
    }
    if (name != null && !name.equals("")) {
        setCallerDisplayName(name, TelecomManager.PRESENTATION_ALLOWED);
    }
}
 
Example 21
Source Project: react-native-callkeep   Source File: RNCallKeepModule.java    License: ISC License 5 votes vote down vote up
@ReactMethod
public void updateDisplay(String uuid, String displayName, String uri) {
    Connection conn = VoiceConnectionService.getConnection(uuid);
    if (conn == null) {
        return;
    }

    conn.setAddress(Uri.parse(uri), TelecomManager.PRESENTATION_ALLOWED);
    conn.setCallerDisplayName(displayName, TelecomManager.PRESENTATION_ALLOWED);
}
 
Example 22
Source Project: react-native-callkeep   Source File: RNCallKeepModule.java    License: ISC License 5 votes vote down vote up
@ReactMethod
public void openPhoneAccountSettings() {
    if (!isConnectionServiceAvailable()) {
        return;
    }

    Intent intent = new Intent(TelecomManager.ACTION_CHANGE_PHONE_ACCOUNTS);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
    this.getAppContext().startActivity(intent);
}
 
Example 23
@TargetApi(Build.VERSION_CODES.O)
protected PhoneAccountHandle addAccountToTelecomManager(){
	TelecomManager tm=(TelecomManager) getSystemService(TELECOM_SERVICE);
	TLRPC.User self=UserConfig.getInstance(currentAccount).getCurrentUser();
	PhoneAccountHandle handle=new PhoneAccountHandle(new ComponentName(this, TelegramConnectionService.class), ""+self.id);
	PhoneAccount account=new PhoneAccount.Builder(handle, ContactsController.formatName(self.first_name, self.last_name))
			.setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED)
			.setIcon(Icon.createWithResource(this, R.drawable.ic_launcher))
			.setHighlightColor(0xff2ca5e0)
			.addSupportedUriScheme("sip")
			.build();
	tm.registerPhoneAccount(account);
	return handle;
}
 
Example 24
Source Project: BlackList   Source File: CallBroadcastReceiver.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressLint("NewApi")
private void breakCallPieAndHigher(Context context) {
    Log.d(TAG, "Trying to break call for Pie and higher with TelecomManager.");
    TelecomManager telecomManager = (TelecomManager)
            context.getSystemService(Context.TELECOM_SERVICE);
    try {
        telecomManager.getClass().getMethod("endCall").invoke(telecomManager);
        Log.d(TAG, "Invoked 'endCall' on TelecomManager.");
    } catch (Exception e) {
        Log.e(TAG, "Could not end call. Check stdout for more info.");
        e.printStackTrace();
    }
}
 
Example 25
Source Project: GravityBox   Source File: CallFeatures.java    License: Apache License 2.0 5 votes vote down vote up
private void silenceRinger() {
    try {
        TelecomManager tm = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
        tm.silenceRinger();
    } catch(Throwable t) {
        XposedBridge.log(t);
    }
}
 
Example 26
Source Project: GravityBox   Source File: SubscriptionManager.java    License: Apache License 2.0 5 votes vote down vote up
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;
    }
}
 
Example 27
Source Project: GravityBox   Source File: Utils.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 28
@TargetApi(Build.VERSION_CODES.O)
protected PhoneAccountHandle addAccountToTelecomManager(){
	TelecomManager tm=(TelecomManager) getSystemService(TELECOM_SERVICE);
	TLRPC.User self=UserConfig.getInstance(currentAccount).getCurrentUser();
	PhoneAccountHandle handle=new PhoneAccountHandle(new ComponentName(this, TelegramConnectionService.class), ""+self.id);
	PhoneAccount account=new PhoneAccount.Builder(handle, ContactsController.formatName(self.first_name, self.last_name))
			.setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED)
			.setIcon(Icon.createWithResource(this, R.drawable.ic_launcher_dr))
			.setHighlightColor(0xff2ca5e0)
			.addSupportedUriScheme("sip")
			.build();
	tm.registerPhoneAccount(account);
	return handle;
}
 
Example 29
Source Project: Telegram   Source File: VoIPBaseService.java    License: GNU General Public License v2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.O)
protected PhoneAccountHandle addAccountToTelecomManager(){
	TelecomManager tm=(TelecomManager) getSystemService(TELECOM_SERVICE);
	TLRPC.User self=UserConfig.getInstance(currentAccount).getCurrentUser();
	PhoneAccountHandle handle=new PhoneAccountHandle(new ComponentName(this, TelegramConnectionService.class), ""+self.id);
	PhoneAccount account=new PhoneAccount.Builder(handle, ContactsController.formatName(self.first_name, self.last_name))
			.setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED)
			.setIcon(Icon.createWithResource(this, R.drawable.ic_launcher_dr))
			.setHighlightColor(0xff2ca5e0)
			.addSupportedUriScheme("sip")
			.build();
	tm.registerPhoneAccount(account);
	return handle;
}
 
Example 30
Source Project: AndroidComponentPlugin   Source File: ContextImpl.java    License: Apache License 2.0 4 votes vote down vote up
public Object createService(ContextImpl ctx) {
    return new TelecomManager(ctx.getOuterContext());
}