Loading src/java/com/android/internal/telephony/MissedIncomingCallSmsFilter.java +87 −59 Original line number Diff line number Diff line Loading @@ -23,12 +23,14 @@ 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; Loading Loading @@ -152,9 +154,6 @@ 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) { Loading @@ -162,6 +161,12 @@ 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 { Loading @@ -172,7 +177,7 @@ public class MissedIncomingCallSmsFilter { continue; } Matcher matcher = pattern.matcher(message.getMessageBody()); Matcher matcher = pattern.matcher(parsedMsg); String year = null, month = null, day = null, hour = null, minute = null; if (matcher.find()) { try { Loading Loading @@ -220,18 +225,41 @@ public class MissedIncomingCallSmsFilter { Rlog.d(TAG, "Caller id is not provided or can't be parsed."); } createMissedIncomingCallEvent(missedCallTime, callerId); return true; result = true; break; } } } } if (!result) { Rlog.d(TAG, "SMS did not match any missed incoming call SMS pattern."); return false; } 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; } // Create phone account. The logic is copied from PhoneUtils.makePstnPhoneAccountHandle. private static PhoneAccountHandle makePstnPhoneAccountHandle(Phone phone) { 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); } return new PhoneAccountHandle(PSTN_CONNECTION_SERVICE_COMPONENT, String.valueOf(phone.getFullIccSerialNumber())); String.valueOf(phone.getSubId())); } /** Loading Loading
src/java/com/android/internal/telephony/MissedIncomingCallSmsFilter.java +87 −59 Original line number Diff line number Diff line Loading @@ -23,12 +23,14 @@ 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; Loading Loading @@ -152,9 +154,6 @@ 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) { Loading @@ -162,6 +161,12 @@ 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 { Loading @@ -172,7 +177,7 @@ public class MissedIncomingCallSmsFilter { continue; } Matcher matcher = pattern.matcher(message.getMessageBody()); Matcher matcher = pattern.matcher(parsedMsg); String year = null, month = null, day = null, hour = null, minute = null; if (matcher.find()) { try { Loading Loading @@ -220,18 +225,41 @@ public class MissedIncomingCallSmsFilter { Rlog.d(TAG, "Caller id is not provided or can't be parsed."); } createMissedIncomingCallEvent(missedCallTime, callerId); return true; result = true; break; } } } } if (!result) { Rlog.d(TAG, "SMS did not match any missed incoming call SMS pattern."); return false; } 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; } // Create phone account. The logic is copied from PhoneUtils.makePstnPhoneAccountHandle. private static PhoneAccountHandle makePstnPhoneAccountHandle(Phone phone) { 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); } return new PhoneAccountHandle(PSTN_CONNECTION_SERVICE_COMPONENT, String.valueOf(phone.getFullIccSerialNumber())); String.valueOf(phone.getSubId())); } /** Loading