aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AndroidManifest.xml5
-rw-r--r--src/com/android/providers/contacts/ContactsProvider2.java28
-rw-r--r--src/com/android/providers/contacts/RawContactsChangeNotificationProvider.java65
3 files changed, 98 insertions, 0 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 559e60f1..a673ec4e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -120,5 +120,10 @@
android:exported="true">
</provider>
+ <provider android:name="RawContactsChangeNotificationProvider"
+ android:authorities="com.android.contacts.raw_contacts"
+ android:exported="true">
+ </provider>
+
</application>
</manifest>
diff --git a/src/com/android/providers/contacts/ContactsProvider2.java b/src/com/android/providers/contacts/ContactsProvider2.java
index bd2fe265..3b93e711 100644
--- a/src/com/android/providers/contacts/ContactsProvider2.java
+++ b/src/com/android/providers/contacts/ContactsProvider2.java
@@ -1480,6 +1480,10 @@ public class ContactsProvider2 extends AbstractContactsProvider
private boolean mSyncToNetwork;
private boolean mSyncToMetadataNetWork;
+ private boolean mRawContactInserted;
+ private boolean mRawContactUpdated;
+ private boolean mRawContactDeleted;
+
private LocaleSet mCurrentLocales;
private int mContactsAccountCount;
@@ -2582,6 +2586,22 @@ public class ContactsProvider2 extends AbstractContactsProvider
getContext().getContentResolver().notifyChange(MetadataSync.METADATA_AUTHORITY_URI,
null, syncToMetadataNetwork);
+
+ if (mRawContactInserted) {
+ getContext().getContentResolver().notifyChange(
+ RawContacts.RAW_CONTACTS_NOTIFICATION_INSERT_URI, null);
+ mRawContactInserted = false;
+ }
+ if (mRawContactUpdated) {
+ getContext().getContentResolver().notifyChange(
+ RawContacts.RAW_CONTACTS_NOTIFICATION_UPDATE_URI, null);
+ mRawContactUpdated = false;
+ }
+ if (mRawContactDeleted) {
+ getContext().getContentResolver().notifyChange(
+ RawContacts.RAW_CONTACTS_NOTIFICATION_DELETE_URI, null);
+ mRawContactDeleted = false;
+ }
}
protected void setProviderStatus(int status) {
@@ -2883,6 +2903,7 @@ public class ContactsProvider2 extends AbstractContactsProvider
}
mProviderStatusUpdateNeeded = true;
+ mRawContactInserted = true;
return rawContactId;
}
@@ -3873,6 +3894,9 @@ public class ContactsProvider2 extends AbstractContactsProvider
if (!contactIsSingleton) {
mAggregator.get().updateAggregateData(mTransactionContext.get(), contactId);
}
+ if (count != 0) {
+ mRawContactDeleted = true;
+ }
return count;
}
@@ -4645,6 +4669,9 @@ public class ContactsProvider2 extends AbstractContactsProvider
}
mTransactionContext.get().markRawContactChangedOrDeletedOrInserted(rawContactId);
}
+ if (count != 0) {
+ mRawContactUpdated = true;
+ }
return count;
}
@@ -9040,6 +9067,7 @@ public class ContactsProvider2 extends AbstractContactsProvider
updateValues.put(Photo.PHOTO, processor.getThumbnailPhotoBytes());
update(ContentUris.withAppendedId(Data.CONTENT_URI, mDataId),
updateValues, null, null);
+ mRawContactUpdated = true;
} else {
// Insert a new primary data record with the photo.
ContentValues insertValues = new ContentValues();
diff --git a/src/com/android/providers/contacts/RawContactsChangeNotificationProvider.java b/src/com/android/providers/contacts/RawContactsChangeNotificationProvider.java
new file mode 100644
index 00000000..76749ab5
--- /dev/null
+++ b/src/com/android/providers/contacts/RawContactsChangeNotificationProvider.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.providers.contacts;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.database.Cursor;
+import android.net.Uri;
+
+/**
+ * An empty provider to support RawContacts change notification.
+ */
+public class RawContactsChangeNotificationProvider extends ContentProvider {
+ public static final String AUTHORITY = "com.android.contacts.raw_contacts";
+
+ @Override
+ public boolean onCreate() {
+ return true;
+ }
+
+ @Override
+ public Uri insert(Uri uri, ContentValues values) {
+ // Not needed.
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int delete(Uri uri, String selection, String[] selectionArgs) {
+ // Not needed.
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+ // Not needed.
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String getType(Uri uri) {
+ // Not needed.
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Cursor query(Uri uri, String[] inProjection, String selection, String[] selectionArgs,
+ String sortOrder) {
+ // Not needed.
+ throw new UnsupportedOperationException();
+ }
+}