diff options
author | Chris Wren <cwren@android.com> | 2014-09-12 19:19:41 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-09-12 19:19:41 +0000 |
commit | 446bb6117dff5f5588e35709043059c0364a6d3d (patch) | |
tree | 20a670451119d1adb102bed8fe8c1dc27a86f660 /services | |
parent | 2977e88f6049d0ce12137439f862e304dceeb876 (diff) | |
parent | 07fa4538a714dd87a88d394c07c0c13b51148abb (diff) | |
download | frameworks_base-446bb6117dff5f5588e35709043059c0364a6d3d.zip frameworks_base-446bb6117dff5f5588e35709043059c0364a6d3d.tar.gz frameworks_base-446bb6117dff5f5588e35709043059c0364a6d3d.tar.bz2 |
am 8bce74e6: am c92ee713: Merge "Invalidate the people cache on Contacts provider changes." into lmp-dev
* commit '8bce74e6388883286c8f630cebd1870cd8b7ee5f':
Invalidate the people cache on Contacts provider changes.
Diffstat (limited to 'services')
-rw-r--r-- | services/core/java/com/android/server/notification/ValidateNotificationPeople.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/notification/ValidateNotificationPeople.java b/services/core/java/com/android/server/notification/ValidateNotificationPeople.java index d49dc9a..1c1a034 100644 --- a/services/core/java/com/android/server/notification/ValidateNotificationPeople.java +++ b/services/core/java/com/android/server/notification/ValidateNotificationPeople.java @@ -19,9 +19,11 @@ package com.android.server.notification; import android.app.Notification; import android.content.Context; import android.content.pm.PackageManager; +import android.database.ContentObserver; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; +import android.os.Handler; import android.os.UserHandle; import android.provider.ContactsContract; import android.provider.ContactsContract.Contacts; @@ -75,6 +77,9 @@ public class ValidateNotificationPeople implements NotificationSignalExtractor { // maps raw person handle to resolved person object private LruCache<String, LookupResult> mPeopleCache; private Map<Integer, Context> mUserToContextMap; + private Handler mHandler; + private ContentObserver mObserver; + private int mEvictionCount; public void initialize(Context context) { if (DEBUG) Slog.d(TAG, "Initializing " + getClass().getSimpleName() + "."); @@ -83,6 +88,22 @@ public class ValidateNotificationPeople implements NotificationSignalExtractor { mPeopleCache = new LruCache<String, LookupResult>(PEOPLE_CACHE_SIZE); mEnabled = ENABLE_PEOPLE_VALIDATOR && 1 == Settings.Global.getInt( mBaseContext.getContentResolver(), SETTING_ENABLE_PEOPLE_VALIDATOR, 1); + if (mEnabled) { + mHandler = new Handler(); + mObserver = new ContentObserver(mHandler) { + @Override + public void onChange(boolean selfChange, Uri uri, int userId) { + super.onChange(selfChange, uri, userId); + if (DEBUG || mEvictionCount % 100 == 0) { + if (INFO) Slog.i(TAG, "mEvictionCount: " + mEvictionCount); + } + mPeopleCache.evictAll(); + mEvictionCount++; + } + }; + mBaseContext.getContentResolver().registerContentObserver(Contacts.CONTENT_URI, true, + mObserver, UserHandle.USER_ALL); + } } public RankingReconsideration process(NotificationRecord record) { |