Skip to content

Commit

Permalink
bump gradle, agp and deps
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutoshgngwr committed Dec 24, 2023
1 parent 262724d commit f2cc848
Show file tree
Hide file tree
Showing 19 changed files with 99 additions and 60 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/android.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ jobs:
strategy:
matrix:
include:
- android: 30
- android: 32
target: aosp_atd
appVariant: FreeDebug
- android: 30
- android: 32
target: google_atd
appVariant: FullDebug
fail-fast: false
Expand All @@ -118,7 +118,7 @@ jobs:
with:
api-level: ${{ matrix.android }}
target: ${{ matrix.target }}
arch: x86
arch: x86_64
script: ./scripts/run-ui-tests.sh :app:create${{ matrix.appVariant }}CoverageReport
emulator-options: >-
-camera-back none -camera-front none -gpu swiftshader_indirect
Expand Down
22 changes: 11 additions & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ project.afterEvaluate {
}

dependencies {
def androidXHiltVersion = '1.0.0'
def androidXHiltVersion = '1.1.0'
def fragmentVersion = '1.6.1'
def media3Version = '1.1.1'
def roomVersion = '2.5.2'
def workManagerVersion = '2.8.1'
def media3Version = '1.2.0'
def roomVersion = '2.6.1'
def workManagerVersion = '2.9.0'

def espressoVersion = '3.5.1'
def mockkVersion = '1.13.8'
Expand All @@ -104,14 +104,14 @@ dependencies {
ksp "androidx.room:room-compiler:$roomVersion"

implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.browser:browser:1.5.0'
implementation 'androidx.browser:browser:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "androidx.core:core-ktx:$deps.androidXCoreVersion"
implementation "androidx.fragment:fragment-ktx:$fragmentVersion"
implementation "androidx.hilt:hilt-work:$androidXHiltVersion"
implementation "androidx.lifecycle:lifecycle-common-java8:$deps.lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$deps.lifecycleVersion"
implementation 'androidx.media:media:1.6.0' // needed for audio focus management.
implementation 'androidx.media:media:1.7.0' // needed for audio focus management.
implementation "androidx.media3:media3-common:$media3Version"
implementation "androidx.media3:media3-exoplayer:$media3Version"
implementation "androidx.media3:media3-exoplayer-workmanager:$media3Version"
Expand All @@ -120,7 +120,7 @@ dependencies {
implementation "androidx.navigation:navigation-ui-ktx:$deps.navVersion"
implementation 'androidx.paging:paging-runtime-ktx:3.2.1'
implementation 'androidx.preference:preference-ktx:1.2.1'
implementation 'androidx.recyclerview:recyclerview:1.3.1'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation "androidx.room:room-ktx:$roomVersion"
implementation "androidx.room:room-paging:$roomVersion"
implementation "androidx.room:room-runtime:$roomVersion"
Expand All @@ -129,7 +129,7 @@ dependencies {
implementation 'com.caverock:androidsvg-aar:1.4'
implementation 'com.github.AppIntro:AppIntro:6.2.0'
implementation 'com.google.android.flexbox:flexbox:3.0.0'
implementation 'com.google.android.material:material:1.9.0'
implementation 'com.google.android.material:material:1.11.0'
implementation 'com.google.code.gson:gson:2.10.1'
implementation "com.google.dagger:hilt-android:$deps.hiltVersion"
implementation "com.mikepenz:aboutlibraries:${deps.aboutLibrariesVersion}"
Expand All @@ -138,10 +138,10 @@ dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$deps.coroutinesVersion"
implementation project(":api-client")

fullImplementation 'androidx.mediarouter:mediarouter:1.4.0'
fullImplementation 'com.android.billingclient:billing-ktx:6.0.1'
fullImplementation 'androidx.mediarouter:mediarouter:1.6.0'
fullImplementation 'com.android.billingclient:billing-ktx:6.1.0'
fullImplementation 'com.google.android.gms:play-services-base:18.2.0'
fullImplementation 'com.google.android.gms:play-services-cast-framework:21.3.0'
fullImplementation 'com.google.android.gms:play-services-cast-framework:21.4.0'
fullImplementation 'com.google.android.play:core:1.10.3'
fullImplementation platform('com.google.firebase:firebase-bom:31.5.0')

Check warning on line 146 in app/build.gradle

View workflow job for this annotation

GitHub Actions / Lint

Obsolete Gradle Dependency: A newer version of com.google.firebase:firebase-bom than 31.5.0 is available: 32.7.0
fullImplementation 'com.google.firebase:firebase-analytics-ktx'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import java.util.Random
import javax.inject.Singleton

@Module
Expand All @@ -15,6 +16,6 @@ object ReviewFlowProviderModule {
@Provides
@Singleton
fun reviewFlowProvider(): ReviewFlowProvider {
return GitHubReviewFlowProvider()
return GitHubReviewFlowProvider(Random())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import java.util.Random
import javax.inject.Singleton

@Module
Expand All @@ -21,6 +22,6 @@ object ReviewFlowProviderModule {
if (isGoogleMobileServiceAvailable(context)) {
return PlayStoreReviewFlowProvider()
}
return GitHubReviewFlowProvider()
return GitHubReviewFlowProvider(Random())
}
}
16 changes: 15 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@

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

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

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

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

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

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
Expand Down Expand Up @@ -203,7 +209,15 @@

<service android:name=".service.SubscriptionStatusPollService" />

<service android:name=".service.AlarmRingerService" />
<service
android:name=".service.AlarmRingerService"
android:foregroundServiceType="specialUse">

<property
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
android:value="required for showing the alarm ringer UI when a scheduled alarm fires" />

</service>

<receiver
android:name=".receiver.AlarmInitReceiver"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ class NoiceApplication : Application(), Configuration.Provider {
@set:Inject
internal lateinit var workerFactory: HiltWorkerFactory

override val workManagerConfiguration: Configuration
get() = Configuration.Builder()
.setWorkerFactory(workerFactory)
.build()

Check warning on line 26 in app/src/main/java/com/github/ashutoshgngwr/noice/NoiceApplication.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/java/com/github/ashutoshgngwr/noice/NoiceApplication.kt#L24-L26

Added lines #L24 - L26 were not covered by tests

override fun onCreate() {
super.onCreate()
DynamicColorsOptions.Builder()
Expand All @@ -31,10 +36,4 @@ class NoiceApplication : Application(), Configuration.Provider {
.setAction(AlarmInitReceiver.ACTION_INIT)
.also { sendBroadcast(it) }
}

override fun getWorkManagerConfiguration(): Configuration {
return Configuration.Builder()
.setWorkerFactory(workerFactory)
.build()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import android.view.WindowManager
import androidx.activity.addCallback
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.content.ContextCompat
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
Expand Down Expand Up @@ -70,7 +71,12 @@ class AlarmRingerActivity : AppCompatActivity() {

override fun onStart() {
super.onStart()
registerReceiver(dismissBroadcastReceiver, IntentFilter(ACTION_DISMISS))
ContextCompat.registerReceiver(
this,
dismissBroadcastReceiver,
IntentFilter(ACTION_DISMISS),
ContextCompat.RECEIVER_NOT_EXPORTED,
)
}

override fun onStop() {
Expand Down Expand Up @@ -137,7 +143,9 @@ class AlarmRingerActivity : AppCompatActivity() {
}

fun dismiss(context: Context) {
context.sendBroadcast(Intent(ACTION_DISMISS))
Intent(ACTION_DISMISS)
.setPackage(context.packageName)
.also { context.sendBroadcast(it) }
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.ashutoshgngwr.noice.engine

import android.annotation.SuppressLint
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
Expand Down Expand Up @@ -111,6 +112,7 @@ class SoundPlaybackNotificationManager(
updateForegroundNotification()
}

@SuppressLint("ForegroundServiceType") // TODO: lint error even when foregroundServiceType is present in the manifest.
private fun updateForegroundNotification() {
if (soundPlayerManagerState == SoundPlayerManager.State.STOPPED) {
if (isServiceInForeground) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import androidx.fragment.app.FragmentActivity
import androidx.preference.PreferenceManager
import com.github.ashutoshgngwr.noice.R
import com.github.ashutoshgngwr.noice.fragment.DialogFragment
import kotlin.random.Random
import java.util.Random

/**
* [GitHubReviewFlowProvider] provides a simple review flow that prompts user for feedback through
Expand All @@ -19,7 +19,7 @@ import kotlin.random.Random
* If the user has opted for 'don't show again', the flow will never be shown again. Otherwise,
* it'll be shown every 1/20 calls to [GitHubReviewFlowProvider.maybeAskForReview].
*/
class GitHubReviewFlowProvider : ReviewFlowProvider {
class GitHubReviewFlowProvider(private val random: Random) : ReviewFlowProvider {

override fun init(context: Context) = Unit

Expand All @@ -34,7 +34,7 @@ class GitHubReviewFlowProvider : ReviewFlowProvider {
return
}

if (Random.nextInt(20) != 0) {
if (random.nextInt(20) != 0) {
Log.d(LOG_TAG, "abandoning request due to bad luck!")
return
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.ashutoshgngwr.noice.service

import android.annotation.SuppressLint
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
Expand Down Expand Up @@ -134,6 +135,7 @@ class AlarmRingerService : LifecycleService(), AudioFocusManager.Listener {
wakeLock.acquire(wakeLockTimeout.inWholeMilliseconds)
lifecycleScope.launch { startRinger(alarmId) }
}

ACTION_SNOOZE -> lifecycleScope.launch { dismiss(alarmId, isSnoozed = true) }
ACTION_DISMISS -> lifecycleScope.launch { dismiss(alarmId, isSnoozed = false) }
}
Expand Down Expand Up @@ -167,6 +169,7 @@ class AlarmRingerService : LifecycleService(), AudioFocusManager.Listener {
.also { notificationManager.createNotificationChannel(it) }
}

@SuppressLint("ForegroundServiceType") // TODO: lint error even when foregroundServiceType is present in the manifest.
private suspend fun startRinger(alarmId: Int) {
val alarm = alarmRepository.get(alarmId)
if (alarm == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,12 @@ class SoundPlaybackService : LifecycleService(), SoundPlayerManager.Listener,

override fun onCreate() {
super.onCreate()
registerReceiver(becomingNoisyReceiver, IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY))
ContextCompat.registerReceiver(
this,
becomingNoisyReceiver,
IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY),
ContextCompat.RECEIVER_EXPORTED,
)
castApiProvider?.addSessionListener(this)

lifecycleScope.launch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import androidx.fragment.app.FragmentActivity
import androidx.preference.PreferenceManager
import io.mockk.every
import io.mockk.mockk
import io.mockk.mockkObject
import io.mockk.mockkStatic
import io.mockk.unmockkAll
import org.junit.After
Expand All @@ -17,24 +16,24 @@ import org.junit.runner.RunWith
import org.robolectric.Robolectric
import org.robolectric.RobolectricTestRunner
import org.robolectric.shadows.ShadowLooper
import kotlin.random.Random
import java.util.Random

@RunWith(RobolectricTestRunner::class)
class GitHubReviewFlowProviderTest {

private lateinit var fragmentActivity: FragmentActivity
private lateinit var mockRandom: Random
private lateinit var mockPrefs: SharedPreferences
private lateinit var provider: GitHubReviewFlowProvider

@Before
fun setup() {
mockkObject(Random.Default)
mockkStatic(PreferenceManager::class)

fragmentActivity = Robolectric.buildActivity(FragmentActivity::class.java).setup().get()
provider = GitHubReviewFlowProvider()
mockRandom = mockk(relaxed = true)
mockPrefs = mockk(relaxed = true)
every { PreferenceManager.getDefaultSharedPreferences(any()) } returns mockPrefs
fragmentActivity = Robolectric.buildActivity(FragmentActivity::class.java).setup().get()
provider = GitHubReviewFlowProvider(mockRandom)
}

@After
Expand All @@ -44,7 +43,7 @@ class GitHubReviewFlowProviderTest {

@Test
fun testMaybeAskForReview_whenUnlucky() {
every { Random.Default.nextInt(any()) } returns 1 // expecting 0 but return something else
every { mockRandom.nextInt(any()) } returns 1 // expecting 0 but return something else
every {
mockPrefs.getBoolean(GitHubReviewFlowProvider.PREF_FLOW_SUCCESSFULLY_COMPLETED, any())
} returns false
Expand All @@ -57,7 +56,7 @@ class GitHubReviewFlowProviderTest {

@Test
fun testMaybeAskForReview_whenLucky() {
every { Random.Default.nextInt(any()) } returns 0 // returns the expected value
every { mockRandom.nextInt(any()) } returns 0 // returns the expected value
every {
mockPrefs.getBoolean(GitHubReviewFlowProvider.PREF_FLOW_SUCCESSFULLY_COMPLETED, any())
} returns false
Expand All @@ -71,7 +70,7 @@ class GitHubReviewFlowProviderTest {

@Test
fun testMaybeAskForReview_whenUserHasCompletedReviewFlow() {
every { Random.Default.nextInt(any()) } returns 0 // returns the expected value
every { mockRandom.nextInt(any()) } returns 0 // returns the expected value
every {
mockPrefs.getBoolean(GitHubReviewFlowProvider.PREF_FLOW_SUCCESSFULLY_COMPLETED, any())
} returns true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ class SoundPlaybackServiceTest {
}

every {
bindService(match { it.component?.className == serviceName }, any(), any())
bindService(match { it.component?.className == serviceName }, any(), any<Int>())
} answers {
val intent = firstArg<Intent>()
secondArg<ServiceConnection>().onServiceConnected(intent.component, onBind(intent))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class ShadowMediaSession : Player.Listener {
callback: MediaSession.Callback,
tokenExtras: Bundle,
bitmapLoader: BitmapLoader,
playIfSuppressed: Boolean,
isPeriodicPositionUpdateEnabled: Boolean,
) {
invokeConstructor(
MediaSession::class.java,
Expand All @@ -62,6 +64,11 @@ class ShadowMediaSession : Player.Listener {
ReflectionHelpers.ClassParameter.from(MediaSession.Callback::class.java, callback),
ReflectionHelpers.ClassParameter.from(Bundle::class.java, tokenExtras),
ReflectionHelpers.ClassParameter.from(BitmapLoader::class.java, bitmapLoader),
ReflectionHelpers.ClassParameter.from(Boolean::class.javaPrimitiveType, playIfSuppressed),
ReflectionHelpers.ClassParameter.from(
Boolean::class.javaPrimitiveType,
isPeriodicPositionUpdateEnabled,
),
)

this.player = player
Expand Down
Loading

0 comments on commit f2cc848

Please sign in to comment.