diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-07-02 01:10:42 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-07-02 01:10:42 +0000 |
commit | cfda9760399f854c44c6c4fcc7fced2855e35a19 (patch) | |
tree | f8a830c92a860a78923539b7c07607d0386be95c | |
parent | 2ed0fe0eda1f10ae3eb5f7d574479d5b1ba6ddaa (diff) | |
parent | 7cbb98fe0e64f74fb2ad816d96b98b3d17a492de (diff) | |
download | Contacts-cfda9760399f854c44c6c4fcc7fced2855e35a19.tar.gz |
Snap for 7514518 from 7cbb98fe0e64f74fb2ad816d96b98b3d17a492de to sc-release
Change-Id: I7b84f5d5ebed1632e573a366148347b3d26d7420
-rw-r--r-- | src/com/android/contacts/model/ContactLoader.java | 20 | ||||
-rw-r--r-- | src/com/android/contacts/model/account/GoogleAccountType.java | 27 |
2 files changed, 31 insertions, 16 deletions
diff --git a/src/com/android/contacts/model/ContactLoader.java b/src/com/android/contacts/model/ContactLoader.java index cf5442f80..9e690e338 100644 --- a/src/com/android/contacts/model/ContactLoader.java +++ b/src/com/android/contacts/model/ContactLoader.java @@ -887,24 +887,12 @@ public class ContactLoader extends AsyncTaskLoader<Contact> { .getViewContactNotifyServicePackageName(); if (!TextUtils.isEmpty(serviceName) && !TextUtils.isEmpty(servicePackageName)) { final Uri uri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId); - final Intent intent = new Intent(); - intent.setDataAndType(uri, RawContacts.CONTENT_ITEM_TYPE); if (accountType instanceof GoogleAccountType) { - intent.setPackage(servicePackageName); - intent - .setAction("com.google.android.syncadapters.contacts.SYNC_HIGH_RES_PHOTO"); - List<ResolveInfo> broadcastReceivers = - context.getPackageManager().queryBroadcastReceivers(intent, 0); - if (!broadcastReceivers.isEmpty()) { - if (Log.isLoggable(TAG, Log.DEBUG)) { - for (ResolveInfo broadcastReceiver : broadcastReceivers) { - Log.d(TAG, broadcastReceiver.activityInfo.toString()); - } - } - context.sendBroadcast(intent); - continue; - } + ((GoogleAccountType) accountType).handleRawContactViewed(context, uri); + continue; } + final Intent intent = new Intent(); + intent.setData(uri); // TODO: Social Stream API is deprecated, and once the opted-in // sync adapters target Android O+, we won't be able to start their services // since they'll likely be in the background, so we'll need to remove the diff --git a/src/com/android/contacts/model/account/GoogleAccountType.java b/src/com/android/contacts/model/account/GoogleAccountType.java index c7aac7639..14d8a3d7e 100644 --- a/src/com/android/contacts/model/account/GoogleAccountType.java +++ b/src/com/android/contacts/model/account/GoogleAccountType.java @@ -18,10 +18,14 @@ package com.android.contacts.model.account; import android.content.ContentValues; import android.content.Context; +import android.content.Intent; +import android.content.pm.ResolveInfo; +import android.net.Uri; import android.provider.ContactsContract.CommonDataKinds.Email; import android.provider.ContactsContract.CommonDataKinds.Event; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.ContactsContract.CommonDataKinds.Relation; +import android.util.Log; import com.android.contacts.R; import com.android.contacts.model.dataitem.DataKind; @@ -203,4 +207,27 @@ public class GoogleAccountType extends BaseAccountType { public String getViewContactNotifyServicePackageName() { return "com.google.android.syncadapters.contacts"; } + + /** + * 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); + + // Old broadcast. This can be removed in T + intent.setPackage(getViewContactNotifyServicePackageName()); + intent.setAction( + "com.google.android.syncadapters.contacts.SYNC_HIGH_RES_PHOTO"); + context.sendBroadcast(intent); + } } |