From aeba2338942eaf972ca6e31a1c5674499dc85ad6 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Mon, 15 May 2017 09:08:19 +0200 Subject: [PATCH 1/2] use app specific log folder --- build.gradle | 2 +- src/main/java/com/owncloud/android/MainApp.java | 9 ++------- .../owncloud/android/ui/activity/LogHistoryActivity.java | 9 ++------- .../owncloud/android/ui/activity/StorageMigration.java | 5 ----- .../com/owncloud/android/utils/FileStorageUtils.java | 4 ---- src/main/res/xml/exposed_filepaths.xml | 5 ++++- 6 files changed, 9 insertions(+), 25 deletions(-) diff --git a/build.gradle b/build.gradle index 728cf968d0..2e136eb20f 100644 --- a/build.gradle +++ b/build.gradle @@ -179,7 +179,7 @@ dependencies { compile name: 'touch-image-view' compile 'com.android.support:multidex:1.0.1' - compile 'com.github.nextcloud:android-library:1.0.17' + compile 'com.github.nextcloud:android-library:logFolder-SNAPSHOT' compile "com.android.support:support-v4:${supportLibraryVersion}" compile "com.android.support:design:${supportLibraryVersion}" compile 'com.jakewharton:disklrucache:2.0.2' diff --git a/src/main/java/com/owncloud/android/MainApp.java b/src/main/java/com/owncloud/android/MainApp.java index 6aec46118f..d55fe15b31 100644 --- a/src/main/java/com/owncloud/android/MainApp.java +++ b/src/main/java/com/owncloud/android/MainApp.java @@ -112,13 +112,8 @@ public class MainApp extends MultiDexApplication { new ThumbnailsCacheManager.InitDiskCacheTask().execute(); if (BuildConfig.DEBUG) { - - String dataFolder = getDataFolder(); - - // Set folder for store logs - Log_OC.setLogDataFolder(dataFolder); - - Log_OC.startLogging(MainApp.storagePath); + // use app writable dir, no permissions needed + Log_OC.startLogging(getAppContext()); Log_OC.d("Debug", "start logging"); } diff --git a/src/main/java/com/owncloud/android/ui/activity/LogHistoryActivity.java b/src/main/java/com/owncloud/android/ui/activity/LogHistoryActivity.java index f22a55e292..14490a3ba1 100644 --- a/src/main/java/com/owncloud/android/ui/activity/LogHistoryActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/LogHistoryActivity.java @@ -40,7 +40,6 @@ import com.owncloud.android.R; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.ui.dialog.LoadingDialog; import com.owncloud.android.utils.AnalyticsUtils; -import com.owncloud.android.utils.FileStorageUtils; import java.io.BufferedReader; import java.io.File; @@ -64,7 +63,7 @@ public class LogHistoryActivity extends ToolbarActivity { private static final String SCREEN_NAME = "Logs"; - private String mLogPath = FileStorageUtils.getLogPath(); + private String mLogPath = Log_OC.getLogPath(); private File logDIR = null; private String mLogText; @@ -166,11 +165,7 @@ public class LogHistoryActivity extends ToolbarActivity { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { uris.add(Uri.fromFile(logFile)); } else { - uris.add(FileProvider.getUriForFile( - this, - getString(R.string.file_provider_authority), - logFile - )); + uris.add(FileProvider.getUriForFile(this, getString(R.string.file_provider_authority), logFile)); } } } diff --git a/src/main/java/com/owncloud/android/ui/activity/StorageMigration.java b/src/main/java/com/owncloud/android/ui/activity/StorageMigration.java index f53d80d9da..76443c1a29 100644 --- a/src/main/java/com/owncloud/android/ui/activity/StorageMigration.java +++ b/src/main/java/com/owncloud/android/ui/activity/StorageMigration.java @@ -296,7 +296,6 @@ public class StorageMigration { protected Integer doInBackground(Void... voids) { publishProgress(R.string.file_migration_preparing); - Log_OC.stopLogging(); boolean[] syncStates = null; try { publishProgress(R.string.file_migration_saving_accounts_configuration); @@ -309,7 +308,6 @@ public class StorageMigration { publishProgress(R.string.file_migration_restoring_accounts_configuration); restoreAccountsSyncStatus(syncStates); } - Log_OC.startLogging(mStorageTarget); return 0; } @@ -338,7 +336,6 @@ public class StorageMigration { @Override protected Integer doInBackground(Void... args) { publishProgress(R.string.file_migration_preparing); - Log_OC.stopLogging(); boolean[] syncState = null; @@ -372,14 +369,12 @@ public class StorageMigration { } catch (MigrationException e) { rollback(); - Log_OC.startLogging(mStorageSource); return e.getResId(); } finally { publishProgress(R.string.file_migration_restoring_accounts_configuration); restoreAccountsSyncStatus(syncState); } - Log_OC.startLogging(mStorageTarget); publishProgress(R.string.file_migration_ok_finished); return 0; diff --git a/src/main/java/com/owncloud/android/utils/FileStorageUtils.java b/src/main/java/com/owncloud/android/utils/FileStorageUtils.java index 173cc704c6..b17b89773b 100644 --- a/src/main/java/com/owncloud/android/utils/FileStorageUtils.java +++ b/src/main/java/com/owncloud/android/utils/FileStorageUtils.java @@ -115,10 +115,6 @@ public class FileStorageUtils { return savePath.getUsableSpace(); } - public static String getLogPath() { - return MainApp.getStoragePath() + File.separator + MainApp.getDataFolder() + File.separator + "log"; - } - /** * Returns the a string like 2016/08/ for the passed date. If date is 0 an empty * string is returned diff --git a/src/main/res/xml/exposed_filepaths.xml b/src/main/res/xml/exposed_filepaths.xml index c7bc0925d3..9a47df8a0b 100644 --- a/src/main/res/xml/exposed_filepaths.xml +++ b/src/main/res/xml/exposed_filepaths.xml @@ -1,5 +1,8 @@ - + +