JLChen
2021-08-20 1b11947cc15245ae005a7cc8cc2f93c5660b0c23
HDLLinphoneSDKDemoNew/app/src/main/java/com/example/hdllinphonesdkdemo/MainActivity.java
@@ -13,8 +13,9 @@
import com.hdl.hdllinphonesdk.HDLLinphoneKit;
import com.hdl.hdllinphonesdk.activity.HDLLinphoneMonitorActivity;
import com.hdl.hdllinphonesdk.callback.OnHDLLinphoneCallListener;
import com.hdl.hdllinphonesdk.core.EasyLinphone;
//import com.hdl.hdllinphonesdk.core.EasyLinphone;
import com.hdl.hdllinphonesdk.core.service.HDLLinphoneService;
import com.hdl.hdllinphonesdk.utils.HDLLog;
import org.linphone.core.Address;
import org.linphone.core.Call;
@@ -25,7 +26,7 @@
public class MainActivity extends Activity {
    private static final String TAG = "MainActivity";
    private TextView mTextView,mTextView2,mTextView3;
    private TextView mTextView,mTextView2,mTextView3,mTextView4;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
@@ -34,7 +35,7 @@
        mTextView = findViewById(R.id.tv_hello);
        mTextView2 = findViewById(R.id.mTextView2);
        mTextView3 = findViewById(R.id.mTextView3);
        mTextView4 = findViewById(R.id.mTextView4);
        mTextView.setOnClickListener(new View.OnClickListener() {
            @Override
@@ -49,20 +50,39 @@
//                HDLLinphoneKit.getInstance().setAccountAndLogin("61723164995710", "8ec02ce0", "sipproxy.ucpaas.com:25060");
//                HDLLinphoneKit.getInstance().setAccountAndLogin("5555", "85521566", "116.62.26.215:5060");
//                HDLLinphoneKit.getInstance().setAccountAndLogin("5555", "85521566", "test-gz.hdlcontrol.com:5060");
//                HDLLinphoneKit.getInstance().setAccountAndLogin("6666", "85521566", "test-gz.hdlcontrol.com:5060");
                HDLLinphoneKit.getInstance().setAccountAndLogin("7777", "85521566", "test-gz.hdlcontrol.com:5060");
//
//                HDLLinphoneKit.getInstance().setAccountAndLogin("8888", "85521566", "test-gz.hdlcontrol.com:5060");
//
//                HDLLinphoneKit.getInstance().setAccountAndLogin("4444", "85521566", "test-gz.hdlcontrol.com:5060");
            }
        });
        mTextView4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                clearProxyConfig();
                HDLLinphoneKit.getInstance().setAccountAndLogin("5555", "85521566", "test-gz.hdlcontrol.com:5060");
            }
        });
        mTextView2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                logoutLog();
//                return;
//                HDLLinphoneKit.getInstance().callTo("61723164995779",true);
//                HDLcallTo("61723164995779",true);
                HDLcallTo("1427186301744910338",true);
                HDLLinphoneKit.getInstance().callTo("1427186301744910338",true);
                startActivity(HDLLinphoneMonitorActivity.class);
            }
        });
@@ -74,48 +94,64 @@
        });
        HDLLinphoneKit.getInstance().initLinphone(this);
        HDLLinphoneKit.getInstance().setAutoJumpCallView(true);
        setOnHDLLinphoneCallListener();
    }
    /**
     * 退出清空账号
     * enableRegister false
     */
    public void logout() {
        try {
            Core core = HDLLinphoneService.getCore();
            ProxyConfig[] configs = core.getProxyConfigList();
            for (ProxyConfig config : configs) {
                if (config != null) {
                    config.edit();
                    config.enableRegister(false);
                    config.done();
            if (core != null) {
                ProxyConfig[] configs = core.getProxyConfigList();
                for (ProxyConfig config : configs) {
                    if (config != null) {
                        config.edit();
                        config.enableRegister(false);
                        config.done();
                    }
                }
//                core.clearAllAuthInfo();//清除所有认证信息。
//                core.clearProxyConfig();//从配置中删除所有代理。
            }
//            core.clearAllAuthInfo();
//            core.clearProxyConfig();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public Call HDLcallTo(String userName, boolean isVideoCall) {
        Call call = null;
    public void clearProxyConfig() {
        Core core = HDLLinphoneService.getCore();
        Address addressToCall = core.interpretUrl(userName);
        CallParams params = core.createCallParams(null);
        if (isVideoCall) {
            params.enableVideo(true);
            params.enableLowBandwidth(false);
        } else {
            params.enableVideo(false);
        if (core != null) {
            core.setDefaultProxyConfig(null);
            core.clearAllAuthInfo();
            core.clearProxyConfig();
//            core.refreshRegisters();//强制在下一次迭代时启动注册刷新
//            core.ensureRegistered();
        }
        if (addressToCall != null) {
            call = core.inviteAddressWithParams(addressToCall, params);
        }
        return call;
    }
    public void logoutLog() {
        try {
            Core core = HDLLinphoneService.getCore();
            ProxyConfig[] configs = core.getProxyConfigList();
            if(configs != null) {
                HDLLog.E("registrationState账户length" + configs.length);
            }
            for (ProxyConfig config : configs) {
                HDLLog.E("registrationState账户"+config.getIdentityAddress().getUsername());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    boolean openSuccess;
    void setOnHDLLinphoneCallListener(){
@@ -156,7 +192,12 @@
            public void onScreenshotSuccessfulAction(Bitmap image) {
                showToast("截图");
            }
        });
           @Override
           public void onIncomingCall(String s) {
           }
       });
    }
    /**