Skip to content

Commit

Permalink
Validate account existence before setting user data and log sync adap…
Browse files Browse the repository at this point in the history
…ter errors instead of throwing exceptions
  • Loading branch information
rfc2822 committed Feb 5, 2025
1 parent 6eab827 commit 49242f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ abstract class SyncAdapterService: Service() {
message.append("fakeSyncAdapter onPerformSync(account=$account, extras=$extras, authority=$authority, syncResult=$syncResult)")
for (key in extras.keySet())
message.append("\n\textras[$key] = ${extras[key]}")
throw NotImplementedError(message.toString())
Logger.getGlobal().warning(message.toString())
}
}
return fakeAdapter.syncAdapterBinder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ fun AccountManager.setAndVerifyUserData(account: Account, key: String, value: St
/* already set / success */
return

if (!accounts.contains(account))
/* invalid account */
return

// set user data
setUserData(account, key, value)

// wait a bit because AccountManager access sometimes seems a bit asynchronous
Expand Down

0 comments on commit 49242f0

Please sign in to comment.