Now minimum supported Android version is 6 (API level 23)
This commit is contained in:
+2
-2
@@ -7,7 +7,7 @@ android {
|
|||||||
ndkVersion = '25.1.8937393'
|
ndkVersion = '25.1.8937393'
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId = 'com.tutpro.baresip'
|
applicationId = 'com.tutpro.baresip'
|
||||||
minSdkVersion 21
|
minSdkVersion 23
|
||||||
targetSdkVersion 33
|
targetSdkVersion 33
|
||||||
versionCode = 275
|
versionCode = 275
|
||||||
versionName = '53.2.3'
|
versionName = '53.2.3'
|
||||||
@@ -64,7 +64,7 @@ dependencies {
|
|||||||
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
|
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
|
||||||
implementation "androidx.preference:preference-ktx:1.2.0"
|
implementation "androidx.preference:preference-ktx:1.2.0"
|
||||||
implementation "androidx.exifinterface:exifinterface:1.3.6"
|
implementation "androidx.exifinterface:exifinterface:1.3.6"
|
||||||
implementation "androidx.core:core-ktx:1.9.0"
|
implementation "androidx.core:core-ktx:1.10.0"
|
||||||
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.7.0"
|
implementation "androidx.activity:activity-ktx:1.7.0"
|
||||||
|
|||||||
@@ -701,13 +701,9 @@ class BaresipService: Service() {
|
|||||||
Log.d(TAG, "Incoming call $uap/$callp/$peerUri")
|
Log.d(TAG, "Incoming call $uap/$callp/$peerUri")
|
||||||
Call(callp, ua, peerUri, "in", "incoming", Utils.dtmfWatcher(callp)).add()
|
Call(callp, ua, peerUri, "in", "incoming", Utils.dtmfWatcher(callp)).add()
|
||||||
if (ua.account.answerMode == Api.ANSWERMODE_MANUAL) {
|
if (ua.account.answerMode == Api.ANSWERMODE_MANUAL) {
|
||||||
if (VERSION.SDK_INT >= 23) {
|
|
||||||
Log.d(TAG, "CurrentInterruptionFilter ${nm.currentInterruptionFilter}")
|
Log.d(TAG, "CurrentInterruptionFilter ${nm.currentInterruptionFilter}")
|
||||||
if (nm.currentInterruptionFilter <= NotificationManager.INTERRUPTION_FILTER_ALL)
|
if (nm.currentInterruptionFilter <= NotificationManager.INTERRUPTION_FILTER_ALL)
|
||||||
startRinging()
|
startRinging()
|
||||||
} else {
|
|
||||||
startRinging()
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
val newIntent = Intent(this, MainActivity::class.java)
|
val newIntent = Intent(this, MainActivity::class.java)
|
||||||
newIntent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP or
|
newIntent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP or
|
||||||
@@ -719,10 +715,7 @@ class BaresipService: Service() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!Utils.isVisible()) {
|
if (!Utils.isVisible()) {
|
||||||
val piFlags = if (VERSION.SDK_INT >= 23)
|
val piFlags = PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
|
||||||
else
|
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT
|
|
||||||
val intent = Intent(applicationContext, MainActivity::class.java)
|
val intent = Intent(applicationContext, MainActivity::class.java)
|
||||||
intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP or
|
intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP or
|
||||||
Intent.FLAG_ACTIVITY_NEW_TASK
|
Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
@@ -827,10 +820,7 @@ class BaresipService: Service() {
|
|||||||
}
|
}
|
||||||
"call transfer" -> {
|
"call transfer" -> {
|
||||||
if (!Utils.isVisible()) {
|
if (!Utils.isVisible()) {
|
||||||
val piFlags = if (VERSION.SDK_INT >= 23)
|
val piFlags = PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
|
||||||
else
|
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT
|
|
||||||
val intent = Intent(applicationContext, MainActivity::class.java)
|
val intent = Intent(applicationContext, MainActivity::class.java)
|
||||||
intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or
|
intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or
|
||||||
Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK
|
Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
@@ -917,10 +907,7 @@ class BaresipService: Service() {
|
|||||||
}
|
}
|
||||||
if (!Utils.isVisible()) {
|
if (!Utils.isVisible()) {
|
||||||
if (missed) {
|
if (missed) {
|
||||||
val piFlags = if (VERSION.SDK_INT >= 23)
|
val piFlags = PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
|
||||||
else
|
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT
|
|
||||||
val caller = Utils.friendlyUri(this, call.peerUri, ua.account)
|
val caller = Utils.friendlyUri(this, call.peerUri, ua.account)
|
||||||
val intent = Intent(applicationContext, MainActivity::class.java)
|
val intent = Intent(applicationContext, MainActivity::class.java)
|
||||||
intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or
|
intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or
|
||||||
@@ -935,10 +922,6 @@ class BaresipService: Service() {
|
|||||||
.setContentIntent(pi)
|
.setContentIntent(pi)
|
||||||
.setCategory(Notification.CATEGORY_CALL)
|
.setCategory(Notification.CATEGORY_CALL)
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
if (VERSION.SDK_INT < 23) {
|
|
||||||
nb.setContentTitle(getString(R.string.missed_call_from))
|
|
||||||
nb.setContentText(caller)
|
|
||||||
} else {
|
|
||||||
var missedCalls = 0
|
var missedCalls = 0
|
||||||
for (notification in nm.activeNotifications)
|
for (notification in nm.activeNotifications)
|
||||||
if (notification.id == CALL_MISSED_NOTIFICATION_ID)
|
if (notification.id == CALL_MISSED_NOTIFICATION_ID)
|
||||||
@@ -952,7 +935,6 @@ class BaresipService: Service() {
|
|||||||
String.format(getString(R.string.missed_calls_count),
|
String.format(getString(R.string.missed_calls_count),
|
||||||
missedCalls + 1))
|
missedCalls + 1))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (VERSION.SDK_INT < 26) {
|
if (VERSION.SDK_INT < 26) {
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
nb.setVibrate(LongArray(0))
|
nb.setVibrate(LongArray(0))
|
||||||
@@ -1012,10 +994,7 @@ class BaresipService: Service() {
|
|||||||
Message.save()
|
Message.save()
|
||||||
ua.account.unreadMessages = true
|
ua.account.unreadMessages = true
|
||||||
if (!Utils.isVisible()) {
|
if (!Utils.isVisible()) {
|
||||||
val piFlags = if (VERSION.SDK_INT >= 23)
|
val piFlags = PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
|
||||||
else
|
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT
|
|
||||||
val intent = Intent(applicationContext, MainActivity::class.java)
|
val intent = Intent(applicationContext, MainActivity::class.java)
|
||||||
intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP or
|
intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP or
|
||||||
Intent.FLAG_ACTIVITY_NEW_TASK
|
Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
@@ -1062,11 +1041,8 @@ class BaresipService: Service() {
|
|||||||
nm.notify(MESSAGE_NOTIFICATION_ID, nb.build())
|
nm.notify(MESSAGE_NOTIFICATION_ID, nb.build())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (VERSION.SDK_INT >= 23) {
|
|
||||||
if (nm.currentInterruptionFilter <= NotificationManager.INTERRUPTION_FILTER_ALL)
|
if (nm.currentInterruptionFilter <= NotificationManager.INTERRUPTION_FILTER_ALL)
|
||||||
nt.play()
|
nt.play()
|
||||||
} else
|
|
||||||
nt.play()
|
|
||||||
postServiceEvent(ServiceEvent("message show", arrayListOf(uap, peerUri), System.nanoTime()))
|
postServiceEvent(ServiceEvent("message show", arrayListOf(uap, peerUri), System.nanoTime()))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1098,7 +1074,6 @@ class BaresipService: Service() {
|
|||||||
Api.net_debug()
|
Api.net_debug()
|
||||||
postServiceEvent(ServiceEvent("started", arrayListOf(callActionUri), System.nanoTime()))
|
postServiceEvent(ServiceEvent("started", arrayListOf(callActionUri), System.nanoTime()))
|
||||||
callActionUri = ""
|
callActionUri = ""
|
||||||
if (VERSION.SDK_INT >= 23)
|
|
||||||
Log.d(TAG, "Battery optimizations are ignored: " +
|
Log.d(TAG, "Battery optimizations are ignored: " +
|
||||||
"${pm.isIgnoringBatteryOptimizations(packageName)}")
|
"${pm.isIgnoringBatteryOptimizations(packageName)}")
|
||||||
Log.d(TAG, "Partial wake lock/wifi lock is held: " +
|
Log.d(TAG, "Partial wake lock/wifi lock is held: " +
|
||||||
@@ -1140,11 +1115,8 @@ class BaresipService: Service() {
|
|||||||
val intent = Intent(applicationContext, MainActivity::class.java)
|
val intent = Intent(applicationContext, MainActivity::class.java)
|
||||||
.setAction(Intent.ACTION_MAIN)
|
.setAction(Intent.ACTION_MAIN)
|
||||||
.addCategory(Intent.CATEGORY_LAUNCHER)
|
.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||||
val pi = if (VERSION.SDK_INT >= 23)
|
val pi = PendingIntent.getActivity(applicationContext, STATUS_REQ_CODE, intent,
|
||||||
PendingIntent.getActivity(applicationContext, STATUS_REQ_CODE, intent,
|
|
||||||
PendingIntent.FLAG_IMMUTABLE)
|
PendingIntent.FLAG_IMMUTABLE)
|
||||||
else
|
|
||||||
PendingIntent.getActivity(applicationContext, STATUS_REQ_CODE, intent, 0)
|
|
||||||
val notificationLayout = RemoteViews(packageName, R.layout.status_notification)
|
val notificationLayout = RemoteViews(packageName, R.layout.status_notification)
|
||||||
snb.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
snb.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||||
.setSmallIcon(R.drawable.ic_stat)
|
.setSmallIcon(R.drawable.ic_stat)
|
||||||
@@ -1240,12 +1212,8 @@ class BaresipService: Service() {
|
|||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
if (am.getStreamVolume(AudioManager.STREAM_RING) != 0) {
|
if (am.getStreamVolume(AudioManager.STREAM_RING) != 0) {
|
||||||
if (VERSION.SDK_INT >= Build.VERSION_CODES.M) /* M == 23 */ {
|
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
Settings.System.getInt(contentResolver, Settings.System.VIBRATE_WHEN_RINGING, 0) == 1
|
Settings.System.getInt(contentResolver, Settings.System.VIBRATE_WHEN_RINGING, 0) == 1
|
||||||
} else {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
@@ -1370,7 +1338,7 @@ class BaresipService: Service() {
|
|||||||
removed++
|
removed++
|
||||||
}
|
}
|
||||||
|
|
||||||
val active = activeNetwork()
|
val active = cm.activeNetwork
|
||||||
Log.d(TAG, "Added/Removed/Active = $added/$removed/$active")
|
Log.d(TAG, "Added/Removed/Active = $added/$removed/$active")
|
||||||
|
|
||||||
if (added > 0 || removed > 0 || active != activeNetwork) {
|
if (added > 0 || removed > 0 || active != activeNetwork) {
|
||||||
@@ -1430,7 +1398,7 @@ class BaresipService: Service() {
|
|||||||
return
|
return
|
||||||
val servers = mutableListOf<InetAddress>()
|
val servers = mutableListOf<InetAddress>()
|
||||||
// Use DNS servers first from active network (if available)
|
// Use DNS servers first from active network (if available)
|
||||||
val activeNetwork = activeNetwork()
|
val activeNetwork = cm.activeNetwork
|
||||||
if (activeNetwork != null) {
|
if (activeNetwork != null) {
|
||||||
val linkProps = cm.getLinkProperties(activeNetwork)
|
val linkProps = cm.getLinkProperties(activeNetwork)
|
||||||
if (linkProps != null)
|
if (linkProps != null)
|
||||||
@@ -1438,7 +1406,7 @@ class BaresipService: Service() {
|
|||||||
}
|
}
|
||||||
// Then add DNS servers from the other networks
|
// Then add DNS servers from the other networks
|
||||||
for (n in allNetworks) {
|
for (n in allNetworks) {
|
||||||
if (isNetworkActive(n)) continue
|
if (n == cm.activeNetwork) continue
|
||||||
val linkProps = cm.getLinkProperties(n)
|
val linkProps = cm.getLinkProperties(n)
|
||||||
if (linkProps != null)
|
if (linkProps != null)
|
||||||
for (server in linkProps.dnsServers)
|
for (server in linkProps.dnsServers)
|
||||||
@@ -1455,25 +1423,6 @@ class BaresipService: Service() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun activeNetwork(): Network? {
|
|
||||||
return if (VERSION.SDK_INT >= 23)
|
|
||||||
cm.activeNetwork
|
|
||||||
else {
|
|
||||||
for (n in allNetworks)
|
|
||||||
if (isNetworkActive(n)) return n
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun isNetworkActive(network: Network): Boolean {
|
|
||||||
if (VERSION.SDK_INT >= 23)
|
|
||||||
return network == cm.activeNetwork
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
if ((cm.activeNetworkInfo != null) && (cm.getNetworkInfo(network) != null))
|
|
||||||
return cm.activeNetworkInfo!!.toString() == cm.getNetworkInfo(network)!!.toString()
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun registerContentObserver() {
|
private fun registerContentObserver() {
|
||||||
if (!contentObserverRegistered)
|
if (!contentObserverRegistered)
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -45,11 +45,8 @@ class BootCompletedReceiver : BroadcastReceiver() {
|
|||||||
val channel = NotificationChannel("default", "default",
|
val channel = NotificationChannel("default", "default",
|
||||||
NotificationManager.IMPORTANCE_DEFAULT)
|
NotificationManager.IMPORTANCE_DEFAULT)
|
||||||
nm.createNotificationChannel(channel)
|
nm.createNotificationChannel(channel)
|
||||||
val pi = if (Build.VERSION.SDK_INT >= 23)
|
val pi = PendingIntent.getActivity(context, 0, i,
|
||||||
PendingIntent.getActivity(context, 0, i,
|
|
||||||
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_ONE_SHOT)
|
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_ONE_SHOT)
|
||||||
else
|
|
||||||
PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_ONE_SHOT)
|
|
||||||
with(NotificationCompat.Builder(context, "default")) {
|
with(NotificationCompat.Builder(context, "default")) {
|
||||||
setSmallIcon(R.drawable.ic_stat)
|
setSmallIcon(R.drawable.ic_stat)
|
||||||
setContentTitle(context.getString(R.string.app_name))
|
setContentTitle(context.getString(R.string.app_name))
|
||||||
|
|||||||
@@ -93,7 +93,6 @@ class ConfigActivity : AppCompatActivity() {
|
|||||||
oldAutoStart = if (asCv.size == 0) "no" else asCv[0]
|
oldAutoStart = if (asCv.size == 0) "no" else asCv[0]
|
||||||
autoStart.isChecked = oldAutoStart == "yes"
|
autoStart.isChecked = oldAutoStart == "yes"
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 23) {
|
|
||||||
val pm = getSystemService(Context.POWER_SERVICE) as PowerManager
|
val pm = getSystemService(Context.POWER_SERVICE) as PowerManager
|
||||||
val androidSettingsRequest = registerForActivityResult(
|
val androidSettingsRequest = registerForActivityResult(
|
||||||
ActivityResultContracts.StartActivityForResult()
|
ActivityResultContracts.StartActivityForResult()
|
||||||
@@ -109,9 +108,6 @@ class ConfigActivity : AppCompatActivity() {
|
|||||||
Log.e(TAG, "ActivityNotFound exception: $e")
|
Log.e(TAG, "ActivityNotFound exception: $e")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
binding.Battery.visibility = View.GONE
|
|
||||||
}
|
|
||||||
|
|
||||||
listenAddr = binding.ListenAddress
|
listenAddr = binding.ListenAddress
|
||||||
val laCv = Config.variable("sip_listen")
|
val laCv = Config.variable("sip_listen")
|
||||||
@@ -352,8 +348,7 @@ class ConfigActivity : AppCompatActivity() {
|
|||||||
contactsSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
contactsSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) {
|
override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) {
|
||||||
contactsMode = contactsModeKeys[position]
|
contactsMode = contactsModeKeys[position]
|
||||||
if (contactsMode != "baresip" && Build.VERSION.SDK_INT >= 23 &&
|
if (contactsMode != "baresip" && !Utils.checkPermissions(applicationContext, contactsPermissions))
|
||||||
!Utils.checkPermissions(applicationContext, contactsPermissions))
|
|
||||||
with(MaterialAlertDialogBuilder(this@ConfigActivity, R.style.AlertDialogTheme)) {
|
with(MaterialAlertDialogBuilder(this@ConfigActivity, R.style.AlertDialogTheme)) {
|
||||||
setTitle(getText(R.string.consent_request))
|
setTitle(getText(R.string.consent_request))
|
||||||
setMessage(getText(R.string.contacts_consent))
|
setMessage(getText(R.string.contacts_consent))
|
||||||
|
|||||||
@@ -1215,8 +1215,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
if (acc.missedCalls)
|
if (acc.missedCalls)
|
||||||
callsButton.setImageResource(R.drawable.calls_missed)
|
callsButton.setImageResource(R.drawable.calls_missed)
|
||||||
}
|
}
|
||||||
if ((Build.VERSION.SDK_INT >= 22 && kgm.isDeviceLocked) ||
|
if (kgm.isDeviceLocked)
|
||||||
(Build.VERSION.SDK_INT < 22 && kgm.isKeyguardLocked && kgm.isKeyguardSecure))
|
|
||||||
Utils.setShowWhenLocked(this, false)
|
Utils.setShowWhenLocked(this, false)
|
||||||
}
|
}
|
||||||
"message", "message show", "message reply" -> {
|
"message", "message show", "message reply" -> {
|
||||||
|
|||||||
@@ -476,8 +476,6 @@ object Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun checkPermissions(ctx: Context, permissions: Array<String>) : Boolean {
|
fun checkPermissions(ctx: Context, permissions: Array<String>) : Boolean {
|
||||||
if (Build.VERSION.SDK_INT < 23)
|
|
||||||
return true
|
|
||||||
for (p in permissions) {
|
for (p in permissions) {
|
||||||
if (ContextCompat.checkSelfPermission(ctx, p) != PackageManager.PERMISSION_GRANTED) {
|
if (ContextCompat.checkSelfPermission(ctx, p) != PackageManager.PERMISSION_GRANTED) {
|
||||||
Log.d(TAG, "Permission $p is denied")
|
Log.d(TAG, "Permission $p is denied")
|
||||||
|
|||||||
Reference in New Issue
Block a user