Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b3fa8338 authored by Jayachandran C's avatar Jayachandran C Committed by Gerrit Code Review
Browse files

Merge "Revert "Feature support for SMS to misscall notification""

parents 4a738ebe f6ebf7ba
Loading
Loading
Loading
Loading
+59 −87
Original line number Diff line number Diff line
@@ -23,14 +23,12 @@ import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.os.UserHandle;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.telephony.CarrierConfigManager;
import android.telephony.Rlog;
import android.telephony.SmsMessage;
import android.telephony.SubscriptionManager;
import android.text.TextUtils;

import java.time.Instant;
@@ -154,6 +152,9 @@ public class MissedIncomingCallSmsFilter {
     * @return {@code true} if the SMS message has been processed as a missed incoming call SMS.
     */
    private boolean processSms(@NonNull SmsMessage message) {
        long missedCallTime = 0;
        String callerId = null;

        String[] smsPatterns = mCarrierConfig.getStringArray(CarrierConfigManager
                .KEY_MISSED_INCOMING_CALL_SMS_PATTERN_STRING_ARRAY);
        if (smsPatterns == null || smsPatterns.length == 0) {
@@ -161,12 +162,6 @@ public class MissedIncomingCallSmsFilter {
            return false;
        }

        boolean result = false;
        String[] missedCallMsgs = splitCalls(message.getMessageBody());
        if (missedCallMsgs != null && missedCallMsgs.length > 0) {
            for (String parsedMsg : missedCallMsgs) {
                long missedCallTime = 0;
                String callerId = null;
        for (String smsPattern : smsPatterns) {
            Pattern pattern;
            try {
@@ -177,7 +172,7 @@ public class MissedIncomingCallSmsFilter {
                continue;
            }

                    Matcher matcher = pattern.matcher(parsedMsg);
            Matcher matcher = pattern.matcher(message.getMessageBody());
            String year = null, month = null, day = null, hour = null, minute = null;
            if (matcher.find()) {
                try {
@@ -225,41 +220,18 @@ public class MissedIncomingCallSmsFilter {
                    Rlog.d(TAG, "Caller id is not provided or can't be parsed.");
                }
                createMissedIncomingCallEvent(missedCallTime, callerId);
                        result = true;
                        break;
                    }
                return true;
            }
        }
        }
        if (!result) {
            Rlog.d(TAG, "SMS did not match any missed incoming call SMS pattern.");
        }
        return result;
    }

    private String[] splitCalls(String messageBody) {
        String[] messages = null;
        if (messageBody != null) {
            messages = messageBody.split("\\n" + "\\n");
            Rlog.d(TAG,
                    "splitTheMultipleCalls no of calls = " + ((messages != null) ? messages.length
                            : 0));
        }
        return messages;
        Rlog.d(TAG, "SMS did not match any missed incoming call SMS pattern.");
        return false;
    }

    // Create phone account. The logic is copied from PhoneUtils.makePstnPhoneAccountHandle.
    private PhoneAccountHandle makePstnPhoneAccountHandle(Phone phone) {
        SubscriptionManager subscriptionManager =
                (SubscriptionManager) phone.getContext().getSystemService(
                        Context.TELEPHONY_SUBSCRIPTION_SERVICE);
        UserHandle userHandle = subscriptionManager.getSubscriptionUserHandle(phone.getSubId());
        if (userHandle != null) {
            return new PhoneAccountHandle(PSTN_CONNECTION_SERVICE_COMPONENT,
                    String.valueOf(phone.getSubId()), userHandle);
        }
    private static PhoneAccountHandle makePstnPhoneAccountHandle(Phone phone) {
        return new PhoneAccountHandle(PSTN_CONNECTION_SERVICE_COMPONENT,
                String.valueOf(phone.getSubId()));
                String.valueOf(phone.getFullIccSerialNumber()));
    }

    /**