fix content observer notification in IdentityLoader
This commit is contained in:
@@ -26,6 +26,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import android.content.ContentProvider;
|
import android.content.ContentProvider;
|
||||||
|
import android.content.ContentResolver;
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.UriMatcher;
|
import android.content.UriMatcher;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
@@ -904,6 +905,7 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
int count;
|
int count;
|
||||||
final int match = mUriMatcher.match(uri);
|
final int match = mUriMatcher.match(uri);
|
||||||
|
|
||||||
|
ContentResolver contentResolver = getContext().getContentResolver();
|
||||||
switch (match) {
|
switch (match) {
|
||||||
// dangerous
|
// dangerous
|
||||||
case KEY_RINGS_UNIFIED: {
|
case KEY_RINGS_UNIFIED: {
|
||||||
@@ -918,7 +920,7 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
}
|
}
|
||||||
// corresponding keys and userIds are deleted by ON DELETE CASCADE
|
// corresponding keys and userIds are deleted by ON DELETE CASCADE
|
||||||
count = db.delete(Tables.KEY_RINGS_PUBLIC, selection, selectionArgs);
|
count = db.delete(Tables.KEY_RINGS_PUBLIC, selection, selectionArgs);
|
||||||
uri = KeyRings.buildGenericKeyRingUri(uri.getPathSegments().get(1));
|
contentResolver.notifyChange(KeyRings.buildGenericKeyRingUri(uri.getPathSegments().get(1)), null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case KEY_RING_SECRET: {
|
case KEY_RING_SECRET: {
|
||||||
@@ -928,7 +930,7 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
selection += " AND (" + additionalSelection + ")";
|
selection += " AND (" + additionalSelection + ")";
|
||||||
}
|
}
|
||||||
count = db.delete(Tables.KEY_RINGS_SECRET, selection, selectionArgs);
|
count = db.delete(Tables.KEY_RINGS_SECRET, selection, selectionArgs);
|
||||||
uri = KeyRings.buildGenericKeyRingUri(uri.getPathSegments().get(1));
|
contentResolver.notifyChange(KeyRings.buildGenericKeyRingUri(uri.getPathSegments().get(1)), null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -948,6 +950,11 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
|
|
||||||
count = db.delete(Tables.API_AUTOCRYPT_PEERS, selection, selectionArgs);
|
count = db.delete(Tables.API_AUTOCRYPT_PEERS, selection, selectionArgs);
|
||||||
|
|
||||||
|
if (masterKeyId != null) {
|
||||||
|
contentResolver.notifyChange(KeyRings.buildGenericKeyRingUri(masterKeyId), null);
|
||||||
|
}
|
||||||
|
contentResolver.notifyChange(
|
||||||
|
ApiAutocryptPeer.buildByPackageNameAndAutocryptId(packageName, autocryptPeer), null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -957,7 +964,7 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
selection += " AND (" + additionalSelection + ")";
|
selection += " AND (" + additionalSelection + ")";
|
||||||
}
|
}
|
||||||
count = db.delete(Tables.API_AUTOCRYPT_PEERS, selection, selectionArgs);
|
count = db.delete(Tables.API_AUTOCRYPT_PEERS, selection, selectionArgs);
|
||||||
uri = KeyRings.buildGenericKeyRingUri(uri.getLastPathSegment());
|
contentResolver.notifyChange(KeyRings.buildGenericKeyRingUri(uri.getLastPathSegment()), null);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case API_APPS_BY_PACKAGE_NAME: {
|
case API_APPS_BY_PACKAGE_NAME: {
|
||||||
@@ -975,9 +982,6 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// notify of changes in db
|
|
||||||
getContext().getContentResolver().notifyChange(uri, null);
|
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -989,6 +993,7 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
Log.v(Constants.TAG, "update(uri=" + uri + ", values=" + values.toString() + ")");
|
Log.v(Constants.TAG, "update(uri=" + uri + ", values=" + values.toString() + ")");
|
||||||
|
|
||||||
final SQLiteDatabase db = getDb().getWritableDatabase();
|
final SQLiteDatabase db = getDb().getWritableDatabase();
|
||||||
|
ContentResolver contentResolver = getContext().getContentResolver();
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
try {
|
try {
|
||||||
@@ -1052,6 +1057,8 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
values.getAsLong(ApiAutocryptPeer.STATE));
|
values.getAsLong(ApiAutocryptPeer.STATE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
contentResolver.notifyChange(KeyRings.buildGenericKeyRingUri(masterKeyId), null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
db.replace(Tables.API_AUTOCRYPT_PEERS, null, actualValues);
|
db.replace(Tables.API_AUTOCRYPT_PEERS, null, actualValues);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -1065,7 +1072,7 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// notify of changes in db
|
// notify of changes in db
|
||||||
getContext().getContentResolver().notifyChange(uri, null);
|
contentResolver.notifyChange(uri, null);
|
||||||
|
|
||||||
} catch (SQLiteConstraintException e) {
|
} catch (SQLiteConstraintException e) {
|
||||||
Log.d(Constants.TAG, "Constraint exception on update! Entry already existing?", e);
|
Log.d(Constants.TAG, "Constraint exception on update! Entry already existing?", e);
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import org.sufficientlysecure.keychain.linked.UriAttribute;
|
|||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAutocryptPeer;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAutocryptPeer;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.Certs;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.Certs;
|
||||||
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets;
|
||||||
import org.sufficientlysecure.keychain.ui.keyview.loader.IdentityLoader.IdentityInfo;
|
import org.sufficientlysecure.keychain.ui.keyview.loader.IdentityLoader.IdentityInfo;
|
||||||
import org.sufficientlysecure.keychain.ui.util.PackageIconGetter;
|
import org.sufficientlysecure.keychain.ui.util.PackageIconGetter;
|
||||||
@@ -92,6 +93,8 @@ public class IdentityLoader extends AsyncTaskLoader<List<IdentityInfo>> {
|
|||||||
|
|
||||||
this.identityObserver = new ForceLoadContentObserver();
|
this.identityObserver = new ForceLoadContentObserver();
|
||||||
this.packageIconGetter = PackageIconGetter.getInstance(context);
|
this.packageIconGetter = PackageIconGetter.getInstance(context);
|
||||||
|
|
||||||
|
this.identityObserver = new ForceLoadContentObserver();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user