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

Commit aac0e66f authored by Wenyi Wang's avatar Wenyi Wang
Browse files

Backport ContactsContract.PinnedPositions and create compat package

This class was unhidden in API level 21 and the undemote method was
added in API level 21 as well.

Bug: 25629359
Change-Id: I7eecd28338a8f14fca7b8249599c3f7eac70442c
parent 4c3d3e24
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@ import android.provider.ContactsContract.CommonDataKinds.StructuredName;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.Groups;
import android.provider.ContactsContract.PinnedPositions;
import android.provider.ContactsContract.Profile;
import android.provider.ContactsContract.RawContacts;
import android.provider.ContactsContract.RawContactsEntity;
@@ -59,6 +58,7 @@ import com.android.contacts.common.model.RawContactDeltaList;
import com.android.contacts.common.model.RawContactModifier;
import com.android.contacts.common.model.account.AccountWithDataSet;
import com.android.contacts.common.util.PermissionsUtil;
import com.android.contacts.compat.PinnedPositionsCompat;
import com.android.contacts.util.ContactPhotoUtils;

import com.google.common.collect.Lists;
@@ -952,7 +952,7 @@ public class ContactSaveService extends IntentService {

                // Don't bother undemoting if this contact is the user's profile.
                if (id < Profile.MIN_ID) {
                    PinnedPositions.undemote(getContentResolver(), id);
                    PinnedPositionsCompat.undemote(getContentResolver(), id);
                }
            }
        } finally {
+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

package com.android.contacts.util;
package com.android.contacts.compat;

import android.net.Uri;
import android.provider.ContactsContract;
+56 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.contacts.compat;

import android.content.ContentResolver;
import android.provider.ContactsContract;
import android.provider.ContactsContract.PinnedPositions;

import com.android.contacts.common.compat.CompatUtils;

/**
 * Compatibility class for {@link android.provider.ContactsContract.PinnedPositions}
 */
public class PinnedPositionsCompat {
    /**
     * Not instantiable.
     */
    private PinnedPositionsCompat() {
    }

    /**
     * copied from android.provider.ContactsContract.PinnedPositions#UNDEMOTE_METHOD
     */
    private static final String UNDEMOTE_METHOD = "undemote";

    /**
     * Compatibility method for {@link android.provider.ContactsContract.PinnedPositions#undemote}
     */
    public static void undemote(ContentResolver contentResolver, long contactId) {
        if (contentResolver == null) {
            return;
        }
        if (CompatUtils.isLollipopCompatible()) {
            PinnedPositions.undemote(contentResolver, contactId);
        } else {
            // copied from android.provider.ContactsContract.PinnedPositions.undemote()
            contentResolver.call(ContactsContract.AUTHORITY_URI, UNDEMOTE_METHOD,
                    String.valueOf(contactId), null);
        }
    }

}
+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

package com.android.contacts.util;
package com.android.contacts.compat;

import android.os.Build;
import android.provider.ContactsContract.ProviderStatus;
+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

package com.android.contacts.util;
package com.android.contacts.compat;

import android.content.Context;
import android.os.Build;
Loading