Create placeholder ContentProviders for database observations.

Required for the API 26 migration.

See https://developer.android.com/about/versions/oreo/android-8.0-changes#ccn
This commit is contained in:
Greyson Parrelli
2018-08-21 13:28:01 -07:00
parent 1c75f375c3
commit c3bdc48ee3
3 changed files with 86 additions and 10 deletions

View File

@@ -28,10 +28,7 @@ import java.util.Set;
public abstract class Database {
protected static final String ID_WHERE = "_id = ?";
private static final String CONVERSATION_URI = "content://textsecure/thread/";
private static final String CONVERSATION_LIST_URI = "content://textsecure/conversation-list";
private static final String ATTACHMENT_URI = "content://textsecure/attachment/";
protected static final String ID_WHERE = "_id = ?";
protected SQLCipherOpenHelper databaseHelper;
protected final Context context;
@@ -47,29 +44,29 @@ public abstract class Database {
}
protected void notifyConversationListeners(long threadId) {
context.getContentResolver().notifyChange(Uri.parse(CONVERSATION_URI + threadId), null);
context.getContentResolver().notifyChange(DatabaseContentProviders.Conversation.getUriForThread(threadId), null);
}
protected void notifyConversationListListeners() {
context.getContentResolver().notifyChange(Uri.parse(CONVERSATION_LIST_URI), null);
context.getContentResolver().notifyChange(DatabaseContentProviders.ConversationList.CONTENT_URI, null);
}
protected void setNotifyConverationListeners(Cursor cursor, long threadId) {
cursor.setNotificationUri(context.getContentResolver(), Uri.parse(CONVERSATION_URI + threadId));
cursor.setNotificationUri(context.getContentResolver(), DatabaseContentProviders.Conversation.getUriForThread(threadId));
}
protected void setNotifyConverationListListeners(Cursor cursor) {
cursor.setNotificationUri(context.getContentResolver(), Uri.parse(CONVERSATION_LIST_URI));
cursor.setNotificationUri(context.getContentResolver(), DatabaseContentProviders.ConversationList.CONTENT_URI);
}
protected void registerAttachmentListeners(@NonNull ContentObserver observer) {
context.getContentResolver().registerContentObserver(Uri.parse(ATTACHMENT_URI),
context.getContentResolver().registerContentObserver(DatabaseContentProviders.Attachment.CONTENT_URI,
true,
observer);
}
protected void notifyAttachmentListeners() {
context.getContentResolver().notifyChange(Uri.parse(ATTACHMENT_URI), null);
context.getContentResolver().notifyChange(DatabaseContentProviders.Attachment.CONTENT_URI, null);
}
public void reset(SQLCipherOpenHelper databaseHelper) {