mirror of
https://github.com/etesync/android
synced 2025-01-11 00:01:12 +00:00
Rename account: don't crash when content providers are not accessible
This commit is contained in:
parent
d34efb103d
commit
d2df3c9027
@ -17,7 +17,7 @@ android {
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 24
|
||||
|
||||
versionCode 128
|
||||
versionCode 129
|
||||
|
||||
buildConfigField "long", "buildTime", System.currentTimeMillis() + "L"
|
||||
buildConfigField "boolean", "customCerts", "true"
|
||||
|
@ -233,9 +233,11 @@ public class LocalAddressBook extends AndroidAddressBook implements LocalCollect
|
||||
|
||||
public static void onRenameAccount(@NonNull ContentResolver resolver, @NonNull String oldName, @NonNull String newName) throws RemoteException {
|
||||
@Cleanup("release") ContentProviderClient client = resolver.acquireContentProviderClient(ContactsContract.AUTHORITY);
|
||||
ContentValues values = new ContentValues(1);
|
||||
values.put(RawContacts.ACCOUNT_NAME, newName);
|
||||
client.update(RawContacts.CONTENT_URI, values, RawContacts.ACCOUNT_NAME + "=?", new String[] { oldName });
|
||||
if (client != null) {
|
||||
ContentValues values = new ContentValues(1);
|
||||
values.put(RawContacts.ACCOUNT_NAME, newName);
|
||||
client.update(RawContacts.CONTENT_URI, values, RawContacts.ACCOUNT_NAME + "=?", new String[]{oldName});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -172,9 +172,11 @@ public class LocalTaskList extends AndroidTaskList implements LocalCollection {
|
||||
|
||||
public static void onRenameAccount(@NonNull ContentResolver resolver, @NonNull String oldName, @NonNull String newName) throws RemoteException {
|
||||
@Cleanup("release") ContentProviderClient client = resolver.acquireContentProviderClient(TaskProvider.ProviderName.OpenTasks.authority);
|
||||
ContentValues values = new ContentValues(1);
|
||||
values.put(Tasks.ACCOUNT_NAME, newName);
|
||||
client.update(Tasks.getContentUri(TaskProvider.ProviderName.OpenTasks.authority), values, Tasks.ACCOUNT_NAME + "=?", new String[] { oldName });
|
||||
if (client != null) {
|
||||
ContentValues values = new ContentValues(1);
|
||||
values.put(Tasks.ACCOUNT_NAME, newName);
|
||||
client.update(Tasks.getContentUri(TaskProvider.ProviderName.OpenTasks.authority), values, Tasks.ACCOUNT_NAME + "=?", new String[]{oldName});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user