|
|
|
@ -28,7 +28,6 @@ import android.text.TextUtils;
|
|
|
|
|
import android.view.Menu;
|
|
|
|
|
import android.view.MenuItem;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
|
|
|
|
import org.apache.commons.lang3.text.WordUtils;
|
|
|
|
@ -86,23 +85,39 @@ public class DebugInfoActivity extends AppCompatActivity implements LoaderManage
|
|
|
|
|
sendIntent.setType("text/plain");
|
|
|
|
|
sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name) + " " + BuildConfig.VERSION_NAME + " debug info");
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
File debugInfoDir = new File(getCacheDir(), "debug-info");
|
|
|
|
|
debugInfoDir.mkdir();
|
|
|
|
|
// since Android 4.1, FileProvider permissions are handled in a useful way (using ClipData)
|
|
|
|
|
boolean asAttachment = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
|
|
|
|
|
|
|
|
|
|
reportFile = new File(debugInfoDir, "debug.txt");
|
|
|
|
|
App.log.fine("Writing debug info to " + reportFile.getAbsolutePath());
|
|
|
|
|
FileWriter writer = new FileWriter(reportFile);
|
|
|
|
|
writer.write(report);
|
|
|
|
|
writer.close();
|
|
|
|
|
if (asAttachment)
|
|
|
|
|
try {
|
|
|
|
|
File debugInfoDir = new File(getCacheDir(), "debug-info");
|
|
|
|
|
debugInfoDir.mkdir();
|
|
|
|
|
|
|
|
|
|
reportFile = new File(debugInfoDir, "debug.txt");
|
|
|
|
|
App.log.fine("Writing debug info to " + reportFile.getAbsolutePath());
|
|
|
|
|
FileWriter writer = new FileWriter(reportFile);
|
|
|
|
|
writer.write(report);
|
|
|
|
|
writer.close();
|
|
|
|
|
|
|
|
|
|
sendIntent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(this, getString(R.string.authority_log_provider), reportFile));
|
|
|
|
|
sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
|
|
|
|
|
|
|
|
} catch(IOException e) {
|
|
|
|
|
// creating an attachment failed, so send it inline
|
|
|
|
|
asAttachment = false;
|
|
|
|
|
|
|
|
|
|
StringBuilder builder = new StringBuilder();
|
|
|
|
|
builder .append("Couldn't write debug info file:\n")
|
|
|
|
|
.append(ExceptionUtils.getStackTrace(e))
|
|
|
|
|
.append("\n\n")
|
|
|
|
|
.append(report);
|
|
|
|
|
report = builder.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sendIntent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(this, getString(R.string.authority_log_provider), reportFile));
|
|
|
|
|
if (!asAttachment)
|
|
|
|
|
sendIntent.putExtra(Intent.EXTRA_TEXT, report);
|
|
|
|
|
|
|
|
|
|
startActivity(Intent.createChooser(sendIntent, null));
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
App.log.log(Level.SEVERE, "Couldn't write debug info file", e);
|
|
|
|
|
Toast.makeText(this, e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
|
|
|
|
|
}
|
|
|
|
|
startActivity(Intent.createChooser(sendIntent, null));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|