Oreo, default SMS App and ACTION_RESPOND_VIA_MESSAGE

情到浓时终转凉″ 提交于 2019-12-06 01:38:21

This shouldn't be the case with stock android, as default implementation does not call SMS App to reject calls with message and usage SmsManager instead.

reference from RespondViaSmsManager.java in AOSP oreo

/**
 * Reject the call with the specified message. If message is null this call is ignored.
 */
private void rejectCallWithMessage(Context context, String phoneNumber, String textMessage,
                                   int subId, String contactName) {
    if (TextUtils.isEmpty(textMessage)) {
        Log.w(RespondViaSmsManager.this, "Couldn't send SMS message: empty text message. ");
        return;
    }
    if (!SubscriptionManager.isValidSubscriptionId(subId)) {
        Log.w(RespondViaSmsManager.this, "Couldn't send SMS message: Invalid SubId: " +
                subId);
        return;
    }

    SmsManager smsManager = SmsManager.getSmsManagerForSubscriptionId(subId);
    try {
        smsManager.sendTextMessage(phoneNumber, null, textMessage, null /*sentIntent*/,
                null /*deliveryIntent*/);

        SomeArgs args = SomeArgs.obtain();
        args.arg1 = !TextUtils.isEmpty(contactName) ? contactName : phoneNumber;
        args.arg2 = context;
        mHandler.obtainMessage(MSG_SHOW_SENT_TOAST, args).sendToTarget();
    } catch (IllegalArgumentException e) {
        Log.w(RespondViaSmsManager.this, "Couldn't send SMS message: " +
                e.getMessage());
    }
}

seems like some oems (I have experianced this with oneplus) customized this and kept older behaviour which requires starting the service of SMS app. without keeping in mind that there are limatations in oreo with respect to background services.

following are a few complaints:

  1. https://www.reddit.com/r/oneplus/comments/8n9w37/cant_send_text_message_when_rejecting_phone_call/
  2. https://forums.oneplus.com/threads/reject-call-with-sms-is-not-working-after-oreo-update-oxygen-5-0-1-3t.817578/

I have experianced this behaviour on most of the SMS apps, including Messages from google on oneplus 5 with android version 8.1

This still doesn't explain how OEM provided sms app or SMS Organizer from microsoft works for this use case on same device.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!