Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e66d38a6 authored by Trung Lam's avatar Trung Lam
Browse files

Implement onDestroy for ConversationStore for when an app gets

uninstalled.

Change-Id: I8ad6ec2987c509d6713abdd4244c314cb05e79a1
Test: Built and tested on device.
Bug: 149789130
parent 88961798
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ abstract class AbstractProtoDiskReadWriter<T> {
    @GuardedBy("this")
    private ScheduledFuture<?> mScheduledFuture;

    // File name -> data class
    @GuardedBy("this")
    private Map<String, T> mScheduledFileDataMap = new ArrayMap<>();

@@ -84,7 +85,8 @@ abstract class AbstractProtoDiskReadWriter<T> {
    }

    @WorkerThread
    void delete(@NonNull String fileName) {
    synchronized void delete(@NonNull String fileName) {
        mScheduledFileDataMap.remove(fileName);
        final File file = getFile(fileName);
        if (!file.exists()) {
            return;
+14 −0
Original line number Diff line number Diff line
@@ -191,6 +191,15 @@ class ConversationStore {
        return getConversation(mNotifChannelIdToShortcutIdMap.get(notifChannelId));
    }

    synchronized void onDestroy() {
        mConversationInfoMap.clear();
        mContactUriToShortcutIdMap.clear();
        mLocusIdToShortcutIdMap.clear();
        mNotifChannelIdToShortcutIdMap.clear();
        mPhoneNumberToShortcutIdMap.clear();
        mConversationInfosProtoDiskReadWriter.deleteConversationsFile();
    }

    @MainThread
    private synchronized void updateConversationsInMemory(
            @NonNull ConversationInfo conversationInfo) {
@@ -324,5 +333,10 @@ class ConversationStore {
        void saveConversationsImmediately(@NonNull List<ConversationInfo> conversationInfos) {
            saveImmediately(mConversationInfoFileName, conversationInfos);
        }

        @WorkerThread
        void deleteConversationsFile() {
            delete(mConversationInfoFileName);
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -253,6 +253,6 @@ public class PackageData {

    void onDestroy() {
        mEventStore.onDestroy();
        // TODO: STOPSHIP: Destroy conversation info for the case of package being uninstalled.
        mConversationStore.onDestroy();
    }
}