Loading app/src/main/java/foundation/e/drive/work/FullScanWorker.java +19 −2 Original line number Diff line number Diff line Loading @@ -8,8 +8,11 @@ package foundation.e.drive.work; import android.accounts.Account; import android.accounts.AccountManager; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.util.Log; import androidx.annotation.NonNull; Loading @@ -17,6 +20,8 @@ import androidx.work.Worker; import androidx.work.WorkerParameters; import foundation.e.drive.services.ObserverService; import foundation.e.drive.utils.AppConstants; import foundation.e.drive.utils.CommonUtils; /** * As a first step, this class must replace foundation.e.drive.jobs.ScannerJob Loading @@ -39,8 +44,20 @@ public class FullScanWorker extends Worker { @Override public Result doWork() { Log.d(TAG, "doWork(): going to send intent to ObserverService"); Intent observerServiceIntent = new Intent(this.getApplicationContext(), ObserverService.class); final SharedPreferences prefs = getApplicationContext().getSharedPreferences(AppConstants.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE ); final String accountName = prefs.getString( AccountManager.KEY_ACCOUNT_NAME, "" ); final String accountType = prefs.getString( AccountManager.KEY_ACCOUNT_TYPE, "" ); final Account mAccount = CommonUtils.getAccount( accountName, accountType, AccountManager.get(this.getApplicationContext()) ); if(mAccount != null && CommonUtils.isSettingsSyncEnabled(mAccount) && CommonUtils.isMediaSyncEnabled(mAccount)) { final Intent observerServiceIntent = new Intent(this.getApplicationContext(), ObserverService.class); this.getApplicationContext().startService(observerServiceIntent); }else{ Log.w(TAG, "Intent for ObserverService not send : account is null or \"settings sync\" & \"media sync\" settings are disabled"); } return Result.success(); } } Loading
app/src/main/java/foundation/e/drive/work/FullScanWorker.java +19 −2 Original line number Diff line number Diff line Loading @@ -8,8 +8,11 @@ package foundation.e.drive.work; import android.accounts.Account; import android.accounts.AccountManager; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.util.Log; import androidx.annotation.NonNull; Loading @@ -17,6 +20,8 @@ import androidx.work.Worker; import androidx.work.WorkerParameters; import foundation.e.drive.services.ObserverService; import foundation.e.drive.utils.AppConstants; import foundation.e.drive.utils.CommonUtils; /** * As a first step, this class must replace foundation.e.drive.jobs.ScannerJob Loading @@ -39,8 +44,20 @@ public class FullScanWorker extends Worker { @Override public Result doWork() { Log.d(TAG, "doWork(): going to send intent to ObserverService"); Intent observerServiceIntent = new Intent(this.getApplicationContext(), ObserverService.class); final SharedPreferences prefs = getApplicationContext().getSharedPreferences(AppConstants.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE ); final String accountName = prefs.getString( AccountManager.KEY_ACCOUNT_NAME, "" ); final String accountType = prefs.getString( AccountManager.KEY_ACCOUNT_TYPE, "" ); final Account mAccount = CommonUtils.getAccount( accountName, accountType, AccountManager.get(this.getApplicationContext()) ); if(mAccount != null && CommonUtils.isSettingsSyncEnabled(mAccount) && CommonUtils.isMediaSyncEnabled(mAccount)) { final Intent observerServiceIntent = new Intent(this.getApplicationContext(), ObserverService.class); this.getApplicationContext().startService(observerServiceIntent); }else{ Log.w(TAG, "Intent for ObserverService not send : account is null or \"settings sync\" & \"media sync\" settings are disabled"); } return Result.success(); } }