parse reject cmd and talk request resut.
authorTrillGates <williamtrillgates@gmail.com>
Sat, 20 Feb 2021 08:27:29 +0000 (16:27 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Sat, 20 Feb 2021 08:27:29 +0000 (16:27 +0800)
app/src/main/aidl/com/enqualcomm/support/IFZDCallback.aidl
app/src/main/aidl/com/enqualcomm/support/IFZDService.aidl
app/src/main/java/com/enqualcomm/support/CoreService.java
app/src/main/java/com/ic/protocols/protocol_fzd.java

index 14622ac..ea2b3f0 100644 (file)
@@ -2,10 +2,10 @@
 package com.enqualcomm.support;
 
 interface IFZDCallback {
-    void onCallRequest(in int type);
     void onContractsLoaded();
     void onBRIdLoaded(in String brId);
     void onFriendsAddResult(in boolean isSuccess);
-    void onCallRequestResult(in int result);
+    void onCallRequestResult(int result);
     void onBRIdEmpty();
+    void onRemoteReject(in String remoteUserId,in int type);
 }
\ No newline at end of file
index 6524529..f68b5cc 100644 (file)
@@ -9,8 +9,7 @@ interface IFZDService {
     void unregisterCallback(in IFZDCallback callback);
     void getContracts();
     void getBRId();
-    void makeFriends();
-    void rejectCallInCome();
+    void rejectCallInCome(in String remoteId,in int type);
     void requireCall(in int type,in String remoteUserId);
     void test();
     void setUpEnvState(in int state);
index 0f2176b..191dcf2 100644 (file)
@@ -1667,6 +1667,7 @@ public class CoreService extends Service {
             StringMessage cmdmMembers = protocol_fzd.MEMBERS();
             //获取佰锐ID
             Deliver.sendLocationMSG(cmdmMembers);
+            ICLogger.d("get contacts...");
         }
 
         @Override
@@ -1674,18 +1675,16 @@ public class CoreService extends Service {
             StringMessage cmdBREG = protocol_fzd.BRREG();
             //获取佰锐ID
             Deliver.sendLocationMSG(cmdBREG);
+            ICLogger.d("get bairui id..");
         }
 
-        @Override
-        public void makeFriends() {
-            //加朋友
-        }
 
         @Override
-        public void rejectCallInCome() {
+        public void rejectCallInCome(String remoteId, int type) {
             //拒绝来电
-//            protocol_fzd.RCALLING()
-//            Deliver.sendLocationMSG();
+            StringMessage rejectMsg = protocol_fzd.RCALLING(remoteId, type);
+            Deliver.sendLocationMSG(rejectMsg);
+            ICLogger.d("reject remote call request..." + remoteId + "..." + type);
         }
 
         @Override
@@ -1693,6 +1692,7 @@ public class CoreService extends Service {
             //请求与对方通话
             StringMessage talk = protocol_fzd.TALK(type, remoteUserId);
             Deliver.sendLocationMSG(talk);
+            ICLogger.d("require call == > type is " + type + " remote user id is == > " + remoteUserId);
         }
 
         @Override
index 2779a9b..996360f 100644 (file)
@@ -412,7 +412,7 @@ public class protocol_fzd {
      */
     public void handleSILENCETIME2(Connection connection, Runtime runtime, String cmd, String data) {
         connection.send(SILENCETIME2(runtime));
-        String[] silent_items = data.split(",");
+        String[] silent_items = data.split(CMDSPLIT);
         ArrayList<Silent> slist = new ArrayList<>();
         if (silent_items.length > 0) {
             for (String si : silent_items) {
@@ -944,7 +944,7 @@ public class protocol_fzd {
      * @param data
      */
     private void handleCallRequest(Connection mConnection, Runtime mRuntime, String data) {
-        String[] split = data.split(",");
+        String[] split = data.split(CMDSPLIT);
         if (split.length == 3) {
             needResponseCalling = true;
             //1、准备数据:对方的id,来电类型
@@ -985,7 +985,18 @@ public class protocol_fzd {
      * @param data
      */
     private void handleRTalk(Connection mConnection, Runtime mRuntime, String data) {
-        //TODO:
+        try {
+            IFZDCallback fzdCallback = mRuntime.getFZDCallback();
+            if (fzdCallback != null && !TextUtils.isEmpty(data)) {
+                ICLogger.d("data == > " + data);
+                String[] split = data.split(CMDSPLIT);
+                if (split.length == 3) {
+                    fzdCallback.onRemoteReject(split[0], Integer.parseInt(split[1]));
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
         //终端回复: [XT*设备 ID*LEN*RTALK]
         mConnection.send(genFZDCMD(cmdMap.get(CMD_TYPE.RTALK)));
     }
@@ -1000,11 +1011,7 @@ public class protocol_fzd {
      */
     public static StringMessage TALK(int type, String remoteAccount) {
         //准备数据
-        StringBuilder sb = new StringBuilder();
-        sb.append(type);
-        sb.append(",");
-        sb.append(remoteAccount);
-        String data = sb.toString();
+        String data = type + CMDSPLIT + remoteAccount;
         ICLogger.d("request talk == > " + data);
         return genFZDCMD(cmdMap.get(CMD_TYPE.MEMBERS), data);
     }
@@ -1021,7 +1028,7 @@ public class protocol_fzd {
      *
      * @return
      */
-    public static StringMessage RCALLING(String remoteUserId, String type) {
+    public static StringMessage RCALLING(String remoteUserId, int type) {
         StringBuilder sb = new StringBuilder();
         sb.append(remoteUserId);
         sb.append(",,");
@@ -1041,7 +1048,19 @@ public class protocol_fzd {
      */
     private void handlerTalkRequestResult(Runtime mRuntime, String data) {
         ICLogger.d("handlerTalkRequestResult == > " + data);
+        //可以正常通话,可以不处理
+        //如果不能正常通话,则要提示用户了
+        try {
 
+            IFZDCallback fzdCallback = mRuntime.getFZDCallback();
+            if (fzdCallback != null) {
+                int result = Integer.parseInt(data);
+                ICLogger.d("0 表示可正常通话,-1 表示余额不足,不能通话,1 表示对方不在线或未登陆成功 === > " + data);
+                fzdCallback.onCallRequestResult(result);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
     }
 
     /**
@@ -1068,6 +1087,7 @@ public class protocol_fzd {
             ICLogger.d("members data == > " + data);
             String s = Util.decodeUnicode2Utf8(data);
             ICLogger.d("members result == > " + s);
+            //TODO:
         }
     }