Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 97bdacc6 authored by Victor Chang's avatar Victor Chang
Browse files

Launch managed quick contacts without contact id

set contact id to enterprise base contact id if it's enterprise uri

BUG=26176780

Change-Id: Ie1160bef22d44c90eb4015783fafdafd160bcdd8
parent 8b15c9c5
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -3717,14 +3717,15 @@ public class DevicePolicyManager {

    /**
     * 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);
            }
@@ -3737,7 +3738,7 @@ public class DevicePolicyManager {
     */
    public void startManagedQuickContact(String actualLookupKey, long actualContactId,
            Intent originalIntent) {
        startManagedQuickContact(actualLookupKey, actualContactId, Directory.DEFAULT,
        startManagedQuickContact(actualLookupKey, actualContactId, false, Directory.DEFAULT,
                originalIntent);
    }

+1 −1
Original line number Diff line number Diff line
@@ -210,7 +210,7 @@ interface IDevicePolicyManager {
    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);
+7 −2
Original line number Diff line number Diff line
@@ -8401,10 +8401,15 @@ public final class ContactsContract {
         * @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();
+9 −3
Original line number Diff line number Diff line
@@ -42,10 +42,12 @@ public class ContactsInternal {
    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);
    }

@@ -57,6 +59,7 @@ public class ContactsInternal {

        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.
@@ -89,7 +92,10 @@ public class ContactsInternal {

        // 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)
@@ -119,8 +125,8 @@ public class ContactsInternal {
        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;
    }
}
+3 −3
Original line number Diff line number Diff line
@@ -6739,9 +6739,9 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {

    @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();