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

Commit 697815ed authored by Victor Chang's avatar Victor Chang Committed by Android (Google) Code Review
Browse files

Merge "Launch managed quick contacts without contact id"

parents d307a704 97bdacc6
Loading
Loading
Loading
Loading
+5 −4
Original line number Original line Diff line number Diff line
@@ -3792,14 +3792,15 @@ public class DevicePolicyManager {


    /**
    /**
     * Start Quick Contact on the managed profile for the user, if the policy allows.
     * Start Quick Contact on the managed profile for the user, if the policy allows.
     *
     * @hide
     * @hide
     */
     */
    public void startManagedQuickContact(String actualLookupKey, long actualContactId,
    public void startManagedQuickContact(String actualLookupKey, long actualContactId,
            long directoryId, Intent originalIntent) {
            boolean isContactIdIgnored, long directoryId, Intent originalIntent) {
        if (mService != null) {
        if (mService != null) {
            try {
            try {
                mService.startManagedQuickContact(
                mService.startManagedQuickContact(actualLookupKey, actualContactId,
                        actualLookupKey, actualContactId, directoryId, originalIntent);
                        isContactIdIgnored, directoryId, originalIntent);
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
                Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
            }
            }
@@ -3812,7 +3813,7 @@ public class DevicePolicyManager {
     */
     */
    public void startManagedQuickContact(String actualLookupKey, long actualContactId,
    public void startManagedQuickContact(String actualLookupKey, long actualContactId,
            Intent originalIntent) {
            Intent originalIntent) {
        startManagedQuickContact(actualLookupKey, actualContactId, Directory.DEFAULT,
        startManagedQuickContact(actualLookupKey, actualContactId, false, Directory.DEFAULT,
                originalIntent);
                originalIntent);
    }
    }


+1 −1
Original line number Original line Diff line number Diff line
@@ -211,7 +211,7 @@ interface IDevicePolicyManager {
    void setCrossProfileContactsSearchDisabled(in ComponentName who, boolean disabled);
    void setCrossProfileContactsSearchDisabled(in ComponentName who, boolean disabled);
    boolean getCrossProfileContactsSearchDisabled(in ComponentName who);
    boolean getCrossProfileContactsSearchDisabled(in ComponentName who);
    boolean getCrossProfileContactsSearchDisabledForUser(int userId);
    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);
    void setBluetoothContactSharingDisabled(in ComponentName who, boolean disabled);
    boolean getBluetoothContactSharingDisabled(in ComponentName who);
    boolean getBluetoothContactSharingDisabled(in ComponentName who);
+7 −2
Original line number Original line Diff line number Diff line
@@ -8401,10 +8401,15 @@ public final class ContactsContract {
         * @hide
         * @hide
         */
         */
        public static Intent rebuildManagedQuickContactsIntent(String lookupKey, long contactId,
        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);
            final Intent intent = new Intent(ACTION_QUICK_CONTACT);
            // Rebuild the URI from a lookup key and a contact ID.
            // 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) {
            if (uri != null && directoryId != Directory.DEFAULT) {
                uri = uri.buildUpon().appendQueryParameter(
                uri = uri.buildUpon().appendQueryParameter(
                        ContactsContract.DIRECTORY_PARAM_KEY, String.valueOf(directoryId)).build();
                        ContactsContract.DIRECTORY_PARAM_KEY, String.valueOf(directoryId)).build();
+9 −3
Original line number Original line 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 UriMatcher sContactsUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);


    private static final int CONTACTS_URI_LOOKUP_ID = 1000;
    private static final int CONTACTS_URI_LOOKUP_ID = 1000;
    private static final int CONTACTS_URI_LOOKUP = 1001;


    static {
    static {
        // Contacts URI matching table
        // Contacts URI matching table
        final UriMatcher matcher = sContactsUriMatcher;
        final UriMatcher matcher = sContactsUriMatcher;
        matcher.addURI(ContactsContract.AUTHORITY, "contacts/lookup/*", CONTACTS_URI_LOOKUP);
        matcher.addURI(ContactsContract.AUTHORITY, "contacts/lookup/*/#", CONTACTS_URI_LOOKUP_ID);
        matcher.addURI(ContactsContract.AUTHORITY, "contacts/lookup/*/#", CONTACTS_URI_LOOKUP_ID);
    }
    }


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


        final int match = sContactsUriMatcher.match(uri);
        final int match = sContactsUriMatcher.match(uri);
        switch (match) {
        switch (match) {
            case CONTACTS_URI_LOOKUP:
            case CONTACTS_URI_LOOKUP_ID: {
            case CONTACTS_URI_LOOKUP_ID: {
                if (maybeStartManagedQuickContact(context, intent)) {
                if (maybeStartManagedQuickContact(context, intent)) {
                    return; // Request handled by DPM.  Just return here.
                    return; // Request handled by DPM.  Just return here.
@@ -89,7 +92,10 @@ public class ContactsInternal {


        // Decompose into an ID and a lookup key.
        // Decompose into an ID and a lookup key.
        final List<String> pathSegments = uri.getPathSegments();
        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 lookupKey = pathSegments.get(2);
        final String directoryIdStr = uri.getQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY);
        final String directoryIdStr = uri.getQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY);
        final long directoryId = (directoryIdStr == null)
        final long directoryId = (directoryIdStr == null)
@@ -119,8 +125,8 @@ public class ContactsInternal {
        final long actualDirectoryId = (directoryId
        final long actualDirectoryId = (directoryId
                - ContactsContract.Directory.ENTERPRISE_DIRECTORY_ID_BASE);
                - ContactsContract.Directory.ENTERPRISE_DIRECTORY_ID_BASE);


        dpm.startManagedQuickContact(actualLookupKey, actualContactId, actualDirectoryId,
        dpm.startManagedQuickContact(actualLookupKey, actualContactId, isContactIdIgnored,
                originalIntent);
                actualDirectoryId, originalIntent);
        return true;
        return true;
    }
    }
}
}
+3 −3
Original line number Original line Diff line number Diff line
@@ -7041,9 +7041,9 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {


    @Override
    @Override
    public void startManagedQuickContact(String actualLookupKey, long actualContactId,
    public void startManagedQuickContact(String actualLookupKey, long actualContactId,
            long actualDirectoryId, Intent originalIntent) {
            boolean isContactIdIgnored, long actualDirectoryId, Intent originalIntent) {
        final Intent intent = QuickContact.rebuildManagedQuickContactsIntent(
        final Intent intent = QuickContact.rebuildManagedQuickContactsIntent(actualLookupKey,
                actualLookupKey, actualContactId, actualDirectoryId, originalIntent);
                actualContactId, isContactIdIgnored, actualDirectoryId, originalIntent);
        final int callingUserId = UserHandle.getCallingUserId();
        final int callingUserId = UserHandle.getCallingUserId();


        final long ident = mInjector.binderClearCallingIdentity();
        final long ident = mInjector.binderClearCallingIdentity();