- fixed bug in checking of record audio permission
- do not load baresip lib if it has already been loaded - removed call uri adapter when call comes in
This commit is contained in:
@ -7,8 +7,8 @@ android {
|
||||
applicationId = 'com.tutpro.baresip'
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 27
|
||||
versionCode = 34
|
||||
versionName = '4.1.0'
|
||||
versionCode = 35
|
||||
versionName = '4.1.1'
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
cFlags '-DHAVE_INTTYPES_H'
|
||||
|
||||
@ -329,6 +329,8 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) {
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_tutpro_baresip_BaresipService_baresipStart(JNIEnv *env, jobject instance, jstring javaPath) {
|
||||
|
||||
LOGD("Starting baresip\n");
|
||||
|
||||
BaresipContext *pctx = (BaresipContext *)(&g_ctx);
|
||||
JavaVM *javaVM = pctx->javaVM;
|
||||
jint res = (*javaVM)->GetEnv(javaVM, (void **) &env, JNI_VERSION_1_6);
|
||||
|
||||
@ -218,7 +218,7 @@ class BaresipService: Service() {
|
||||
|
||||
@Keep
|
||||
fun uaAdd(uap: String) {
|
||||
Log.d(LOG_TAG, "addUA at BaresipService")
|
||||
Log.d(LOG_TAG, "uaAdd at BaresipService")
|
||||
val ua = UserAgent(uap)
|
||||
uas.add(ua)
|
||||
if (Api.ua_isregistered(uap)) {
|
||||
@ -641,6 +641,7 @@ class BaresipService: Service() {
|
||||
var isServiceRunning = false
|
||||
var disconnected = false
|
||||
var forceStop = false
|
||||
var libraryLoaded = false
|
||||
|
||||
var uas = ArrayList<UserAgent>()
|
||||
var status = ArrayList<Int>()
|
||||
@ -655,7 +656,10 @@ class BaresipService: Service() {
|
||||
}
|
||||
|
||||
init {
|
||||
Log.d(LOG_TAG, "Loading baresip library")
|
||||
System.loadLibrary("baresip")
|
||||
if (!libraryLoaded) {
|
||||
Log.d("Baresip", "Loading baresip library")
|
||||
System.loadLibrary("baresip")
|
||||
libraryLoaded = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,15 +63,6 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
if (ContextCompat.checkSelfPermission(applicationContext,
|
||||
Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_DENIED) {
|
||||
Toast.makeText(applicationContext,"You have not granted microphone permission.",
|
||||
Toast.LENGTH_SHORT).show()
|
||||
finishAndRemoveTask()
|
||||
System.exit(0)
|
||||
return
|
||||
}
|
||||
|
||||
layout = findViewById(R.id.mainActivityLayout) as RelativeLayout
|
||||
callTitle = findViewById(R.id.callTitle) as TextView
|
||||
callUri = findViewById(R.id.callUri) as AutoCompleteTextView
|
||||
@ -166,12 +157,11 @@ class MainActivity : AppCompatActivity() {
|
||||
false
|
||||
}
|
||||
}
|
||||
callUri.setAdapter(ArrayAdapter(this, android.R.layout.select_dialog_item,
|
||||
Contact.contacts().map{Contact -> Contact.name}))
|
||||
callUri.threshold = 2
|
||||
|
||||
ContactsActivity.restoreContacts(applicationContext.filesDir.absolutePath)
|
||||
callUri.setAdapter(ArrayAdapter(this, android.R.layout.select_dialog_item,
|
||||
Contact.contacts().map{Contact -> Contact.name}))
|
||||
callUri.threshold = 2
|
||||
|
||||
securityButton.setOnClickListener {
|
||||
when (securityButton.tag) {
|
||||
@ -417,6 +407,15 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
"call incoming" -> {
|
||||
val callp = params[1]
|
||||
if (ContextCompat.checkSelfPermission(applicationContext,
|
||||
Manifest.permission.RECORD_AUDIO) ==
|
||||
PackageManager.PERMISSION_DENIED) {
|
||||
Toast.makeText(applicationContext,
|
||||
"You have not granted microphone permission.",
|
||||
Toast.LENGTH_SHORT).show()
|
||||
Api.ua_hangup(uap, callp, 486, "Busy Here")
|
||||
return
|
||||
}
|
||||
val call = Call.find(callp)
|
||||
if (call == null) {
|
||||
Log.e("Baresip", "Incoming call $callp not found")
|
||||
@ -426,6 +425,7 @@ class MainActivity : AppCompatActivity() {
|
||||
aorSpinner.setSelection(account_index)
|
||||
} else {
|
||||
callTitle.text = "Incoming call from ..."
|
||||
callUri.setAdapter(null)
|
||||
callUri.setText(Utils.friendlyUri(ContactsActivity.contactName(call.peerURI),
|
||||
Utils.aorDomain(ua.account.aor)))
|
||||
securityButton.visibility = View.INVISIBLE
|
||||
@ -1086,7 +1086,11 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
init {
|
||||
Log.d("Baresip", "Loading baresip library")
|
||||
System.loadLibrary("baresip")
|
||||
if (!BaresipService.libraryLoaded) {
|
||||
Log.d("Baresip", "Loading baresip library")
|
||||
System.loadLibrary("baresip")
|
||||
BaresipService.libraryLoaded = true
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user