浏览代码

on account removal also disable contacts backup job
remove unneeded function

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>

tobiasKaminsky 7 年之前
父节点
当前提交
f1731f889d

+ 9 - 0
src/main/java/com/owncloud/android/jobs/AccountRemovalJob.java

@@ -38,6 +38,7 @@ import com.owncloud.android.datamodel.FilesystemDataProvider;
 import com.owncloud.android.datamodel.SyncedFolder;
 import com.owncloud.android.datamodel.SyncedFolderProvider;
 import com.owncloud.android.datamodel.UploadsStorageManager;
+import com.owncloud.android.ui.activity.ContactsPreferenceActivity;
 import com.owncloud.android.ui.events.AccountRemovedEvent;
 import com.owncloud.android.utils.FileStorageUtils;
 import com.owncloud.android.utils.FilesSyncHelper;
@@ -67,7 +68,15 @@ public class AccountRemovalJob extends Job implements AccountManagerCallback<Boo
         Account account = AccountUtils.getOwnCloudAccountByName(context, bundle.getString(ACCOUNT, ""));
 
         if (account != null ) {
+            // disable contact backup job
+            ContactsPreferenceActivity.cancelPreviousContactBackupJobForAccount(context, account);
+
             AccountManager am = (AccountManager) context.getSystemService(ACCOUNT_SERVICE);
+
+            if (am == null) {
+                return Result.FAILURE;
+            }
+
             am.removeAccount(account, this, null);
 
             FileDataStorageManager storageManager = new FileDataStorageManager(account, context.getContentResolver());

+ 0 - 11
src/main/java/com/owncloud/android/ui/activity/ContactsPreferenceActivity.java

@@ -129,17 +129,6 @@ public class ContactsPreferenceActivity extends FileActivity implements FileFrag
                 .schedule();
     }
 
-    public static void cancelAllContactBackupJobs(Context context) {
-        Log_OC.d(TAG, "disabling all contacts backup job");
-
-        JobManager jobManager = JobManager.create(context);
-        Set<JobRequest> jobs = jobManager.getAllJobRequestsForTag(ContactsBackupJob.TAG);
-
-        for (JobRequest jobRequest : jobs) {
-            jobManager.cancel(jobRequest.getJobId());
-        }
-    }
-
     public static void cancelPreviousContactBackupJobForAccount(Context context, Account account) {
         Log_OC.d(TAG, "disabling existing contacts backup job for account: " + account.name);