From 22f2d94e81e7f77df4a7a63b370a06a66dd1b93e Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期三, 26 十月 2022 17:10:35 +0800
Subject: [PATCH] 0312 BT7sdk

---
 Project/js_sdk/src/game_jisugame/java/com/secondworld/univeralsdk/H2EngineSDK.java |   77 ++++++++++++++++++++++++--------------
 1 files changed, 49 insertions(+), 28 deletions(-)

diff --git a/Project/js_sdk/src/game_jisugame/java/com/secondworld/univeralsdk/H2EngineSDK.java b/Project/js_sdk/src/game_jisugame/java/com/secondworld/univeralsdk/H2EngineSDK.java
index 94eb3e4..4515a69 100644
--- a/Project/js_sdk/src/game_jisugame/java/com/secondworld/univeralsdk/H2EngineSDK.java
+++ b/Project/js_sdk/src/game_jisugame/java/com/secondworld/univeralsdk/H2EngineSDK.java
@@ -33,6 +33,8 @@
     private static final String TAG = "H2EngineSDK";
     private static String APP_ID = "";
 
+    private static boolean PushEnable = true;
+
     public static void HandleUnityMessage(String json)
     {
         LogUtil.i(TAG, "鏀跺埌Unity鍙戞潵鐨勪俊鎭�: " + json);
@@ -51,6 +53,9 @@
                     break;
                 case CodeU2A.AssetCopy:
                     FileUtil.copyAssets(_activity);
+                    break;
+                case CodeU2A.CopyOneAsset:
+                    FileUtil.copy(_activity, _json.getString("fileName"));
                     break;
                 case CodeU2A.BatteryListenStart:
                     BatteryUtil.getInstance().start(_activity);
@@ -133,6 +138,9 @@
                 case CodeU2A.JPushRemoveLocalMessage:
                     removeNotification(_activity, _json.getInt("id"));
                     break;
+                case CodeU2A.SendRegistEvent:
+                    JSPlatformUtil.getInstance().SendRegisterEvent();
+                    break;
             }
 
         } catch (JSONException e)
@@ -145,25 +153,31 @@
     public static void addLocalNotification(Activity activity, int id, String title, String content,
                                             long fireTime)
     {
-        try
+        if (PushEnable)
         {
-            JPushLocalNotification ln = new JPushLocalNotification();
-            ln.setBuilderId(0);// 璁剧疆鏍峰紡
-            ln.setNotificationId(id);// id
-            ln.setTitle(title);// 鏍囬
+            try
+            {
+                JPushLocalNotification ln = new JPushLocalNotification();
+                ln.setBuilderId(0);// 璁剧疆鏍峰紡
+                ln.setNotificationId(id);// id
+                ln.setTitle(title);// 鏍囬
 
-            ln.setContent(content);// 鍐呭
-            ln.setBroadcastTime(fireTime);// 绛夊緟鏃堕棿
-            JPushInterface.addLocalNotification(activity, ln);
-        } catch (Exception e)
-        {
-            e.printStackTrace();
+                ln.setContent(content);// 鍐呭
+                ln.setBroadcastTime(fireTime);// 绛夊緟鏃堕棿
+                JPushInterface.addLocalNotification(activity, ln);
+            } catch (Exception e)
+            {
+                e.printStackTrace();
+            }
         }
     }
 
     public static void removeNotification(Activity activity, int id)
     {
-        JPushInterface.removeLocalNotification(activity, id);
+        if (PushEnable)
+        {
+            JPushInterface.removeLocalNotification(activity, id);
+        }
     }
 
     public static void GetExternalStorage()
@@ -275,6 +289,8 @@
             return;
         }
 
+        PushEnable = activity.getPackageName().equals("com.lingleigame.shaonianqixiachuan");
+
         new Thread(new Runnable()
         {
             @Override
@@ -298,31 +314,36 @@
                 UniversalUtil.sendMessageToUnity(_msgStruct);
 
                 // ------------------------------- 鏋佸厜鎺ㄩ�� -------------------------------
-                JPushInterface.setDebugMode(true);
-                JPushInterface.init(activity);
-
-                final long _waitingTime = System.currentTimeMillis();
-
-                while (true)
+                String _registrationID = "0";
+                if (PushEnable)
                 {
-                    // 绛夊緟鑾峰彇鏋佸厜registrationID
-                    if (!JPushInterface.getRegistrationID(activity).equals(""))
-                    {
-                        break;
-                    }
+                    JPushInterface.setDebugMode(true);
+                    JPushInterface.init(activity);
 
-                    long _escapeTime = System.currentTimeMillis() - _waitingTime;
+                    final long _waitingTime = System.currentTimeMillis();
 
-                    if (_escapeTime > 3000)
+                    while (true)
                     {
-                        LogUtil.w(TAG, "绛夊緟鑾峰彇鏋佸厜鎺ㄩ�乺egistrationID瓒呮椂: 3绉�");
-                        break;
+                        // 绛夊緟鑾峰彇鏋佸厜registrationID
+                        if (!JPushInterface.getRegistrationID(activity).equals(""))
+                        {
+                            _registrationID = JPushInterface.getRegistrationID(activity);
+                            break;
+                        }
+
+                        long _escapeTime = System.currentTimeMillis() - _waitingTime;
+
+                        if (_escapeTime > 3000)
+                        {
+                            LogUtil.w(TAG, "绛夊緟鑾峰彇鏋佸厜鎺ㄩ�乺egistrationID瓒呮椂: 3绉�");
+                            break;
+                        }
                     }
                 }
 
                 _msgStruct.clear();
                 _msgStruct.put("code", CodeA2U.PushClientID);
-                _msgStruct.put("clientID", JPushInterface.getRegistrationID(activity));
+                _msgStruct.put("clientID", _registrationID);
                 UniversalUtil.sendMessageToUnity(_msgStruct);
 
                 _msgStruct.clear();

--
Gitblit v1.8.0