fwk-detect: Relocate from vendor/qcom-opensource/core-utils

 * After blobs are updated to Q ,these "libqti_vndfwk_detect*" are requied by audio/BT/CNE/GPS/IMS etc.
   see (https://pastebin.com/qQQDgpfy).
 * Relocation of some files from vendor/qcom-opensource/core-utils at
   https://source.codeaurora.org/quic/la/platform/vendor/qcom-opensource/core-utils/commit/fwk-detect?h=LA.UM.8.1.r1-09500-sm8150.0&id=d2ef554165c6175f20d8a320508396e73843b3b1

Change-Id: I41c2cf2d082993e0170b37a9b83d37b8aa18edc2
Signed-off-by: PIPIPIG233666 <pig.priv@gmail.com>

fwk-detect: Drop vndfwk-test

Change-Id: I48467e1c312a0052c4cd85393064149bbb7c46cb
Signed-off-by: PIPIPIG233666 <pig.priv@gmail.com>
diff --git a/fwk-detect/Android.bp b/fwk-detect/Android.bp
new file mode 100644
index 0000000..f5ad7e8
--- /dev/null
+++ b/fwk-detect/Android.bp
@@ -0,0 +1,44 @@
+cc_library_shared {
+    name: "libqti_vndfwk_detect",
+    srcs: ["vndfwk-detect.c"],
+    shared_libs: ["libcutils"],
+    vendor_available: true,
+    export_include_dirs: ["."],
+
+    compile_multilib: "both",
+    cflags: [
+        "-Wall",
+        "-Werror",
+    ],
+}
+
+cc_library_shared {
+    name: "libvndfwk_detect_jni.qti",
+    srcs: ["jni/com_qualcomm_qti_VndFwkDetect.cpp"],
+    shared_libs: [
+        "libqti_vndfwk_detect",
+        "libcutils",
+        "libutils",
+        "liblog",
+    ],
+    include_dirs: [
+        "libnativehelper/include/nativehelper",
+        ".",
+    ],
+    header_libs: [
+        "jni_headers",
+    ],
+
+    vendor_available: true,
+    compile_multilib: "both",
+
+    cflags: [
+        "-Wno-unused-parameter",
+    ],
+}
+
+java_library_static {
+    name: "vndfwk.detect",
+    srcs: ["src/**/*.java"],
+    sdk_version: "current",
+}
diff --git a/fwk-detect/jni/com_qualcomm_qti_VndFwkDetect.cpp b/fwk-detect/jni/com_qualcomm_qti_VndFwkDetect.cpp
new file mode 100644
index 0000000..8ca78f1
--- /dev/null
+++ b/fwk-detect/jni/com_qualcomm_qti_VndFwkDetect.cpp
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2019, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *    * Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ *    * Redistributions in binary form must reproduce the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer in the documentation and/or other materials provided
+ *      with the distribution.
+ *    * Neither the name of The Linux Foundation nor the names of its
+ *      contributors may be used to endorse or promote products derived
+ *      from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#define LOG_TAG "VndFwkDetectJNI"
+
+#include "vndfwk-detect.h"
+
+#include "jni.h"
+#include "JNIHelp.h"
+#include <dlfcn.h>
+#include <string.h>
+#include <android/log.h>
+#include <utils/Log.h>
+
+#define VNDFWK_DETECT_LIB "libqti_vndfwk_detect.so"
+
+typedef struct dlHandler {
+    void *dlHandle;
+    int (*vndFwkDetect)(void);
+    int (*vndEnhancedInfo)(void);
+    const char *dlName;
+} dlHandler;
+
+static dlHandler mDlHandler = {
+    NULL, NULL, NULL, VNDFWK_DETECT_LIB};
+
+static void
+com_qualcomm_qti_VndFwkDetect_init()
+{
+    mDlHandler.dlHandle = dlopen(VNDFWK_DETECT_LIB, RTLD_NOW | RTLD_LOCAL);
+    if (mDlHandler.dlHandle == NULL) return;
+
+    *(void **)(&mDlHandler.vndFwkDetect) = dlsym(mDlHandler.dlHandle, "isRunningWithVendorEnhancedFramework");
+    if (mDlHandler.vndFwkDetect == NULL)
+    {
+        if (mDlHandler.dlHandle)
+        {
+            dlclose(mDlHandler.dlHandle);
+            mDlHandler.dlHandle = NULL;
+        }
+
+        return;
+    }
+
+    *(void **)(&mDlHandler.vndEnhancedInfo) = dlsym(mDlHandler.dlHandle, "getVendorEnhancedInfo");
+    if (mDlHandler.vndEnhancedInfo == NULL)
+    {
+        if (mDlHandler.dlHandle)
+        {
+            dlclose(mDlHandler.dlHandle);
+            mDlHandler.dlHandle = NULL;
+        }
+    }
+
+    return;
+}
+
+static int
+com_qualcomm_qti_VndFwkDetect_native_isRunningWithVendorEnhancedFramework(JNIEnv *env, jobject clazz)
+{
+    if(mDlHandler.vndFwkDetect != NULL)
+        return (*mDlHandler.vndFwkDetect)();
+
+    return 0;
+}
+
+
+static int
+com_qualcomm_qti_VndFwkDetect_native_getVendorEnhancedInfo(JNIEnv *env, jobject clazz)
+{
+    if(mDlHandler.vndEnhancedInfo != NULL)
+        return (*mDlHandler.vndEnhancedInfo)();
+
+    return 0;
+}
+static JNINativeMethod gMethods[] = {
+    {"native_isRunningWithVendorEnhancedFramework", "()I", (int*)com_qualcomm_qti_VndFwkDetect_native_isRunningWithVendorEnhancedFramework},
+    {"native_getVendorEnhancedInfo", "()I", (int*)com_qualcomm_qti_VndFwkDetect_native_getVendorEnhancedInfo}
+};
+
+/*
+ * JNI initialization
+ */
+jint JNI_OnLoad(JavaVM *jvm, void *reserved)
+{
+    JNIEnv *e;
+    jclass clazz = 0;
+    int status;
+
+    ALOGV("com.qualcomm.qti.VndFwkDetect: loading JNI\n");
+
+    // check JNI version
+    if (jvm->GetEnv((void**)&e, JNI_VERSION_1_6)) {
+        ALOGE("com.qualcomm.qti.VndFwkDetect: JNI version mismatch error");
+        return JNI_ERR;
+    }
+
+    clazz = e->FindClass("com/qualcomm/qti/VndFwkDetect");
+    if((jclass)0 == clazz) {
+        ALOGE("JNI_OnLoad: FindClass failed");
+        return JNI_ERR;
+    }
+
+    com_qualcomm_qti_VndFwkDetect_init();
+
+    if ((status = e->RegisterNatives(clazz, gMethods, NELEM(gMethods))) < 0) {
+        ALOGE("com.qualcomm.qti.VndFwkDetect: jni registration failure: %d", status);
+        return JNI_ERR;
+    }
+
+    return JNI_VERSION_1_6;
+}
diff --git a/fwk-detect/src/com/qualcomm/qti/VndFwkDetect.java b/fwk-detect/src/com/qualcomm/qti/VndFwkDetect.java
new file mode 100644
index 0000000..0a96a0a
--- /dev/null
+++ b/fwk-detect/src/com/qualcomm/qti/VndFwkDetect.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2019, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *    * Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ *    * Redistributions in binary form must reproduce the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer in the documentation and/or other materials provided
+ *      with the distribution.
+ *    * Neither the name of The Linux Foundation nor the names of its
+ *      contributors may be used to endorse or promote products derived
+ *      from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.qualcomm.qti;
+
+import android.util.Log;
+
+public class VndFwkDetect
+{
+    private static final String TAG = "VndFwkDetect";
+
+    static {
+        try {
+            System.loadLibrary("vndfwk_detect_jni.qti");
+        } catch (Exception ex) {
+            Log.d(TAG, "Cannot load libvndfwk_detect_jni.qti shared library!!!");
+            ex.printStackTrace();
+        }
+    }
+
+    public VndFwkDetect() {
+    }
+
+    public int isRunningWithVendorEnhancedFramework() {
+        return native_isRunningWithVendorEnhancedFramework();
+    }
+
+    public int getVendorEnhancedInfo() {
+        return native_getVendorEnhancedInfo();
+    }
+
+    private native int native_isRunningWithVendorEnhancedFramework();
+    private native int native_getVendorEnhancedInfo();
+}
diff --git a/fwk-detect/vndfwk-detect.c b/fwk-detect/vndfwk-detect.c
new file mode 100644
index 0000000..1ff1aa7
--- /dev/null
+++ b/fwk-detect/vndfwk-detect.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *    * Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ *    * Redistributions in binary form must reproduce the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer in the documentation and/or other materials provided
+ *      with the distribution.
+ *    * Neither the name of The Linux Foundation nor the names of its
+ *      contributors may be used to endorse or promote products derived
+ *      from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <string.h>
+#include <cutils/properties.h>
+
+#include "vndfwk-detect.h"
+
+#define VALUEADD_AOSP_SUPPORT_PROPERTY "ro.vendor.qti.va_aosp.support"
+#define VALUEADD_ODM_SUPPORT_PROPERTY "ro.vendor.qti.va_odm.support"
+#define VND_ENHANCED_ODM_STATUS_BIT 0x01
+#define VND_ENHANCED_SYS_STATUS_BIT 0x02
+
+int isRunningWithVendorEnhancedFramework() {
+    bool va_aosp_support = false;
+    va_aosp_support = property_get_bool(VALUEADD_AOSP_SUPPORT_PROPERTY, false);
+
+    if (va_aosp_support)
+        return 1;
+
+    return 0;
+}
+
+/*
+ * int getVendorEnhancedInfo(void)
+ * return val(int32_t):
+ * bit0: for ODM status
+ *    =>0: PureAOSP Building
+ *    =>1: QC VA Building
+ *
+ * bit1: for System status
+ *    =>0: PureAOSP Building
+ *    =>1: QC VA Building
+ */
+int getVendorEnhancedInfo() {
+    int val = 0;
+    bool va_odm_support = false;
+    va_odm_support = property_get_bool(VALUEADD_ODM_SUPPORT_PROPERTY, false);
+
+    if (va_odm_support) {
+        val |= VND_ENHANCED_ODM_STATUS_BIT;
+    }
+
+    if (1 == isRunningWithVendorEnhancedFramework()) {
+        val |= VND_ENHANCED_SYS_STATUS_BIT;
+    }
+
+    return val;
+}
diff --git a/fwk-detect/vndfwk-detect.h b/fwk-detect/vndfwk-detect.h
new file mode 100644
index 0000000..6a26394
--- /dev/null
+++ b/fwk-detect/vndfwk-detect.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *    * Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ *    * Redistributions in binary form must reproduce the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer in the documentation and/or other materials provided
+ *      with the distribution.
+ *    * Neither the name of The Linux Foundation nor the names of its
+ *      contributors may be used to endorse or promote products derived
+ *      from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __VNDFWK_DETECT_H__
+#define __VNDFWK_DETECT_H__
+// return 1 on enhanced AOSP framework; 0 otherwise
+int isRunningWithVendorEnhancedFramework(void);
+int getVendorEnhancedInfo(void);
+
+#endif  // __VNDFWK_DETECT_H__