diff --git a/res/values/non_localizable_custom.xml b/res/values/non_localizable_custom.xml
index 11b0698f2..4b9a5905a 100644
--- a/res/values/non_localizable_custom.xml
+++ b/res/values/non_localizable_custom.xml
@@ -55,6 +55,7 @@
true
+ false
false
false
false
diff --git a/src/org/linphone/AboutFragment.java b/src/org/linphone/AboutFragment.java
index 1d1d2617a..7a8130d8a 100644
--- a/src/org/linphone/AboutFragment.java
+++ b/src/org/linphone/AboutFragment.java
@@ -69,7 +69,12 @@ public class AboutFragment extends Fragment implements OnClickListener {
@Override
public void onClick(View v) {
if (LinphoneActivity.isInstanciated()) {
- LinphoneActivity.instance().exit();
+
+ if (getResources().getBoolean(R.bool.enable_log_collect)) {
+ LinphoneUtils.collectLogs(getString(R.string.app_name), getString(R.string.about_bugreport_email));
+ } else {
+ LinphoneActivity.instance().exit();
+ }
}
}
}
diff --git a/src/org/linphone/LinphoneManager.java b/src/org/linphone/LinphoneManager.java
index b9ce0b14c..96ddd636f 100644
--- a/src/org/linphone/LinphoneManager.java
+++ b/src/org/linphone/LinphoneManager.java
@@ -192,6 +192,10 @@ public class LinphoneManager implements LinphoneCoreListener {
mConnectivityManager = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE);
mR = c.getResources();
+ if (mR.getBoolean(R.bool.enable_log_collect)) {
+ LinphoneUtils.clearLogs();
+ }
+
chatStorage = new ChatStorage(mServiceContext);
}
@@ -341,7 +345,7 @@ public class LinphoneManager implements LinphoneCoreListener {
Context c, LinphoneServiceListener listener) {
if (instance != null)
throw new RuntimeException("Linphone Manager is already initialized");
-
+
instance = new LinphoneManager(c, listener);
instance.startLibLinphone(c);
TelephonyManager tm = (TelephonyManager) c.getSystemService(Context.TELEPHONY_SERVICE);
diff --git a/src/org/linphone/LinphoneUtils.java b/src/org/linphone/LinphoneUtils.java
index 97af9bda3..321285430 100644
--- a/src/org/linphone/LinphoneUtils.java
+++ b/src/org/linphone/LinphoneUtils.java
@@ -21,8 +21,10 @@ package org.linphone;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
+import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
@@ -325,5 +327,42 @@ public final class LinphoneUtils {
return false;
}
}
+
+ public static void clearLogs() {
+ try {
+ Runtime.getRuntime().exec(new String[] { "logcat", "-c" });
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void collectLogs(String logTag, String email) {
+ BufferedReader br = null;
+ Process p = null;
+ StringBuilder sb = new StringBuilder();
+
+ try {
+ p = Runtime.getRuntime().exec(new String[] { "logcat", "-d", "|", "grep", "`adb shell ps | grep org.linphone | cut -c10-15`" });
+ br = new BufferedReader(new InputStreamReader(p.getInputStream()), 2048);
+
+ String line;
+ while ((line = br.readLine()) != null) {
+ sb.append(line);
+ sb.append("\r\n");
+ }
+
+ Intent i = new Intent(Intent.ACTION_SEND);
+ i.setType("message/rfc822");
+ i.putExtra(Intent.EXTRA_EMAIL, new String[]{email});
+ i.putExtra(Intent.EXTRA_SUBJECT, "Linphone Logs");
+ i.putExtra(Intent.EXTRA_TEXT, sb.toString());
+ try {
+ LinphoneActivity.instance().startActivity(Intent.createChooser(i, "Send mail..."));
+ } catch (android.content.ActivityNotFoundException ex) {
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
}