From d45c8b76a64ab22cad7c1b110db1f152f5e599b7 Mon Sep 17 00:00:00 2001
From: Sylvain Berfini <sylvain.berfini@belledonne-communications.com>
Date: Thu, 20 Mar 2025 23:17:13 +0100
Subject: [PATCH] Do not check if ringtone file exists on Android

---
 coreapi/linphonecore.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c
index 89a3c8bb1b..ec4fd0b755 100644
--- a/coreapi/linphonecore.c
+++ b/coreapi/linphonecore.c
@@ -1669,20 +1669,26 @@ static void sound_config_read(LinphoneCore *lc) {
 	*/
 
 	bool_t default_native_ringing_value = FALSE;
+	bool_t check_if_ringing_file_exists = TRUE;
 #ifdef __ANDROID__
 	default_native_ringing_value = TRUE;
+	check_if_ringing_file_exists = FALSE;
 #endif
 	lc->native_ringing_enabled =
 	    !!linphone_config_get_int(lc->config, "sound", "use_native_ringing", default_native_ringing_value);
 
 	tmpbuf = linphone_config_get_string(lc->config, "sound", "local_ring", NULL);
 	if (tmpbuf) {
-		if (bctbx_file_exist(tmpbuf) == 0) {
-			linphone_core_set_ring(lc, tmpbuf);
+		if (check_if_ringing_file_exists) {
+			if (bctbx_file_exist(tmpbuf) == 0) {
+				linphone_core_set_ring(lc, tmpbuf);
+			} else {
+				string soundResource = static_cast<PlatformHelpers *>(lc->platform_helper)->getSoundResource(tmpbuf);
+				if (bctbx_file_exist(soundResource.c_str()) == 0) linphone_core_set_ring(lc, soundResource.c_str());
+				else ms_warning("'%s' ring file does not exist", tmpbuf);
+			}
 		} else {
-			string soundResource = static_cast<PlatformHelpers *>(lc->platform_helper)->getSoundResource(tmpbuf);
-			if (bctbx_file_exist(soundResource.c_str()) == 0) linphone_core_set_ring(lc, soundResource.c_str());
-			else ms_warning("'%s' ring file does not exist", tmpbuf);
+			linphone_core_set_ring(lc, tmpbuf);
 		}
 	} else {
 #ifdef __ANDROID__
-- 
GitLab