From 88c323337b1b196dd3098c14c30de5725a21c4d3 Mon Sep 17 00:00:00 2001
From: yy1717 <fctom1215@outlook.com>
Date: 星期五, 22 五月 2020 19:02:09 +0800
Subject: [PATCH] Merge branch 'master' of https://gitee.com/endian11/DriveJudge

---
 app/src/main/java/safeluck/drive/evaluation/app.java                                                    |   23 +++++++
 app/src/main/java/safeluck/drive/evaluation/fragment/VPFragment.java                                    |  103 +++++++++++++++++++++++++++++++---
 app/libs/tbs_sdk_thirdapp_v4.3.0.3_43903_sharewithdownloadwithfile_withoutGame_obfs_20200402_121309.jar |    0 
 app/src/main/jniLibs/armeabi/libtbs.so                                                                  |    0 
 app/build.gradle                                                                                        |    6 ++
 lib/src/main/java/com/anyun/exam/lib/RemoteService.java                                                 |    3 
 6 files changed, 123 insertions(+), 12 deletions(-)

diff --git a/app/build.gradle b/app/build.gradle
index 0d98b9a..85f7c62 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -11,6 +11,12 @@
         versionCode 1
         versionName "1.0"
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+
+        ndk {
+            // Specifies the ABI configurations of your native
+            // libraries Gradle should build and package with your APK.
+            abiFilters 'armeabi-v7a'
+        }
     }
     compileOptions {
         sourceCompatibility 1.8
diff --git a/app/libs/tbs_sdk_thirdapp_v4.3.0.3_43903_sharewithdownloadwithfile_withoutGame_obfs_20200402_121309.jar b/app/libs/tbs_sdk_thirdapp_v4.3.0.3_43903_sharewithdownloadwithfile_withoutGame_obfs_20200402_121309.jar
new file mode 100644
index 0000000..87c40fa
--- /dev/null
+++ b/app/libs/tbs_sdk_thirdapp_v4.3.0.3_43903_sharewithdownloadwithfile_withoutGame_obfs_20200402_121309.jar
Binary files differ
diff --git a/app/src/main/java/safeluck/drive/evaluation/app.java b/app/src/main/java/safeluck/drive/evaluation/app.java
index 6761109..cef9ce9 100644
--- a/app/src/main/java/safeluck/drive/evaluation/app.java
+++ b/app/src/main/java/safeluck/drive/evaluation/app.java
@@ -26,6 +26,7 @@
 import com.google.gson.JsonArray;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
+import com.tencent.smtt.sdk.QbSdk;
 
 
 import org.json.JSONException;
@@ -65,7 +66,7 @@
  */
 public class app extends Application implements IAYExamListener  {
 
-    private static final String TAG = "app";
+    private static final String TAG = "JiaKaoApplication";
     private static Context appContext=null;
     @Override
     public void onCreate() {
@@ -97,12 +98,29 @@
 
             //鑰冭瘯鐘舵�� 锛屼竴浜涘垵濮嬬姸鎬侊紝app涓�浜涚姸鎬佸簲璇ュ厛鍒濆鍖栦竴涓�
             initData();
-
+            QbSdk.initX5Environment(this,cb);
 
         }
 
     }
+    QbSdk.PreInitCallback cb = new QbSdk.PreInitCallback() {
+        @Override
+        public void onViewInitFinished(boolean arg0) {
+            MyLog.i(" QbSdk onViewInitFinished is " + arg0);
+        }
 
+        @Override
+        public void onCoreInitFinished() {
+            MyLog.i("x5鍐呮牳onCoreInitFinished");
+        }
+    };
+    private void preinitX5WebCore() {
+        if (!QbSdk.isTbsCoreInited()) {
+            // preinit鍙渶瑕佽皟鐢ㄤ竴娆★紝濡傛灉宸茬粡瀹屾垚浜嗗垵濮嬪寲锛岄偅涔堝氨鐩存帴鏋勯�爒iew
+            QbSdk.preInit(this, null);// 璁剧疆X5鍒濆鍖栧畬鎴愮殑鍥炶皟鎺ュ彛
+            MyLog.i(" QbSdk isTbsCoreInited  " );
+        }
+    }
     private void initData() {
         CThreadPoolExecutor.runInBackground(()->{
                 int type = WorkRoomDataBase.getWorkRoomDataBase(getApplicationContext()).getExamStatusDao().getStartExamInt();
@@ -132,6 +150,7 @@
     @Override
     public void callBackMsg(final int cmd, String json) {
         String strConent = String.format("鏀跺埌鍛戒护[%d],Json鍐呭涓�%s", cmd, json);
+        Log.i(TAG,strConent);
         if (strConent.equalsIgnoreCase(lastStr)){
 
         }else{
diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/VPFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/VPFragment.java
index 886c096..b4725bb 100644
--- a/app/src/main/java/safeluck/drive/evaluation/fragment/VPFragment.java
+++ b/app/src/main/java/safeluck/drive/evaluation/fragment/VPFragment.java
@@ -1,15 +1,28 @@
 package safeluck.drive.evaluation.fragment;
 
+import android.os.Build;
 import android.os.Bundle;
 
-import android.view.Gravity;
+import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.widget.TextView;
 
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
+
+import com.anyun.exam.lib.MyLog;
+import com.tencent.smtt.export.external.interfaces.SslError;
+import com.tencent.smtt.export.external.interfaces.SslErrorHandler;
+import com.tencent.smtt.export.external.interfaces.WebResourceRequest;
+import com.tencent.smtt.export.external.interfaces.WebResourceResponse;
+import com.tencent.smtt.sdk.WebSettings;
+import com.tencent.smtt.sdk.WebView;
+import com.tencent.smtt.sdk.WebViewClient;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
 
 import me.yokeyword.fragmentation.SupportFragment;
 
@@ -29,19 +42,91 @@
         return vpFragment;
     }
 
+    private String url = "http://192.168.40.202:9527/#/visitor/monitor?device_id=0314200100000002";
+    private String url1 = "http://www.baidu.com";
+    private static final String TAG = VPFragment.class.getCanonicalName();
+
     @Nullable
     @Override
     public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
-        TextView textView = new TextView(_mActivity);
+        hookWebView();
+        WebView webView = new WebView(_mActivity);
         ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
-        textView.setGravity(Gravity.CENTER);
-        textView.setLayoutParams(layoutParams);
+        webView.setLayoutParams(layoutParams);
         Bundle bundle = getArguments();
         if (bundle != null){
 
-        textView.setText(bundle.getString("argu"));
-        }else
-        textView.setText("kong");
-        return textView;
+        }else{
+
+        }
+        WebSettings webSettings = webView.getSettings();
+
+
+        webSettings.setDomStorageEnabled(true);
+        webSettings.setAppCacheMaxSize(1024*1024*8);//瀛樺偍鐨勬渶澶у閲�
+        String appCachePath = _mActivity.getCacheDir().getAbsolutePath();
+        webSettings.setAppCachePath(appCachePath);
+        webSettings.setAllowFileAccess(true);
+        webSettings.setAppCacheEnabled(true);
+                webSettings.setJavaScriptEnabled(true);
+        webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
+        webView.loadUrl(url);
+        webView.setWebViewClient(new WebViewClient(){
+            @Override
+            public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
+                view.loadUrl(url);
+                return true;
+            }
+
+            @Override
+            public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
+                super.onReceivedHttpError(view, request, errorResponse);
+                Log.i(TAG,errorResponse.getReasonPhrase());
+            }
+
+            @Override
+            public void onReceivedSslError(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) {
+                super.onReceivedSslError(webView, sslErrorHandler, sslError);
+                sslErrorHandler.proceed();
+            }
+        });
+        return webView;
+    }
+    public static void hookWebView() {
+        int sdkInt = Build.VERSION.SDK_INT;
+        try {
+            Class<?> factoryClass = Class.forName("android.webkit.WebViewFactory");
+            Field field = factoryClass.getDeclaredField("sProviderInstance");
+            field.setAccessible(true);
+            Object sProviderInstance = field.get(null);
+            if (sProviderInstance != null) {
+                MyLog.i("sProviderInstance isn't null");
+                return;
+            }
+            Method getProviderClassMethod;
+            if (sdkInt > 22) {
+                getProviderClassMethod = factoryClass.getDeclaredMethod("getProviderClass");
+            } else if (sdkInt == 22) {
+                getProviderClassMethod = factoryClass.getDeclaredMethod("getFactoryClass");
+            } else {
+                MyLog.i("Don't need to Hook WebView");
+                return;
+            }
+            getProviderClassMethod.setAccessible(true);
+            Class<?> providerClass = (Class<?>) getProviderClassMethod.invoke(factoryClass);
+            Class<?> delegateClass = Class.forName("android.webkit.WebViewDelegate");
+            Constructor<?> providerConstructor = providerClass.getConstructor(delegateClass);
+            if (providerConstructor != null) {
+                providerConstructor.setAccessible(true);
+                Constructor<?> declaredConstructor = delegateClass.getDeclaredConstructor();
+                declaredConstructor.setAccessible(true);
+                sProviderInstance = providerConstructor.newInstance(declaredConstructor.newInstance());
+                MyLog.i("sProviderInstance:{}", sProviderInstance);
+                field.set("sProviderInstance", sProviderInstance);
+            }
+            MyLog.i("Hook done!");
+        } catch (Throwable e) {
+            MyLog.i(e);
+        }
     }
 }
diff --git a/app/src/main/jniLibs/armeabi/libtbs.so b/app/src/main/jniLibs/armeabi/libtbs.so
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/app/src/main/jniLibs/armeabi/libtbs.so
diff --git a/lib/src/main/java/com/anyun/exam/lib/RemoteService.java b/lib/src/main/java/com/anyun/exam/lib/RemoteService.java
index e89893c..7fbe4ae 100644
--- a/lib/src/main/java/com/anyun/exam/lib/RemoteService.java
+++ b/lib/src/main/java/com/anyun/exam/lib/RemoteService.java
@@ -166,6 +166,8 @@
     }
 
     private void onMessageArrived(int cmd, String json) {
+
+        Log.d(TAG, "SendMsgToMainProc cmd = " + String.format("%04X", cmd) + " json = " + json);
         int N = mListenerList.getRegisteredCallbackCount();
 
         synchronized(this) {
@@ -191,7 +193,6 @@
 
 
 
-        Log.d(TAG, "SendMsgToMainProc cmd = " + String.format("%04X", cmd) + " json = " + value);
     }
 
     public String javaDESEncrypt(String plaintext, String key) {

--
Gitblit v1.8.0