1
0
mirror of https://github.com/etesync/android synced 2024-12-27 00:48:12 +00:00

Amend DebugInfoActivity

* write report to temporary file in external cache dir before sending
* don't delete the report file onActivityResult (because services like the email service may access it asynchronously)
* don't show label of installer (just the package name), because some use ambiguous strings like "App Store" etc.
* show sync. settings for all accounts again
This commit is contained in:
Ricki Hirner 2015-11-07 14:03:22 +01:00
parent 4a00ba647d
commit 241e15404f
No known key found for this signature in database
GPG Key ID: C4A212CF0B2B4566
3 changed files with 24 additions and 33 deletions

View File

@ -10,7 +10,7 @@ apply plugin: 'com.android.application'
android { android {
compileSdkVersion 23 compileSdkVersion 23
buildToolsVersion '23.0.1' buildToolsVersion '23.0.2'
defaultConfig { defaultConfig {
applicationId "at.bitfire.davdroid" applicationId "at.bitfire.davdroid"

View File

@ -9,6 +9,7 @@
package at.bitfire.davdroid.ui; package at.bitfire.davdroid.ui;
import android.accounts.Account; import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.Activity; import android.app.Activity;
import android.app.LoaderManager; import android.app.LoaderManager;
import android.content.AsyncTaskLoader; import android.content.AsyncTaskLoader;
@ -16,11 +17,11 @@ import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.Loader; import android.content.Loader;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.provider.CalendarContract;
import android.provider.ContactsContract; import android.provider.ContactsContract;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.Menu; import android.view.Menu;
@ -28,6 +29,7 @@ import android.view.MenuItem;
import android.widget.TextView; import android.widget.TextView;
import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.commons.lang3.text.WordUtils;
import java.io.File; import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
@ -37,6 +39,7 @@ import at.bitfire.dav4android.exception.HttpException;
import at.bitfire.davdroid.BuildConfig; import at.bitfire.davdroid.BuildConfig;
import at.bitfire.davdroid.Constants; import at.bitfire.davdroid.Constants;
import at.bitfire.davdroid.R; import at.bitfire.davdroid.R;
import at.bitfire.davdroid.syncadapter.AccountSettings;
public class DebugInfoActivity extends Activity implements LoaderManager.LoaderCallbacks<String> { public class DebugInfoActivity extends Activity implements LoaderManager.LoaderCallbacks<String> {
public static final String public static final String
@ -74,8 +77,9 @@ public class DebugInfoActivity extends Activity implements LoaderManager.LoaderC
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "DAVdroid Exception Details"); sendIntent.putExtra(Intent.EXTRA_SUBJECT, "DAVdroid Exception Details");
try { try {
File reportFile = reportFile(); File reportFile = File.createTempFile("davdroid-debug", ".txt", getExternalCacheDir());
FileWriter writer = new FileWriter(reportFile()); Constants.log.debug("Writing debug info to " + reportFile.getAbsolutePath());
FileWriter writer = new FileWriter(reportFile);
writer.write(report); writer.write(report);
writer.close(); writer.close();
@ -89,15 +93,6 @@ public class DebugInfoActivity extends Activity implements LoaderManager.LoaderC
} }
} }
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
reportFile().delete();
}
File reportFile() {
return new File(getExternalCacheDir(), "error-report.txt");
}
@Override @Override
public Loader<String> onCreateLoader(int id, Bundle args) { public Loader<String> onCreateLoader(int id, Bundle args) {
@ -179,11 +174,6 @@ public class DebugInfoActivity extends Activity implements LoaderManager.LoaderC
String installedFrom = pm.getInstallerPackageName(BuildConfig.APPLICATION_ID); String installedFrom = pm.getInstallerPackageName(BuildConfig.APPLICATION_ID);
if (TextUtils.isEmpty(installedFrom)) if (TextUtils.isEmpty(installedFrom))
installedFrom = "APK (directly)"; installedFrom = "APK (directly)";
else {
PackageInfo installer = pm.getPackageInfo(installedFrom, PackageManager.GET_META_DATA);
if (installer != null)
installedFrom = pm.getApplicationLabel(installer.applicationInfo).toString();
}
boolean workaroundInstalled = false; boolean workaroundInstalled = false;
try { try {
workaroundInstalled = pm.getPackageInfo("at.bitfire.davdroid.jbworkaround", 0) != null; workaroundInstalled = pm.getPackageInfo("at.bitfire.davdroid.jbworkaround", 0) != null;
@ -200,25 +190,25 @@ public class DebugInfoActivity extends Activity implements LoaderManager.LoaderC
report.append( report.append(
"CONFIGURATION\n" + "CONFIGURATION\n" +
"System-wide synchronization: " + (ContentResolver.getMasterSyncAutomatically() ? "automatically" : "manually") + "\n\n" "System-wide synchronization: " + (ContentResolver.getMasterSyncAutomatically() ? "automatically" : "manually") + "\n"
); );
/* TODO
AccountManager accountManager = AccountManager.get(getContext()); AccountManager accountManager = AccountManager.get(getContext());
for (Account acc : accountManager.getAccountsByType(Constants.ACCOUNT_TYPE)) { for (Account acct : accountManager.getAccountsByType(Constants.ACCOUNT_TYPE)) {
AccountSettings settings = new AccountSettings(getContext(), acct);
report.append( report.append(
" Account: " + acc.name + "\n" + "Account: " + acct.name + "\n" +
" Address book synchronization: " + syncStatus(acc, ContactsContract.AUTHORITY) + "\n" + " Address book sync. interval: " + syncStatus(settings, ContactsContract.AUTHORITY) + "\n" +
" Calendar synchronization: " + syncStatus(acc, CalendarContract.AUTHORITY) + "\n" + " Calendar sync. interval: " + syncStatus(settings, CalendarContract.AUTHORITY) + "\n" +
" OpenTasks synchronization: " + syncStatus(acc, "org.dmfs.tasks") + "\n" " OpenTasks sync. interval: " + syncStatus(settings, "org.dmfs.tasks") + "\n"
); );
}*/ }
report.append("\n"); report.append("\n");
try { try {
report.append( report.append(
"SYSTEM INFORMATION\n" + "SYSTEM INFORMATION\n" +
"Android version: " + Build.VERSION.RELEASE + " (" + Build.DISPLAY + ")\n" + "Android version: " + Build.VERSION.RELEASE + " (" + Build.DISPLAY + ")\n" +
"Device: " + Build.MANUFACTURER + " / " + Build.MODEL + " (" + Build.DEVICE + ")\n\n" "Device: " + WordUtils.capitalize(Build.MANUFACTURER) + " " + Build.MODEL + " (" + Build.DEVICE + ")\n\n"
); );
} catch (Exception ex) { } catch (Exception ex) {
Constants.log.error("Couldn't get system details", ex); Constants.log.error("Couldn't get system details", ex);
@ -227,9 +217,10 @@ public class DebugInfoActivity extends Activity implements LoaderManager.LoaderC
return report.toString(); return report.toString();
} }
protected String syncStatus(Account account, String authority) { protected String syncStatus(AccountSettings settings, String authority) {
return ContentResolver.getIsSyncable(account, authority) > 0 ? Long interval = settings.getSyncInterval(authority);
(ContentResolver.getSyncAutomatically(account, ContactsContract.AUTHORITY) ? "automatically" : "manually") : return interval != null ?
(interval == AccountSettings.SYNC_INTERVAL_MANUALLY ? "manually" : interval/60 + " min") :
""; "";
} }
} }

View File

@ -1,6 +1,6 @@
#Fri Oct 09 23:40:23 CEST 2015 #Fri Oct 30 11:00:03 CET 2015
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip