From f2c991ca41afbc1198ce1af1c484335c6cec6157 Mon Sep 17 00:00:00 2001 From: Peter Cai Date: Wed, 17 May 2023 14:14:25 -0400 Subject: [PATCH] frameworks/opt/telephony: Include more patches from TD, mostly for IMS --- ...roller-Do-not-override-default-calli.patch | 6 +- ...ic-void-TelephonyMetrics.writeRilSen.patch | 46 +++++++++++++++ ...ue-to-setPreferredNetworkType-for-RI.patch | 53 +++++++++++++++++ ...vert-Block-Binder-thread-until-incom.patch | 57 +++++++++++++++++++ ...ng-too-long-to-fit-into-a-91-chars-p.patch | 27 +++++++++ 5 files changed, 186 insertions(+), 3 deletions(-) create mode 100644 frameworks/opt/telephony/0002-Reintroduce-public-void-TelephonyMetrics.writeRilSen.patch create mode 100644 frameworks/opt/telephony/0003-Pass-correct-value-to-setPreferredNetworkType-for-RI.patch create mode 100644 frameworks/opt/telephony/0004-Conditionally-revert-Block-Binder-thread-until-incom.patch create mode 100644 frameworks/opt/telephony/0005-Fix-baseband-being-too-long-to-fit-into-a-91-chars-p.patch diff --git a/frameworks/opt/telephony/0001-SubscriptionController-Do-not-override-default-calli.patch b/frameworks/opt/telephony/0001-SubscriptionController-Do-not-override-default-calli.patch index d7f28f3..6bb0898 100644 --- a/frameworks/opt/telephony/0001-SubscriptionController-Do-not-override-default-calli.patch +++ b/frameworks/opt/telephony/0001-SubscriptionController-Do-not-override-default-calli.patch @@ -1,7 +1,7 @@ -From 9990507a53c8bc7ac154f78ed260fea6be30f252 Mon Sep 17 00:00:00 2001 +From 02041484d88e3c8a6cd62e1253f4b12b15be6852 Mon Sep 17 00:00:00 2001 From: Peter Cai Date: Mon, 5 Sep 2022 14:02:37 -0400 -Subject: [PATCH] SubscriptionController: Do not override default calling +Subject: [PATCH 1/5] SubscriptionController: Do not override default calling account from third-party apps When the user has selected a calling account from a third-party app as @@ -41,5 +41,5 @@ index 82799bea8b..5105d3a183 100644 if (previousDefaultSub != getDefaultSubId()) { -- -2.39.2 +2.40.0 diff --git a/frameworks/opt/telephony/0002-Reintroduce-public-void-TelephonyMetrics.writeRilSen.patch b/frameworks/opt/telephony/0002-Reintroduce-public-void-TelephonyMetrics.writeRilSen.patch new file mode 100644 index 0000000..6dc0420 --- /dev/null +++ b/frameworks/opt/telephony/0002-Reintroduce-public-void-TelephonyMetrics.writeRilSen.patch @@ -0,0 +1,46 @@ +From bcaff4d8a493c657519ae50cf7f3661da6c4a46b Mon Sep 17 00:00:00 2001 +From: ironydelerium <42721860+ironydelerium@users.noreply.github.com> +Date: Fri, 31 Dec 2021 02:20:28 -0800 +Subject: [PATCH 2/5] Reintroduce 'public void + TelephonyMetrics.writeRilSendSms(int, int, int, int)'. (#8) + +The MediaTek IMS package for Android Q, at the very least (likely for the rest, too) +invoke this method in their `sendSms` method; Google, in their infinite wisdom, +decided that this method needed a message ID passed in as well, changing the signature +to 'public void TelephonyMetrics.writeRilSendSms(int, int, int, int, long)' and resulting +in a MethodNotFoundException being raised in com.mediatek.ims, crashing it. + +Fixes https://github.com/phhusson/treble_experimentations/issues/2125. + +Co-authored-by: Sarah Vandomelen +--- + .../telephony/metrics/TelephonyMetrics.java | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/src/java/com/android/internal/telephony/metrics/TelephonyMetrics.java b/src/java/com/android/internal/telephony/metrics/TelephonyMetrics.java +index 3fdbfe0ed7..fb8011c3df 100644 +--- a/src/java/com/android/internal/telephony/metrics/TelephonyMetrics.java ++++ b/src/java/com/android/internal/telephony/metrics/TelephonyMetrics.java +@@ -2320,6 +2320,19 @@ public class TelephonyMetrics { + smsSession.increaseExpectedResponse(); + } + ++ /** ++ * Write Send SMS event (backwards-compatible method for R and earlier IMS implementations) ++ * ++ * @param phoneId Phone id ++ * @param rilSerial RIL request serial number ++ * @param tech SMS RAT ++ * @param format SMS format. Either {@link SmsMessage#FORMAT_3GPP} or ++ * {@link SmsMessage#FORMAT_3GPP2}. ++ */ ++ public void writeRilSendSms(int phoneId, int rilSerial, int tech, int format) { ++ writeRilSendSms(phoneId, rilSerial, tech, format, 0); ++ } ++ + /** + * Write Send SMS event using ImsService. Expecting response from + * {@link #writeOnSmsSolicitedResponse}. +-- +2.40.0 + diff --git a/frameworks/opt/telephony/0003-Pass-correct-value-to-setPreferredNetworkType-for-RI.patch b/frameworks/opt/telephony/0003-Pass-correct-value-to-setPreferredNetworkType-for-RI.patch new file mode 100644 index 0000000..c070a86 --- /dev/null +++ b/frameworks/opt/telephony/0003-Pass-correct-value-to-setPreferredNetworkType-for-RI.patch @@ -0,0 +1,53 @@ +From 9550951ff96e643d143da826cb9560da572850a1 Mon Sep 17 00:00:00 2001 +From: LuK1337 +Date: Fri, 21 Oct 2022 20:55:05 +0200 +Subject: [PATCH 3/5] Pass correct value to setPreferredNetworkType() for RIL + version < 1.4 + +Change-Id: Id14be66a2ea4e85b6504bc03fd7d2f038185c17d +--- + src/java/com/android/internal/telephony/RIL.java | 3 ++- + .../com/android/internal/telephony/RadioNetworkProxy.java | 5 +++-- + 2 files changed, 5 insertions(+), 3 deletions(-) + +diff --git a/src/java/com/android/internal/telephony/RIL.java b/src/java/com/android/internal/telephony/RIL.java +index 6de66527e1..0c1b7cdf8c 100644 +--- a/src/java/com/android/internal/telephony/RIL.java ++++ b/src/java/com/android/internal/telephony/RIL.java +@@ -2879,7 +2879,8 @@ public class RIL extends BaseCommands implements CommandsInterface { + mMetrics.writeSetPreferredNetworkType(mPhoneId, networkType); + + try { +- networkProxy.setPreferredNetworkTypeBitmap(rr.mSerial, mAllowedNetworkTypesBitmask); ++ networkProxy.setPreferredNetworkTypeBitmap( ++ rr.mSerial, mAllowedNetworkTypesBitmask, networkType); + } catch (RemoteException | RuntimeException e) { + handleRadioProxyExceptionForRR(NETWORK_SERVICE, "setPreferredNetworkType", e); + } +diff --git a/src/java/com/android/internal/telephony/RadioNetworkProxy.java b/src/java/com/android/internal/telephony/RadioNetworkProxy.java +index b88103510a..661fa56954 100644 +--- a/src/java/com/android/internal/telephony/RadioNetworkProxy.java ++++ b/src/java/com/android/internal/telephony/RadioNetworkProxy.java +@@ -379,16 +379,17 @@ public class RadioNetworkProxy extends RadioServiceProxy { + * Call IRadioNetwork#setPreferredNetworkTypeBitmap + * @param serial Serial number of request + * @param networkTypesBitmask Preferred network types bitmask to set ++ * @param networkType Preferred network type to set for RIL version < 1.4 + * @throws RemoteException + */ +- public void setPreferredNetworkTypeBitmap(int serial, int networkTypesBitmask) ++ public void setPreferredNetworkTypeBitmap(int serial, int networkTypesBitmask, int networkType) + throws RemoteException { + if (isEmpty() || mHalVersion.greaterOrEqual(RIL.RADIO_HAL_VERSION_1_6)) return; + if (mHalVersion.greaterOrEqual(RIL.RADIO_HAL_VERSION_1_4)) { + ((android.hardware.radio.V1_4.IRadio) mRadioProxy).setPreferredNetworkTypeBitmap(serial, + RILUtils.convertToHalRadioAccessFamily(networkTypesBitmask)); + } else { +- mRadioProxy.setPreferredNetworkType(serial, networkTypesBitmask); ++ mRadioProxy.setPreferredNetworkType(serial, networkType); + } + } + +-- +2.40.0 + diff --git a/frameworks/opt/telephony/0004-Conditionally-revert-Block-Binder-thread-until-incom.patch b/frameworks/opt/telephony/0004-Conditionally-revert-Block-Binder-thread-until-incom.patch new file mode 100644 index 0000000..5e1d94d --- /dev/null +++ b/frameworks/opt/telephony/0004-Conditionally-revert-Block-Binder-thread-until-incom.patch @@ -0,0 +1,57 @@ +From c527732943bc02fd434cbecbd07787e2d429023d Mon Sep 17 00:00:00 2001 +From: ExactExampl +Date: Tue, 11 Oct 2022 12:38:00 +0300 +Subject: [PATCH 4/5] Conditionally revert "Block Binder thread until incoming + call process completes" + +* Legacy IMS packages handling incoming calls in such a way that + a blocked binder thread won`t allow to complete call setup, + thus we have half dead incoming calls with unattached call session + (caller can hear dialing tone whereas recipient got nothing) + +This conditionally reverts commit 75c3dc9ba272b43971f519caba0382f9871c7d9d. + +Change-Id: I55a8f3bbca4a2b9a6bc7511e9fe2d0884a8818e5 +--- + .../imsphone/ImsPhoneCallTracker.java | 18 ++++++++++++++---- + 1 file changed, 14 insertions(+), 4 deletions(-) + +diff --git a/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java b/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java +index 5968ba6fa1..86034f6fa1 100644 +--- a/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java ++++ b/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java +@@ -50,6 +50,7 @@ import android.os.Registrant; + import android.os.RegistrantList; + import android.os.RemoteException; + import android.os.SystemClock; ++import android.os.SystemProperties; + import android.preference.PreferenceManager; + import android.provider.Settings; + import android.sysprop.TelephonyProperties; +@@ -322,10 +323,19 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall { + + @Override + public void onIncomingCall(IImsCallSession c, Bundle extras) { +- // we want to ensure we block this binder thread until incoming call setup completes +- // as to avoid race conditions where the ImsService tries to update the state of the +- // call before the listeners have been attached. +- executeAndWait(()-> processIncomingCall(c, extras)); ++ final boolean shouldBlockBinderThreadOnIncomingCalls = SystemProperties.getBoolean( ++ "ro.telephony.block_binder_thread_on_incoming_calls", true); ++ if (shouldBlockBinderThreadOnIncomingCalls) { ++ // we want to ensure we block this binder thread until incoming call setup completes ++ // as to avoid race conditions where the ImsService tries to update the state of the ++ // call before the listeners have been attached. ++ executeAndWait(()-> processIncomingCall(c, extras)); ++ } else { ++ // for legacy IMS we want to avoid blocking the binder thread, otherwise ++ // we end up with half dead incoming calls with unattached call session ++ TelephonyUtils.runWithCleanCallingIdentity(()-> processIncomingCall(c, extras), ++ mExecutor); ++ } + } + + @Override +-- +2.40.0 + diff --git a/frameworks/opt/telephony/0005-Fix-baseband-being-too-long-to-fit-into-a-91-chars-p.patch b/frameworks/opt/telephony/0005-Fix-baseband-being-too-long-to-fit-into-a-91-chars-p.patch new file mode 100644 index 0000000..9210d5e --- /dev/null +++ b/frameworks/opt/telephony/0005-Fix-baseband-being-too-long-to-fit-into-a-91-chars-p.patch @@ -0,0 +1,27 @@ +From 53160d33c83afe4f56862c3c12d4b61e2970209b Mon Sep 17 00:00:00 2001 +From: Pierre-Hugues Husson +Date: Mon, 6 Dec 2021 16:28:22 -0500 +Subject: [PATCH 5/5] Fix baseband being too long to fit into a 91 chars + property, preventing telephony subsystem from starting + +Change-Id: I1762e4a8cc137626be89f350229d6be162bdaf57 +--- + src/java/com/android/internal/telephony/GsmCdmaPhone.java | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/java/com/android/internal/telephony/GsmCdmaPhone.java b/src/java/com/android/internal/telephony/GsmCdmaPhone.java +index 76a8d57246..9a72712c59 100644 +--- a/src/java/com/android/internal/telephony/GsmCdmaPhone.java ++++ b/src/java/com/android/internal/telephony/GsmCdmaPhone.java +@@ -3124,7 +3124,7 @@ public class GsmCdmaPhone extends Phone { + String version = (String)ar.result; + if (version != null) { + int length = version.length(); +- final int MAX_VERSION_LEN = SystemProperties.PROP_VALUE_MAX/2; ++ final int MAX_VERSION_LEN = SystemProperties.PROP_VALUE_MAX/2 - 2; + TelephonyManager.from(mContext).setBasebandVersionForPhone(getPhoneId(), + length <= MAX_VERSION_LEN ? version + : version.substring(length - MAX_VERSION_LEN, length)); +-- +2.40.0 +