Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6cb10188 authored by Vincent Bourgmayer's avatar Vincent Bourgmayer
Browse files

Limit log sent to sentry

parent 0633ca26
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -98,6 +98,6 @@ public class EdriveApplication extends Application {
    @Override
    public void onLowMemory() {
        super.onLowMemory();
        Timber.w("System is low on memory. Application might get killed by the system.");
        Timber.i("System is low on memory. Application might get killed by the system.");
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -184,7 +184,7 @@ public class FileEventListener {
            final String parentPath = CommonUtils.getLocalPath(file.getParentFile());
            SyncedFolder parentFolder = DbHelper.getSyncedFolderByLocalPath(parentPath, appContext);
            if (parentFolder == null || !parentFolder.isEnabled()) {
                Timber.w("Won't send sync request: no parent are known for new file: %s", file.getName());
                Timber.d("Won't send sync request: no parent are known for new file: %s", file.getName());
                return;
            }
            int scannableValue = 0;
+3 −4
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ public class InitializerService extends Service {
        SharedPreferences prefs = this.getSharedPreferences(AppConstants.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE);

        if (prefs.getBoolean(AppConstants.INITIALIZATION_HAS_BEEN_DONE, false)) {
            Timber.w("Initializer has already been done");
            Timber.i("Initializer has already been done");
        } else {
            String accountName = prefs.getString(AccountManager.KEY_ACCOUNT_NAME, "");
            String accountType = prefs.getString(AccountManager.KEY_ACCOUNT_TYPE, "");
@@ -79,16 +79,15 @@ public class InitializerService extends Service {
            }

            if (accountName.isEmpty()) {
                Timber.w("Account's name not found");
                Timber.d("Account's name not found");
                stopSelf();
            } else {
                this.account = CommonUtils.getAccount(accountName, accountType, AccountManager.get(this));
                //Get OwnCloudlient
                if (this.account != null) {
                    this.cloudClient = DavClientProvider.getInstance().getClientInstance(account, getApplicationContext());
                    start();
                } else {
                    Timber.w("Got account is invalid");
                    Timber.i("Got account is invalid");
                    stopSelf();
                }
            }
+14 −14
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ public class ObserverService extends Service implements OnRemoteOperationListene

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Timber.i("onStartCommand(%s)", startId);
        Timber.v("onStartCommand(%s)", startId);

        CommonUtils.setServiceUnCaughtExceptionHandler(this);

@@ -134,27 +134,27 @@ public class ObserverService extends Service implements OnRemoteOperationListene
     * @return false if at least one condition is false
     */
    private boolean checkStartCondition(final SharedPreferences prefs, final boolean forcedSync) {
        Timber.d("checkStartCondition()");
        Timber.v("checkStartCondition()");

        if (mAccount == null) {
            Timber.w("No account registered");
            Timber.d("No account registered");
            return false;
        }

        if (!CommonUtils.isMediaSyncEnabled(mAccount) && !CommonUtils.isSettingsSyncEnabled(mAccount)) {
            Timber.w("Synchronization has been disabled in account's settings");
            Timber.d("Synchronization has been disabled in account's settings");
            return false;
        }

        if (!prefs.getBoolean(INITIALIZATION_HAS_BEEN_DONE, false)) {
            Timber.w("Initialization hasn't been done");
            Timber.d("Initialization hasn't been done");
            Intent initializerIntent = new Intent(this, InitializerService.class);
            startService(initializerIntent);
            return false;
        }

        if (isWorking) {
            Timber.w("ObserverService is already working");
            Timber.d("ObserverService is already working");
            return false;
        }

@@ -164,14 +164,14 @@ public class ObserverService extends Service implements OnRemoteOperationListene
        final long lastSyncTime = prefs.getLong(AppConstants.KEY_LAST_SYNC_TIME, 0L);
        final long currentTime = System.currentTimeMillis();
        if (!forcedSync && (currentTime - lastSyncTime ) <  INTERSYNC_MINIMUM_DELAY ) {
            Timber.w("Delay between now and last call is too short");
            Timber.d("Delay between now and last call is too short");
            return false;
        }

        final boolean meteredNetworkAllowed = CommonUtils.isMeteredNetworkAllowed(mAccount);
        //check for the case where intent has been launched by initializerService
        if (!CommonUtils.haveNetworkConnection(this, meteredNetworkAllowed)) {
            Timber.w("There is no allowed internet connexion.");
            Timber.d("There is no allowed internet connexion.");
            return false;
        }

@@ -201,13 +201,13 @@ public class ObserverService extends Service implements OnRemoteOperationListene
        Timber.i("deleteOldestCrashLogs()");
        final File externalFilesDir = getExternalFilesDir(ServiceExceptionHandler.CRASH_LOG_FOLDER);
        if (externalFilesDir == null) {
            Timber.e("getExternalFilesDir() returned null. Preventing a NPE");
            Timber.d("getExternalFilesDir() returned null. Preventing a NPE");
            return;
        }

        final File[] fileToRemove = externalFilesDir.listFiles(new CrashlogsFileFilter());
        if (fileToRemove == null) {
            Timber.e("getExternalFilesDir() returned null. Preventing a NPE");
            Timber.d("getExternalFilesDir() returned null. Preventing a NPE");
            return;
        }

@@ -249,7 +249,7 @@ public class ObserverService extends Service implements OnRemoteOperationListene
        this.mSyncedFolders = loadSyncedFolders();

        if (mSyncedFolders.isEmpty()) {
            Timber.w("List of synced folders is empty");
            Timber.d("List of synced folders is empty");
            this.stopSelf();
            return;
        }
@@ -257,7 +257,7 @@ public class ObserverService extends Service implements OnRemoteOperationListene
        if (remote) {
            final OwnCloudClient client = DavClientProvider.getInstance().getClientInstance(mAccount, getApplicationContext());
            if (client == null) {
                Timber.w("OwnCloudClient is null");
                Timber.d("OwnCloudClient is null");
                return;
            }

@@ -305,7 +305,7 @@ public class ObserverService extends Service implements OnRemoteOperationListene
        if (!(operation instanceof ListFileRemoteOperation)) return;

        if (!result.isSuccess()) {
            Timber.w("ListRemoteFileOperation failed. Http code: %s", result.getHttpCode());
            Timber.d("ListRemoteFileOperation failed. Http code: %s", result.getHttpCode());
        }

        final List<RemoteFile> remoteFiles = ((RemoteOperationResult<ArrayList<RemoteFile>>)result).getResultData();
@@ -333,7 +333,7 @@ public class ObserverService extends Service implements OnRemoteOperationListene
            Timber.d("syncRequests contains %s", syncRequests.size());
            passSyncRequestsToSynchronizationService();
        } else {
            Timber.w("There is no file to sync.");
            Timber.i("There is no file to sync.");
            getSharedPreferences(AppConstants.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE)
                    .edit()
                    .putLong(AppConstants.KEY_LAST_SYNC_TIME, System.currentTimeMillis())
+10 −16
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ public class SynchronizationService extends Service implements OnRemoteOperation
        account = CommonUtils.getAccount(accountName, accountType, AccountManager.get(this));

        if (account == null) {
            Timber.w("No account available");
            Timber.d("No account available");
            stopSelf();
            return START_NOT_STICKY;
        }
@@ -113,12 +113,6 @@ public class SynchronizationService extends Service implements OnRemoteOperation
        return binder;
    }

    @Override
    public void onLowMemory() {
        Timber.w("System is low on memory. Service might get killed.");
    }


    /**
     * Try to pause synchronization.
     * Can only be paused if no sync is already running and no request queue is started
@@ -297,38 +291,38 @@ public class SynchronizationService extends Service implements OnRemoteOperation
                    break;
                case SYNC_CONFLICT:
                    //Case specific to UploadFileOperation
                    Timber.e("%s : Sync_conflict : File is already up to date", operationClassName);
                    Timber.d("%s : Sync_conflict : File is already up to date", operationClassName);
                    break;
                case INVALID_OVERWRITE:
                    Timber.e("%s => invalid_overwrite :\n remote file and local file doesn't have the same size", operationClassName);
                    Timber.d("%s => invalid_overwrite :\n remote file and local file doesn't have the same size", operationClassName);
                    break;
                case UNKNOWN_ERROR:
                    if (callerOperation instanceof UploadFileOperation) {
                        final int rowAffected = DbHelper.forceFoldertoBeRescan(((UploadFileOperation) callerOperation).getSyncedState().getId(), getApplicationContext());
                        Timber.e("Upload failed for unknown reason.\n Force folder to be rescan next time (row affected) : %s", rowAffected);
                        Timber.d("Upload failed for unknown reason.\n Force folder to be rescan next time (row affected) : %s", rowAffected);
                    } else if (callerOperation instanceof DownloadFileOperation) {
                        Timber.e("Download: Unknown_error : failed");
                        Timber.d("Download: Unknown_error : failed");
                    }
                    break;
                case FORBIDDEN:
                    if (callerOperation instanceof UploadFileOperation) {
                        final int rowAffected = DbHelper.forceFoldertoBeRescan(((UploadFileOperation) callerOperation).getSyncedState().getId(), getApplicationContext());
                        Timber.e("Upload: Forbidden : Can't get syncedFileState, no remote path defined. Force folder to be rescan next time (row affected) : %s", rowAffected);
                        Timber.d("Upload: Forbidden : Can't get syncedFileState, no remote path defined. Force folder to be rescan next time (row affected) : %s", rowAffected);
                    } else if (callerOperation instanceof DownloadFileOperation) {
                        Timber.e("Download : Forbidden: Can't get syncedFileState, no local path defined");
                        Timber.d("Download : Forbidden: Can't get syncedFileState, no local path defined");
                    }
                    break;
                case QUOTA_EXCEEDED:
                    //Case specific to UploadFileOperation
                    Timber.w("Quota_EXCEEDED");
                    Timber.d("Quota_EXCEEDED");
                    break;
                case FILE_NOT_FOUND:
                    //Case specific to DownloadFileOperation
                    Timber.e("%s : File_not_found: File not found after download", operationClassName);
                    Timber.d("%s : File_not_found: File not found after download", operationClassName);
                    break;
                case ETAG_UNCHANGED:
                    //Case specific to DownloadFileOperation
                    Timber.e("%s : Sync_conflict: File is already up to date", operationClassName);
                    Timber.d("%s : Sync_conflict: File is already up to date", operationClassName);
                    break;
            }
        }
Loading