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:
parent
83ef63e94b
commit
1422d95ccf
@ -128,7 +128,12 @@ public class LocalAddressBook extends AndroidAddressBook implements LocalCollect
|
||||
|
||||
public void delete() {
|
||||
AccountManager accountManager = AccountManager.get(context);
|
||||
accountManager.removeAccount(account, null, null);
|
||||
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) {
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user