Fix log reporting for release builds (#1916)

* Fix log reporting for release builds

* Fix logs for release builds

* wip

* Clean up the branch to exclude unrelated changes

* With java docs

* Uncomment quiz checker

* Check for external storage permissions before sending logs

* With more java docs

* Fix crash while zipping log files

* Do not log token and cookies

* Add instruction to restart app
This commit is contained in:
Vivek Maskara 2018-10-14 16:49:43 +05:30 committed by Josephine Lim
parent 02fe0044a6
commit b0b4b08100
28 changed files with 761 additions and 136 deletions

View file

@ -148,39 +148,6 @@ public class Utils {
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("theme", false);
}
/**
* Will be used to fetch the logs generated by the app ever since the beginning of times....
* i.e. since the time the app started.
*
* @return String containing all the logs since the time the app started
*/
public static String getAppLogs() {
final String processId = Integer.toString(android.os.Process.myPid());
StringBuilder stringBuilder = new StringBuilder();
try {
String[] command = new String[]{"logcat","-d","-v","threadtime"};
Process process = Runtime.getRuntime().exec(command);
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(process.getInputStream())
);
String line;
while ((line = bufferedReader.readLine()) != null) {
if (line.contains(processId)) {
stringBuilder.append(line);
}
}
} catch (IOException ioe) {
Timber.e("getAppLogs failed", ioe);
}
return stringBuilder.toString();
}
public static void rateApp(Context context) {
final String appPackageName = BuildConfig.class.getPackage().getName();
try {