kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fix crash that occurs if we don't have permission to add an account.
rodzic
cd10aa90cc
commit
32ee18240b
|
@ -87,15 +87,19 @@ object SystemContactsRepository {
|
||||||
var account: Account? = if (accounts.isNotEmpty()) accounts[0] else null
|
var account: Account? = if (accounts.isNotEmpty()) accounts[0] else null
|
||||||
|
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
Log.i(TAG, "Attempting to create a new account...")
|
try {
|
||||||
val newAccount = Account(accountDisplayName, applicationId)
|
Log.i(TAG, "Attempting to create a new account...")
|
||||||
|
val newAccount = Account(accountDisplayName, applicationId)
|
||||||
|
|
||||||
if (accountManager.addAccountExplicitly(newAccount, null, null)) {
|
if (accountManager.addAccountExplicitly(newAccount, null, null)) {
|
||||||
Log.i(TAG, "Successfully created a new account.")
|
Log.i(TAG, "Successfully created a new account.")
|
||||||
ContentResolver.setIsSyncable(newAccount, ContactsContract.AUTHORITY, 1)
|
ContentResolver.setIsSyncable(newAccount, ContactsContract.AUTHORITY, 1)
|
||||||
account = newAccount
|
account = newAccount
|
||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "Failed to create a new account!")
|
Log.w(TAG, "Failed to create a new account!")
|
||||||
|
}
|
||||||
|
} catch (e: SecurityException) {
|
||||||
|
Log.w(TAG, "Failed to add an account.", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue