SyncInfo(Parcel parcel) { authorityId = parcel.readInt(); account = new Account(parcel); authority = parcel.readString(); startTime = parcel.readLong(); }
private Account renameAccountInternal(int userId, Account accountToRename, String newName) { // TODO: Cancel Notification synchronized (accountsByUserId) { VAccount vAccount = getAccount(userId, accountToRename); if (vAccount != null) { vAccount.previousName = vAccount.name; vAccount.name = newName; saveAllAccounts(); Account newAccount = new Account(vAccount.name, vAccount.type); synchronized (authTokenRecords) { for (AuthTokenRecord record : authTokenRecords) { if (record.userId == userId && record.account.equals(accountToRename)) { record.account = newAccount; } } } sendAccountsChangedBroadcast(userId); return newAccount; } } return accountToRename; }
@Test public void shouldHaveParcelConstructor() throws Exception { Account expected = new Account("name", "type"); Parcel p = Parcel.obtain(); expected.writeToParcel(p, 0); p.setDataPosition(0); Account actual = new Account(p); assertThat(actual).isEqualTo(expected); }
@Test public void shouldProvideEqualAndHashCode() throws Exception { assertThat(new Account("a", "b")).isEqualTo(new Account("a", "b")); assertThat(new Account("a", "b")).isNotEqualTo(new Account("c", "b")); assertThat(new Account("a", "b").hashCode()).isEqualTo(new Account("a", "b").hashCode()); assertThat(new Account("a", "b").hashCode()).isNotEqualTo(new Account("c", "b").hashCode()); } }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SyncRecordKey that = (SyncRecordKey) o; if (account != null ? !account.equals(that.account) : that.account != null) return false; return authority != null ? authority.equals(that.authority) : that.authority == null; }
public void writeToParcel(Parcel parcel, int flags) { parcel.writeInt(authorityId); account.writeToParcel(parcel, 0); parcel.writeString(authority); parcel.writeLong(startTime); }
@Override public int hashCode() { return ((this.userId * 31 + this.account.hashCode()) * 31 + this.authTokenType.hashCode()) * 31 + this.packageName.hashCode(); } }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; AuthTokenRecord that = (AuthTokenRecord) o; return userId == that.userId && account.equals(that.account) && authTokenType.equals(that.authTokenType) && packageName.equals(that.packageName); }
public void writeToParcel(Parcel dest, int flags) { dest.writeString(id); account.writeToParcel(dest, flags); }
@Override public int hashCode() { return ((this.userId * 31 + this.account.hashCode()) * 31 + this.authTokenType.hashCode()) * 31 + this.packageName.hashCode(); } }
private List<Account> getAccountList(int userId, String type) { synchronized (accountsByUserId) { List<Account> accounts = new ArrayList<>(); List<VAccount> vAccounts = accountsByUserId.get(userId); if (vAccounts != null) { for (VAccount vAccount : vAccounts) { if (type == null || vAccount.type.equals(type)) { accounts.add(new Account(vAccount.name, vAccount.type)); } } } return accounts; } }
private Account renameAccountInternal(int userId, Account accountToRename, String newName) { // TODO: Cancel Notification synchronized (accountsByUserId) { VAccount vAccount = getAccount(userId, accountToRename); if (vAccount != null) { vAccount.previousName = vAccount.name; vAccount.name = newName; saveAllAccounts(); Account newAccount = new Account(vAccount.name, vAccount.type); synchronized (authTokenRecords) { for (AuthTokenRecord record : authTokenRecords) { if (record.userId == userId && record.account.equals(accountToRename)) { record.account = newAccount; } } } sendAccountsChangedBroadcast(userId); return newAccount; } } return accountToRename; }
@Test public void shouldBeParcelable() throws Exception { Account expected = new Account("name", "type"); Parcel p = Parcel.obtain(); expected.writeToParcel(p, 0); p.setDataPosition(0); Account actual = Account.CREATOR.createFromParcel(p); assertThat(actual).isEqualTo(expected); }
private void setPasswordInternal(int userId, Account account, String password) { synchronized (accountsByUserId) { VAccount vAccount = getAccount(userId, account); if (vAccount != null) { vAccount.password = password; vAccount.authTokens.clear(); saveAllAccounts(); synchronized (authTokenRecords) { Iterator<AuthTokenRecord> iterator = authTokenRecords.iterator(); while (iterator.hasNext()) { AuthTokenRecord record = iterator.next(); if (record.userId == userId && record.account.equals(account)) { iterator.remove(); } } } sendAccountsChangedBroadcast(userId); } } }
public void writeToParcel(Parcel parcel, int flags) { parcel.writeInt(authorityId); account.writeToParcel(parcel, 0); parcel.writeString(authority); parcel.writeLong(startTime); }
@Override public int hashCode() { return ((this.userId * 31 + this.account.hashCode()) * 31 + this.authTokenType.hashCode()) * 31 + this.packageName.hashCode(); } }
public String getTokenWithNotification(Context context, String accountName, String scope, Bundle extras, String authority, Bundle syncBundle) throws IOException, UserRecoverableNotifiedException, GoogleAuthException { return getTokenWithNotification(context, new Account(accountName, "robo"), scope, extras, authority, syncBundle); }
private Account renameAccountInternal(int userId, Account accountToRename, String newName) { // TODO: Cancel Notification synchronized (accountsByUserId) { VAccount vAccount = getAccount(userId, accountToRename); if (vAccount != null) { vAccount.previousName = vAccount.name; vAccount.name = newName; saveAllAccounts(); Account newAccount = new Account(vAccount.name, vAccount.type); synchronized (authTokenRecords) { for (AuthTokenRecord record : authTokenRecords) { if (record.userId == userId && record.account.equals(accountToRename)) { record.account = newAccount; } } } sendAccountsChangedBroadcast(userId); return newAccount; } } return accountToRename; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SyncRecordKey that = (SyncRecordKey) o; if (account != null ? !account.equals(that.account) : that.account != null) return false; return authority != null ? authority.equals(that.authority) : that.authority == null; }