diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-01-08 19:42:38 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-01-08 19:42:38 -0800 |
commit | 8a9b2032c2ca706f37a557406428989018177e50 (patch) | |
tree | 855493198708072b856a1a0f6762bb9629cb25f0 /subsonic-android | |
parent | c154f934673efed17a1e33ca179025df81fc9663 (diff) | |
download | dsub-8a9b2032c2ca706f37a557406428989018177e50.tar.gz dsub-8a9b2032c2ca706f37a557406428989018177e50.tar.bz2 dsub-8a9b2032c2ca706f37a557406428989018177e50.zip |
Added an internal logging mechanism for 4.2+
Diffstat (limited to 'subsonic-android')
-rw-r--r-- | subsonic-android/AndroidManifest.xml | 3 | ||||
-rw-r--r-- | subsonic-android/res/menu/main.xml | 5 | ||||
-rw-r--r-- | subsonic-android/res/values/strings.xml | 1 | ||||
-rw-r--r-- | subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java | 57 |
4 files changed, 64 insertions, 2 deletions
diff --git a/subsonic-android/AndroidManifest.xml b/subsonic-android/AndroidManifest.xml index 9561fae6..c366b12c 100644 --- a/subsonic-android/AndroidManifest.xml +++ b/subsonic-android/AndroidManifest.xml @@ -13,7 +13,8 @@ <uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
- <uses-permission android:name="android.permission.BLUETOOTH" />
+ <uses-permission android:name="android.permission.BLUETOOTH"/>
+ <uses-permission android:name="android.permission.READ_LOGS"/>
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="16"/>
diff --git a/subsonic-android/res/menu/main.xml b/subsonic-android/res/menu/main.xml index 449df3a8..85d22dcf 100644 --- a/subsonic-android/res/menu/main.xml +++ b/subsonic-android/res/menu/main.xml @@ -21,6 +21,11 @@ android:id="@+id/menu_about" android:icon="@drawable/action_help" android:title="@string/menu.about"/> + + <item + android:id="@+id/menu_log" + android:icon="@drawable/action_help" + android:title="@string/menu.log"/> <item android:id="@+id/menu_settings" diff --git a/subsonic-android/res/values/strings.xml b/subsonic-android/res/values/strings.xml index 5d0c6bde..fb18d16c 100644 --- a/subsonic-android/res/values/strings.xml +++ b/subsonic-android/res/values/strings.xml @@ -63,6 +63,7 @@ <string name="menu.remove_playlist">Remove From Playlist</string>
<string name="menu.deleted_playlist">Deleted playlist %s</string>
<string name="menu.deleted_playlist_error">Failed to delete playlist %s</string>
+ <string name="menu.log">Send Log</string>
<string name="playlist.label">Playlists</string>
<string name="playlist.update_info">Update Information</string>
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java index 0be15eca..755667aa 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java @@ -36,6 +36,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; +import android.net.Uri; import android.os.Bundle; import android.os.StatFs; import android.preference.PreferenceManager; @@ -47,7 +48,13 @@ import android.widget.ImageButton; import android.widget.ListView; import android.widget.TextView; import android.widget.PopupWindow; +import github.daneren2005.dsub.util.*; import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; public class MainActivity extends SubsonicTabActivity { @@ -163,6 +170,9 @@ public class MainActivity extends SubsonicTabActivity { case R.id.menu_help: startActivity(new Intent(this, HelpActivity.class)); return true; + case R.id.menu_log: + getLogs(); + return true; case R.id.menu_about: showAboutDialog(); return true; @@ -292,5 +302,50 @@ public class MainActivity extends SubsonicTabActivity { private void toggleOffline() { Util.setOffline(this, !Util.isOffline(this)); restart(); - } + } + + private void getLogs() { + new ModalBackgroundTask<File>(this, false) { + @Override + protected File doInBackground() throws Throwable { + updateProgress("Gathering Logs"); + File logcat = new File(FileUtil.getSubsonicDirectory(), "logcat.txt"); + Process logcatProc = null; + + try { + List<String> progs = new ArrayList<String>(); + progs.add("logcat"); + progs.add("-v"); + progs.add("time"); + progs.add("-d"); + progs.add("-f"); + progs.add(logcat.getPath()); + progs.add("*:I"); + + logcatProc = Runtime.getRuntime().exec(progs.toArray(new String[0])); + logcatProc.waitFor(); + } catch(Exception e) { + Util.toast(MainActivity.this, "Failed to gather logs"); + } finally { + if(logcatProc != null) { + logcatProc.destroy(); + } + } + + return logcat; + } + + @Override + protected void done(File logcat) { + Intent email = new Intent(android.content.Intent.ACTION_SEND); + email.setType("text/plain"); + email.putExtra(Intent.EXTRA_EMAIL, new String[] {"daneren2005@gmail.com"}); + email.putExtra(Intent.EXTRA_SUBJECT, "DSub Error Logs"); + email.putExtra(Intent.EXTRA_TEXT, "Describe the problem here"); + Uri attachment = Uri.fromFile(logcat); + email.putExtra(Intent.EXTRA_STREAM, attachment); + startActivity(email); + } + }.execute(); + } }
\ No newline at end of file |