1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-22 12:02:05 +01:00

[android-extensions] Set RECEIVER_NOT_EXPORTED in ServerPingWithAlarmManager

Set RECEIVER_NOT_EXPORTED when registering the receiver in
ServerPingWithAlarmManager, as otherwise this will throw an exception
if the application targets Android API level 34 or higher.

This requires raising the minimum Android API level to 26 for
registerReceiver() with flags.
This commit is contained in:
Florian Schmaus 2024-10-15 12:45:18 +02:00
parent 072761a0ad
commit 5dd08fc215
4 changed files with 10 additions and 4 deletions

View file

@ -56,7 +56,7 @@ jobs:
uses: android-actions/setup-android@v3
- name: Install Android SDK
run: |
sdkmanager "platforms;android-23"
sdkmanager "platforms;android-26"
# Testing
- name: Gradle Check

View file

@ -3,7 +3,7 @@ plugins {
id 'org.igniterealtime.smack.global-conventions'
}
dependencies {
signature "net.sf.androidscents.signature:android-api-level-${smackMinAndroidSdk}:6.0_r3@signature"
signature "net.sf.androidscents.signature:android-api-level-${smackMinAndroidSdk}:8.0.0_r2@signature"
}
animalsniffer {
sourceSets = [sourceSets.main]

View file

@ -1,7 +1,7 @@
ext {
javaVersion = JavaVersion.VERSION_11
javaMajor = javaVersion.getMajorVersion()
smackMinAndroidSdk = 23
smackMinAndroidSdk = 26
androidBootClasspath = { getAndroidRuntimeJar() }
}

View file

@ -173,7 +173,13 @@ public final class ServerPingWithAlarmManager extends Manager {
*/
public static void onCreate(Context context) {
sContext = context;
context.registerReceiver(ALARM_BROADCAST_RECEIVER, new IntentFilter(PING_ALARM_ACTION));
int receiverFlags = 0;
if (Build.VERSION.SDK_INT >= 34) {
receiverFlags |= 4; // RECEIVER_NOT_EXPORTED
}
context.registerReceiver(ALARM_BROADCAST_RECEIVER, new IntentFilter(PING_ALARM_ACTION), receiverFlags);
sAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
int pendingIntentFlags = 0;
if (Build.VERSION.SDK_INT >= 23) {