From bcf080f6eb93b12194208e4114b52767f5b0acb0 Mon Sep 17 00:00:00 2001 From: Simon Redman Date: Mon, 23 Jan 2023 22:02:01 +0000 Subject: [PATCH] [SMS Plugin] Change android-smsmms to in-house build until upstream supports SDK31 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Android apps which target SDK 31+ require specifying the mutability of any PENDING_INTENT. This is not supported in the upstream android-smsmms library: https://github.com/klinker41/android-smsmms/pull/193 Until the above PR is merged, we need a solution. I have pulled the code into https://invent.kde.org/sredman/android-smsmms and published the package in the Maven repository in gitlab. BUG: 464392 ## Test Plan ### Before: Attempting to send an SMS or MMS message using kdeconnect-sms results in no message being sent, and an error being logged: > V/Sending message: Sending new SMS > E/Sending message: Exception > java.lang.IllegalArgumentException: org.kde.kdeconnect_tp: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. > Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles. > at android.app.PendingIntent.checkFlags(PendingIntent.java:382) > at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:673) > at android.app.PendingIntent.getBroadcast(PendingIntent.java:660) > at com.klinker.android.send_message.Transaction.sendSmsMessage(Transaction.java:267) > at com.klinker.android.send_message.Transaction.sendNewMessage(Transaction.java:158) > at com.klinker.android.send_message.Transaction.sendNewMessage(Transaction.java:172) > at org.kde.kdeconnect.Plugins.SMSPlugin.SmsMmsUtils.sendMessage(SmsMmsUtils.java:188) > at org.kde.kdeconnect.Plugins.SMSPlugin.SMSPlugin.onPacketReceived(SMSPlugin.java:414) > at org.kde.kdeconnect.Device.onPacketReceived(Device.java:570) > ### After: SMS and MMS sends normally. --- build.gradle | 10 ++++++++-- settings.gradle | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 6a217d71..164395c1 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ apply plugin: 'kotlin-android' android { compileSdkVersion 33 defaultConfig { - minSdkVersion 14 + minSdkVersion 21 targetSdkVersion 31 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' @@ -166,7 +166,13 @@ dependencies { implementation 'org.atteo.classindex:classindex:3.6' annotationProcessor 'org.atteo.classindex:classindex:3.6' - implementation 'com.klinkerapps:android-smsmms:5.2.6' //For SMS and MMS purposes + // The android-smsmms library is the only way I know to handle MMS in Android + // (Shouldn't a phone OS make phone things easy?) + // This library was originally authored as com.klinkerapps at https://github.com/klinker41/android-smsmms. + // However, that version is under-loved. I have therefore made "some fixes" and published it. + // Please see https://invent.kde.org/sredman/android-smsmms/-/tree/master + implementation 'org.kde:android-smsmms:5.2.7' + implementation 'com.klinkerapps:logger:1.0.3' implementation 'commons-io:commons-io:2.8.0' // newer versions don't work on Android 7: https://stackoverflow.com/questions/73604534/no-static-method-threadlocal-withinitial-commons-io-dependency implementation 'org.apache.commons:commons-collections4:4.4' diff --git a/settings.gradle b/settings.gradle index 6f7043a8..ec5f80d7 100644 --- a/settings.gradle +++ b/settings.gradle @@ -15,6 +15,12 @@ dependencyResolutionManagement { repositories { google() mavenCentral() + maven { + name = "KDE Invent Maven" + // This project_id corresponds to kdeconnect-android project + // Depending on how long we need this custom package, we may decide to move it to a more-official repo + url = "https://invent.kde.org/api/v4/projects/72/packages/maven" + } } } rootProject.name = "kdeconnect-android"