@@ -186,6 +186,59 @@ public final class ContactsContract {
186186 */
187187 public static final String DEFERRED_SNIPPETING_QUERY = "deferred_snippeting_query" ;
188188
189+ /**
190+ * <p>
191+ * API for obtaining a pre-authorized version of a URI that normally requires special
192+ * permission (beyond READ_CONTACTS) to read. The caller obtaining the pre-authorized URI
193+ * must already have the necessary permissions to access the URI; otherwise a
194+ * {@link SecurityException} will be thrown.
195+ * </p>
196+ * <p>
197+ * The authorized URI returned in the bundle contains an expiring token that allows the
198+ * caller to execute the query without having the special permissions that would normally
199+ * be required.
200+ * </p>
201+ * <p>
202+ * This API does not access disk, and should be safe to invoke from the UI thread.
203+ * </p>
204+ * <p>
205+ * Example usage:
206+ * <pre>
207+ * Uri profileUri = ContactsContract.Profile.CONTENT_VCARD_URI;
208+ * Bundle uriBundle = new Bundle();
209+ * uriBundle.putParcelable(ContactsContract.Authorization.KEY_URI_TO_AUTHORIZE, uri);
210+ * Bundle authResponse = getContext().getContentResolver().call(
211+ * ContactsContract.AUTHORITY_URI,
212+ * ContactsContract.Authorization.AUTHORIZATION_METHOD,
213+ * null, // String arg, not used.
214+ * uriBundle);
215+ * if (authResponse != null) {
216+ * Uri preauthorizedProfileUri = (Uri) authResponse.getParcelable(
217+ * ContactsContract.Authorization.KEY_AUTHORIZED_URI);
218+ * // This pre-authorized URI can be queried by a caller without READ_PROFILE
219+ * // permission.
220+ * }
221+ * </pre>
222+ * </p>
223+ * @hide
224+ */
225+ public static final class Authorization {
226+ /**
227+ * The method to invoke to create a pre-authorized URI out of the input argument.
228+ */
229+ public static final String AUTHORIZATION_METHOD = "authorize" ;
230+
231+ /**
232+ * The key to set in the outbound Bundle with the URI that should be authorized.
233+ */
234+ public static final String KEY_URI_TO_AUTHORIZE = "uri_to_authorize" ;
235+
236+ /**
237+ * The key to retrieve from the returned Bundle to obtain the pre-authorized URI.
238+ */
239+ public static final String KEY_AUTHORIZED_URI = "authorized_uri" ;
240+ }
241+
189242 /**
190243 * @hide
191244 */
0 commit comments