Browse Source

use app specific log folder

tobiasKaminsky 8 years ago
parent
commit
aeba233894

+ 1 - 1
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'

+ 2 - 7
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");
         }
 

+ 2 - 7
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));
                 }
             }
         }

+ 0 - 5
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;

+ 0 - 4
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

+ 4 - 1
src/main/res/xml/exposed_filepaths.xml

@@ -1,5 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
-<paths xmlns:android="http://schemas.android.com/apk/res/android">
+<paths>
+    <files-path
+        path="log/"
+        name="log"/>
     <external-path name="external_files" path="."/>
     <root-path name="external_files" path="/storage/" />
     <!-- yes, valid for ALL external storage and not only our app folder, since we can't use @string/data_folder