Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APT-10212] Android 14 & JDK 17 #36

Merged
merged 6 commits into from
Jul 8, 2024
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
33 changes: 24 additions & 9 deletions .github/workflows/on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
run-tests:
strategy:
matrix:
project: [Library, Test App]
include:
- project: Library
gradle-arguments: testReleaseUnitTest
Expand All @@ -31,34 +32,41 @@ jobs:
steps:
# Clone the repo
- name: Clone Repo
uses: actions/checkout@v2
uses: actions/checkout@v4

# Cache the gradle build dependencies for faster builds
- name: Cache Gradle Dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ env.GRADLE_CACHE_PATH }}
key: ${{ runner.os }}-${{ hashFiles('.gradle-cache-buster') }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/gradle.properties') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.gradle-cache-buster') }}-gradle-

# Download Java and set version
- name: Set Up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ vars.JDK_VERSION }}
distribution: 'temurin'

# Test using gradle
- name: Run ${{ matrix.project }} Tests
run: ./gradlew ${{ matrix.gradle-arguments }} --warning-mode all

# Upload the html test report as a build artifact for easier debugging
- name: Upload Test Report
if: ${{ always() }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.test-group }} Test Reports
name: ${{ matrix.project }} Test Reports
path: ${{ matrix.base-folder }}/build/reports/tests/${{ matrix.test-report-folder }}/*

# Upload XML logs as build artifacts (accessible from the Summary page of the run)
- name: Upload JUnit Logs
if: ${{ always() }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.test-group }} Testing Logs
name: ${{ matrix.project }} Testing Logs
path: "${{ matrix.base-folder }}/build/test-results/test*UnitTest/TEST-*.xml"

# If the workflow was started on the main branch then publish the library and test app. If started on a release branch publish only the library.
Expand All @@ -82,16 +90,23 @@ jobs:
steps:
# Retrieve the repo
- name: Clone Repo
uses: actions/checkout@v2
uses: actions/checkout@v4

# Cache the gradle build dependencies for faster builds
- name: Cache Gradle Dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ env.GRADLE_CACHE_PATH }}
key: ${{ runner.os }}-${{ hashFiles('.gradle-cache-buster') }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/gradle.properties') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.gradle-cache-buster') }}-gradle-

# Download Java and set version
- name: Set Up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ vars.JDK_VERSION }}
distribution: 'temurin'

# Build using gradle
- name: Build ${{ matrix.project }} Release
run: ./gradlew ${{ matrix.gradle-arguments }}
Expand All @@ -116,7 +131,7 @@ jobs:

# Upload the AAR file as a build artifact (accessible from the Summary page of the run)
- name: Upload AAR file
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact-name }}
path: ${{ matrix.artifact-path }}
Expand Down
27 changes: 15 additions & 12 deletions Armadillo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@ plugins {
id 'org.jetbrains.kotlin.plugin.serialization' version "${kotlin_version}"
}

android {
compileSdkVersion 33

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}

android {
compileSdk 34

defaultConfig {
minSdkVersion 21
targetSdkVersion 33
versionCode 1
versionName project.LIBRARY_VERSION
targetSdkVersion 34
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'proguard-rules.pro'
buildConfigField("String", "VERSION_NAME", "\"${project.LIBRARY_VERSION}\"")
Expand All @@ -44,6 +43,10 @@ android {
}

resourcePrefix 'arm'
buildFeatures {
buildConfig true
}
namespace 'com.scribd.armadillo'
}

dependencies {
Expand All @@ -62,11 +65,11 @@ dependencies {
implementation 'androidx.media:media:1.6.0'
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:${SERIALIZATON_VERSION}"

testImplementation "org.robolectric:robolectric:4.5.1"
testImplementation "org.robolectric:robolectric:4.9.2"
testImplementation 'junit:junit:4.13.2'
testImplementation("org.assertj:assertj-core:3.10.0")
testImplementation "org.mockito:mockito-core:2.28.2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes

testImplementation("org.mockito.kotlin:mockito-kotlin:3.2.0") {
testImplementation "org.mockito:mockito-core:5.6.0"
testImplementation("org.mockito.kotlin:mockito-kotlin:4.1.0") {
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib'
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-reflect'
}
Expand Down
4 changes: 2 additions & 2 deletions Armadillo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.scribd.armadillo">
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
Expand All @@ -13,6 +12,7 @@
android:exported="true"
android:stopWithTask="false"
android:foregroundServiceType="mediaPlayback"
android:permission="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"
tools:ignore="ExportedService">

<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.media.AudioManager
import android.os.Build
import android.util.Log

/**
Expand Down Expand Up @@ -45,7 +46,12 @@ class ArmadilloNoisyReceiver(val application: Application)
if(!isRegistered) {
this.listener = listener
Log.v(TAG, "registered for listening noisy")
application.registerReceiver(this, intentFilter)

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
application.registerReceiver(this, intentFilter, Context.RECEIVER_EXPORTED)
} else {
application.registerReceiver(this, intentFilter)
}
isRegistered = true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.os.Build
import com.scribd.armadillo.hasSnowCone

/**
Expand All @@ -33,7 +34,11 @@ internal class ArmadilloNotificationDeleteReceiver(val application: Application)

override fun register(listener: NotificationDeleteReceiver.Listener) {
if (!isRegistered) {
application.registerReceiver(this, IntentFilter(ACTION))
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
application.registerReceiver(this, IntentFilter(ACTION), Context.RECEIVER_NOT_EXPORTED)
} else {
application.registerReceiver(this, IntentFilter(ACTION))
}
deleteListener = listener
isRegistered = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import org.assertj.core.api.Assertions.assertThat
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.mockito.Mockito.times
import org.mockito.kotlin.any
import org.mockito.kotlin.mock
import org.mockito.kotlin.never
import org.mockito.kotlin.verify
import org.mockito.kotlin.verifyZeroInteractions
import org.mockito.kotlin.whenever

class ExoplayerPlaybackEngineTest {
Expand Down Expand Up @@ -197,7 +197,7 @@ class ExoplayerPlaybackEngineTest {

playbackEngine.updateProgress()

verifyZeroInteractions(stateModifier)
verify(stateModifier, times(0)).dispatch(any())
}

@Test
Expand All @@ -208,7 +208,7 @@ class ExoplayerPlaybackEngineTest {

playbackEngine.updateProgress()

verifyZeroInteractions(stateModifier)
verify(stateModifier, times(0)).dispatch(any())
}

@Test
Expand All @@ -219,7 +219,7 @@ class ExoplayerPlaybackEngineTest {

playbackEngine.updateProgress()

verifyZeroInteractions(stateModifier)
verify(stateModifier, times(0)).dispatch(any())
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito
import org.mockito.kotlin.mock
import org.mockito.kotlin.times
import org.mockito.kotlin.verify
import org.mockito.kotlin.verifyZeroInteractions
import org.mockito.kotlin.whenever
import org.robolectric.RobolectricTestRunner
import org.robolectric.Shadows
Expand Down Expand Up @@ -128,7 +128,7 @@ class MediaSessionCallbackTest {
mediaSessionCallback.isPlaying = true
whenever(playbackInfo.audioPlayable).thenReturn(audiobookOne)
mediaSessionCallback.onPlayFromUri(URL.toUri(), bundleOne)
verifyZeroInteractions(mediaSessionCallback.playbackEngine!!)
verify(mediaSessionCallback.playbackEngine!!, times(0)).deinit()
}

@Test
Expand Down
3 changes: 3 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Project Armadillo Release Notes

## 1.4.0
- Targets Android 14 (SDK 34), with appropriate service permissions.

## 1.3.3
- Reverted fix in 1.3.2 as it may have affected listening progress not being correctly reported
- Added support for passing in load control parameters via ArmadilloConfiguration to the exo player instance
Expand Down
15 changes: 9 additions & 6 deletions TestApp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 32

compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}

android {
compileSdk 34

defaultConfig {
applicationId "com.scribd.armadillotestapp"
minSdkVersion 21
targetSdkVersion 32
targetSdkVersion 34
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -49,6 +51,7 @@ android {
dimension "ARMADILLO_SOURCE"
}
}
namespace 'com.scribd.armadillotestapp'
}

dependencies {
Expand Down
7 changes: 4 additions & 3 deletions TestApp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.scribd.armadillotestapp">
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>

<uses-feature
android:name="android.hardware.type.automotive"
Expand Down Expand Up @@ -45,7 +45,8 @@

<service
android:name="com.scribd.armadillo.download.DefaultExoplayerDownloadService"
android:exported="false">
android:exported="false"
android:permission="android.permission.FOREGROUND_SERVICE">
<intent-filter>
<action android:name="com.google.android.exoplayer.downloadService.action.INIT"/>
<category android:name="android.intent.category.DEFAULT"/>
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
apply from: "$project.rootDir/gradle/shared.gradle"

dependencies {
classpath 'com.android.tools.build:gradle:7.2.0'
classpath "com.android.tools.build:gradle:$GRADLE_PLUGIN_VERSION"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
10 changes: 6 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ org.gradle.jvmargs=-Xmx1536m
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
PACKAGE_NAME=com.scribd.armadillo
LIBRARY_VERSION=1.3.3
GRADLE_PLUGIN_VERSION=7.2.0
LIBRARY_VERSION=1.4.0
EXOPLAYER_VERSION=2.17.1
RXJAVA_VERSION=2.2.4
RXANDROID_VERSION=2.0.1
DAGGER_VERSION=2.16
MAVEN_PUBLISH_VERSION=3.6.2
DOKKA_VERSION=1.6.10
SERIALIZATON_VERSION=1.4.1
# Update package-list when updating build tools version
BUILD_TOOLS_VERSION=29.0.3
BUILD_TOOLS_VERSION=34.0.0
android.useAndroidX=true
android.enableJetifier=true
android.enableJetifier=true
android.nonTransitiveRClass=true
android.suppressUnsupportedCompileSdk=34
Loading