diff options
author | Brian Attwell <brianattwell@google.com> | 2015-05-27 19:40:36 -0700 |
---|---|---|
committer | Brian Attwell <brianattwell@google.com> | 2015-05-28 23:32:06 +0000 |
commit | 652936f204b15097d030e870dda5054d8115cbf3 (patch) | |
tree | 3c8034bca6950e5f26e74fc93945b2cc4f9767f6 /src | |
parent | f2db7d5de84ab1d8c1ca851e2ce8eb4b58f1f834 (diff) | |
download | packages_apps_Contacts-652936f204b15097d030e870dda5054d8115cbf3.tar.gz packages_apps_Contacts-652936f204b15097d030e870dda5054d8115cbf3.tar.bz2 packages_apps_Contacts-652936f204b15097d030e870dda5054d8115cbf3.zip |
Use FLAG_GRANT_READ_URI_PERMISSION for ACTION_SEND
Now that read/writing the profile only has a single permission
associated with it, we can use the platform's existing
grantUriPermission() support.
Bug: 21090207
Change-Id: I31e6ae7b0f49c3589071f6a95f8d69a9456c144d
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/contacts/quickcontact/QuickContactActivity.java | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/src/com/android/contacts/quickcontact/QuickContactActivity.java b/src/com/android/contacts/quickcontact/QuickContactActivity.java index 7e02782ee..405d8f0e1 100644 --- a/src/com/android/contacts/quickcontact/QuickContactActivity.java +++ b/src/com/android/contacts/quickcontact/QuickContactActivity.java @@ -2251,38 +2251,17 @@ public class QuickContactActivity extends ContactsActivity { } } - /** - * Calls into the contacts provider to get a pre-authorized version of the given URI. - */ - private Uri getPreAuthorizedUri(Uri uri) { - final Bundle uriBundle = new Bundle(); - uriBundle.putParcelable(ContactsContract.Authorization.KEY_URI_TO_AUTHORIZE, uri); - final Bundle authResponse = getContentResolver().call( - ContactsContract.AUTHORITY_URI, - ContactsContract.Authorization.AUTHORIZATION_METHOD, - null, - uriBundle); - if (authResponse != null) { - return (Uri) authResponse.getParcelable( - ContactsContract.Authorization.KEY_AUTHORIZED_URI); - } else { - return uri; - } - } - private void shareContact() { final String lookupKey = mContactData.getLookupKey(); - Uri shareUri = Uri.withAppendedPath(Contacts.CONTENT_VCARD_URI, lookupKey); - if (mContactData.isUserProfile()) { - // User is sharing the profile. We don't want to force the receiver to have - // the highly-privileged READ_PROFILE permission, so we need to request a - // pre-authorized URI from the provider. - shareUri = getPreAuthorizedUri(shareUri); - } - + final Uri shareUri = Uri.withAppendedPath(Contacts.CONTENT_VCARD_URI, lookupKey); final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType(Contacts.CONTENT_VCARD_TYPE); intent.putExtra(Intent.EXTRA_STREAM, shareUri); + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + + // Even though the data doesn't need to be set for ACTION_SEND, it does need + // to be set so that FLAG_GRANT_READ_URI_PERMISSION can create a URI permission grant. + intent.setData(shareUri); // Launch chooser to share contact via final CharSequence chooseTitle = getText(R.string.share_via); @@ -2290,7 +2269,7 @@ public class QuickContactActivity extends ContactsActivity { try { mHasIntentLaunched = true; - ImplicitIntentsUtil.startActivityOutsideApp(this, intent); + ImplicitIntentsUtil.startActivityOutsideApp(this, chooseIntent); } catch (final ActivityNotFoundException ex) { Toast.makeText(this, R.string.share_error, Toast.LENGTH_SHORT).show(); } |