Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ jobs:
with:
submodules: true

- name: Set up Java 17
uses: actions/setup-java@v2
- name: Set up Java 21
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '17'
distribution: 'temurin'
java-version: '21'

- name: Test Bash Keystores scripts
run: make test-bash-keystore
Expand Down Expand Up @@ -85,11 +85,11 @@ jobs:
with:
submodules: true

- name: Set up Java 17
uses: actions/setup-java@v2
- name: Set up Java 21
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '17'
distribution: 'temurin'
java-version: '21'

- name: Enable KVM
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:
- name: Set release version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Set up Java 17
uses: actions/setup-java@v2
- name: Set up Java 21
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '17'
distribution: 'temurin'
java-version: '21'

- name: Set up Ruby
uses: ruby/setup-ruby@v1
Expand Down
15 changes: 10 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,14 @@ def getVersionCode = {
def getVersionName = {
System.env.RELEASE_VERSION ?: 'SNAPSHOT'
}

java {
// Pins the JDK used to compile
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
android {
compileSdk 35
compileSdk 36
packagingOptions {
resources {
excludes += ['META-INF/LICENSE', 'META-INF/NOTICE']
Expand All @@ -114,7 +119,7 @@ android {

defaultConfig {
//noinspection OldTargetApi
targetSdkVersion 35
targetSdkVersion 36
minSdkVersion 21 // Android 5.0
versionCode getVersionCode()
versionName getVersionName()
Expand Down Expand Up @@ -496,9 +501,9 @@ dependencies {
compileOnly 'com.github.spotbugs:spotbugs-annotations:4.9.3'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-inline:5.2.0'
testImplementation 'org.mockito:mockito-core:5.23.0'
testImplementation 'com.google.android:android-test:4.1.1.4'
testImplementation 'org.robolectric:robolectric:4.15.1'
testImplementation 'org.robolectric:robolectric:4.16.1'
testImplementation 'androidx.test.espresso:espresso-core:3.7.0'
testImplementation 'androidx.test.espresso:espresso-intents:3.7.0'
testImplementation 'androidx.test.ext:junit:1.3.0'
Expand Down
1 change: 1 addition & 0 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
android:fullBackupContent="@xml/backup_rules_sdk_30_and_lower"
android:dataExtractionRules="@xml/backup_rules"
android:largeHeap="true"
android:enableOnBackInvokedCallback="false"
tools:ignore="LockedOrientationActivity,UnusedAttribute">
<activity android:name="StartupActivity" android:exported="true">
<intent-filter>
Expand Down
22 changes: 19 additions & 3 deletions src/test/java/org/medicmobile/webapp/mobile/SmsSenderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.telephony.SmsManager;

import androidx.core.content.ContextCompat;
Expand All @@ -39,6 +40,7 @@
import org.mockito.quality.Strictness;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -76,6 +78,21 @@ public void setup() {
smsSender = SmsSender.createInstance(parentMock);
}

/**
* Robolectric no longer emulates SDK < 23, so tests covering the pre-M code
* path (still reachable with minSdkVersion 21) have to force SDK_INT instead
* of using {@code @Config(sdk = 22)}.
*/
private void withSdkInt(int sdkInt, Runnable body) {
int originalSdkInt = Build.VERSION.SDK_INT;
ReflectionHelpers.setStaticField(Build.VERSION.class, "SDK_INT", sdkInt);
try {
body.run();
} finally {
ReflectionHelpers.setStaticField(Build.VERSION.class, "SDK_INT", originalSdkInt);
}
}

@Test
public void createInstance() {
assertEquals(SmsSender.class, smsSender.getClass());
Expand All @@ -88,9 +105,8 @@ public void createInstance_RSmsSender() {
}

@Test
@Config(sdk = 22)
public void createInstance_LSmsSender() {
assertEquals(SmsSender.LSmsSender.class, smsSender.getClass());
withSdkInt(22, () -> assertEquals(SmsSender.LSmsSender.class, SmsSender.createInstance(parentMock).getClass()));
}

@Test
Expand Down Expand Up @@ -165,14 +181,14 @@ public void send_withPermissions_sendsMultipartTextMessage_RSmsSender() {
}

@Test
@Config(sdk = 22)
public void send_withPermissions_sendsMultipartTextMessage_LSmsSender() {
try (
MockedStatic<ContextCompat> contextCompatMock = mockStatic(ContextCompat.class);
MockedStatic<SmsManager> smsManagerStaticMock = mockStatic(SmsManager.class);
MockedStatic<PendingIntent> pendingIntentMock = mockStatic(PendingIntent.class)
) {
//> GIVEN
withSdkInt(22, () -> smsSender = SmsSender.createInstance(parentMock));
contextCompatMock.when(() -> ContextCompat.checkSelfPermission(eq(parentMock), eq(SEND_SMS))).thenReturn(PERMISSION_GRANTED);
int expectedBroadcastFlags = FLAG_ONE_SHOT;
mockGetBroadcast(pendingIntentMock, expectedBroadcastFlags);
Expand Down
Loading