Browse Source

call log

dev_2020
chenbin 3 years ago
parent
commit
e786fd266d

BIN
Assets/3rd/AndroidOpener/Plugins/release.aar View File


+ 3
- 1
Assets/Plugins/Android/AndroidManifest.xml View File

@@ -71,7 +71,9 @@
71 71
     <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
72 72
     
73 73
     <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
74
-    <uses-permission android:name="android.permission.RECORD_AUDIO" />
74
+    <uses-permission android:name="android.permission.RECORD_AUDIO" /> 
75
+
76
+
75 77
     
76 78
     <uses-permission android:name="android.permission.CAMERA" />
77 79
     <uses-feature android:name="android.hardware.camera" android:required="false" />

+ 38
- 0
Assets/trCRM/Plugins/Android/java/com/coolape/tianrun/CallLogInfo.java View File

@@ -0,0 +1,38 @@
1
+package com.coolape.tianrun;
2
+
3
+import android.util.Log;
4
+
5
+import org.json.JSONException;
6
+import org.json.JSONObject;
7
+
8
+public class CallLogInfo {
9
+    public String number;
10
+    public String date;
11
+    public int type;
12
+    public CallLogInfo(String number, String date, int type) {
13
+        super();
14
+        this.number = number;
15
+        this.date = date;
16
+        this.type = type;
17
+    }
18
+
19
+    public JSONObject toJson(){
20
+        try {
21
+            JSONObject jsonObject = new JSONObject();
22
+            jsonObject.put("number", number);
23
+            jsonObject.put("date", date);
24
+            /* Call log type for incoming calls.
25
+            public static final int INCOMING_TYPE = 1;
26
+             Call log type for outgoing calls.
27
+            public static final int OUTGOING_TYPE = 2;
28
+             Call log type for missed calls.
29
+            public static final int MISSED_TYPE = 3;
30
+            */
31
+            jsonObject.put("type", type);
32
+            return  jsonObject;
33
+        } catch (JSONException e) {
34
+            Log.i("", e.getMessage());
35
+            return  null;
36
+        }
37
+    }
38
+}

+ 32
- 0
Assets/trCRM/Plugins/Android/java/com/coolape/tianrun/CallLogInfo.java.meta View File

@@ -0,0 +1,32 @@
1
+fileFormatVersion: 2
2
+guid: 1801de6425b084a7da4903cf17039d82
3
+PluginImporter:
4
+  externalObjects: {}
5
+  serializedVersion: 2
6
+  iconMap: {}
7
+  executionOrder: {}
8
+  defineConstraints: []
9
+  isPreloaded: 0
10
+  isOverridable: 0
11
+  isExplicitlyReferenced: 0
12
+  validateReferences: 1
13
+  platformData:
14
+  - first:
15
+      Android: Android
16
+    second:
17
+      enabled: 1
18
+      settings: {}
19
+  - first:
20
+      Any: 
21
+    second:
22
+      enabled: 0
23
+      settings: {}
24
+  - first:
25
+      Editor: Editor
26
+    second:
27
+      enabled: 0
28
+      settings:
29
+        DefaultValueInitialized: true
30
+  userData: 
31
+  assetBundleName: 
32
+  assetBundleVariant: 

+ 47
- 0
Assets/trCRM/Plugins/Android/java/com/coolape/tianrun/CallLogUtl.java View File

@@ -0,0 +1,47 @@
1
+package com.coolape.tianrun;
2
+
3
+import android.content.ContentResolver;
4
+import android.content.Context;
5
+import android.database.Cursor;
6
+import android.net.Uri;
7
+import android.provider.CallLog;
8
+
9
+import org.json.JSONArray;
10
+import org.json.JSONObject;
11
+import org.json.JSONException;
12
+
13
+import java.text.SimpleDateFormat;
14
+import java.util.ArrayList;
15
+import java.util.List;
16
+
17
+public class CallLogUtl {
18
+    public static List<CallLogInfo> getCallLog(Context context) {
19
+        List<CallLogInfo> infos = new ArrayList<CallLogInfo>();
20
+        ContentResolver cr = context.getContentResolver();
21
+        Uri uri = CallLog.Calls.CONTENT_URI;
22
+        String[] projection = new String[] { CallLog.Calls.NUMBER, CallLog.Calls.DATE,
23
+                CallLog.Calls.TYPE };
24
+
25
+        SimpleDateFormat format = new SimpleDateFormat(
26
+                "yyyy-MM-dd hh:mm:ss");
27
+        Cursor cursor = cr.query(uri, projection, null, null, null);
28
+        while (cursor.moveToNext()) {
29
+            String number = cursor.getString(0);
30
+            long date = cursor.getLong(1);
31
+            int type = cursor.getInt(2);
32
+            infos.add(new CallLogInfo(number, format.format(date), type));
33
+        }
34
+        cursor.close();
35
+        return infos;
36
+    }
37
+
38
+    public static String getCallLogJson(Context context) {
39
+        List<CallLogInfo> infos = getCallLog(context);
40
+
41
+        JSONArray array = new JSONArray();
42
+        for(int i=0; i < infos.size(); i++){
43
+            array.put(infos.get(i).toJson());
44
+        }
45
+        return  array.toString();
46
+    }
47
+}

+ 32
- 0
Assets/trCRM/Plugins/Android/java/com/coolape/tianrun/CallLogUtl.java.meta View File

@@ -0,0 +1,32 @@
1
+fileFormatVersion: 2
2
+guid: 3146148febae9416bb04160071c8876c
3
+PluginImporter:
4
+  externalObjects: {}
5
+  serializedVersion: 2
6
+  iconMap: {}
7
+  executionOrder: {}
8
+  defineConstraints: []
9
+  isPreloaded: 0
10
+  isOverridable: 0
11
+  isExplicitlyReferenced: 0
12
+  validateReferences: 1
13
+  platformData:
14
+  - first:
15
+      Android: Android
16
+    second:
17
+      enabled: 1
18
+      settings: {}
19
+  - first:
20
+      Any: 
21
+    second:
22
+      enabled: 0
23
+      settings: {}
24
+  - first:
25
+      Editor: Editor
26
+    second:
27
+      enabled: 0
28
+      settings:
29
+        DefaultValueInitialized: true
30
+  userData: 
31
+  assetBundleName: 
32
+  assetBundleVariant: 

+ 5
- 0
Assets/trCRM/Plugins/Android/java/com/coolape/tianrun/U3dPlugin.java View File

@@ -216,6 +216,11 @@ public class U3dPlugin {
216 216
 		return mediaPlayer.getProgress();
217 217
 	}
218 218
 
219
+	//取得记录记录
220
+	public String getCallLog() {
221
+		return CallLogUtl.getCallLogJson(UnityPlayer.currentActivity);
222
+	}
223
+
219 224
 	public static void UnitySendMessage(String CallbackFunc, String retCode,
220 225
 			String orgs) {
221 226
 		if (u3dListener.isEmpty()) {

+ 32
- 0
Assets/trCRM/Scripts/call/CallLogUtl.cs View File

@@ -0,0 +1,32 @@
1
+using System.Collections;
2
+using System.Collections.Generic;
3
+using UnityEngine;
4
+
5
+public static class CallLogUtl
6
+{
7
+    const string className = "com.coolape.tianrun.U3dPlugin";
8
+#if UNITY_ANDROID
9
+    static AndroidJavaObject _plugin;
10
+    public static AndroidJavaObject plugin
11
+    {
12
+        get
13
+        {
14
+            if (_plugin == null)
15
+            {
16
+                _plugin = new AndroidJavaObject(className);
17
+            }
18
+            return _plugin;
19
+        }
20
+    }
21
+#endif
22
+    public static string getCallLog()
23
+    {
24
+#if UNITY_ANDROID
25
+        return plugin.CallStatic<string>("getCallLog");
26
+#elif UNITY_IOS
27
+
28
+#else
29
+        return "";
30
+#endif
31
+    }
32
+}

+ 11
- 0
Assets/trCRM/Scripts/call/CallLogUtl.cs.meta View File

@@ -0,0 +1,11 @@
1
+fileFormatVersion: 2
2
+guid: 06baaefd3505747e19fe243a0b84bc56
3
+MonoImporter:
4
+  externalObjects: {}
5
+  serializedVersion: 2
6
+  defaultReferences: []
7
+  executionOrder: 0
8
+  icon: {instanceID: 0}
9
+  userData: 
10
+  assetBundleName: 
11
+  assetBundleVariant: 

+ 1
- 0
Assets/trCRM/Scripts/xLua/XluaGenCodeConfig.cs View File

@@ -210,6 +210,7 @@ public static class XluaGenCodeConfig
210 210
 		typeof(TextureFormat),
211 211
 		typeof(FileInfo),
212 212
 		typeof(CallListner),
213
+		typeof(CallLogUtl),
213 214
 	};
214 215
 
215 216
 	//C#静态调用Lua的配置(包括事件的原型),仅可以配delegate,interface

+ 2
- 0
Assets/trCRM/upgradeRes4Dev/priority/lua/public/CLLInclude.lua View File

@@ -284,6 +284,8 @@ ImageConversion = CS.UnityEngine.ImageConversion
284 284
 FileInfo = CS.System.IO.FileInfo
285 285
 ---@type CallListner
286 286
 CallListner = CS.CallListner
287
+---@type CallLogUtl
288
+CallLogUtl = CS.CallLogUtl
287 289
 -------------------------------------------------------
288 290
 
289 291
 -------------------------------------------------------

+ 1
- 0
tianrunPlugins/.idea/gradle.xml View File

@@ -14,6 +14,7 @@
14 14
           </set>
15 15
         </option>
16 16
         <option name="resolveModulePerSourceSet" value="false" />
17
+        <option name="useQualifiedModuleNames" value="true" />
17 18
       </GradleProjectSettings>
18 19
     </option>
19 20
   </component>

+ 38
- 0
tianrunPlugins/app/src/main/java/com/coolape/tianrun/CallLogInfo.java View File

@@ -0,0 +1,38 @@
1
+package com.coolape.tianrun;
2
+
3
+import android.util.Log;
4
+
5
+import org.json.JSONException;
6
+import org.json.JSONObject;
7
+
8
+public class CallLogInfo {
9
+    public String number;
10
+    public String date;
11
+    public int type;
12
+    public CallLogInfo(String number, String date, int type) {
13
+        super();
14
+        this.number = number;
15
+        this.date = date;
16
+        this.type = type;
17
+    }
18
+
19
+    public JSONObject toJson(){
20
+        try {
21
+            JSONObject jsonObject = new JSONObject();
22
+            jsonObject.put("number", number);
23
+            jsonObject.put("date", date);
24
+            /* Call log type for incoming calls.
25
+            public static final int INCOMING_TYPE = 1;
26
+             Call log type for outgoing calls.
27
+            public static final int OUTGOING_TYPE = 2;
28
+             Call log type for missed calls.
29
+            public static final int MISSED_TYPE = 3;
30
+            */
31
+            jsonObject.put("type", type);
32
+            return  jsonObject;
33
+        } catch (JSONException e) {
34
+            Log.i("", e.getMessage());
35
+            return  null;
36
+        }
37
+    }
38
+}

+ 47
- 0
tianrunPlugins/app/src/main/java/com/coolape/tianrun/CallLogUtl.java View File

@@ -0,0 +1,47 @@
1
+package com.coolape.tianrun;
2
+
3
+import android.content.ContentResolver;
4
+import android.content.Context;
5
+import android.database.Cursor;
6
+import android.net.Uri;
7
+import android.provider.CallLog;
8
+
9
+import org.json.JSONArray;
10
+import org.json.JSONObject;
11
+import org.json.JSONException;
12
+
13
+import java.text.SimpleDateFormat;
14
+import java.util.ArrayList;
15
+import java.util.List;
16
+
17
+public class CallLogUtl {
18
+    public static List<CallLogInfo> getCallLog(Context context) {
19
+        List<CallLogInfo> infos = new ArrayList<CallLogInfo>();
20
+        ContentResolver cr = context.getContentResolver();
21
+        Uri uri = CallLog.Calls.CONTENT_URI;
22
+        String[] projection = new String[] { CallLog.Calls.NUMBER, CallLog.Calls.DATE,
23
+                CallLog.Calls.TYPE };
24
+
25
+        SimpleDateFormat format = new SimpleDateFormat(
26
+                "yyyy-MM-dd hh:mm:ss");
27
+        Cursor cursor = cr.query(uri, projection, null, null, null);
28
+        while (cursor.moveToNext()) {
29
+            String number = cursor.getString(0);
30
+            long date = cursor.getLong(1);
31
+            int type = cursor.getInt(2);
32
+            infos.add(new CallLogInfo(number, format.format(date), type));
33
+        }
34
+        cursor.close();
35
+        return infos;
36
+    }
37
+
38
+    public static String getCallLogJson(Context context) {
39
+        List<CallLogInfo> infos = getCallLog(context);
40
+
41
+        JSONArray array = new JSONArray();
42
+        for(int i=0; i < infos.size(); i++){
43
+            array.put(infos.get(i).toJson());
44
+        }
45
+        return  array.toString();
46
+    }
47
+}

+ 5
- 0
tianrunPlugins/app/src/main/java/com/coolape/tianrun/U3dPlugin.java View File

@@ -216,6 +216,11 @@ public class U3dPlugin {
216 216
 		return mediaPlayer.getProgress();
217 217
 	}
218 218
 
219
+	//取得记录记录
220
+	public String getCallLog() {
221
+		return CallLogUtl.getCallLogJson(UnityPlayer.currentActivity);
222
+	}
223
+
219 224
 	public static void UnitySendMessage(String CallbackFunc, String retCode,
220 225
 			String orgs) {
221 226
 		if (u3dListener.isEmpty()) {

Loading…
Cancel
Save