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

Commit 91f02cd3 authored by Vincent Bourgmayer's avatar Vincent Bourgmayer
Browse files

Replace Log in ResetService to use Timber

parent f12e8219
Loading
Loading
Loading
Loading
+9 −10
Original line number Diff line number Diff line
@@ -15,13 +15,13 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.IBinder;
import android.util.Log;

import java.io.File;

import foundation.e.drive.EdriveApplication;
import foundation.e.drive.database.DbHelper;
import foundation.e.drive.utils.AppConstants;
import timber.log.Timber;

import static foundation.e.drive.utils.AppConstants.INITIALFOLDERS_NUMBER;
import static foundation.e.drive.utils.AppConstants.INITIALIZATION_HAS_BEEN_DONE;
@@ -34,11 +34,10 @@ import androidx.work.WorkManager;
 * Service which stop others, remove DB, clear sharedPrefs and unregister ScreenOffReceiver
 */
public class ResetService extends Service {
    private static final String TAG = ResetService.class.getSimpleName();

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.i(TAG, "onStartCommand()");
        Timber.tag(ResetService.class.getSimpleName()).i("onStartCommand()");
        if ( intent.getExtras() != null ) {
            final String intent_accountName = intent.getExtras().getString(AccountManager.KEY_ACCOUNT_NAME, "");
            final String intent_accountType = intent.getExtras().getString(AccountManager.KEY_ACCOUNT_TYPE, "");
@@ -53,8 +52,8 @@ public class ResetService extends Service {

                    stopAllServices();

                    boolean result = deleteDatabase(DbHelper.DATABASE_NAME);
                    Log.d(TAG, "Remove Database: "+result);
                    final boolean result = deleteDatabase(DbHelper.DATABASE_NAME);
                    Timber.d("Remove Database: %s", result);

                    cleanSharedPreferences(prefs);
                    removeCachedFiles();
@@ -69,16 +68,16 @@ public class ResetService extends Service {
    private void stopAllServices() {
        Intent stopperIntent = new Intent(getApplicationContext(), ObserverService.class);
        boolean result = getApplicationContext().stopService( stopperIntent );
        Log.d(TAG, "stop ObserverService: "+result);
        Timber.d("stop ObserverService: %s", result);

        stopperIntent = new Intent(getApplicationContext(), InitializerService.class);
        result = getApplicationContext().stopService( stopperIntent );
        Log.d(TAG, "stop InitializerService: "+result);
        Timber.d("stop InitializerService: %s", result);

        stopperIntent = new Intent(getApplicationContext(), SynchronizationService.class);
        result = getApplicationContext().stopService( stopperIntent );

        Log.d(TAG, "stop SynchronizationService: "+result);
        Timber.d("stop SynchronizationService: %s", result);
    }

    private void cleanSharedPreferences(SharedPreferences prefs) {
@@ -97,9 +96,9 @@ public class ResetService extends Service {
    }

    private void removeCachedFiles() {
        File[] cachedFiles =  this.getApplicationContext().getExternalCacheDir().listFiles();
        final File[] cachedFiles =  this.getApplicationContext().getExternalCacheDir().listFiles();
        if (cachedFiles == null) {
            Log.e(TAG, "listFiles() returned null. Returning to prevent a NPE");
            Timber.e("listFiles() returned null. preventing a NPE");
            return;
        }