| | |
| | | import android.os.AsyncTask; |
| | | import android.os.Bundle; |
| | | |
| | | import android.text.TextUtils; |
| | | import android.util.Log; |
| | | import android.widget.Toast; |
| | | |
| | |
| | | import com.anyun.exam.lib.AYSdk; |
| | | import com.anyun.exam.lib.MyLog; |
| | | import com.anyun.exam.lib.util.ByteUtil; |
| | | import com.anyun.im_lib.listener.IMSConnectStatusCallback; |
| | | import com.google.gson.Gson; |
| | | import com.safeluck.aykj.utils.BytesUtils; |
| | | |
| | | import org.json.JSONException; |
| | | import org.json.JSONObject; |
| | |
| | | import java.util.List; |
| | | import java.util.concurrent.ArrayBlockingQueue; |
| | | |
| | | import safeluck.drive.evaluation.im.IMSClientBootstrap; |
| | | import safeluck.drive.evaluation.im.MessageProcessor; |
| | | import safeluck.drive.evaluation.platformMessage.JKMessage0100; |
| | | import safeluck.drive.evaluation.platformMessage.JKMessage0101; |
| | | import safeluck.drive.evaluation.util.CThreadPoolExecutor; |
| | | import safeluck.drive.evaluation.util.FileUtil; |
| | | import safeluck.drive.evaluation.util.PermissionManager; |
| | | import safeluck.drive.evaluation.util.SPUtils; |
| | | import safeluck.drive.evaluation.viewmodels.MainViewModel; |
| | | import safeluck.drive.evaluation.viewmodels.RTKConnAndLogin; |
| | | import safeluck.drive.evaluation.viewmodels.RTKConnAndLoginViewModel; |
| | | |
| | | public class MainActivity extends SupportActivity { |
| | | public class MainActivity extends SupportActivity implements IMSConnectStatusCallback { |
| | | |
| | | private static final int PERMISSIONS_REQUEST_CODE = 1001; |
| | | private String TAG = MainActivity.class.getCanonicalName(); |
| | |
| | | String[] PERMISSIONS = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA}; |
| | | RTKConfigViewModel rtkConfigViewModel; |
| | | private boolean onlySendOnceRTKConfig = true; |
| | | |
| | | |
| | | private ICEventListener icEventListener = new ICEventListener() { |
| | | @Override |
| | |
| | | //全屏 |
| | | |
| | | setContentView(R.layout.activity_main); |
| | | // TODO |
| | | // 进行tcp连接 |
| | | String userId = "100002"; |
| | | String token = "token_" + userId; |
| | | String hosts = "[{\"host\":\"192.168.31.77\", \"port\":12125}]"; |
| | | IMSClientBootstrap.getInstance().init(userId,token,hosts,1,this); |
| | | |
| | | WokViewModel wokViewModel = ViewModelProviders.of(this).get(WokViewModel.class); |
| | | wokViewModel.getStudents().observe(this, new Observer<List<Student>>() { |
| | |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public void onConnecting() { |
| | | MyLog.i(TAG,"TCP onConnecting"); |
| | | } |
| | | |
| | | @Override |
| | | public void onConnected() { |
| | | MyLog.i(TAG,"TCP连接成功"); |
| | | //TODO 判断SPUtils 是否保存有des密码;如果没有则进行注册JKMessage0100,如果有密码则进行鉴权JKMessage0101 |
| | | String hexPwd = (String) SPUtils.get(this,SPUtils.DES_HEX_PWD,""); |
| | | MessageProcessor.getInstance().addBeatHeart(10); |
| | | if (TextUtils.isEmpty(hexPwd)){ |
| | | |
| | | JKMessage0100 jkRegisterMessage = new JKMessage0100(); |
| | | jkRegisterMessage.proviceid = 23; |
| | | jkRegisterMessage.cityid = 1; |
| | | jkRegisterMessage.imei = "460123874561"; |
| | | jkRegisterMessage.model = "123"; |
| | | jkRegisterMessage.sn = "0314200100000004"; |
| | | |
| | | Log.i(TAG, "onClick: msg len "+jkRegisterMessage.getMessageLen()+" "+ jkRegisterMessage.props.value); |
| | | byte[] str = jkRegisterMessage.toBytes(); |
| | | MessageProcessor.getInstance().sendMessage(jkRegisterMessage); |
| | | Log.i(TAG, "onClick: "+ BytesUtils.bytesToHexString(str)+" ============"); |
| | | }else{ |
| | | JKMessage0101 jkMessage0101 = new JKMessage0101(); |
| | | jkMessage0101.des =hexPwd; |
| | | jkMessage0101.timestamp = (int) System.currentTimeMillis(); |
| | | MessageProcessor.getInstance().sendMessage(jkMessage0101); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onConnectFailed() { |
| | | MyLog.i(TAG,"TCP连接失败"); |
| | | } |
| | | |
| | | } |