Fix crash that occurs if we don't have permission to add an account.

fork-5.53.8
Greyson Parrelli 2022-04-22 14:30:37 -04:00
rodzic cd10aa90cc
commit 32ee18240b
1 zmienionych plików z 12 dodań i 8 usunięć

Wyświetl plik

@ -87,6 +87,7 @@ object SystemContactsRepository {
var account: Account? = if (accounts.isNotEmpty()) accounts[0] else null
if (account == null) {
try {
Log.i(TAG, "Attempting to create a new account...")
val newAccount = Account(accountDisplayName, applicationId)
@ -97,6 +98,9 @@ object SystemContactsRepository {
} else {
Log.w(TAG, "Failed to create a new account!")
}
} catch (e: SecurityException) {
Log.w(TAG, "Failed to add an account.", e)
}
}
if (account != null && !ContentResolver.getSyncAutomatically(account, ContactsContract.AUTHORITY)) {