Bug 1046709 - Remove all remote visits when sync account is deleted r=nalexander
MozReview-Commit-ID: B4WkZyIllkE
--- a/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/receivers/FxAccountDeletedService.java
+++ b/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/receivers/FxAccountDeletedService.java
@@ -5,16 +5,17 @@
package org.mozilla.gecko.fxa.receivers;
import java.util.concurrent.Executor;
import org.mozilla.gecko.background.common.log.Logger;
import org.mozilla.gecko.background.fxa.oauth.FxAccountAbstractClient;
import org.mozilla.gecko.background.fxa.oauth.FxAccountAbstractClientException.FxAccountAbstractClientRemoteException;
import org.mozilla.gecko.background.fxa.oauth.FxAccountOAuthClient10;
+import org.mozilla.gecko.db.BrowserContract;
import org.mozilla.gecko.fxa.FxAccountConstants;
import org.mozilla.gecko.fxa.sync.FxAccountNotificationManager;
import org.mozilla.gecko.fxa.sync.FxAccountSyncAdapter;
import org.mozilla.gecko.sync.repositories.android.ClientsDatabase;
import org.mozilla.gecko.sync.repositories.android.FennecTabsRepository;
import android.app.IntentService;
import android.content.Context;
@@ -81,16 +82,25 @@ public class FxAccountDeletedService ext
if (db != null) {
db.close();
}
}
} catch (Exception e) {
Logger.warn(LOG_TAG, "Got exception deleting the Firefox Sync clients database; ignoring.", e);
}
+ // Delete visits we have received from Sync (anything marked as "remote").
+ // Note that we do not adjust "visits" counter on history records themselves.
+ int visitsDeleted = context.getContentResolver().delete(
+ BrowserContract.Visits.CONTENT_URI,
+ BrowserContract.Visits.IS_LOCAL + " = ?",
+ new String[]{"0"}
+ );
+ Logger.info(LOG_TAG, "Deleted " + visitsDeleted + " remote visits.");
+
// Remove any displayed notifications.
new FxAccountNotificationManager(FxAccountSyncAdapter.NOTIFICATION_ID).clear(context);
// Bug 1147275: Delete cached oauth tokens. There's no way to query all
// oauth tokens from Android, so this is tricky to do comprehensively. We
// can query, individually, for specific oauth tokens to delete, however.
final String oauthServerURI = intent.getStringExtra(FxAccountConstants.ACCOUNT_OAUTH_SERVICE_ENDPOINT_KEY);
final String[] tokens = intent.getStringArrayExtra(FxAccountConstants.ACCOUNT_DELETED_INTENT_ACCOUNT_AUTH_TOKENS);