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