From 8a0f119970cf6168a2e8b81c5c872269b6b6c895 Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Thu, 18 Mar 2021 21:20:15 -0400 Subject: [PATCH] disable LogCollector --- .../instagrabber/InstaGrabberApplication.java | 6 +- .../instagrabber/asyncs/CommentsFetcher.java | 20 +-- .../instagrabber/asyncs/HashtagFetcher.java | 8 +- .../instagrabber/asyncs/LocationFetcher.java | 8 +- .../instagrabber/asyncs/PostFetcher.java | 10 +- .../fragments/HashTagFragment.java | 8 +- .../fragments/LocationFragment.java | 8 +- .../fragments/StoryViewerFragment.java | 12 +- .../awais/instagrabber/utils/CookieUtils.java | 6 +- .../instagrabber/utils/ExportImportUtils.java | 34 ++--- .../instagrabber/utils/ResponseBodyUtils.java | 16 +-- .../java/awais/instagrabber/utils/Utils.java | 4 +- .../instagrabber/workers/DownloadWorker.java | 16 +-- .../java/awaisomereport/CrashReporter.java | 126 +++++++++--------- .../awaisomereport/ErrorReporterActivity.java | 2 +- .../java/awaisomereport/LogCollector.java | 4 +- 16 files changed, 141 insertions(+), 147 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/InstaGrabberApplication.java b/app/src/main/java/awais/instagrabber/InstaGrabberApplication.java index c5cd0d69..b90c8343 100644 --- a/app/src/main/java/awais/instagrabber/InstaGrabberApplication.java +++ b/app/src/main/java/awais/instagrabber/InstaGrabberApplication.java @@ -18,14 +18,14 @@ import awais.instagrabber.utils.LocaleUtils; import awais.instagrabber.utils.SettingsHelper; import awais.instagrabber.utils.TextUtils; import awaisomereport.CrashReporter; -import awaisomereport.LogCollector; +//import awaisomereport.LogCollector; import static awais.instagrabber.utils.CookieUtils.NET_COOKIE_MANAGER; import static awais.instagrabber.utils.Utils.applicationHandler; import static awais.instagrabber.utils.Utils.cacheDir; import static awais.instagrabber.utils.Utils.clipboardManager; import static awais.instagrabber.utils.Utils.datetimeParser; -import static awais.instagrabber.utils.Utils.logCollector; +//import static awais.instagrabber.utils.Utils.logCollector; import static awais.instagrabber.utils.Utils.settingsHelper; public final class InstaGrabberApplication extends Application { @@ -56,7 +56,7 @@ public final class InstaGrabberApplication extends Application { } if (!BuildConfig.DEBUG) CrashReporter.get(this).start(); - logCollector = new LogCollector(this); +// logCollector = new LogCollector(this); CookieHandler.setDefault(NET_COOKIE_MANAGER); diff --git a/app/src/main/java/awais/instagrabber/asyncs/CommentsFetcher.java b/app/src/main/java/awais/instagrabber/asyncs/CommentsFetcher.java index 044ebfe0..b75b758c 100755 --- a/app/src/main/java/awais/instagrabber/asyncs/CommentsFetcher.java +++ b/app/src/main/java/awais/instagrabber/asyncs/CommentsFetcher.java @@ -22,9 +22,9 @@ import awais.instagrabber.repositories.responses.User; import awais.instagrabber.utils.Constants; import awais.instagrabber.utils.NetworkUtils; import awais.instagrabber.utils.TextUtils; -import awaisomereport.LogCollector; +//import awaisomereport.LogCollector; -import static awais.instagrabber.utils.Utils.logCollector; +//import static awais.instagrabber.utils.Utils.logCollector; public final class CommentsFetcher extends AsyncTask> { private static final String TAG = "CommentsFetcher"; @@ -130,11 +130,11 @@ public final class CommentsFetcher extends AsyncTask("commentModels.size", commentModels.size())); +// if (logCollector != null) +// logCollector.appendException(e, +// LogCollector.LogFile.ASYNC_COMMENTS_FETCHER, +// "getChildComments", +// new Pair<>("commentModels.size", commentModels.size())); if (BuildConfig.DEBUG) Log.e(TAG, "", e); if (fetchListener != null) fetchListener.onFailure(e); break; @@ -256,9 +256,9 @@ public final class CommentsFetcher extends AsyncTask("commentModelsList.size", commentModels.size())); +// if (logCollector != null) +// logCollector.appendException(e, LogCollector.LogFile.ASYNC_COMMENTS_FETCHER, "getParentComments", +// new Pair<>("commentModelsList.size", commentModels.size())); if (BuildConfig.DEBUG) Log.e("AWAISKING_APP", "", e); if (fetchListener != null) fetchListener.onFailure(e); return null; diff --git a/app/src/main/java/awais/instagrabber/asyncs/HashtagFetcher.java b/app/src/main/java/awais/instagrabber/asyncs/HashtagFetcher.java index db2f5df3..09630e6f 100644 --- a/app/src/main/java/awais/instagrabber/asyncs/HashtagFetcher.java +++ b/app/src/main/java/awais/instagrabber/asyncs/HashtagFetcher.java @@ -20,9 +20,9 @@ import awais.instagrabber.interfaces.FetchListener; import awais.instagrabber.models.HashtagModel; import awais.instagrabber.utils.Constants; import awais.instagrabber.utils.NetworkUtils; -import awaisomereport.LogCollector; +//import awaisomereport.LogCollector; -import static awais.instagrabber.utils.Utils.logCollector; +//import static awais.instagrabber.utils.Utils.logCollector; public final class HashtagFetcher extends AsyncTask { private static final String TAG = "HashtagFetcher"; @@ -86,8 +86,8 @@ public final class HashtagFetcher extends AsyncTask { conn.disconnect(); } catch (final Exception e) { - if (logCollector != null) - logCollector.appendException(e, LogCollector.LogFile.ASYNC_HASHTAG_FETCHER, "doInBackground"); +// if (logCollector != null) +// logCollector.appendException(e, LogCollector.LogFile.ASYNC_HASHTAG_FETCHER, "doInBackground"); if (BuildConfig.DEBUG) Log.e(TAG, "", e); if (fetchListener != null) fetchListener.onFailure(e); } diff --git a/app/src/main/java/awais/instagrabber/asyncs/LocationFetcher.java b/app/src/main/java/awais/instagrabber/asyncs/LocationFetcher.java index 8ccd47ce..8aabc107 100644 --- a/app/src/main/java/awais/instagrabber/asyncs/LocationFetcher.java +++ b/app/src/main/java/awais/instagrabber/asyncs/LocationFetcher.java @@ -16,9 +16,9 @@ import awais.instagrabber.interfaces.FetchListener; import awais.instagrabber.models.LocationModel; import awais.instagrabber.utils.Constants; import awais.instagrabber.utils.NetworkUtils; -import awaisomereport.LogCollector; +//import awaisomereport.LogCollector; -import static awais.instagrabber.utils.Utils.logCollector; +//import static awais.instagrabber.utils.Utils.logCollector; public final class LocationFetcher extends AsyncTask { private static final String TAG = "LocationFetcher"; @@ -65,8 +65,8 @@ public final class LocationFetcher extends AsyncTask conn.disconnect(); } catch (final Exception e) { - if (logCollector != null) - logCollector.appendException(e, LogCollector.LogFile.ASYNC_LOCATION_FETCHER, "doInBackground"); +// if (logCollector != null) +// logCollector.appendException(e, LogCollector.LogFile.ASYNC_LOCATION_FETCHER, "doInBackground"); if (BuildConfig.DEBUG) { Log.e(TAG, "", e); } diff --git a/app/src/main/java/awais/instagrabber/asyncs/PostFetcher.java b/app/src/main/java/awais/instagrabber/asyncs/PostFetcher.java index c22954b5..eef69f41 100755 --- a/app/src/main/java/awais/instagrabber/asyncs/PostFetcher.java +++ b/app/src/main/java/awais/instagrabber/asyncs/PostFetcher.java @@ -12,9 +12,9 @@ import awais.instagrabber.interfaces.FetchListener; import awais.instagrabber.repositories.responses.Media; import awais.instagrabber.utils.NetworkUtils; import awais.instagrabber.utils.ResponseBodyUtils; -import awaisomereport.LogCollector; +//import awaisomereport.LogCollector; -import static awais.instagrabber.utils.Utils.logCollector; +//import static awais.instagrabber.utils.Utils.logCollector; public final class PostFetcher extends AsyncTask { private static final String TAG = "PostFetcher"; @@ -136,9 +136,9 @@ public final class PostFetcher extends AsyncTask { return ResponseBodyUtils.parseGraphQLItem(media); } } catch (Exception e) { - if (logCollector != null) { - logCollector.appendException(e, LogCollector.LogFile.ASYNC_POST_FETCHER, "doInBackground"); - } +// if (logCollector != null) { +// logCollector.appendException(e, LogCollector.LogFile.ASYNC_POST_FETCHER, "doInBackground"); +// } Log.e(TAG, "Error fetching post", e); } finally { if (conn != null) { diff --git a/app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java b/app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java index 68e26dbd..d2b30803 100644 --- a/app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java @@ -70,11 +70,11 @@ import awais.instagrabber.utils.Utils; import awais.instagrabber.webservices.ServiceCallback; import awais.instagrabber.webservices.StoriesService; import awais.instagrabber.webservices.TagsService; -import awaisomereport.LogCollector; +//import awaisomereport.LogCollector; import static androidx.core.content.PermissionChecker.checkSelfPermission; import static awais.instagrabber.utils.DownloadUtils.WRITE_PERMISSION; -import static awais.instagrabber.utils.Utils.logCollector; +//import static awais.instagrabber.utils.Utils.logCollector; import static awais.instagrabber.utils.Utils.settingsHelper; public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener { @@ -607,8 +607,8 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe try { currentlyExecuting.cancel(true); } catch (final Exception e) { - if (logCollector != null) - logCollector.appendException(e, LogCollector.LogFile.MAIN_HELPER, "stopCurrentExecutor"); +// if (logCollector != null) +// logCollector.appendException(e, LogCollector.LogFile.MAIN_HELPER, "stopCurrentExecutor"); Log.e(TAG, "", e); } } diff --git a/app/src/main/java/awais/instagrabber/fragments/LocationFragment.java b/app/src/main/java/awais/instagrabber/fragments/LocationFragment.java index d21e750e..24fa4b88 100644 --- a/app/src/main/java/awais/instagrabber/fragments/LocationFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/LocationFragment.java @@ -69,12 +69,12 @@ import awais.instagrabber.utils.TextUtils; import awais.instagrabber.utils.Utils; import awais.instagrabber.webservices.ServiceCallback; import awais.instagrabber.webservices.StoriesService; -import awaisomereport.LogCollector; +//import awaisomereport.LogCollector; import static androidx.core.content.PermissionChecker.checkSelfPermission; import static awais.instagrabber.fragments.HashTagFragment.ARG_HASHTAG; import static awais.instagrabber.utils.DownloadUtils.WRITE_PERMISSION; -import static awais.instagrabber.utils.Utils.logCollector; +//import static awais.instagrabber.utils.Utils.logCollector; import static awais.instagrabber.utils.Utils.settingsHelper; public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener { @@ -586,8 +586,8 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR try { currentlyExecuting.cancel(true); } catch (final Exception e) { - if (logCollector != null) logCollector.appendException( - e, LogCollector.LogFile.MAIN_HELPER, "stopCurrentExecutor"); +// if (logCollector != null) logCollector.appendException( +// e, LogCollector.LogFile.MAIN_HELPER, "stopCurrentExecutor"); Log.e(TAG, "", e); } } diff --git a/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java b/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java index e99c6967..4b2108a8 100644 --- a/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java @@ -103,7 +103,7 @@ import awais.instagrabber.webservices.DirectMessagesService; import awais.instagrabber.webservices.MediaService; import awais.instagrabber.webservices.ServiceCallback; import awais.instagrabber.webservices.StoriesService; -import awaisomereport.LogCollector; +//import awaisomereport.LogCollector; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; @@ -111,7 +111,7 @@ import retrofit2.Response; import static awais.instagrabber.customviews.helpers.SwipeGestureListener.SWIPE_THRESHOLD; import static awais.instagrabber.customviews.helpers.SwipeGestureListener.SWIPE_VELOCITY_THRESHOLD; import static awais.instagrabber.utils.Constants.MARK_AS_SEEN; -import static awais.instagrabber.utils.Utils.logCollector; +//import static awais.instagrabber.utils.Utils.logCollector; import static awais.instagrabber.utils.Utils.settingsHelper; public class StoryViewerFragment extends Fragment { @@ -400,10 +400,10 @@ public class StoryViewerFragment extends Fragment { return true; } } catch (final Exception e) { - if (logCollector != null) - logCollector.appendException(e, LogCollector.LogFile.ACTIVITY_STORY_VIEWER, "setupListeners", - new Pair<>("swipeEvent", swipeEvent), - new Pair<>("diffX", diffX)); +// if (logCollector != null) +// logCollector.appendException(e, LogCollector.LogFile.ACTIVITY_STORY_VIEWER, "setupListeners", +// new Pair<>("swipeEvent", swipeEvent), +// new Pair<>("diffX", diffX)); if (BuildConfig.DEBUG) Log.e(TAG, "Error", e); } return false; diff --git a/app/src/main/java/awais/instagrabber/utils/CookieUtils.java b/app/src/main/java/awais/instagrabber/utils/CookieUtils.java index 59bb805e..76bb55cd 100644 --- a/app/src/main/java/awais/instagrabber/utils/CookieUtils.java +++ b/app/src/main/java/awais/instagrabber/utils/CookieUtils.java @@ -21,7 +21,7 @@ import awais.instagrabber.BuildConfig; import awais.instagrabber.db.datasources.AccountDataSource; import awais.instagrabber.db.repositories.AccountRepository; import awais.instagrabber.db.repositories.RepositoryCallback; -import awaisomereport.LogCollector; +//import awaisomereport.LogCollector; public final class CookieUtils { private static final String TAG = CookieUtils.class.getSimpleName(); @@ -52,8 +52,8 @@ public final class CookieUtils { cookieStore.add(uri3, httpCookie); } } catch (final URISyntaxException e) { - if (Utils.logCollector != null) - Utils.logCollector.appendException(e, LogCollector.LogFile.UTILS, "setupCookies"); +// if (Utils.logCollector != null) +// Utils.logCollector.appendException(e, LogCollector.LogFile.UTILS, "setupCookies"); if (BuildConfig.DEBUG) Log.e(TAG, "", e); } } diff --git a/app/src/main/java/awais/instagrabber/utils/ExportImportUtils.java b/app/src/main/java/awais/instagrabber/utils/ExportImportUtils.java index e94f71c7..9c24db69 100755 --- a/app/src/main/java/awais/instagrabber/utils/ExportImportUtils.java +++ b/app/src/main/java/awais/instagrabber/utils/ExportImportUtils.java @@ -41,9 +41,9 @@ import awais.instagrabber.db.repositories.RepositoryCallback; import awais.instagrabber.interfaces.FetchListener; import awais.instagrabber.models.enums.FavoriteType; import awais.instagrabber.utils.PasswordUtils.IncorrectPasswordException; -import awaisomereport.LogCollector.LogFile; +//import awaisomereport.LogCollector.LogFile; -import static awais.instagrabber.utils.Utils.logCollector; +//import static awais.instagrabber.utils.Utils.logCollector; import static awais.instagrabber.utils.Utils.settingsHelper; public final class ExportImportUtils { @@ -80,8 +80,8 @@ public final class ExportImportUtils { throw e; } catch (final Exception e) { if (fetchListener != null) fetchListener.onResult(false); - if (logCollector != null) - logCollector.appendException(e, LogFile.UTILS_IMPORT, "Import::pass"); +// if (logCollector != null) +// logCollector.appendException(e, LogFile.UTILS_IMPORT, "Import::pass"); if (BuildConfig.DEBUG) Log.e(TAG, "Error importing backup", e); } } else if (configType == 'Z') { @@ -99,7 +99,7 @@ public final class ExportImportUtils { throw e; } catch (final Exception e) { if (fetchListener != null) fetchListener.onResult(false); - if (logCollector != null) logCollector.appendException(e, LogFile.UTILS_IMPORT, "Import"); +// if (logCollector != null) logCollector.appendException(e, LogFile.UTILS_IMPORT, "Import"); if (BuildConfig.DEBUG) Log.e(TAG, "", e); } } @@ -122,7 +122,7 @@ public final class ExportImportUtils { if (fetchListener != null) fetchListener.onResult(true); } catch (final Exception e) { if (fetchListener != null) fetchListener.onResult(false); - if (logCollector != null) logCollector.appendException(e, LogFile.UTILS_IMPORT, "importJson"); +// if (logCollector != null) logCollector.appendException(e, LogFile.UTILS_IMPORT, "importJson"); if (BuildConfig.DEBUG) Log.e(TAG, "", e); } } @@ -241,8 +241,8 @@ public final class ExportImportUtils { exportBytes = PasswordUtils.enc(exportString, bytes); } catch (final Exception e) { if (fetchListener != null) fetchListener.onResult(false); - if (logCollector != null) - logCollector.appendException(e, LogFile.UTILS_EXPORT, "Export::isPass"); +// if (logCollector != null) +// logCollector.appendException(e, LogFile.UTILS_EXPORT, "Export::isPass"); if (BuildConfig.DEBUG) Log.e(TAG, "", e); } } else { @@ -255,8 +255,8 @@ public final class ExportImportUtils { if (fetchListener != null) fetchListener.onResult(true); } catch (final Exception e) { if (fetchListener != null) fetchListener.onResult(false); - if (logCollector != null) - logCollector.appendException(e, LogFile.UTILS_EXPORT, "Export::notPass"); +// if (logCollector != null) +// logCollector.appendException(e, LogFile.UTILS_EXPORT, "Export::notPass"); if (BuildConfig.DEBUG) Log.e(TAG, "", e); } } else if (fetchListener != null) fetchListener.onResult(false); @@ -324,7 +324,7 @@ public final class ExportImportUtils { }, AppExecutors.getInstance().tasksThread()); return; } catch (final Exception e) { - if (logCollector != null) logCollector.appendException(e, LogFile.UTILS_EXPORT, "getExportString"); +// if (logCollector != null) logCollector.appendException(e, LogFile.UTILS_EXPORT, "getExportString"); if (BuildConfig.DEBUG) Log.e(TAG, "", e); } callback.onCreated(null); @@ -373,9 +373,9 @@ public final class ExportImportUtils { jsonArray.put(jsonObject); } } catch (Exception e) { - if (logCollector != null) { - logCollector.appendException(e, LogFile.UTILS_EXPORT, "getFavorites"); - } +// if (logCollector != null) { +// logCollector.appendException(e, LogFile.UTILS_EXPORT, "getFavorites"); +// } if (BuildConfig.DEBUG) { Log.e(TAG, "Error exporting favorites", e); } @@ -409,9 +409,9 @@ public final class ExportImportUtils { jsonArray.put(jsonObject); } } catch (Exception e) { - if (logCollector != null) { - logCollector.appendException(e, LogFile.UTILS_EXPORT, "getCookies"); - } +// if (logCollector != null) { +// logCollector.appendException(e, LogFile.UTILS_EXPORT, "getCookies"); +// } if (BuildConfig.DEBUG) { Log.e(TAG, "Error exporting accounts", e); } diff --git a/app/src/main/java/awais/instagrabber/utils/ResponseBodyUtils.java b/app/src/main/java/awais/instagrabber/utils/ResponseBodyUtils.java index 07d795d0..7a5b8361 100644 --- a/app/src/main/java/awais/instagrabber/utils/ResponseBodyUtils.java +++ b/app/src/main/java/awais/instagrabber/utils/ResponseBodyUtils.java @@ -31,7 +31,7 @@ import awais.instagrabber.repositories.responses.Media; import awais.instagrabber.repositories.responses.MediaCandidate; import awais.instagrabber.repositories.responses.User; import awais.instagrabber.repositories.responses.VideoVersion; -import awaisomereport.LogCollector; +//import awaisomereport.LogCollector; public final class ResponseBodyUtils { private static final String TAG = "ResponseBodyUtils"; @@ -76,10 +76,10 @@ public final class ResponseBodyUtils { if (lastIndexMain >= 0) return sources[lastIndexMain]; else if (lastIndexBase >= 0) return sources[lastIndexBase]; } catch (final Exception e) { - if (Utils.logCollector != null) - Utils.logCollector.appendException(e, LogCollector.LogFile.UTILS, "getHighQualityPost", - new Pair<>("resourcesNull", resources == null), - new Pair<>("isVideo", isVideo)); +// if (Utils.logCollector != null) +// Utils.logCollector.appendException(e, LogCollector.LogFile.UTILS, "getHighQualityPost", +// new Pair<>("resourcesNull", resources == null), +// new Pair<>("isVideo", isVideo)); if (BuildConfig.DEBUG) Log.e("AWAISKING_APP", "", e); } return null; @@ -94,9 +94,9 @@ public final class ResponseBodyUtils { src = getHighQualityPost(resources.getJSONObject("image_versions2").getJSONArray("candidates"), false, true, false); if (src == null) return resources.getString("display_url"); } catch (final Exception e) { - if (Utils.logCollector != null) - Utils.logCollector.appendException(e, LogCollector.LogFile.UTILS, "getHighQualityImage", - new Pair<>("resourcesNull", resources == null)); +// if (Utils.logCollector != null) +// Utils.logCollector.appendException(e, LogCollector.LogFile.UTILS, "getHighQualityImage", +// new Pair<>("resourcesNull", resources == null)); if (BuildConfig.DEBUG) Log.e("AWAISKING_APP", "", e); } return src; diff --git a/app/src/main/java/awais/instagrabber/utils/Utils.java b/app/src/main/java/awais/instagrabber/utils/Utils.java index ed22c52a..29425a27 100644 --- a/app/src/main/java/awais/instagrabber/utils/Utils.java +++ b/app/src/main/java/awais/instagrabber/utils/Utils.java @@ -56,13 +56,13 @@ import java.util.Map; import awais.instagrabber.R; import awais.instagrabber.models.PostsLayoutPreferences; import awais.instagrabber.models.enums.FavoriteType; -import awaisomereport.LogCollector; +//import awaisomereport.LogCollector; public final class Utils { private static final String TAG = "Utils"; private static final int VIDEO_CACHE_MAX_BYTES = 10 * 1024 * 1024; - public static LogCollector logCollector; +// public static LogCollector logCollector; public static SettingsHelper settingsHelper; public static boolean sessionVolumeFull = false; public static final MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton(); diff --git a/app/src/main/java/awais/instagrabber/workers/DownloadWorker.java b/app/src/main/java/awais/instagrabber/workers/DownloadWorker.java index b3557e9f..b0dae625 100644 --- a/app/src/main/java/awais/instagrabber/workers/DownloadWorker.java +++ b/app/src/main/java/awais/instagrabber/workers/DownloadWorker.java @@ -52,11 +52,11 @@ import awais.instagrabber.utils.Constants; import awais.instagrabber.utils.DownloadUtils; import awais.instagrabber.utils.TextUtils; import awais.instagrabber.utils.Utils; -import awaisomereport.LogCollector; +//import awaisomereport.LogCollector; import static awais.instagrabber.utils.Constants.DOWNLOAD_CHANNEL_ID; import static awais.instagrabber.utils.Constants.NOTIF_GROUP_NAME; -import static awais.instagrabber.utils.Utils.logCollector; +//import static awais.instagrabber.utils.Utils.logCollector; public class DownloadWorker extends Worker { private static final String TAG = "DownloadWorker"; @@ -260,8 +260,8 @@ public class DownloadWorker extends Worker { try (final InputStream inputStream = contentResolver.openInputStream(uri)) { bitmap = BitmapFactory.decodeStream(inputStream); } catch (final Exception e) { - if (logCollector != null) - logCollector.appendException(e, LogCollector.LogFile.ASYNC_DOWNLOADER, "onPostExecute::bitmap_1"); +// if (logCollector != null) +// logCollector.appendException(e, LogCollector.LogFile.ASYNC_DOWNLOADER, "onPostExecute::bitmap_1"); if (BuildConfig.DEBUG) Log.e(TAG, "", e); } } else if (mimeType.startsWith("video")) { @@ -277,13 +277,13 @@ public class DownloadWorker extends Worker { try { retriever.close(); } catch (final Exception e) { - if (logCollector != null) - logCollector.appendException(e, LogCollector.LogFile.ASYNC_DOWNLOADER, "onPostExecute::bitmap_2"); +// if (logCollector != null) +// logCollector.appendException(e, LogCollector.LogFile.ASYNC_DOWNLOADER, "onPostExecute::bitmap_2"); } } catch (final Exception e) { if (BuildConfig.DEBUG) Log.e(TAG, "", e); - if (logCollector != null) - logCollector.appendException(e, LogCollector.LogFile.ASYNC_DOWNLOADER, "onPostExecute::bitmap_3"); +// if (logCollector != null) +// logCollector.appendException(e, LogCollector.LogFile.ASYNC_DOWNLOADER, "onPostExecute::bitmap_3"); } } } diff --git a/app/src/main/java/awaisomereport/CrashReporter.java b/app/src/main/java/awaisomereport/CrashReporter.java index d538bb4c..f5f22143 100755 --- a/app/src/main/java/awaisomereport/CrashReporter.java +++ b/app/src/main/java/awaisomereport/CrashReporter.java @@ -19,8 +19,8 @@ import java.io.PrintWriter; import java.io.StringWriter; import java.io.Writer; import java.util.Date; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; +//import java.util.zip.ZipEntry; +//import java.util.zip.ZipOutputStream; import awais.instagrabber.BuildConfig; import awais.instagrabber.utils.Utils; @@ -29,7 +29,7 @@ public final class CrashReporter implements Thread.UncaughtExceptionHandler { private static CrashReporter reporterInstance; private final Application application; private final String email; - private final File crashLogsZip; +// private final File crashLogsZip; private boolean startAttempted = false; public static CrashReporter get(final Application application) { @@ -40,7 +40,7 @@ public final class CrashReporter implements Thread.UncaughtExceptionHandler { private CrashReporter(@NonNull final Application application) { this.application = application; this.email = "barinsta@austinhuang.me"; - this.crashLogsZip = new File(application.getExternalCacheDir(), "crash_logs.zip"); +// this.crashLogsZip = new File(application.getExternalCacheDir(), "crash_logs.zip"); } public void start() { @@ -99,94 +99,88 @@ public final class CrashReporter implements Thread.UncaughtExceptionHandler { application.startActivity(new Intent(application, ErrorReporterActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); - zipLogs(); +// zipLogs(); Process.killProcess(Process.myPid()); System.exit(10); } - public synchronized CrashReporter zipLogs() { - final File logDir = Utils.logCollector != null ? Utils.logCollector.getLogDir() : - new File(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? application.getDataDir() : application.getFilesDir(), "crashlogs"); - - try (final FileOutputStream fos = new FileOutputStream(crashLogsZip); - final ZipOutputStream zos = new ZipOutputStream(fos)) { - - final File[] files = logDir.listFiles(); - - if (files != null) { - zos.setLevel(5); - byte[] buffer; - for (final File file : files) { - if (file != null && file.length() > 0) { - buffer = new byte[1024]; - try (final FileInputStream fis = new FileInputStream(file)) { - zos.putNextEntry(new ZipEntry(file.getName())); - int length; - while ((length = fis.read(buffer)) > 0) zos.write(buffer, 0, length); - zos.closeEntry(); - } - } - } - } - - } catch (final Exception e) { - if (BuildConfig.DEBUG) Log.e("AWAISKING_APP", "", e); - } - - return this; - } +// public synchronized CrashReporter zipLogs() { +// final File logDir = Utils.logCollector != null ? Utils.logCollector.getLogDir() : +// new File(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? application.getDataDir() : application.getFilesDir(), "crashlogs"); +// +// try (final FileOutputStream fos = new FileOutputStream(crashLogsZip); +// final ZipOutputStream zos = new ZipOutputStream(fos)) { +// +// final File[] files = logDir.listFiles(); +// +// if (files != null) { +// zos.setLevel(5); +// byte[] buffer; +// for (final File file : files) { +// if (file != null && file.length() > 0) { +// buffer = new byte[1024]; +// try (final FileInputStream fis = new FileInputStream(file)) { +// zos.putNextEntry(new ZipEntry(file.getName())); +// int length; +// while ((length = fis.read(buffer)) > 0) zos.write(buffer, 0, length); +// zos.closeEntry(); +// } +// } +// } +// } +// +// } catch (final Exception e) { +// if (BuildConfig.DEBUG) Log.e("AWAISKING_APP", "", e); +// } +// +// return this; +// } @SuppressWarnings("ResultOfMethodCallIgnored") - public void startCrashEmailIntent(final Context context, final boolean sendZipsOnly) { + public void startCrashEmailIntent(final Context context) { try { final String filePath = context.getFilesDir().getAbsolutePath(); String[] errorFileList; - if (sendZipsOnly) errorFileList = null; - else { - try { - final File dir = new File(filePath); - if (dir.exists() && !dir.isDirectory()) dir.delete(); - dir.mkdir(); - errorFileList = dir.list((d, name) -> name.endsWith(".stacktrace")); - } catch (final Exception e) { - errorFileList = null; - } + try { + final File dir = new File(filePath); + if (dir.exists() && !dir.isDirectory()) dir.delete(); + dir.mkdir(); + errorFileList = dir.list((d, name) -> name.endsWith(".stacktrace")); + } catch (final Exception e) { + errorFileList = null; } - if ((errorFileList != null && errorFileList.length > 0) || sendZipsOnly) { + if (errorFileList != null && errorFileList.length > 0) { final StringBuilder errorStringBuilder; - if (sendZipsOnly) errorStringBuilder = new StringBuilder("(Not a crash)\n\n"); - else { - errorStringBuilder = new StringBuilder("\r\n\r\n"); - final int maxSendMail = 5; + errorStringBuilder = new StringBuilder("\r\n\r\n"); + final int maxSendMail = 5; - int curIndex = 0; - for (final String curString : errorFileList) { - final File file = new File(filePath + '/' + curString); + int curIndex = 0; + for (final String curString : errorFileList) { + final File file = new File(filePath + '/' + curString); - if (curIndex++ <= maxSendMail) { - errorStringBuilder.append("New Trace collected:\r\n=====================\r\n"); - try (final BufferedReader input = new BufferedReader(new FileReader(file))) { - String line; - while ((line = input.readLine()) != null) - errorStringBuilder.append(line).append("\r\n"); - } + if (curIndex++ <= maxSendMail) { + errorStringBuilder.append("New Trace collected:\r\n=====================\r\n"); + try (final BufferedReader input = new BufferedReader(new FileReader(file))) { + String line; + while ((line = input.readLine()) != null) + errorStringBuilder.append(line).append("\r\n"); } - - file.delete(); } - errorStringBuilder.append("\r\n\r\n"); + file.delete(); } + errorStringBuilder.append("\r\n\r\n"); + context.startActivity(Intent.createChooser(new Intent(Intent.ACTION_SEND).setType("message/rfc822") .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION) .putExtra(Intent.EXTRA_EMAIL, new String[]{email}) - .putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(application, BuildConfig.APPLICATION_ID + ".provider", crashLogsZip)) +// .putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(application, BuildConfig.APPLICATION_ID + ".provider", crashLogsZip)) .putExtra(Intent.EXTRA_SUBJECT, "Barinsta Crash Report") .putExtra(Intent.EXTRA_TEXT, errorStringBuilder.toString()), "Select an email app to send crash logs")); } diff --git a/app/src/main/java/awaisomereport/ErrorReporterActivity.java b/app/src/main/java/awaisomereport/ErrorReporterActivity.java index 5bd4669c..9fb1ce40 100755 --- a/app/src/main/java/awaisomereport/ErrorReporterActivity.java +++ b/app/src/main/java/awaisomereport/ErrorReporterActivity.java @@ -44,7 +44,7 @@ public final class ErrorReporterActivity extends Activity implements View.OnClic @Override public void onClick(@NonNull final View v) { if (v == btnReport) - CrashReporter.get(getApplication()).startCrashEmailIntent(this, false); + CrashReporter.get(getApplication()).startCrashEmailIntent(this); finish(); System.exit(10); } diff --git a/app/src/main/java/awaisomereport/LogCollector.java b/app/src/main/java/awaisomereport/LogCollector.java index b784de6f..1222701f 100755 --- a/app/src/main/java/awaisomereport/LogCollector.java +++ b/app/src/main/java/awaisomereport/LogCollector.java @@ -1,4 +1,4 @@ -package awaisomereport; +/*package awaisomereport; import android.app.Application; import android.os.Build; @@ -140,4 +140,4 @@ public final class LogCollector { //noinspection ResultOfMethodCallIgnored fileOrDirectory.delete(); } -} \ No newline at end of file +}*/ \ No newline at end of file