[Feature][ZXW-214]Add (CAP core) An interface that needs to provide the results returned by the interface of the query (AP core) by switching the USB part of the query (on/off)
Only Configure :No
Affected branch: master
Affected module: USB
Is it affected on both ZXIC and MTK:only ZXIC
Self-test: Yes
Doc Update: Yes
Change-Id: I42ac94ef7acc65eccb583db25d81bcab6c5457c4
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf b/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf
index 5af9072..cff302b 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf
+++ b/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf
@@ -199,6 +199,7 @@
liblynq-qser-gnss \
liblynq-qser-fota \
liblynq-qser-audio \
+ liblynq-qser-usb \
libpoweralarm \
liblynq-systime \
liblynq-autosuspend \
@@ -299,6 +300,7 @@
lynq-irq-demo \
lynq-gnss-update \
lynq-audio-demo \
+ lynq-usb-demo \
lynq-adc-demo \
lynq-at-test \
"
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-usb/liblynq-qser-usb.bb b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-usb/liblynq-qser-usb.bb
new file mode 100755
index 0000000..2330365
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-usb/liblynq-qser-usb.bb
@@ -0,0 +1,58 @@
+#inherit externalsrc package
+
+DESCRIPTION = "liblynq-qser-usb.so "
+SECTION = "base"
+#LICENSE = "Mobiletek""
+LICENSE = "CLOSED"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=4f60c98fa94e02f659ef5939f67fa8ae"
+DEPENDS += "bootchart liblynq-log libupi-ab openssl libbsp"
+
+#inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/lib/liblynq-qser-usb/"
+
+FILESEXTRAPATHS_prepend :="${TOPDIR}/../src/lynq/lib/:"
+SRC_URI = " \
+ file://liblynq-qser-usb \
+ "
+
+SRC-DIR = "${S}/../liblynq-qser-usb"
+TARGET_CC_ARCH += "${LDFLAGS}"
+BB_INCLUDE_ADD = "--sysroot=${STAGING_DIR_HOST}"
+BB_LDFLAGS_ADD = "--sysroot=${STAGING_DIR_HOST} -Wl,--hash-style=gnu"
+
+#Parameters passed to do_compile()
+
+FILES_${PN} = "${base_libdir}/*.so "
+
+
+FILES_${PN}-dev = "/test \
+ ${includedir}"
+
+FILES_${PN}-doc = "/doc"
+
+FILES_${PN}-dbg ="${base_bindir}/.debug \
+ ${base_libdir}/.debug \
+ ${base_sbindir}/.debug"
+
+INSANE_SKIP_${PN} += "already-stripped"
+INSANE_SKIP_${PN} += "installed-vs-shipped"
+
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+ oe_runmake all -C ${SRC-DIR} ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -Wl,--hash-style=gnu"
+}
+
+do_install () {
+ oe_runmake install -C ${SRC-DIR} ROOT=${D}
+
+ if [ -d "${WORKONSRC}" ] ; then
+ install -d ${D}${includedir}/
+ cp -af ${SRC-DIR}/include/ ${D}${includedir}/
+ fi
+}
+
+addtask bachclean
+do_bachclean () {
+ oe_runmake clean
+}
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-usb-demo/files/LICENSE b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-usb-demo/files/LICENSE
new file mode 100755
index 0000000..cb88533
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-usb-demo/files/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("Mobiletek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to Mobiletek Inc. and/or its licensors. Without
+the prior written permission of Mobiletek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of Mobiletek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+Mobiletek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("Mobiletek SOFTWARE")
+RECEIVED FROM Mobiletek AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. Mobiletek EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES Mobiletek PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE Mobiletek SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN Mobiletek
+SOFTWARE. Mobiletek SHALL ALSO NOT BE RESPONSIBLE FOR ANY Mobiletek SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND Mobiletek'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE Mobiletek SOFTWARE
+RELEASED HEREUNDER WILL BE, AT Mobiletek'S OPTION, TO REVISE OR REPLACE THE
+Mobiletek SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO Mobiletek FOR SUCH Mobiletek SOFTWARE AT ISSUE.
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-usb-demo/files/lynq-usb-demo.cpp b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-usb-demo/files/lynq-usb-demo.cpp
new file mode 100755
index 0000000..a73190d
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-usb-demo/files/lynq-usb-demo.cpp
@@ -0,0 +1,53 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <sys/socket.h>
+#include <semaphore.h>
+#include <linux/netlink.h>
+
+#include <include/lynq-qser-usb.h>
+
+sem_t usbplug_sem;
+void do_get_adb_state(int nargs, char **argv)
+{
+
+ int ret = 0;
+
+ ret = qser_get_usb_usermode_adb_state();
+ if (ret < 0)
+ {
+ printf("get adb state fail,ret:%d \n", ret);
+ return;
+ }
+
+ printf("adb state:%d, %s\n", ret, ((ret == 0) ? "off" : "on"));
+}
+
+void do_get_net_state(int nargs, char **argv)
+{
+
+ int ret = 0;
+
+ ret = qser_get_usb_usermode_net_state();
+ if (ret < 0)
+ {
+ printf("get net state fail,ret:%d \n", ret);
+ return;
+ }
+
+ printf("net state:%d, %s\n", ret, ((ret == 0) ? "off" : "on"));
+}
+
+int main(int argc, char *argv[])
+{
+ sem_init(&usbplug_sem, 0, 0);
+ do_get_adb_state(argc, argv);
+ do_get_net_state(argc, argv);
+ sem_post(&usbplug_sem);
+ return 0;
+}
\ No newline at end of file
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-usb-demo/files/makefile b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-usb-demo/files/makefile
new file mode 100755
index 0000000..002868d
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-usb-demo/files/makefile
@@ -0,0 +1,51 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+ -std=gnu++14 \
+ -g -Os \
+ -flto \
+ -fpermissive \
+
+ifeq ($(strip $(TARGET_PLATFORM)), T106)
+LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1 -DHAVE_ENDIAN_H -DHAVE_PTHREADS -DHAVE_SYS_UIO_H -DHAVE_POSIX_FILEMAP -DHAVE_STRLCPY -DHAVE_PRCTL -DHAVE_MEMSET16 -DHAVE_MEMSET32 -DANDROID_SMP=0
+endif
+
+LOCAL_CFLAGS += -Werror=format-security
+
+$(warning ################# rock ROOT: $(ROOT),includedir:$(includedir),)
+
+LOCAL_PATH = .
+
+LOCAL_C_INCLUDES = \
+ -I. \
+ -I$(LOCAL_PATH)/include/ \
+ -I$(ROOT)$(includedir)/ \
+
+
+LOCAL_LIBS := \
+ -L. \
+ -ldl \
+ -lstdc++ \
+ -lpthread \
+ -llynq-qser-usb \
+
+SOURCES = lynq-usb-demo.cpp
+
+EXECUTABLE = lynq-usb-demo
+
+OBJECTS=$(SOURCES:.cpp=.o)
+
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+ $(CXX) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o : %.cpp
+ $(CXX) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+ $(RM) $(OBJECTS) $(EXECUTABLE)
+ $(RM) $(OBJECTS_TOOL) $(EXECUTABLE)
+
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-usb-demo/lynq-usb-demo.bb b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-usb-demo/lynq-usb-demo.bb
new file mode 100644
index 0000000..12dc832
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-usb-demo/lynq-usb-demo.bb
@@ -0,0 +1,31 @@
+#inherit externalsrc package
+#inherit externalsrc package systemd
+DESCRIPTION = "lynq-usb-demo"
+LICENSE = "CLOSED"
+LICENSE = "CLOSED"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=b1e07e8d88e26263e71d3a9e2aa9a2ff"
+SRC_URI = "file://lynq-usb-demo.cpp \
+ file://makefile \
+"
+DEPENDS += "liblynq-qser-usb"
+
+SRC-DIR = "${S}/../lynq-usb-demo"
+FILES_${PN} += "${bindir}/"
+TARGET_CC_ARCH += "${LDFLAGS}"
+SYSTEMD_PACKAGES = "${PN}"
+S = "${WORKDIR}"
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+ if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float"
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}"
+ fi
+}
+
+
+do_install() {
+
+ install -d ${D}${bindir}/
+ install -m 0755 ${S}/lynq-usb-demo ${D}${bindir}/
+}
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-usb/LICENSE b/cap/zx297520v3/src/lynq/lib/liblynq-qser-usb/LICENSE
new file mode 100644
index 0000000..605b7ea
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-usb/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MobileTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MobileTek Inc. and/or its licensors. Without
+the prior written permission of MobileTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MobileTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MobileTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MobileTek SOFTWARE")
+RECEIVED FROM MobileTek AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MobileTek EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MobileTek PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MobileTek SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MobileTek
+SOFTWARE. MobileTek SHALL ALSO NOT BE RESPONSIBLE FOR ANY MobileTek SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MobileTek'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MobileTek SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MobileTek'S OPTION, TO REVISE OR REPLACE THE
+MobileTek SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MobileTek FOR SUCH MobileTek SOFTWARE AT ISSUE.
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-usb/include/lynq-qser-usb.h b/cap/zx297520v3/src/lynq/lib/liblynq-qser-usb/include/lynq-qser-usb.h
new file mode 100644
index 0000000..97428d4
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-usb/include/lynq-qser-usb.h
@@ -0,0 +1,25 @@
+/*******************************************************
+*
+* @brief: Add usb api
+* @details: add liblynq-qser-usb api
+* @author: wz.wang
+* @date: 2024.2.18
+* @version: V1.0
+* @copyright:Copyright (c) MobileTek
+*
+*********************************************/
+#ifndef LYNQ_QSER_USB
+#define LYNQ_QSER_USB
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int qser_get_usb_usermode_net_state(void);
+int qser_get_usb_usermode_adb_state(void);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-usb/lynq-qser-usb.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-usb/lynq-qser-usb.cpp
new file mode 100644
index 0000000..90e5b77
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-usb/lynq-qser-usb.cpp
@@ -0,0 +1,43 @@
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "liblog/lynq_deflog.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "sc_usb.h"
+#include "nv_api.h"
+#include "lynq-qser-usb.h"
+
+/********************************************************************
+* @brief: qser_get_usb_usermode_net_state, Get Net user mode adb status
+* @return : int, Be greater than zero if successful, Less than zero if failed
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+int qser_get_usb_usermode_net_state(void)
+{
+ return sc_usb_usermode_net_state();
+}
+
+/********************************************************************
+* @brief: qser_get_usb_usermode_adb_state, Get Usb user mode adb status
+* @return : int, Be greater than zero if successful, Less than zero if failed
+* @todo: NA
+* @see: NA
+* @warning: NA
+*********************************************************************/
+int qser_get_usb_usermode_adb_state(void)
+{
+ return sc_usb_usermode_adb_state();
+}
+
+DEFINE_LYNQ_LIB_LOG(LYNQ_USB)
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-usb/makefile b/cap/zx297520v3/src/lynq/lib/liblynq-qser-usb/makefile
new file mode 100644
index 0000000..48bfdbf
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-usb/makefile
@@ -0,0 +1,48 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+ -std=gnu++14 \
+ -g -Os \
+ -flto \
+ -fPIC \
+
+LOCAL_PATH = .
+
+LOCAL_C_INCLUDES = \
+ -I. \
+ -I$(LOCAL_PATH)/include \
+ -I$(LOCAL_PATH)/ \
+ -I$(ROOT)$(includedir)/logger \
+ -I$(ROOT)$(includedir)/liblog \
+
+LOCAL_LIBS := \
+ -L. \
+ -ldl \
+ -lstdc++ \
+ -llynq-log \
+ -lbsp \
+ -lnvram \
+
+SOURCES = lynq-qser-usb.cpp
+LIBRARY = liblynq-qser-usb.so
+
+OBJECTS=$(SOURCES:.cpp=.o)
+
+all: $(LIBRARY)
+
+$(LIBRARY): $(OBJECTS)
+ $(CXX) -shared -o $@ $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES)
+
+%.o : %.cpp
+ $(CXX) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -fPIC -c $<
+
+install:
+ mkdir -p $(ROOT)$(base_libdir)/
+ install $(LIBRARY) $(ROOT)$(base_libdir)/
+ mkdir -p $(ROOT)$(includedir)/$(NAME)/sdk
+
+clean:
+ $(RM) $(OBJECTS) $(LIBRARY)
+
+