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

Commit 2656d03b authored by Wenyi Wang's avatar Wenyi Wang Committed by Walter Jang
Browse files

Merge contacts src-N/ and src-pre-N/ dirs (2/3)

Bug 30124466

(cherry picked from commit 68378150328d720af5c084ae04b3007ce4118a63)

Change-Id: Idcb3fb3a1cb571b5d3575ca3d55f0f84bc20eb31
parent 159b1c3c
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -21,11 +21,9 @@ import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Build.VERSION;
import android.provider.ContactsContract.CommonDataKinds.Im;
import android.support.annotation.IntDef;
import android.provider.ContactsContract.DisplayPhoto;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import android.util.Pair;

@@ -34,7 +32,6 @@ import com.android.contacts.common.model.dataitem.ImDataItem;
import com.android.contacts.common.testing.NeededForTesting;
import com.android.contacts.common.compat.ContactsCompat;
import com.android.contacts.common.compat.DirectoryCompat;
import com.android.contacts.common.compat.SdkSelectionUtils;
import com.android.contacts.common.model.AccountTypeManager;

import java.lang.annotation.Retention;
+53 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 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.common.compat;

import android.telecom.Call;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class CallSdkCompat {
    public static class Details {
        public static final int PROPERTY_IS_EXTERNAL_CALL = Call.Details.PROPERTY_IS_EXTERNAL_CALL;
        public static final int PROPERTY_ENTERPRISE_CALL = Call.Details.PROPERTY_ENTERPRISE_CALL;
        public static final int CAPABILITY_CAN_PULL_CALL = Call.Details.CAPABILITY_CAN_PULL_CALL;
        public static final int CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO =
                Call.Details.CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO;
    }

    /**
     * TODO: This API is hidden in the N release; replace the implementation with a call to the
     * actual once it is made public.
     */
    public static void pullExternalCall(Call call) {
        if (!CompatUtils.isNCompatible()) {
            return;
        }
        Class<?> callClass = Call.class;
        try {
            Method pullExternalCallMethod = callClass.getDeclaredMethod("pullExternalCall");
            pullExternalCallMethod.invoke(call);
        } catch (NoSuchMethodException e) {
            // Ignore requests to pull call if there is a problem.
        } catch (InvocationTargetException e) {
            // Ignore requests to pull call if there is a problem.
        } catch (IllegalAccessException e) {
            // Ignore requests to pull call if there is a problem.
        }
    }
}
+0 −2
Original line number Diff line number Diff line
@@ -18,14 +18,12 @@ package com.android.contacts.common.compat;
import android.os.Build;
import android.os.Build.VERSION;
import android.support.annotation.Nullable;
import android.support.v4.os.BuildCompat;
import android.text.TextUtils;
import android.util.Log;

import com.android.contacts.common.model.CPOWrapper;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public final class CompatUtils {

+37 −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.common.compat;

import android.net.Uri;
import android.provider.ContactsContract.Directory;

public class DirectorySdkCompat {

    private static final String TAG = "DirectorySdkCompat";

    public static final Uri ENTERPRISE_CONTENT_URI = Directory.ENTERPRISE_CONTENT_URI;
    public static final long ENTERPRISE_LOCAL_DEFAULT = Directory.ENTERPRISE_DEFAULT;
    public static final long ENTERPRISE_LOCAL_INVISIBLE = Directory.ENTERPRISE_LOCAL_INVISIBLE;

    public static boolean isRemoteDirectoryId(long directoryId) {
        return CompatUtils.isNCompatible() ? Directory.isRemoteDirectoryId(directoryId) : false;
    }

    public static boolean isEnterpriseDirectoryId(long directoryId) {
        return CompatUtils.isNCompatible() ? Directory.isEnterpriseDirectoryId(directoryId) : false;
    }
}
+29 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 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.common.compat;

import android.content.Context;
import android.provider.Settings;

public class MetadataSyncEnabledCompat {
    public static boolean isMetadataSyncEnabled(Context context) {
        return CompatUtils.isNCompatible()
                ? (Settings.Global.getInt(context.getContentResolver(),
                        Settings.Global.CONTACT_METADATA_SYNC_ENABLED, 0) == 1)
                : false;
    }
}
 No newline at end of file
Loading