Example usage for android.telecom PhoneAccount SCHEME_TEL

List of usage examples for android.telecom PhoneAccount SCHEME_TEL

Introduction

In this page you can find the example usage for android.telecom PhoneAccount SCHEME_TEL.

Prototype

String SCHEME_TEL

To view the source code for android.telecom PhoneAccount SCHEME_TEL.

Click Source Link

Document

URI scheme for telephone number URIs.

Usage

From source file:com.mobileglobe.android.customdialer.common.CallUtil.java

/**
 * Return Uri with an appropriate scheme, accepting both SIP and usual phone call
 * numbers./*w  ww.  j  a  v  a 2  s  .  c  om*/
 */
public static Uri getCallUri(String number) {
    if (PhoneNumberHelper.isUriNumber(number)) {
        return Uri.fromParts(PhoneAccount.SCHEME_SIP, number, null);
    }
    return Uri.fromParts(PhoneAccount.SCHEME_TEL, number, null);
}

From source file:com.android.dialer.calllog.DefaultVoicemailNotifier.java

/**
 * Determines which ringtone Uri and Notification defaults to use when updating the notification
 * for the given call./*from   w  w w .  j av  a 2  s.  c o m*/
 */
private Pair<Uri, Integer> getNotificationInfo(@Nullable NewCall callToNotify) {
    Log.v(TAG, "getNotificationInfo");
    if (callToNotify == null) {
        Log.i(TAG, "callToNotify == null");
        return new Pair<>(null, 0);
    }
    PhoneAccountHandle accountHandle = null;
    if (callToNotify.accountComponentName == null || callToNotify.accountId == null) {
        Log.v(TAG, "accountComponentName == null || callToNotify.accountId == null");
        accountHandle = TelecomUtil.getDefaultOutgoingPhoneAccount(mContext, PhoneAccount.SCHEME_TEL);
        if (accountHandle == null) {
            Log.i(TAG, "No default phone account found, using default notification ringtone");
            return new Pair<>(null, Notification.DEFAULT_ALL);
        }

    } else {
        accountHandle = new PhoneAccountHandle(
                ComponentName.unflattenFromString(callToNotify.accountComponentName), callToNotify.accountId);
    }
    if (accountHandle.getComponentName() != null) {
        Log.v(TAG, "PhoneAccountHandle.ComponentInfo:" + accountHandle.getComponentName());
    } else {
        Log.i(TAG, "PhoneAccountHandle.ComponentInfo: null");
    }
    return new Pair<>(TelephonyManagerCompat.getVoicemailRingtoneUri(getTelephonyManager(), accountHandle),
            getNotificationDefaults(accountHandle));
}

From source file:com.android.contacts.common.list.ShortcutIntentBuilder.java

private void createPhoneNumberShortcutIntent(Uri uri, String displayName, String lookupKey, byte[] bitmapData,
        String phoneNumber, int phoneType, String phoneLabel, String shortcutAction) {
    Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey);

    Bitmap bitmap;/*from   ww  w . j a v  a 2 s .  c om*/
    Uri phoneUri;
    if (Intent.ACTION_CALL.equals(shortcutAction)) {
        // Make the URI a direct tel: URI so that it will always continue to work
        phoneUri = Uri.fromParts(PhoneAccount.SCHEME_TEL, phoneNumber, null);
        bitmap = generatePhoneNumberIcon(drawable, phoneType, phoneLabel, R.drawable.ic_call);
    } else {
        phoneUri = Uri.fromParts(ContactsUtils.SCHEME_SMSTO, phoneNumber, null);
        bitmap = generatePhoneNumberIcon(drawable, phoneType, phoneLabel, R.drawable.ic_message_24dp);
    }

    Intent shortcutIntent = new Intent(shortcutAction, phoneUri);
    shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    Intent intent = new Intent();
    intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, bitmap);
    intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);

    if (TextUtils.isEmpty(displayName)) {
        displayName = mContext.getResources().getString(R.string.missing_name);
    }
    if (TextUtils.equals(shortcutAction, Intent.ACTION_CALL)) {
        intent.putExtra(Intent.EXTRA_SHORTCUT_NAME,
                mContext.getResources().getString(R.string.call_by_shortcut, displayName));
    } else if (TextUtils.equals(shortcutAction, Intent.ACTION_SENDTO)) {
        intent.putExtra(Intent.EXTRA_SHORTCUT_NAME,
                mContext.getResources().getString(R.string.sms_by_shortcut, displayName));
    }

    mListener.onShortcutIntentCreated(uri, intent);
}

From source file:com.mobileglobe.android.customdialer.common.list.ShortcutIntentBuilder.java

private void createPhoneNumberShortcutIntent(Uri uri, String displayName, String lookupKey, byte[] bitmapData,
        String phoneNumber, int phoneType, String phoneLabel, String shortcutAction) {
    Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey);

    Bitmap bitmap;/*from   ww  w.  j  a  va 2  s  .c  om*/
    Uri phoneUri;
    if (Intent.ACTION_CALL.equals(shortcutAction)) {
        // Make the URI a direct tel: URI so that it will always continue to work
        phoneUri = Uri.fromParts(PhoneAccount.SCHEME_TEL, phoneNumber, null);
        bitmap = generatePhoneNumberIcon(drawable, phoneType, phoneLabel, R.drawable.ic_call);
    } else {
        phoneUri = Uri.fromParts(ContactsUtils.SCHEME_SMSTO, phoneNumber, null);
        bitmap = generatePhoneNumberIcon(drawable, phoneType, phoneLabel, R.drawable.ic_message_24dp_mirrored);
    }

    Intent shortcutIntent = new Intent(shortcutAction, phoneUri);
    shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    Intent intent = new Intent();
    intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, bitmap);
    intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);

    if (TextUtils.isEmpty(displayName)) {
        displayName = mContext.getResources().getString(R.string.missing_name);
    }
    if (TextUtils.equals(shortcutAction, Intent.ACTION_CALL)) {
        intent.putExtra(Intent.EXTRA_SHORTCUT_NAME,
                mContext.getResources().getString(R.string.call_by_shortcut, displayName));
    } else if (TextUtils.equals(shortcutAction, Intent.ACTION_SENDTO)) {
        intent.putExtra(Intent.EXTRA_SHORTCUT_NAME,
                mContext.getResources().getString(R.string.sms_by_shortcut, displayName));
    }

    mListener.onShortcutIntentCreated(uri, intent);
}

From source file:com.android.contacts.ShortcutIntentBuilder.java

private void createPhoneNumberShortcutIntent(Uri uri, String displayName, String lookupKey, byte[] bitmapData,
        String phoneNumber, int phoneType, String phoneLabel, String shortcutAction) {
    final Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey);
    final Bitmap icon;
    final Uri phoneUri;
    final String shortcutName;
    if (TextUtils.isEmpty(displayName)) {
        displayName = mContext.getResources().getString(R.string.missing_name);
    }/*from  ww  w . j  a  va 2 s  .  c  o  m*/

    if (Intent.ACTION_CALL.equals(shortcutAction)) {
        // Make the URI a direct tel: URI so that it will always continue to work
        phoneUri = Uri.fromParts(PhoneAccount.SCHEME_TEL, phoneNumber, null);
        icon = generatePhoneNumberIcon(drawable, phoneType, phoneLabel,
                R.drawable.quantum_ic_phone_vd_theme_24);
        shortcutName = mContext.getResources().getString(R.string.call_by_shortcut, displayName);
    } else {
        phoneUri = Uri.fromParts(ContactsUtils.SCHEME_SMSTO, phoneNumber, null);
        icon = generatePhoneNumberIcon(drawable, phoneType, phoneLabel,
                R.drawable.quantum_ic_message_vd_theme_24);
        shortcutName = mContext.getResources().getString(R.string.sms_by_shortcut, displayName);
    }

    final Intent shortcutIntent = new Intent(shortcutAction, phoneUri);
    shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    Intent intent = null;
    IconCompat compatAdaptiveIcon = null;
    if (BuildCompat.isAtLeastO()) {
        compatAdaptiveIcon = IconCompat.createWithAdaptiveBitmap(icon);
        final ShortcutManager sm = (ShortcutManager) mContext.getSystemService(Context.SHORTCUT_SERVICE);
        final String id = shortcutAction + lookupKey + phoneUri.toString().hashCode();
        final DynamicShortcuts dynamicShortcuts = new DynamicShortcuts(mContext);
        final ShortcutInfo shortcutInfo = dynamicShortcuts.getActionShortcutInfo(id, displayName,
                shortcutIntent, compatAdaptiveIcon.toIcon());
        if (shortcutInfo != null) {
            intent = sm.createShortcutResultIntent(shortcutInfo);
        }
    }

    intent = intent == null ? new Intent() : intent;
    // This will be non-null in O and above.
    if (compatAdaptiveIcon != null) {
        compatAdaptiveIcon.addToShortcutIntent(intent, null, mContext);
    } else {
        intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, icon);
    }
    intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
    intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, shortcutName);

    mListener.onShortcutIntentCreated(uri, intent);
}

From source file:com.android.server.telecom.testapps.TestConnectionService.java

@Override
public Connection onCreateIncomingConnection(PhoneAccountHandle connectionManagerAccount,
        final ConnectionRequest request) {
    PhoneAccountHandle accountHandle = request.getAccountHandle();
    ComponentName componentName = new ComponentName(this, TestConnectionService.class);

    if (accountHandle != null && componentName.equals(accountHandle.getComponentName())) {
        final TestConnection connection = new TestConnection(true);
        // Get the stashed intent extra that determines if this is a video call or audio call.
        Bundle extras = request.getExtras();
        boolean isVideoCall = extras.getBoolean(EXTRA_IS_VIDEO_CALL);
        Uri providedHandle = extras.getParcelable(EXTRA_HANDLE);

        // Use dummy number for testing incoming calls.
        Uri address = providedHandle == null
                ? Uri.fromParts(PhoneAccount.SCHEME_TEL, getDummyNumber(isVideoCall), null)
                : providedHandle;/*from  ww  w  . j  a  v a2  s  . c  om*/

        int videoState = isVideoCall ? VideoProfile.STATE_BIDIRECTIONAL : VideoProfile.STATE_AUDIO_ONLY;
        connection.setVideoState(videoState);
        setAddress(connection, address);

        addVideoProvider(connection);

        addCall(connection);

        ConnectionRequest newRequest = new ConnectionRequest(request.getAccountHandle(), address,
                request.getExtras(), videoState);
        connection.setVideoState(videoState);
        return connection;
    } else {
        return Connection.createFailedConnection(new DisconnectCause(DisconnectCause.ERROR,
                "Invalid inputs: " + accountHandle + " " + componentName));
    }
}

From source file:com.android.server.telecom.testapps.TestConnectionService.java

@Override
public Connection onCreateUnknownConnection(PhoneAccountHandle connectionManagerPhoneAccount,
        final ConnectionRequest request) {
    PhoneAccountHandle accountHandle = request.getAccountHandle();
    ComponentName componentName = new ComponentName(this, TestConnectionService.class);
    if (accountHandle != null && componentName.equals(accountHandle.getComponentName())) {
        final TestConnection connection = new TestConnection(false);
        final Bundle extras = request.getExtras();
        final Uri providedHandle = extras.getParcelable(EXTRA_HANDLE);

        Uri handle = providedHandle == null
                ? Uri.fromParts(PhoneAccount.SCHEME_TEL, getDummyNumber(false), null)
                : providedHandle;/*from  w ww .ja v  a 2  s.  co  m*/

        connection.setAddress(handle, TelecomManager.PRESENTATION_ALLOWED);
        connection.setDialing();

        addCall(connection);
        return connection;
    } else {
        return Connection.createFailedConnection(new DisconnectCause(DisconnectCause.ERROR,
                "Invalid inputs: " + accountHandle + " " + componentName));
    }
}

From source file:com.android.dialer.DialtactsActivity.java

/** Returns true if the given intent contains a phone number to populate the dialer with */
private boolean isDialIntent(Intent intent) {
    final String action = intent.getAction();
    if (Intent.ACTION_DIAL.equals(action) || ACTION_TOUCH_DIALER.equals(action)) {
        return true;
    }/*from w w w. j a  v  a  2s .  co  m*/
    if (Intent.ACTION_VIEW.equals(action)) {
        final Uri data = intent.getData();
        if (data != null && PhoneAccount.SCHEME_TEL.equals(data.getScheme())) {
            return true;
        }
    }
    return false;
}