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

Increase SDK level to 35 #1003

Merged
merged 9 commits into from
Sep 10, 2024
Merged
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ plugins {

// Android configuration
android {
compileSdk = 34
compileSdk = 35

defaultConfig {
applicationId = "at.bitfire.davdroid"
Expand All @@ -24,7 +24,7 @@ android {
setProperty("archivesBaseName", "davx5-ose-$versionName")

minSdk = 24 // Android 7.0
targetSdk = 34 // Android 14
targetSdk = 35 // Android 15

testInstrumentationRunner = "at.bitfire.davdroid.HiltTestRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import android.content.pm.PackageManager
import at.bitfire.davdroid.db.AppDatabase
import at.bitfire.davdroid.db.SyncStats
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
import java.text.Collator
import java.util.logging.Logger
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map

class DavSyncStatsRepository @Inject constructor(
@ApplicationContext val context: Context,
Expand Down Expand Up @@ -61,11 +61,14 @@ class DavSyncStatsRepository @Inject constructor(
val packageManager = context.packageManager
val packageName = packageManager.resolveContentProvider(authority, 0)?.packageName ?: authority
return try {
val appInfo = packageManager.getPackageInfo(packageName, 0).applicationInfo
val appInfo = packageManager.getPackageInfo(packageName, 0).applicationInfo!!
packageManager.getApplicationLabel(appInfo).toString()
} catch (e: PackageManager.NameNotFoundException) {
logger.warning("Application name not found for authority: $authority")
authority
} catch (_: NullPointerException) {
logger.warning("Package name ($packageName) not found for authority: $authority")
authority
ArnyminerZ marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ import at.bitfire.ical4android.TaskProvider
import at.bitfire.ical4android.TaskProvider.ProviderName
import dagger.Lazy
import dagger.hilt.android.qualifiers.ApplicationContext
import java.util.logging.Logger
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
import java.util.logging.Logger
import javax.inject.Inject

/**
* Responsible for setting/getting the currently used tasks app, and for communicating with it.
Expand Down Expand Up @@ -168,7 +168,7 @@ class TasksAppManager @Inject constructor(

val pm = context.packageManager
val tasksAppInfo = pm.getPackageInfo(e.provider.packageName, 0)
val tasksAppLabel = tasksAppInfo.applicationInfo.loadLabel(pm)
val tasksAppLabel = tasksAppInfo.applicationInfo?.loadLabel(pm)

val notify = NotificationCompat.Builder(context, registry.CHANNEL_SYNC_ERRORS)
.setSmallIcon(R.drawable.ic_sync_problem_notify)
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/kotlin/at/bitfire/davdroid/ui/DebugInfoModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import dagger.hilt.android.lifecycle.HiltViewModel
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.dmfs.tasks.contract.TaskContract
import java.io.File
import java.io.IOException
import java.io.Writer
Expand All @@ -67,6 +64,9 @@ import java.util.logging.Level
import java.util.logging.Logger
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.dmfs.tasks.contract.TaskContract
import at.bitfire.ical4android.util.MiscUtils.asSyncAdapter as asCalendarSyncAdapter
import at.bitfire.vcard4android.Utils.asSyncAdapter as asContactsSyncAdapter
import at.techbee.jtx.JtxContract.asSyncAdapter as asJtxSyncAdapter
Expand Down Expand Up @@ -239,9 +239,9 @@ class DebugInfoModel @AssistedInject constructor(
val info = pm.getPackageInfo(packageName, 0)
val appInfo = info.applicationInfo
val notes = mutableListOf<String>()
if (!appInfo.enabled)
if (appInfo?.enabled == false)
notes += "disabled"
if (appInfo.flags.and(ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0)
if (appInfo?.flags?.and(ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0)
notes += "<em>on external storage</em>"
table.addLine(
info.packageName, info.versionName, PackageInfoCompat.getLongVersionCode(info),
Expand Down Expand Up @@ -366,7 +366,7 @@ class DebugInfoModel @AssistedInject constructor(
// permissions
writer.append("Permissions:\n")
val ownPkgInfo = context.packageManager.getPackageInfo(BuildConfig.APPLICATION_ID, PackageManager.GET_PERMISSIONS)
for (permission in ownPkgInfo.requestedPermissions) {
for (permission in ownPkgInfo.requestedPermissions ?: emptyArray()) {
ArnyminerZ marked this conversation as resolved.
Show resolved Hide resolved
val shortPermission = permission.removePrefix("android.permission.")
writer.append(" - $shortPermission: ")
.append(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class DiskCache(
files.sortBy { file -> file.lastModified() } // sort by modification time (ascending)

while (files.sumOf { file -> file.length() } > maxSize) {
val file = files.removeFirst() // take first (= oldest) file
rfc2822 marked this conversation as resolved.
Show resolved Hide resolved
val file = files.removeAt(0) // take first (= oldest) file
logger.finer("Removing $file")
file.delete()
removed++
Expand Down
Loading