Fix first read of debug value and enable/disable logs accordingly

This commit is contained in:
Sylvain Berfini 2016-05-11 15:48:04 +02:00
parent 06089a8ed8
commit 5f19770910
5 changed files with 32 additions and 4 deletions

View file

@ -14,6 +14,7 @@ size=vga
[app]
tunnel=disabled
push_notification=1
debug=0
[tunnel]
host=

View file

@ -15,6 +15,7 @@ size=qvga
tunnel=disabled
push_notification=1
auto_start=1
debug=0
[tunnel]
host=

View file

@ -19,6 +19,12 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneAddress.TransportType;
import org.linphone.core.LinphoneAuthInfo;
@ -81,7 +87,25 @@ public class LinphonePreferences {
}
if (!LinphoneManager.isInstanciated()) {
return LinphoneCoreFactory.instance().createLpConfig(mContext.getFilesDir().getAbsolutePath() + "/.linphonerc");
File linphonerc = new File(mContext.getFilesDir().getAbsolutePath() + "/.linphonerc");
if (linphonerc.exists()) {
return LinphoneCoreFactory.instance().createLpConfig(linphonerc.getAbsolutePath());
} else {
InputStream inputStream = mContext.getResources().openRawResource(R.raw.linphonerc_default);
InputStreamReader inputreader = new InputStreamReader(inputStream);
BufferedReader buffreader = new BufferedReader(inputreader);
StringBuilder text = new StringBuilder();
String line;
try {
while ((line = buffreader.readLine()) != null) {
text.append(line);
text.append('\n');
}
} catch (IOException ioe) {
}
return LinphoneCoreFactory.instance().createLpConfigFromString(text.toString());
}
}
return LinphoneCoreFactory.instance().createLpConfig(LinphoneManager.getInstance().mLinphoneConfigFile);

View file

@ -135,9 +135,11 @@ public final class LinphoneService extends Service {
mNotificationTitle = getString(R.string.service_name);
// Needed in order for the two next calls to succeed, libraries must have been loaded first
LinphonePreferences.instance().setContext(getApplicationContext());
LinphonePreferences.instance().setContext(getBaseContext());
LinphoneCoreFactory.instance().setLogCollectionPath(getFilesDir().getAbsolutePath());
LinphoneCoreFactory.instance().enableLogCollection(LinphonePreferences.instance().isDebugEnabled());
boolean isDebugEnabled = LinphonePreferences.instance().isDebugEnabled();
LinphoneCoreFactory.instance().enableLogCollection(isDebugEnabled);
LinphoneCoreFactory.instance().setDebugMode(isDebugEnabled, getString(R.string.app_name));
// Dump some debugging information to the logs
Log.i(START_LINPHONE_LOGS);

@ -1 +1 @@
Subproject commit 5872dddc3c49838899a1eec80cbb61eaa0fbf299
Subproject commit 618661f0b72e8a0284afd779ba4773e3e80af5da