[Feature]add MT2731_MP2_MR2_SVN388 baseline version

Change-Id: Ief04314834b31e27effab435d3ca8ba33b499059
diff --git a/src/lynq/lib/liblynq-tele-ril/lynq-riltel/main.cpp b/src/lynq/lib/liblynq-tele-ril/lynq-riltel/main.cpp
new file mode 100644
index 0000000..690cf3f
--- /dev/null
+++ b/src/lynq/lib/liblynq-tele-ril/lynq-riltel/main.cpp
@@ -0,0 +1,152 @@
+/*
+*  Copyright (C) 2014 MediaTek Inc.
+*
+*  Modification based on code covered by the below mentioned copyright
+*  and/or permission notice(s).
+*/
+
+/* 
+**
+** Copyright 2006 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.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+#include <string.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <vendor-ril/telephony/ril.h>
+#include <log/log.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include "stateManager/stateManager.h"
+#include "common.h"
+#include <lib_tele.h>
+#include <lynq_call.h>
+#include <lynq_sms.h>
+
+extern "C" void RIL_register (const RIL_RadioFunctions *callbacks);
+
+extern "C" void RIL_onRequestComplete(RIL_Token t, RIL_Errno e,
+                           void *response, size_t responselen);
+
+
+#if defined(ANDROID_MULTI_SIM)
+extern "C" void RIL_onUnsolicitedResponse(int unsolResponse, const void *data,
+                                size_t datalen, RIL_SOCKET_ID socket_id);
+#else
+extern "C" void RIL_onUnsolicitedResponse(int unsolResponse, const void *data,
+                                size_t datalen);
+#endif
+
+#undef LOG_TAG
+#define LOG_TAG "DEMO_MAIN"
+//static const struct RIL_Cb *mRIL_Cb = NULL;
+requestResponse mRequestCb = NULL;
+unsolicitedResponse mUnsolicitedCb = NULL;
+static user_cb *lynq_Cb=NULL;
+static struct RIL_Env s_rilEnv = {
+    RIL_onRequestComplete,
+    RIL_onUnsolicitedResponse,
+    NULL
+};
+/*
+ void lynqRegisterRequestResponse(user_cb * cb){
+    lynq_cb = cb;
+    return ;
+}
+*/
+void lynqRegisterUnsolicitedResponse(user_cb * cb){
+    lynq_Cb = cb;
+    return ;
+}
+static void lynqOnUnsolicitedResponseCallback(int unsolResponse,char *response,int responselen) {
+}
+void  lynq_ril_init()
+{
+    int lock_file = open("/tmp/tel_demo_single_proc.lock", O_CREAT|O_RDWR, 0666);
+    int rc = flock(lock_file,LOCK_EX|LOCK_NB);
+    if(rc) {
+        if(EWOULDBLOCK == errno) {
+            printf("Error: cannot restart the telephony app repeatedly\n");
+            RLOGD("Error: cannot restart the telephony app repeatedly");
+            exit(0);
+        }
+    }
+#ifdef BASELIB_DIR_LIB64
+    const char *rilLibPath = "/lib64/libvendor-ril.so";
+#else
+    const char *rilLibPath = "/lib/libvendor-ril.so";
+#endif
+    void *dlHandle;
+    const RIL_RadioFunctions *(*rilInit)(const struct RIL_Env *, int, char **);
+
+    const RIL_RadioFunctions *funcs;
+
+    RLOGD("**RIL Daemon Started**");
+    android::registerOnUnsolicitedResponse(lynq_Cb);
+    //prctl(PR_SET_NAME,(unsigned long)"demo_main_thread");
+    dlHandle = dlopen(rilLibPath, RTLD_NOW);
+
+    if (dlHandle == NULL) {
+        RLOGE("dlopen failed: %s", dlerror());
+        exit(EXIT_FAILURE);
+    }
+
+    android::RIL_startEventLoop();
+    //android::startATCILoop();
+    //android::startPMLoop();
+    //android::startWakupLoop();
+
+    rilInit =
+        (const RIL_RadioFunctions *(*)(const struct RIL_Env *, int, char **))
+        dlsym(dlHandle, "RIL_Init");
+
+    if (rilInit == NULL) {
+        RLOGE("RIL_Init not defined or exported in %s", rilLibPath);
+        exit(EXIT_FAILURE);
+    }
+
+    dlerror(); // Clear any previous dlerror
+    RLOGD("start rilInit");
+    funcs = rilInit(&s_rilEnv, 0, NULL);;
+    RLOGD("start RIL_register");
+    RIL_register(funcs);
+    if(lynqApiInit()!=0)
+    {
+        RLOGD("lynq api init fail");
+        exit(0);
+    }
+   // android::registerForAppResponse(lynqResponseCallback);
+   // android::registerOnUnsolicitedResponse(lynqOnUnsolicitedResponseCallback);
+   // android::startGdbusLoop();
+    RLOGD("RIL_Init RIL_register completed");
+    printf("DemoApp launch done!\n");
+    //while (true) {
+        //sleep(UINT32_MAX);
+    //}
+    close(lock_file);
+}
+int lynq_waitToRcvCmd(char **data, int lenth)
+{
+    printf("--------->[%s,%d] \n",__FUNCTION__,__LINE__);
+    android::getRequestData(data,lenth);
+    
+    return 0;
+}
\ No newline at end of file