|
@@ -0,0 +1,719 @@
|
|
|
+package com.hh.bdface.ui;
|
|
|
+
|
|
|
+import android.annotation.SuppressLint;
|
|
|
+import android.app.AlertDialog;
|
|
|
+import android.app.Dialog;
|
|
|
+import android.content.Context;
|
|
|
+import android.content.DialogInterface;
|
|
|
+import android.content.Intent;
|
|
|
+import android.net.ConnectivityManager;
|
|
|
+import android.net.LinkProperties;
|
|
|
+import android.net.Network;
|
|
|
+import android.net.NetworkCapabilities;
|
|
|
+import android.net.NetworkRequest;
|
|
|
+import android.os.Handler;
|
|
|
+import android.view.View;
|
|
|
+import android.widget.ImageView;
|
|
|
+import android.widget.RelativeLayout;
|
|
|
+import android.widget.TextView;
|
|
|
+
|
|
|
+import com.baidu.idl.main.facesdk.FaceAuth;
|
|
|
+import com.baidu.idl.main.facesdk.callback.Callback;
|
|
|
+import com.baidu.idl.main.facesdk.identifylibrary.utils.FaceUtils;
|
|
|
+import com.blankj.utilcode.util.PathUtils;
|
|
|
+import com.common.lib_base.base.BaseActivity;
|
|
|
+import com.common.lib_base.common.async.ThreadPoolManager;
|
|
|
+import com.common.lib_base.utils.NetworkUtils;
|
|
|
+import com.common.lib_base.utils.StringUtils;
|
|
|
+import com.common.lib_base.utils.ui.UIUtils;
|
|
|
+import com.common.lib_base.view.dialog.MessageRoundBtnDialog;
|
|
|
+import com.example.datalibrary.api.FaceApi;
|
|
|
+import com.example.datalibrary.listener.DBLoadListener;
|
|
|
+import com.example.datalibrary.listener.SdkInitListener;
|
|
|
+import com.example.datalibrary.manager.FaceSDKManager;
|
|
|
+import com.example.datalibrary.model.User;
|
|
|
+import com.google.gson.Gson;
|
|
|
+import com.hh.bdface.R;
|
|
|
+import com.hh.bdface.bean.LocalConfigBean;
|
|
|
+import com.hh.bdface.bean.LogcatAddRequestBean;
|
|
|
+import com.hh.bdface.bean.SimpleResultBean;
|
|
|
+import com.hh.bdface.common.deviceui.F10DeviceUI;
|
|
|
+import com.hh.bdface.mvp.contract.LogcatAddContract;
|
|
|
+import com.hh.bdface.mvp.presenter.LogcatAddPresenter;
|
|
|
+import com.hh.bdface.utils.DeviceUtils;
|
|
|
+import com.hh.bdface.utils.log.AppLogUtils;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import static com.hh.bdface.common.Constants.Value.TOKEN;
|
|
|
+
|
|
|
+public class SplashActivity extends BaseActivity implements LogcatAddContract.View, View.OnClickListener {
|
|
|
+
|
|
|
+ private TextView tv_config_status;
|
|
|
+ private TextView tv_version;
|
|
|
+ private TextView tv_sn;
|
|
|
+ private TextView tv_hello;
|
|
|
+ private TextView tv_net_no;
|
|
|
+ private ImageView iv_net_wifi;
|
|
|
+ private ImageView iv_net_flow;
|
|
|
+ private ImageView iv_net_line;
|
|
|
+ private ImageView iv_setting;
|
|
|
+ private RelativeLayout item_top;
|
|
|
+ private TextView tv_accredit_deviceTv;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int setLayout() {
|
|
|
+ return R.layout.activity_splash;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initView() {
|
|
|
+
|
|
|
+ tv_config_status = findViewById(R.id.tv_config_status);
|
|
|
+ tv_version = findViewById(R.id.tv_version);
|
|
|
+ tv_sn = findViewById(R.id.tv_sn);
|
|
|
+ tv_hello = findViewById(R.id.tv_hello);
|
|
|
+ tv_net_no = findViewById(R.id.tv_net_no);
|
|
|
+ iv_net_wifi = findViewById(R.id.iv_net_wifi);
|
|
|
+ iv_net_flow = findViewById(R.id.iv_net_flow);
|
|
|
+ iv_net_line = findViewById(R.id.iv_net_line);
|
|
|
+ iv_setting = findViewById(R.id.iv_setting);
|
|
|
+ tv_hello.setOnClickListener(this);
|
|
|
+ tv_net_no.setOnClickListener(this);
|
|
|
+ item_top = findViewById(R.id.item_top);
|
|
|
+ tv_accredit_deviceTv = findViewById(R.id.tv_accredit_deviceTv);
|
|
|
+ }
|
|
|
+
|
|
|
+ LogcatAddPresenter mLogcatAddPresenter;
|
|
|
+
|
|
|
+ String deviceSN;
|
|
|
+ String appVersionName;
|
|
|
+
|
|
|
+ F10DeviceUI deviceUI;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initData() {
|
|
|
+
|
|
|
+ mContext = this;
|
|
|
+
|
|
|
+ deviceSN = DeviceUtils.getDeviceSN();
|
|
|
+ appVersionName = DeviceUtils.getAppVersionName(mContext);
|
|
|
+
|
|
|
+
|
|
|
+ // 版本号和sn
|
|
|
+ tv_version.setText("版本号:" + DeviceUtils.getAppVersionName(this));
|
|
|
+ tv_sn.setText("SN号:" + deviceSN);
|
|
|
+
|
|
|
+
|
|
|
+ deviceUI = F10DeviceUI.getInstance();
|
|
|
+
|
|
|
+ initNet();
|
|
|
+
|
|
|
+ faceAuth = new FaceAuth();
|
|
|
+
|
|
|
+ mLogcatAddPresenter = new LogcatAddPresenter(this);
|
|
|
+
|
|
|
+// initBaiduLicense();
|
|
|
+
|
|
|
+
|
|
|
+ // 设备指纹
|
|
|
+ String deviceId = faceAuth.getDeviceId(mContext);
|
|
|
+ tv_accredit_deviceTv.setText("设备指纹:"+deviceId);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void initListener() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ Handler mHandler = new Handler();
|
|
|
+ Gson gson = new Gson();
|
|
|
+
|
|
|
+ private void initBaiduLicense() {
|
|
|
+
|
|
|
+ //获取外存路径
|
|
|
+// LocalConfigBean localConfigBean = getLocalConfigData();
|
|
|
+// if (localConfigBean != null) {
|
|
|
+// String baiduFaceOnlineCode = localConfigBean.getBaiduFaceOnlineCode();
|
|
|
+// startLicenseBaiduFace(baiduFaceOnlineCode);
|
|
|
+// } else {
|
|
|
+// // 有误,开始弹窗
|
|
|
+// showErrorDailog();
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+ FaceSDKManager.getInstance().init(mContext, new SdkInitListener() {
|
|
|
+ @Override
|
|
|
+ public void initStart() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void initLicenseSuccess() {
|
|
|
+ // 已激活成功
|
|
|
+ AppLogUtils.e("initLicenseSuccess已激活成功");
|
|
|
+
|
|
|
+
|
|
|
+ // 日志
|
|
|
+ LogcatAddRequestBean bean = new LogcatAddRequestBean();
|
|
|
+ bean.setLogContent("已激活,进入识别MainActivity");
|
|
|
+ bean.setLogTag("百度人脸 " + appVersionName);
|
|
|
+ bean.setLogType("logcat");
|
|
|
+ requestLogcatAdd(bean);
|
|
|
+
|
|
|
+
|
|
|
+ mHandler.postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ startActivity(MainActivity.class);
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+ }, delayTime);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void initLicenseFail(int errorCode, String msg) {
|
|
|
+ // 激活失败,或未激活
|
|
|
+ // 开始激活
|
|
|
+
|
|
|
+ // 日志
|
|
|
+ LogcatAddRequestBean bean = new LogcatAddRequestBean();
|
|
|
+ bean.setLogContent("未激活,开始激活");
|
|
|
+ bean.setLogTag("百度人脸 " + appVersionName);
|
|
|
+ bean.setLogType("logcat");
|
|
|
+ requestLogcatAdd(bean);
|
|
|
+
|
|
|
+
|
|
|
+ //获取外存路径
|
|
|
+ LocalConfigBean localConfigBean = getLocalConfigData();
|
|
|
+ if (localConfigBean != null) {
|
|
|
+ String baiduFaceOnlineCode = localConfigBean.getBaiduFaceOnlineCode();
|
|
|
+ startLicenseBaiduFace(baiduFaceOnlineCode);
|
|
|
+ } else {
|
|
|
+ // 有误,开始弹窗
|
|
|
+ showErrorDailog();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void initModelSuccess() {
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void initModelFail(int errorCode, String msg) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showErrorDailog() {
|
|
|
+
|
|
|
+ // 未找到授权码,请联系厂商进行授权
|
|
|
+
|
|
|
+ MessageRoundBtnDialog.Builder builder = new MessageRoundBtnDialog.Builder(mContext);
|
|
|
+ builder.setTitle("温馨提示")
|
|
|
+ .setMessage("未找到授权码,请联系厂商进行授权")
|
|
|
+ .setRightButton("确定")
|
|
|
+ .setOnClickLisener(new MessageRoundBtnDialog.onDialogClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onRightClick(Dialog dialog) {
|
|
|
+ super.onRightClick(dialog);
|
|
|
+ }
|
|
|
+ }).build().show();
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private LocalConfigBean getLocalConfigData() {
|
|
|
+
|
|
|
+ String externalStoragePath = PathUtils.getExternalAppFilesPath();// /storage/emulated/0/Android/data/com.hh.bdface/files
|
|
|
+ // app目录
|
|
|
+// String jsonStr = readJsonFile(externalStoragePath + "/config.json");
|
|
|
+ // Android下目录,会被清除掉
|
|
|
+// String jsonStr = readJsonFile("/storage/emulated/0/Android/config.json");
|
|
|
+ // 根目录
|
|
|
+ String jsonStr = readJsonFile("/storage/emulated/0/config.json");
|
|
|
+
|
|
|
+ AppLogUtils.e("jsonStr:"+jsonStr);
|
|
|
+
|
|
|
+ LocalConfigBean localConfigBean = gson.fromJson(jsonStr, LocalConfigBean.class);
|
|
|
+
|
|
|
+
|
|
|
+ // 日志
|
|
|
+ LogcatAddRequestBean bean = new LogcatAddRequestBean();
|
|
|
+ bean.setLogContent("本地json:" + jsonStr);
|
|
|
+ bean.setLogTag("百度人脸 " + appVersionName);
|
|
|
+ bean.setLogType("logcat");
|
|
|
+ requestLogcatAdd(bean);
|
|
|
+
|
|
|
+ return localConfigBean;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 方法名:readJsonFile(String filePath)
|
|
|
+ * 功 能:从本地读取json
|
|
|
+ * 参 数:String filePath
|
|
|
+ * 返回值:String
|
|
|
+ */
|
|
|
+ public static String readJsonFile(String filePath) {
|
|
|
+
|
|
|
+ AppLogUtils.e("filePath:"+filePath);
|
|
|
+
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ try {
|
|
|
+ File file = new File(filePath);
|
|
|
+ InputStream in = null;
|
|
|
+ in = new FileInputStream(file);
|
|
|
+ int tempbyte;
|
|
|
+ while ((tempbyte = in.read()) != -1) {
|
|
|
+ sb.append((char) tempbyte);
|
|
|
+ }
|
|
|
+ in.close();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 百度
|
|
|
+ FaceAuth faceAuth;
|
|
|
+
|
|
|
+ // 测试激活码-----------begin
|
|
|
+ // X3
|
|
|
+ // String baiduAuthCode = "FXCL-QGQD-9VGX-XMRG";
|
|
|
+ // F10-836
|
|
|
+ String baiduAuthCode = "3JEM-ZULP-TKXN-DV5X";
|
|
|
+ // 清真寺——现场使用的
|
|
|
+// String baiduAuthCode = "WJRR-ZPM3-XAMJ-RGKT";
|
|
|
+ // X1 ZP2415000036
|
|
|
+// String baiduAuthCode = "VRMD-XBLJ-SZBX-GPXW";
|
|
|
+// String baiduAuthCode = "C6XZ-QDX3-MDXX-A2HK";
|
|
|
+ // 测试激活码-----------end
|
|
|
+
|
|
|
+
|
|
|
+ // 正式激活码---------begin
|
|
|
+ // F10-400406
|
|
|
+// String baiduAuthCode = "KRKX-Y4MS-UNXK-ZTNL";
|
|
|
+ //
|
|
|
+// String baiduAuthCode = "XX27-CTMS-BZF2-LPFW";
|
|
|
+ // 清真寺——现场使用的
|
|
|
+// String baiduAuthCode = "XLXT-PXXW-NG2L-X2ZV";
|
|
|
+ // 正式激活码---------end
|
|
|
+
|
|
|
+
|
|
|
+ private void startLicenseBaiduFace(String baiduFaceOnlineCode) {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ faceAuth.initLicenseOnLine(mContext, baiduFaceOnlineCode, new Callback() {
|
|
|
+ @Override
|
|
|
+ public void onResponse(final int code, final String response) {
|
|
|
+ if (code == 0) {
|
|
|
+ AppLogUtils.e("BaiduFace激活成功");
|
|
|
+
|
|
|
+
|
|
|
+ // 日志
|
|
|
+ LogcatAddRequestBean bean = new LogcatAddRequestBean();
|
|
|
+ bean.setLogContent("BaiduFace激活成功");
|
|
|
+ bean.setLogTag("百度人脸 " + appVersionName);
|
|
|
+ bean.setLogType("logcat");
|
|
|
+ requestLogcatAdd(bean);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ mHandler.postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ startActivity(MainActivity.class);
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+ }, delayTime);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ } else {
|
|
|
+ AppLogUtils.e("BaiduFace激活失败");
|
|
|
+
|
|
|
+ // 配置状态
|
|
|
+ setConfigStatusText("Face激活失败,请联系厂商检查激活码是否匹配");
|
|
|
+
|
|
|
+ // 日志
|
|
|
+ LogcatAddRequestBean bean = new LogcatAddRequestBean();
|
|
|
+ bean.setLogContent("BaiduFace激活失败,请联系厂商检查激活码是否匹配");
|
|
|
+ bean.setLogTag("百度人脸 " + appVersionName);
|
|
|
+ bean.setLogType("logcat");
|
|
|
+ requestLogcatAdd(bean);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ int delayTime = 3000;
|
|
|
+
|
|
|
+ private void initBaiduFaceListener() {
|
|
|
+ if (FaceSDKManager.initStatus != FaceSDKManager.SDK_MODEL_LOAD_SUCCESS) {
|
|
|
+ FaceSDKManager.getInstance().initModel(mContext,
|
|
|
+ FaceUtils.getInstance().getBDFaceSDKConfig(), new SdkInitListener() {
|
|
|
+ @Override
|
|
|
+ public void initStart() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void initLicenseSuccess() {
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void initLicenseFail(int errorCode, String msg) {
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void initModelSuccess() {
|
|
|
+ FaceSDKManager.initModelSuccess = true;
|
|
|
+
|
|
|
+ AppLogUtils.e("百度人脸模型加载成功,欢迎使用");
|
|
|
+
|
|
|
+ // 日志
|
|
|
+ LogcatAddRequestBean bean = new LogcatAddRequestBean();
|
|
|
+ bean.setLogContent("百度人脸模型加载成功,欢迎使用");
|
|
|
+ bean.setLogTag("百度人脸 " + appVersionName);
|
|
|
+ bean.setLogType("logcat");
|
|
|
+ requestLogcatAdd(bean);
|
|
|
+
|
|
|
+
|
|
|
+ mHandler.postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ startActivity(MainActivity.class);
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+ },delayTime);
|
|
|
+
|
|
|
+
|
|
|
+// initBaiduFaceListener();
|
|
|
+
|
|
|
+// runOnUiThread(new Runnable() {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// // 创建人脸预览界面
|
|
|
+// createBaiduFaceWindowManager(mContext);
|
|
|
+// }
|
|
|
+// });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void initModelFail(int errorCode, String msg) {
|
|
|
+ FaceSDKManager.initModelSuccess = false;
|
|
|
+ if (errorCode != -12) {
|
|
|
+
|
|
|
+ // 配置状态
|
|
|
+ setConfigStatusText("人脸模型加载失败,请尝试重启应用");
|
|
|
+
|
|
|
+ // 日志
|
|
|
+ LogcatAddRequestBean bean = new LogcatAddRequestBean();
|
|
|
+ bean.setLogContent("百度人脸模型加载失败,请尝试重启应用");
|
|
|
+ bean.setLogTag("百度人脸 " + appVersionName);
|
|
|
+ bean.setLogType("logcat");
|
|
|
+ requestLogcatAdd(bean);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void dbBaiduFaceInit() {
|
|
|
+ AppLogUtils.e("dbBaiduFaceInit");
|
|
|
+
|
|
|
+ FaceApi.getInstance().init(new DBLoadListener() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onStart(int successCount) {
|
|
|
+ AppLogUtils.e("BaiduFace--onStart");
|
|
|
+// if (successCount < 5000 && successCount != 0){
|
|
|
+//
|
|
|
+// runOnUiThread(new Runnable() {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// loadProgress(10);
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onLoad(final int finishCount, final int successCount, final float progress) {
|
|
|
+// AppLogUtils.e(false,tag_baidu,"onLoad");
|
|
|
+// if (successCount > 5000 || successCount == 0) {
|
|
|
+// runOnUiThread(new Runnable() {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// progressBar.setProgress((int) (progress * 100));
|
|
|
+// progressText.setText(((int) (progress * 100)) + "%");
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onComplete(final List<User> users, final int successCount) {
|
|
|
+ AppLogUtils.e("BaiduFace--onComplete");
|
|
|
+// FileUtils.saveDBList(HomeActivity.this, users);
|
|
|
+// runOnUiThread(new Runnable() {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// FaceApi.getInstance().setUsers(users);
|
|
|
+// if (successCount > 5000 || successCount == 0) {
|
|
|
+// progressGroup.setVisibility(View.GONE);
|
|
|
+// isDBLoad = true;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// });
|
|
|
+
|
|
|
+
|
|
|
+ for (User user : users) {
|
|
|
+ AppLogUtils.e("百度user--" + user.getId() + " " + user.getUserName() + " " + new String(user.getFeature()));
|
|
|
+ }
|
|
|
+
|
|
|
+ AppLogUtils.e("百度successCount--" + successCount);
|
|
|
+
|
|
|
+ FaceApi.getInstance().setUsers(users);
|
|
|
+ FaceSDKManager.getInstance().initDataBases(mContext);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(final int finishCount, final int successCount, final List<User> users) {
|
|
|
+
|
|
|
+ AppLogUtils.e("百度onFail--1");
|
|
|
+// runOnUiThread(new Runnable() {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// FaceApi.getInstance().setUsers(users);
|
|
|
+// progressGroup.setVisibility(View.GONE);
|
|
|
+// ToastUtils.toast(HomeActivity.this,
|
|
|
+// "人脸库加载失败,共" + successCount + "条数据, 已加载" + finishCount + "条数据");
|
|
|
+// isDBLoad = true;
|
|
|
+// }
|
|
|
+// });
|
|
|
+
|
|
|
+ FaceApi.getInstance().setUsers(users);
|
|
|
+ FaceSDKManager.getInstance().initDataBases(mContext);
|
|
|
+
|
|
|
+ AppLogUtils.e("百度onFail--2");
|
|
|
+
|
|
|
+ }
|
|
|
+ }, mContext);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void setConfigStatusText(String text) {
|
|
|
+ runOnUiThread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ UIUtils.setText(tv_config_status, text);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 在线日志
|
|
|
+ public void requestLogcatAdd(LogcatAddRequestBean bean) {
|
|
|
+
|
|
|
+ if (mLogcatAddPresenter == null) {
|
|
|
+ mLogcatAddPresenter = new LogcatAddPresenter(this);
|
|
|
+ }
|
|
|
+
|
|
|
+ bean.setToken(TOKEN);
|
|
|
+ bean.setSn(DeviceUtils.getDeviceSN());
|
|
|
+
|
|
|
+// if (isNetAvailable) {
|
|
|
+ mLogcatAddPresenter.requestLogcatAdd(bean);
|
|
|
+// }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void showLogcatAddResult(SimpleResultBean resultBean) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void showLoading() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void dismissLoading() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void showError(String msg) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void showError(String url, String msg) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ boolean isNetAvailable;
|
|
|
+
|
|
|
+
|
|
|
+ private ConnectivityManager.NetworkCallback networkCallback;
|
|
|
+ private ConnectivityManager connectivityManager;
|
|
|
+
|
|
|
+ @SuppressLint("MissingPermission")
|
|
|
+ public void initNet() {
|
|
|
+ networkCallback = new NetworkCallbackImpl();
|
|
|
+ NetworkRequest.Builder builder = new NetworkRequest.Builder();
|
|
|
+ NetworkRequest request = builder.build();
|
|
|
+ connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
|
+ connectivityManager.registerNetworkCallback(request, networkCallback);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(View var1) {
|
|
|
+ switch (var1.getId()) {
|
|
|
+ case R.id.tv_hello:
|
|
|
+
|
|
|
+ if (!isShowNavi) {
|
|
|
+ deviceUI.showNavigationBar(mActivity);
|
|
|
+ deviceUI.showNotification(mActivity);
|
|
|
+
|
|
|
+ isShowNavi = true;
|
|
|
+ } else {
|
|
|
+ deviceUI.hideNotification(mActivity);
|
|
|
+ deviceUI.hideNavigationBar(mActivity);
|
|
|
+
|
|
|
+ isShowNavi = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ case R.id.tv_net_no:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ boolean isShowNavi;
|
|
|
+
|
|
|
+
|
|
|
+ private class NetworkCallbackImpl extends ConnectivityManager.NetworkCallback {
|
|
|
+ @Override
|
|
|
+ public void onAvailable(Network network) {
|
|
|
+ super.onAvailable(network);
|
|
|
+ //
|
|
|
+ AppLogUtils.e("网络--连接--onAvailable");
|
|
|
+
|
|
|
+ isNetAvailable = true;
|
|
|
+
|
|
|
+
|
|
|
+ initBaiduLicense();
|
|
|
+
|
|
|
+// try {
|
|
|
+
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+//
|
|
|
+// AppLogUtils.e(e.toString());
|
|
|
+//
|
|
|
+// // 日志
|
|
|
+// LogcatAddRequestBean bean = new LogcatAddRequestBean();
|
|
|
+// bean.setLogContent("initBaiduLicense--Exception:"+e.toString());
|
|
|
+// bean.setLogTag("百度人脸 " + appVersionName);
|
|
|
+// bean.setLogType("error");
|
|
|
+// requestLogcatAdd(bean);
|
|
|
+//
|
|
|
+// setConfigStatusText("百度人脸--未授权设备,请完成激活。具体信息"+e.toString());
|
|
|
+//
|
|
|
+// }
|
|
|
+
|
|
|
+ getNetType();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onLosing(Network network, int maxMsToLive) {
|
|
|
+ super.onLosing(network, maxMsToLive);
|
|
|
+ AppLogUtils.e("网络--onLosing");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onLost(Network network) {
|
|
|
+ super.onLost(network);
|
|
|
+ AppLogUtils.e("网络--断开--onLost");
|
|
|
+
|
|
|
+ isNetAvailable = false;
|
|
|
+
|
|
|
+ getNetType();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onCapabilitiesChanged(Network network, NetworkCapabilities networkCapabilities) {
|
|
|
+ super.onCapabilitiesChanged(network, networkCapabilities);
|
|
|
+ AppLogUtils.i("网络-onCapabilitiesChanged");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onLinkPropertiesChanged(Network network, LinkProperties linkProperties) {
|
|
|
+ super.onLinkPropertiesChanged(network, linkProperties);
|
|
|
+ AppLogUtils.i("网络-onLinkPropertiesChanged");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String netType;
|
|
|
+
|
|
|
+ private void getNetType() {
|
|
|
+
|
|
|
+ runOnUiThread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+
|
|
|
+
|
|
|
+ boolean isNetworkAvaiable = NetworkUtils.isNetworkAvaiable(getApplicationContext());
|
|
|
+ if (isNetworkAvaiable) {
|
|
|
+
|
|
|
+ netType = NetworkUtils.getNetType(getApplicationContext());
|
|
|
+
|
|
|
+ AppLogUtils.e("netType--" + netType);
|
|
|
+
|
|
|
+ setConfigStatusText("有网络");
|
|
|
+
|
|
|
+
|
|
|
+ } else {
|
|
|
+ setConfigStatusText("无网络");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|