1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.contacts.compat; 18 19 import android.content.ContentResolver; 20 import android.provider.ContactsContract; 21 import android.provider.ContactsContract.PinnedPositions; 22 23 import com.android.contacts.common.compat.CompatUtils; 24 25 /** 26 * Compatibility class for {@link android.provider.ContactsContract.PinnedPositions} 27 */ 28 public class PinnedPositionsCompat { 29 /** 30 * Not instantiable. 31 */ PinnedPositionsCompat()32 private PinnedPositionsCompat() { 33 } 34 35 /** 36 * copied from android.provider.ContactsContract.PinnedPositions#UNDEMOTE_METHOD 37 */ 38 private static final String UNDEMOTE_METHOD = "undemote"; 39 40 /** 41 * Compatibility method for {@link android.provider.ContactsContract.PinnedPositions#undemote} 42 */ undemote(ContentResolver contentResolver, long contactId)43 public static void undemote(ContentResolver contentResolver, long contactId) { 44 if (contentResolver == null) { 45 return; 46 } 47 if (CompatUtils.isLollipopCompatible()) { 48 PinnedPositions.undemote(contentResolver, contactId); 49 } else { 50 // copied from android.provider.ContactsContract.PinnedPositions.undemote() 51 contentResolver.call(ContactsContract.AUTHORITY_URI, UNDEMOTE_METHOD, 52 String.valueOf(contactId), null); 53 } 54 } 55 56 } 57