Bug 1497977 p5 - Flag local client record for upload on fxa device id change. r=nalexander
authorEdouard Oger <eoger@fastmail.com>
Wed, 17 Oct 2018 18:23:12 +0000
changeset 490164 60c949b40f469cdb459a1ec9d31efce727593c3a
parent 490163 ea10b0217cec23ce84efefcf437e9a81c33e31fd
child 490165 3506efe6428a9247e324af7a06dc82f61af781f1
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersnalexander
bugs1497977
milestone64.0a1
Bug 1497977 p5 - Flag local client record for upload on fxa device id change. r=nalexander Depends on D8610 Differential Revision: https://phabricator.services.mozilla.com/D8611
mobile/android/services/src/main/java/org/mozilla/gecko/sync/stage/SyncClientsEngineStage.java
--- a/mobile/android/services/src/main/java/org/mozilla/gecko/sync/stage/SyncClientsEngineStage.java
+++ b/mobile/android/services/src/main/java/org/mozilla/gecko/sync/stage/SyncClientsEngineStage.java
@@ -566,17 +566,28 @@ public class SyncClientsEngineStage exte
     long now = System.currentTimeMillis();
     long age = now - lastUpload;
     return age >= CLIENTS_TTL_REFRESH;
   }
 
   protected void handleDownloadedLocalRecord(ClientRecord r) {
     session.config.persistServerClientRecordTimestamp(r.lastModified);
 
-    if (!getLocalClientVersion().equals(r.version) ||
+    final Context context = session.getContext();
+    final Account account = FirefoxAccounts.getFirefoxAccount(context);
+    String fxaDeviceId;
+    if (account != null) {
+      final AndroidFxAccount fxAccount = new AndroidFxAccount(context, account);
+      fxaDeviceId = fxAccount.getDeviceId();
+    } else {
+      fxaDeviceId = null;
+    }
+
+    if (!TextUtils.equals(r.fxaDeviceId, fxaDeviceId) ||
+        !getLocalClientVersion().equals(r.version) ||
         !getLocalClientProtocols().equals(r.protocols)) {
       shouldUploadLocalRecord = true;
     }
     processCommands(r.commands);
   }
 
   protected void processCommands(JSONArray commands) {
     if (commands == null ||