1
0
mirror of https://github.com/etesync/android synced 2025-01-11 08:10:58 +00:00

Rename account: don't crash when content providers are not accessible

This commit is contained in:
Ricki Hirner 2016-11-17 19:58:08 +01:00
parent d34efb103d
commit d2df3c9027
3 changed files with 11 additions and 7 deletions

View File

@ -17,7 +17,7 @@ android {
minSdkVersion 15
targetSdkVersion 24
versionCode 128
versionCode 129
buildConfigField "long", "buildTime", System.currentTimeMillis() + "L"
buildConfigField "boolean", "customCerts", "true"

View File

@ -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);
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});
}
}
}

View File

@ -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);
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});
}
}
}