completed on calling income handler.
authorTrillGates <williamtrillgates@gmail.com>
Sat, 20 Feb 2021 07:37:28 +0000 (15:37 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Sat, 20 Feb 2021 07:37:28 +0000 (15:37 +0800)
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/protocolAPIHelper.java
app/src/main/java/com/ic/protocols/protocol_fzd.java

index 1409d0f..6524529 100644 (file)
@@ -13,4 +13,5 @@ interface IFZDService {
     void rejectCallInCome();
     void requireCall(in int type,in String remoteUserId);
     void test();
+    void setUpEnvState(in int state);
 }
\ No newline at end of file
index ae557ac..0f2176b 100644 (file)
@@ -1702,6 +1702,14 @@ public class CoreService extends Service {
             //获取佰锐ID
             Deliver.sendLocationMSG(MEMBERS);
         }
+
+        @Override
+        public void setUpEnvState(int state) {
+            if (protocolAPIHelper.getProtocolfzd_handler() != null) {
+                ICLogger.d("update bairui env state..." + state);
+                protocolAPIHelper.getProtocolfzd_handler().updateEnvState(state);
+            }
+        }
     };
 
 }
index ab7c25f..590018d 100644 (file)
@@ -18,6 +18,10 @@ public class protocolAPIHelper {
     private static protocol_fzd protocolfzd_handler = null;
     private static protocol_mqtt protocolmqtt_handler = null;
 
+    public static protocol_fzd getProtocolfzd_handler() {
+        return protocolfzd_handler;
+    }
+
     public protocolAPIHelper(Connection connect, Runtime runtime) {
         ICLogger.i("init Protocol " + Config.getProtocolNumber());
         if (protocolbeehome_handler == null)
index d8018df..2779a9b 100644 (file)
@@ -916,6 +916,21 @@ public class protocol_fzd {
         }
     }
 
+    private static final String STATE_ENV = "env_state";
+
+    private boolean needResponseCalling = false;
+
+
+    public void updateEnvState(int state) {
+        if (needResponseCalling) {
+            //通知后台现在的装填
+            ICLogger.d("send cmd calling and state is == > " + state);
+            mConnection.send(genFZDCMD(cmdMap.get(CMD_TYPE.CALLING), String.valueOf(state)));
+            needResponseCalling = false;
+        }
+        sharedPreferences.edit().putInt(STATE_ENV, state).apply();
+    }
+
     /**
      * 有通话请求
      * 注:终端一旦收到该请求,则需要确保音视频 sdk 处于连接状态的,如果未登陆,要登陆后回复服 务端,
@@ -929,9 +944,33 @@ public class protocol_fzd {
      * @param data
      */
     private void handleCallRequest(Connection mConnection, Runtime mRuntime, String data) {
-        //TODO:
-        //需要回复平台结果
-
+        String[] split = data.split(",");
+        if (split.length == 3) {
+            needResponseCalling = true;
+            //1、准备数据:对方的id,来电类型
+            String remoteId = split[0];
+            String type = split[2];
+            ICLogger.d("remote id is == > " + remoteId);
+            ICLogger.d("type is == > " + type);
+            //2、拉起来电界面
+            Intent intent = new Intent();
+            intent.setAction("com.ic.action.VIDEO_CALL");
+            intent.addCategory(Intent.CATEGORY_DEFAULT);
+            intent.putExtra("remoteId", remoteId);
+            intent.putExtra("type", type);
+            //3、来电界面去查询这个用户是谁
+            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+            mRuntime.getContextProxy().context.startActivity(intent);
+            //4、环境是否有准备好
+            int envState = sharedPreferences.getInt(STATE_ENV, -1);
+            //5、需要回复平台结果
+            if (envState == 0) {
+                mConnection.send(genFZDCMD(cmdMap.get(CMD_TYPE.CALLING), "0"));
+                needResponseCalling = false;
+            }
+            //否则由设置的地方去通知后台
+            //needResponseCalling来判断
+        }
     }
 
     /**