/**
* Start Quick Contact on the managed profile for the user, if the policy allows.
+ *
* @hide
*/
public void startManagedQuickContact(String actualLookupKey, long actualContactId,
- long directoryId, Intent originalIntent) {
+ boolean isContactIdIgnored, long directoryId, Intent originalIntent) {
if (mService != null) {
try {
- mService.startManagedQuickContact(
- actualLookupKey, actualContactId, directoryId, originalIntent);
+ mService.startManagedQuickContact(actualLookupKey, actualContactId,
+ isContactIdIgnored, directoryId, originalIntent);
} catch (RemoteException e) {
Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
}
*/
public void startManagedQuickContact(String actualLookupKey, long actualContactId,
Intent originalIntent) {
- startManagedQuickContact(actualLookupKey, actualContactId, Directory.DEFAULT,
+ startManagedQuickContact(actualLookupKey, actualContactId, false, Directory.DEFAULT,
originalIntent);
}
void setCrossProfileContactsSearchDisabled(in ComponentName who, boolean disabled);
boolean getCrossProfileContactsSearchDisabled(in ComponentName who);
boolean getCrossProfileContactsSearchDisabledForUser(int userId);
- void startManagedQuickContact(String lookupKey, long contactId, long directoryId, in Intent originalIntent);
+ void startManagedQuickContact(String lookupKey, long contactId, boolean isContactIdIgnored, long directoryId, in Intent originalIntent);
void setBluetoothContactSharingDisabled(in ComponentName who, boolean disabled);
boolean getBluetoothContactSharingDisabled(in ComponentName who);
* @hide
*/
public static Intent rebuildManagedQuickContactsIntent(String lookupKey, long contactId,
- long directoryId, Intent originalIntent) {
+ boolean isContactIdIgnored, long directoryId, Intent originalIntent) {
final Intent intent = new Intent(ACTION_QUICK_CONTACT);
// Rebuild the URI from a lookup key and a contact ID.
- Uri uri = Contacts.getLookupUri(contactId, lookupKey);
+ Uri uri = null;
+ if (!TextUtils.isEmpty(lookupKey)) {
+ uri = isContactIdIgnored
+ ? Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, lookupKey)
+ : Contacts.getLookupUri(contactId, lookupKey);
+ }
if (uri != null && directoryId != Directory.DEFAULT) {
uri = uri.buildUpon().appendQueryParameter(
ContactsContract.DIRECTORY_PARAM_KEY, String.valueOf(directoryId)).build();
private static final UriMatcher sContactsUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
private static final int CONTACTS_URI_LOOKUP_ID = 1000;
+ private static final int CONTACTS_URI_LOOKUP = 1001;
static {
// Contacts URI matching table
final UriMatcher matcher = sContactsUriMatcher;
+ matcher.addURI(ContactsContract.AUTHORITY, "contacts/lookup/*", CONTACTS_URI_LOOKUP);
matcher.addURI(ContactsContract.AUTHORITY, "contacts/lookup/*/#", CONTACTS_URI_LOOKUP_ID);
}
final int match = sContactsUriMatcher.match(uri);
switch (match) {
+ case CONTACTS_URI_LOOKUP:
case CONTACTS_URI_LOOKUP_ID: {
if (maybeStartManagedQuickContact(context, intent)) {
return; // Request handled by DPM. Just return here.
// Decompose into an ID and a lookup key.
final List<String> pathSegments = uri.getPathSegments();
- final long contactId = ContentUris.parseId(uri);
+ final boolean isContactIdIgnored = pathSegments.size() < 4;
+ final long contactId = isContactIdIgnored
+ ? ContactsContract.Contacts.ENTERPRISE_CONTACT_ID_BASE //contact id will be ignored
+ : ContentUris.parseId(uri);
final String lookupKey = pathSegments.get(2);
final String directoryIdStr = uri.getQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY);
final long directoryId = (directoryIdStr == null)
final long actualDirectoryId = (directoryId
- ContactsContract.Directory.ENTERPRISE_DIRECTORY_ID_BASE);
- dpm.startManagedQuickContact(actualLookupKey, actualContactId, actualDirectoryId,
- originalIntent);
+ dpm.startManagedQuickContact(actualLookupKey, actualContactId, isContactIdIgnored,
+ actualDirectoryId, originalIntent);
return true;
}
}
@Override
public void startManagedQuickContact(String actualLookupKey, long actualContactId,
- long actualDirectoryId, Intent originalIntent) {
- final Intent intent = QuickContact.rebuildManagedQuickContactsIntent(
- actualLookupKey, actualContactId, actualDirectoryId, originalIntent);
+ boolean isContactIdIgnored, long actualDirectoryId, Intent originalIntent) {
+ final Intent intent = QuickContact.rebuildManagedQuickContactsIntent(actualLookupKey,
+ actualContactId, isContactIdIgnored, actualDirectoryId, originalIntent);
final int callingUserId = UserHandle.getCallingUserId();
final long ident = mInjector.binderClearCallingIdentity();