1
0
mirror of https://github.com/etesync/android synced 2025-02-02 19:01:06 +00:00

Disallow user removal of address book accounts

We don't want users to remove address books on their own, we want to
control these automatically. This commit blocks it.
This commit is contained in:
Tom Hacohen 2017-04-21 21:04:24 +01:00
parent 83ef63e94b
commit 1422d95ccf
2 changed files with 14 additions and 1 deletions

View File

@ -128,8 +128,13 @@ public class LocalAddressBook extends AndroidAddressBook implements LocalCollect
public void delete() {
AccountManager accountManager = AccountManager.get(context);
if (Build.VERSION.SDK_INT >=
Build.VERSION_CODES.LOLLIPOP_MR1) {
accountManager.removeAccountExplicitly(account);
} else {
accountManager.removeAccount(account, null, null);
}
}
public LocalAddressBook(Context context, Account account, ContentProviderClient provider) {
super(account, provider, LocalGroup.Factory.INSTANCE, LocalContact.Factory.INSTANCE);

View File

@ -11,6 +11,7 @@ package com.etesync.syncadapter.syncadapter;
import android.accounts.AbstractAccountAuthenticator;
import android.accounts.Account;
import android.accounts.AccountAuthenticatorResponse;
import android.accounts.AccountManager;
import android.accounts.NetworkErrorException;
import android.app.Service;
import android.content.Context;
@ -78,6 +79,13 @@ public class NullAuthenticatorService extends Service {
return null;
}
@Override
public Bundle getAccountRemovalAllowed(AccountAuthenticatorResponse response, Account account) {
Bundle result = new Bundle();
boolean allowed = false; // we don't want users to explicitly delete inner accounts
result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, allowed);
return result;
}
}
}