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

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

Merge "Allow google dialer code to be compiled against M and N SDKs for...

Merge "Allow google dialer code to be compiled against M and N SDKs for enterprise features" into ub-contactsdialer-b-dev
parents 9f3e1348 fdb995dc
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.util.Pair;
import com.android.contacts.common.model.account.AccountWithDataSet;
import com.android.contacts.common.model.dataitem.ImDataItem;
import com.android.contacts.common.testing.NeededForTesting;
import com.android.contacts.common.compat.SdkSelectionUtils;
import com.android.contacts.common.model.AccountTypeManager;

import java.util.List;
@@ -46,10 +47,9 @@ public class ContactsUtils {

    private static int sThumbnailSize = -1;

    public static final boolean FLAG_N_FEATURE =
            false // Enforce Pre-N behavior in release build
            && (Build.VERSION.SDK_INT > Build.VERSION_CODES.M
                    || Build.VERSION.CODENAME.startsWith("N"));
    public static final boolean FLAG_N_FEATURE = SdkSelectionUtils.TARGET_N_SDK // build-time flag
            && (Build.VERSION.SDK_INT > Build.VERSION_CODES.M // runtime flag
                    || Build.VERSION.CODENAME.startsWith("N")); // TODO: remove startsWith("N")

    // TODO find a proper place for the canonical version of these
    public interface ProviderNames {
+1 −2
Original line number Diff line number Diff line
@@ -28,8 +28,7 @@ public class CallableCompat {
            Uri.withAppendedPath(Callable.CONTENT_URI, "filter_enterprise");

    public static Uri getContentFilterUri() {
        // TODO: Use N APIs
        if (ContactsUtils.FLAG_N_FEATURE && android.os.Build.VERSION.CODENAME.startsWith("N")) {
        if (ContactsUtils.FLAG_N_FEATURE) {
            return ENTERPRISE_CONTENT_FILTER_URI;
        }
        return Callable.CONTENT_FILTER_URI;
+1 −2
Original line number Diff line number Diff line
@@ -40,8 +40,7 @@ public class ContactsCompat {
    private static final long ENTERPRISE_CONTACT_ID_BASE = 1000000000;

    public static Uri getContentUri() {
        // TODO: Use N APIs
        if (ContactsUtils.FLAG_N_FEATURE && android.os.Build.VERSION.CODENAME.startsWith("N")) {
        if (ContactsUtils.FLAG_N_FEATURE) {
            return ENTERPRISE_CONTENT_FILTER_URI;
        }
        return Contacts.CONTENT_FILTER_URI;
+14 −13
Original line number Diff line number Diff line
@@ -24,30 +24,31 @@ import com.android.contacts.common.ContactsUtils;

public class DirectoryCompat {

    // TODO: Use N APIs
    private static final Uri ENTERPRISE_CONTENT_URI =
            Uri.withAppendedPath(ContactsContract.AUTHORITY_URI, "directories_enterprise");
    // TODO: Use N APIs
    private static final long ENTERPRISE_LOCAL_INVISIBLE = 1000000000L + Directory.LOCAL_INVISIBLE;

    public static Uri getContentUri() {
        // TODO: Use N APIs
        if (ContactsUtils.FLAG_N_FEATURE && android.os.Build.VERSION.CODENAME.startsWith("N")) {
            return ENTERPRISE_CONTENT_URI;
        if (ContactsUtils.FLAG_N_FEATURE) {
            return DirectorySdkCompat.ENTERPRISE_CONTENT_URI;
        }
        return Directory.CONTENT_URI;
    }

    public static boolean isInvisibleDirectory(long directoryId) {
        if (ContactsUtils.FLAG_N_FEATURE) {
            return (directoryId == Directory.LOCAL_INVISIBLE
                || directoryId == ENTERPRISE_LOCAL_INVISIBLE);
                    || directoryId == DirectorySdkCompat.ENTERPRISE_LOCAL_INVISIBLE);
        }
        return directoryId == Directory.LOCAL_INVISIBLE;
    }

    public static boolean isRemoteDirectory(long directoryId) {
        // TODO: Use N APIs
        if (ContactsUtils.FLAG_N_FEATURE && android.os.Build.VERSION.CODENAME.startsWith("N")) {
        if (ContactsUtils.FLAG_N_FEATURE) {
            return DirectorySdkCompat.isRemoteDirectory(directoryId);
        }
        return !(directoryId == Directory.DEFAULT || directoryId == Directory.LOCAL_INVISIBLE);
    }

    public static boolean isEnterpriseDirectoryId(long directoryId) {
        return ContactsUtils.FLAG_N_FEATURE
                ? DirectorySdkCompat.isEnterpriseDirectoryId(directoryId)
                : false;
    }
}
+1 −2
Original line number Diff line number Diff line
@@ -28,8 +28,7 @@ public class PhoneCompat {
            Uri.withAppendedPath(Phone.CONTENT_URI, "filter_enterprise");

    public static Uri getContentFilterUri() {
        // TODO: Use N APIs
        if (ContactsUtils.FLAG_N_FEATURE && android.os.Build.VERSION.CODENAME.startsWith("N")) {
        if (ContactsUtils.FLAG_N_FEATURE) {
            return ENTERPRISE_CONTENT_FILTER_URI;
        }
        return Phone.CONTENT_FILTER_URI;