From e786fd266d4a01bde925a15aafbdc7f8937d066b Mon Sep 17 00:00:00 2001 From: chenbin Date: Tue, 1 Dec 2020 23:32:28 +0800 Subject: [PATCH] call log --- Assets/3rd/AndroidOpener/Plugins/release.aar | Bin 1231447 -> 1231447 bytes Assets/Plugins/Android/AndroidManifest.xml | 4 +- .../java/com/coolape/tianrun/CallLogInfo.java | 38 ++++++++++++++ .../com/coolape/tianrun/CallLogInfo.java.meta | 32 ++++++++++++ .../java/com/coolape/tianrun/CallLogUtl.java | 47 ++++++++++++++++++ .../com/coolape/tianrun/CallLogUtl.java.meta | 32 ++++++++++++ .../java/com/coolape/tianrun/U3dPlugin.java | 5 ++ Assets/trCRM/Scripts/call/CallLogUtl.cs | 32 ++++++++++++ Assets/trCRM/Scripts/call/CallLogUtl.cs.meta | 11 ++++ .../trCRM/Scripts/xLua/XluaGenCodeConfig.cs | 1 + .../priority/lua/public/CLLInclude.lua | 2 + tianrunPlugins/.idea/gradle.xml | 1 + .../java/com/coolape/tianrun/CallLogInfo.java | 38 ++++++++++++++ .../java/com/coolape/tianrun/CallLogUtl.java | 47 ++++++++++++++++++ .../java/com/coolape/tianrun/U3dPlugin.java | 5 ++ 15 files changed, 294 insertions(+), 1 deletion(-) create mode 100644 Assets/trCRM/Plugins/Android/java/com/coolape/tianrun/CallLogInfo.java create mode 100644 Assets/trCRM/Plugins/Android/java/com/coolape/tianrun/CallLogInfo.java.meta create mode 100644 Assets/trCRM/Plugins/Android/java/com/coolape/tianrun/CallLogUtl.java create mode 100644 Assets/trCRM/Plugins/Android/java/com/coolape/tianrun/CallLogUtl.java.meta create mode 100644 Assets/trCRM/Scripts/call/CallLogUtl.cs create mode 100644 Assets/trCRM/Scripts/call/CallLogUtl.cs.meta create mode 100644 tianrunPlugins/app/src/main/java/com/coolape/tianrun/CallLogInfo.java create mode 100644 tianrunPlugins/app/src/main/java/com/coolape/tianrun/CallLogUtl.java diff --git a/Assets/3rd/AndroidOpener/Plugins/release.aar b/Assets/3rd/AndroidOpener/Plugins/release.aar index c3fde34b7e5215230b46de2815a6c1e89bb44bcd..9af75267930319a47dbd93baa6dabb26a1bb54ec 100644 GIT binary patch delta 82 zcmcaU#rygc?}iq}7N!>F7M2#)7Pc1l7LFFq7OocV7M>Q~7QPn#7J(MQEkd=A@7Vn8ANa$O8b!<{j(+ delta 82 zcmcaU#rygc?}iq}7N!>F7M2#)7Pc1l7LFFq7OocV7M>Q~7QPn#7J(MQEkda0V^c2L{o^eblkr^y>=A@7Vn8ANa$O8c7svkrE diff --git a/Assets/Plugins/Android/AndroidManifest.xml b/Assets/Plugins/Android/AndroidManifest.xml index 6789fd4..886d916 100644 --- a/Assets/Plugins/Android/AndroidManifest.xml +++ b/Assets/Plugins/Android/AndroidManifest.xml @@ -71,7 +71,9 @@ - + + + diff --git a/Assets/trCRM/Plugins/Android/java/com/coolape/tianrun/CallLogInfo.java b/Assets/trCRM/Plugins/Android/java/com/coolape/tianrun/CallLogInfo.java new file mode 100644 index 0000000..01f28b9 --- /dev/null +++ b/Assets/trCRM/Plugins/Android/java/com/coolape/tianrun/CallLogInfo.java @@ -0,0 +1,38 @@ +package com.coolape.tianrun; + +import android.util.Log; + +import org.json.JSONException; +import org.json.JSONObject; + +public class CallLogInfo { + public String number; + public String date; + public int type; + public CallLogInfo(String number, String date, int type) { + super(); + this.number = number; + this.date = date; + this.type = type; + } + + public JSONObject toJson(){ + try { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("number", number); + jsonObject.put("date", date); + /* Call log type for incoming calls. + public static final int INCOMING_TYPE = 1; + Call log type for outgoing calls. + public static final int OUTGOING_TYPE = 2; + Call log type for missed calls. + public static final int MISSED_TYPE = 3; + */ + jsonObject.put("type", type); + return jsonObject; + } catch (JSONException e) { + Log.i("", e.getMessage()); + return null; + } + } +} diff --git a/Assets/trCRM/Plugins/Android/java/com/coolape/tianrun/CallLogInfo.java.meta b/Assets/trCRM/Plugins/Android/java/com/coolape/tianrun/CallLogInfo.java.meta new file mode 100644 index 0000000..d3f7819 --- /dev/null +++ b/Assets/trCRM/Plugins/Android/java/com/coolape/tianrun/CallLogInfo.java.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: 1801de6425b084a7da4903cf17039d82 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Android: Android + second: + enabled: 1 + settings: {} + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/trCRM/Plugins/Android/java/com/coolape/tianrun/CallLogUtl.java b/Assets/trCRM/Plugins/Android/java/com/coolape/tianrun/CallLogUtl.java new file mode 100644 index 0000000..7c8df38 --- /dev/null +++ b/Assets/trCRM/Plugins/Android/java/com/coolape/tianrun/CallLogUtl.java @@ -0,0 +1,47 @@ +package com.coolape.tianrun; + +import android.content.ContentResolver; +import android.content.Context; +import android.database.Cursor; +import android.net.Uri; +import android.provider.CallLog; + +import org.json.JSONArray; +import org.json.JSONObject; +import org.json.JSONException; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; + +public class CallLogUtl { + public static List getCallLog(Context context) { + List infos = new ArrayList(); + ContentResolver cr = context.getContentResolver(); + Uri uri = CallLog.Calls.CONTENT_URI; + String[] projection = new String[] { CallLog.Calls.NUMBER, CallLog.Calls.DATE, + CallLog.Calls.TYPE }; + + SimpleDateFormat format = new SimpleDateFormat( + "yyyy-MM-dd hh:mm:ss"); + Cursor cursor = cr.query(uri, projection, null, null, null); + while (cursor.moveToNext()) { + String number = cursor.getString(0); + long date = cursor.getLong(1); + int type = cursor.getInt(2); + infos.add(new CallLogInfo(number, format.format(date), type)); + } + cursor.close(); + return infos; + } + + public static String getCallLogJson(Context context) { + List infos = getCallLog(context); + + JSONArray array = new JSONArray(); + for(int i=0; i < infos.size(); i++){ + array.put(infos.get(i).toJson()); + } + return array.toString(); + } +} diff --git a/Assets/trCRM/Plugins/Android/java/com/coolape/tianrun/CallLogUtl.java.meta b/Assets/trCRM/Plugins/Android/java/com/coolape/tianrun/CallLogUtl.java.meta new file mode 100644 index 0000000..8506919 --- /dev/null +++ b/Assets/trCRM/Plugins/Android/java/com/coolape/tianrun/CallLogUtl.java.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: 3146148febae9416bb04160071c8876c +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Android: Android + second: + enabled: 1 + settings: {} + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/trCRM/Plugins/Android/java/com/coolape/tianrun/U3dPlugin.java b/Assets/trCRM/Plugins/Android/java/com/coolape/tianrun/U3dPlugin.java index 61edec4..25ee95a 100644 --- a/Assets/trCRM/Plugins/Android/java/com/coolape/tianrun/U3dPlugin.java +++ b/Assets/trCRM/Plugins/Android/java/com/coolape/tianrun/U3dPlugin.java @@ -216,6 +216,11 @@ public class U3dPlugin { return mediaPlayer.getProgress(); } + //取得记录记录 + public String getCallLog() { + return CallLogUtl.getCallLogJson(UnityPlayer.currentActivity); + } + public static void UnitySendMessage(String CallbackFunc, String retCode, String orgs) { if (u3dListener.isEmpty()) { diff --git a/Assets/trCRM/Scripts/call/CallLogUtl.cs b/Assets/trCRM/Scripts/call/CallLogUtl.cs new file mode 100644 index 0000000..97eb782 --- /dev/null +++ b/Assets/trCRM/Scripts/call/CallLogUtl.cs @@ -0,0 +1,32 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public static class CallLogUtl +{ + const string className = "com.coolape.tianrun.U3dPlugin"; +#if UNITY_ANDROID + static AndroidJavaObject _plugin; + public static AndroidJavaObject plugin + { + get + { + if (_plugin == null) + { + _plugin = new AndroidJavaObject(className); + } + return _plugin; + } + } +#endif + public static string getCallLog() + { +#if UNITY_ANDROID + return plugin.CallStatic("getCallLog"); +#elif UNITY_IOS + +#else + return ""; +#endif + } +} diff --git a/Assets/trCRM/Scripts/call/CallLogUtl.cs.meta b/Assets/trCRM/Scripts/call/CallLogUtl.cs.meta new file mode 100644 index 0000000..5b4c9db --- /dev/null +++ b/Assets/trCRM/Scripts/call/CallLogUtl.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 06baaefd3505747e19fe243a0b84bc56 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/trCRM/Scripts/xLua/XluaGenCodeConfig.cs b/Assets/trCRM/Scripts/xLua/XluaGenCodeConfig.cs index ac86fbb..e33fa39 100644 --- a/Assets/trCRM/Scripts/xLua/XluaGenCodeConfig.cs +++ b/Assets/trCRM/Scripts/xLua/XluaGenCodeConfig.cs @@ -210,6 +210,7 @@ public static class XluaGenCodeConfig typeof(TextureFormat), typeof(FileInfo), typeof(CallListner), + typeof(CallLogUtl), }; //C#静态调用Lua的配置(包括事件的原型),仅可以配delegate,interface diff --git a/Assets/trCRM/upgradeRes4Dev/priority/lua/public/CLLInclude.lua b/Assets/trCRM/upgradeRes4Dev/priority/lua/public/CLLInclude.lua index bd348f0..36180a0 100644 --- a/Assets/trCRM/upgradeRes4Dev/priority/lua/public/CLLInclude.lua +++ b/Assets/trCRM/upgradeRes4Dev/priority/lua/public/CLLInclude.lua @@ -284,6 +284,8 @@ ImageConversion = CS.UnityEngine.ImageConversion FileInfo = CS.System.IO.FileInfo ---@type CallListner CallListner = CS.CallListner +---@type CallLogUtl +CallLogUtl = CS.CallLogUtl ------------------------------------------------------- ------------------------------------------------------- diff --git a/tianrunPlugins/.idea/gradle.xml b/tianrunPlugins/.idea/gradle.xml index 5cd135a..9bba60d 100644 --- a/tianrunPlugins/.idea/gradle.xml +++ b/tianrunPlugins/.idea/gradle.xml @@ -14,6 +14,7 @@ diff --git a/tianrunPlugins/app/src/main/java/com/coolape/tianrun/CallLogInfo.java b/tianrunPlugins/app/src/main/java/com/coolape/tianrun/CallLogInfo.java new file mode 100644 index 0000000..01f28b9 --- /dev/null +++ b/tianrunPlugins/app/src/main/java/com/coolape/tianrun/CallLogInfo.java @@ -0,0 +1,38 @@ +package com.coolape.tianrun; + +import android.util.Log; + +import org.json.JSONException; +import org.json.JSONObject; + +public class CallLogInfo { + public String number; + public String date; + public int type; + public CallLogInfo(String number, String date, int type) { + super(); + this.number = number; + this.date = date; + this.type = type; + } + + public JSONObject toJson(){ + try { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("number", number); + jsonObject.put("date", date); + /* Call log type for incoming calls. + public static final int INCOMING_TYPE = 1; + Call log type for outgoing calls. + public static final int OUTGOING_TYPE = 2; + Call log type for missed calls. + public static final int MISSED_TYPE = 3; + */ + jsonObject.put("type", type); + return jsonObject; + } catch (JSONException e) { + Log.i("", e.getMessage()); + return null; + } + } +} diff --git a/tianrunPlugins/app/src/main/java/com/coolape/tianrun/CallLogUtl.java b/tianrunPlugins/app/src/main/java/com/coolape/tianrun/CallLogUtl.java new file mode 100644 index 0000000..7c8df38 --- /dev/null +++ b/tianrunPlugins/app/src/main/java/com/coolape/tianrun/CallLogUtl.java @@ -0,0 +1,47 @@ +package com.coolape.tianrun; + +import android.content.ContentResolver; +import android.content.Context; +import android.database.Cursor; +import android.net.Uri; +import android.provider.CallLog; + +import org.json.JSONArray; +import org.json.JSONObject; +import org.json.JSONException; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; + +public class CallLogUtl { + public static List getCallLog(Context context) { + List infos = new ArrayList(); + ContentResolver cr = context.getContentResolver(); + Uri uri = CallLog.Calls.CONTENT_URI; + String[] projection = new String[] { CallLog.Calls.NUMBER, CallLog.Calls.DATE, + CallLog.Calls.TYPE }; + + SimpleDateFormat format = new SimpleDateFormat( + "yyyy-MM-dd hh:mm:ss"); + Cursor cursor = cr.query(uri, projection, null, null, null); + while (cursor.moveToNext()) { + String number = cursor.getString(0); + long date = cursor.getLong(1); + int type = cursor.getInt(2); + infos.add(new CallLogInfo(number, format.format(date), type)); + } + cursor.close(); + return infos; + } + + public static String getCallLogJson(Context context) { + List infos = getCallLog(context); + + JSONArray array = new JSONArray(); + for(int i=0; i < infos.size(); i++){ + array.put(infos.get(i).toJson()); + } + return array.toString(); + } +} diff --git a/tianrunPlugins/app/src/main/java/com/coolape/tianrun/U3dPlugin.java b/tianrunPlugins/app/src/main/java/com/coolape/tianrun/U3dPlugin.java index 61edec4..25ee95a 100644 --- a/tianrunPlugins/app/src/main/java/com/coolape/tianrun/U3dPlugin.java +++ b/tianrunPlugins/app/src/main/java/com/coolape/tianrun/U3dPlugin.java @@ -216,6 +216,11 @@ public class U3dPlugin { return mediaPlayer.getProgress(); } + //取得记录记录 + public String getCallLog() { + return CallLogUtl.getCallLogJson(UnityPlayer.currentActivity); + } + public static void UnitySendMessage(String CallbackFunc, String retCode, String orgs) { if (u3dListener.isEmpty()) {