Migration to API level 34 (Android 14)

This commit is contained in:
Juha Heinanen
2023-10-07 08:39:59 +03:00
parent 494530c4f7
commit dc3c98e818
5 changed files with 22 additions and 10 deletions
+3 -5
View File
@@ -3,13 +3,12 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
android { android {
compileSdkVersion = 33 compileSdkVersion = 34
ndkVersion '26.0.10792818' ndkVersion '26.0.10792818'
defaultConfig { defaultConfig {
applicationId = 'com.tutpro.baresip' applicationId = 'com.tutpro.baresip'
minSdkVersion 23 minSdkVersion 23
//noinspection OldTargetApi becuase 34 has not been released yet targetSdkVersion 34
targetSdkVersion 33
versionCode = 292 versionCode = 292
versionName = '58.0.0' versionName = '58.0.0'
externalNativeBuild { externalNativeBuild {
@@ -69,8 +68,7 @@ dependencies {
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0" implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
implementation "androidx.preference:preference-ktx:1.2.1" implementation "androidx.preference:preference-ktx:1.2.1"
implementation "androidx.exifinterface:exifinterface:1.3.6" implementation "androidx.exifinterface:exifinterface:1.3.6"
//noinspection GradleDependency would require targetSdkVersion 34 which is still beta implementation "androidx.core:core-ktx:1.12.0"
implementation "androidx.core:core-ktx:1.10.1"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
implementation "androidx.activity:activity-ktx:1.8.0" implementation "androidx.activity:activity-ktx:1.8.0"
+1
View File
@@ -6,6 +6,7 @@
android:maxSdkVersion="30" /> android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_PHONE_CALL" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
@@ -11,6 +11,7 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.IntentFilter import android.content.IntentFilter
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL
import android.database.ContentObserver import android.database.ContentObserver
import android.media.* import android.media.*
import android.media.AudioManager.MODE_IN_COMMUNICATION import android.media.AudioManager.MODE_IN_COMMUNICATION
@@ -245,7 +246,12 @@ class BaresipService: Service() {
proximityWakeLock = pm.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, proximityWakeLock = pm.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK,
"com.tutpro.baresip:proximity_wakelog") "com.tutpro.baresip:proximity_wakelog")
wifiLock = wm.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "Baresip") wifiLock = if (VERSION.SDK_INT < 29)
@Suppress("DEPRECATION")
wm.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "Baresip")
else
wm.createWifiLock(WifiManager.WIFI_MODE_FULL_LOW_LATENCY, "Baresip")
wifiLock.setReferenceCounted(false) wifiLock.setReferenceCounted(false)
bluetoothReceiver = object : BroadcastReceiver() { bluetoothReceiver = object : BroadcastReceiver() {
@@ -1155,6 +1161,9 @@ class BaresipService: Service() {
.setCustomContentView(notificationLayout) .setCustomContentView(notificationLayout)
if (VERSION.SDK_INT >= 31) if (VERSION.SDK_INT >= 31)
snb.foregroundServiceBehavior = Notification.FOREGROUND_SERVICE_DEFAULT snb.foregroundServiceBehavior = Notification.FOREGROUND_SERVICE_DEFAULT
if (VERSION.SDK_INT >= 29)
startForeground(STATUS_NOTIFICATION_ID, snb.build(), FOREGROUND_SERVICE_TYPE_PHONE_CALL)
else
startForeground(STATUS_NOTIFICATION_ID, snb.build()) startForeground(STATUS_NOTIFICATION_ID, snb.build())
} }
@@ -1614,6 +1623,7 @@ class BaresipService: Service() {
private fun isBluetoothScoOn(am: AudioManager): Boolean { private fun isBluetoothScoOn(am: AudioManager): Boolean {
return if (VERSION.SDK_INT < 31) return if (VERSION.SDK_INT < 31)
@Suppress("DEPRECATION")
am.isBluetoothScoOn am.isBluetoothScoOn
else else
if (am.communicationDevice != null) if (am.communicationDevice != null)
@@ -1631,6 +1641,7 @@ class BaresipService: Service() {
Log.d(TAG, "Starting Bluetooth SCO at count $count") Log.d(TAG, "Starting Bluetooth SCO at count $count")
Handler(Looper.getMainLooper()).postDelayed({ Handler(Looper.getMainLooper()).postDelayed({
if (VERSION.SDK_INT < 31) { if (VERSION.SDK_INT < 31) {
@Suppress("DEPRECATION")
am.startBluetoothSco() am.startBluetoothSco()
} else { } else {
Utils.setCommunicationDevice(am, AudioDeviceInfo.TYPE_BLUETOOTH_SCO) Utils.setCommunicationDevice(am, AudioDeviceInfo.TYPE_BLUETOOTH_SCO)
@@ -1651,6 +1662,7 @@ class BaresipService: Service() {
} }
Handler(Looper.getMainLooper()).postDelayed({ Handler(Looper.getMainLooper()).postDelayed({
if (VERSION.SDK_INT < 31) if (VERSION.SDK_INT < 31)
@Suppress("DEPRECATION")
am.stopBluetoothSco() am.stopBluetoothSco()
else else
am.clearCommunicationDevice() am.clearCommunicationDevice()
@@ -37,10 +37,10 @@ open class OnSwipeTouchListener(ctx: Context) : View.OnTouchListener {
return true return true
} }
override fun onFling(e1: MotionEvent, e2: MotionEvent, velX: Float, velY: Float): Boolean { override fun onFling(e1: MotionEvent?, e2: MotionEvent, velX: Float, velY: Float): Boolean {
var result = false var result = false
try { try {
val diffY = e2.y - e1.y val diffY = e2.y - e1!!.y
val diffX = e2.x - e1.x val diffX = e2.x - e1.x
if (abs(diffX) > abs(diffY)) { if (abs(diffX) > abs(diffY)) {
if (abs(diffX) > SWIPE_THRESHOLD && abs(velX) > SWIPE_VELOCITY_THRESHOLD) { if (abs(diffX) > SWIPE_THRESHOLD && abs(velX) > SWIPE_VELOCITY_THRESHOLD) {
+2 -1
View File
@@ -7,7 +7,8 @@ buildscript {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:8.0.2' //noinspection AndroidGradlePluginVersion
classpath 'com.android.tools.build:gradle:8.1.0-alpha09'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files