Update SyncHighRes service in AOSP Dialer app.
Test: manual tests by installing AOSP Dialer App
and open "favorite" tab.
Bug: 197889602
Change-Id: I2a0f85608062e6a466bc4056526bb0d258c8829c
diff --git a/java/com/android/contacts/common/model/ContactLoader.java b/java/com/android/contacts/common/model/ContactLoader.java
index 12cca4f..a3a3b9d 100644
--- a/java/com/android/contacts/common/model/ContactLoader.java
+++ b/java/com/android/contacts/common/model/ContactLoader.java
@@ -39,6 +39,7 @@
import com.android.contacts.common.GroupMetaData;
import com.android.contacts.common.model.account.AccountType;
import com.android.contacts.common.model.account.AccountTypeWithDataSet;
+import com.android.contacts.common.model.account.GoogleAccountType;
import com.android.contacts.common.model.dataitem.DataItem;
import com.android.contacts.common.model.dataitem.PhoneDataItem;
import com.android.contacts.common.model.dataitem.PhotoDataItem;
@@ -727,6 +728,10 @@
final String servicePackageName = accountType.getViewContactNotifyServicePackageName();
if (!TextUtils.isEmpty(serviceName) && !TextUtils.isEmpty(servicePackageName)) {
final Uri uri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId);
+ if (accountType instanceof GoogleAccountType) {
+ ((GoogleAccountType) accountType).handleRawContactViewed(context, uri);
+ continue;
+ }
final Intent intent = new Intent();
intent.setClassName(servicePackageName, serviceName);
intent.setAction(Intent.ACTION_VIEW);
diff --git a/java/com/android/contacts/common/model/account/GoogleAccountType.java b/java/com/android/contacts/common/model/account/GoogleAccountType.java
index 8a3c575..e10ade4 100644
--- a/java/com/android/contacts/common/model/account/GoogleAccountType.java
+++ b/java/com/android/contacts/common/model/account/GoogleAccountType.java
@@ -18,6 +18,8 @@
import android.content.ContentValues;
import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
import android.provider.ContactsContract.CommonDataKinds.Email;
import android.provider.ContactsContract.CommonDataKinds.Event;
import android.provider.ContactsContract.CommonDataKinds.Phone;
@@ -203,4 +205,21 @@
public String getViewContactNotifyServicePackageName() {
return PLUS_EXTENSION_PACKAGE_NAME;
}
+
+ /**
+ * Sends a broadcast to the sync adapter to trigger a high res photo sync for the contact which
+ * was viewed
+ * @param context context to send broadcast in
+ * @param rawContactUri Uri of the raw contact viewed
+ */
+ public void handleRawContactViewed(Context context, Uri rawContactUri) {
+ final Intent intent = new Intent();
+ intent.setData(rawContactUri);
+ // New broadcast for syncing high res photo.
+ intent.setPackage(GoogleAccountType.PLUS_EXTENSION_PACKAGE_NAME);
+ intent.setAction(
+ "com.google.android.gms.people.sync.focus.SYNC_HIGH_RES_PHOTO");
+
+ context.sendBroadcast(intent);
+ }
}