|
@@ -25,12 +25,13 @@ import com.hh.lib_base.utils.device.DeviceUtils;
|
|
|
import com.hh.lib_device.bean.action.AmpeDeviceConfigResultBean;
|
|
|
import com.hh.lib_device.bean.action.AmpeDeviceConfigBean;
|
|
|
import com.hh.lib_device.bean.action.AmpeDeviceInfoResultBean;
|
|
|
-import com.hh.lib_device.bean.action.AmpeDeviceSaveFileConfigBean;
|
|
|
+import com.hh.lib_device.bean.action.AmpeRequestDownloadFileBean;
|
|
|
import com.hh.lib_device.bean.action.AmpeRequestFloatingBackBean;
|
|
|
+import com.hh.lib_device.bean.action.AmpeResultDownloadFileBean;
|
|
|
+import com.hh.lib_device.bean.download.AmpeDownloadFileEvent;
|
|
|
import com.hh.lib_device.deviceui.BaseDeviceUI;
|
|
|
import com.hh.lib_device.deviceui.IDeviceUI;
|
|
|
import com.hh.lib_device.utils.DownloadFileUtils;
|
|
|
-import com.hh.lib_device.utils.FileSaver;
|
|
|
import com.hh.lib_device.view.TouchBackView;
|
|
|
|
|
|
|
|
@@ -69,14 +70,17 @@ public class DevicesInvoker {
|
|
|
case Constants.Ampe.ACTION_FLOATINGEXITBUTTON:
|
|
|
showFloatingBackButton(context,dataBean);
|
|
|
break;
|
|
|
- case Constants.Ampe.ACTION_SETSTORAGE:
|
|
|
- saveStorage(dataBean);
|
|
|
- break;
|
|
|
- case Constants.Ampe.ACTION_GETSTORAGELIST:
|
|
|
- getStorageList(dataBean);
|
|
|
+ case Constants.Ampe.ACTION_STORAGE:
|
|
|
+ if (AmpeDownloadFileEvent.SET.equals(dataBean.getEvent())) {
|
|
|
+ saveStorage(dataBean);
|
|
|
+ } else if (AmpeDownloadFileEvent.GET.equals(dataBean.getEvent())) {
|
|
|
+ getStorageList(dataBean);
|
|
|
+ } else if (AmpeDownloadFileEvent.REMOVE.equals(dataBean.getEvent())) {
|
|
|
+ removeStorage(dataBean);
|
|
|
+ }
|
|
|
break;
|
|
|
- case Constants.Ampe.ACTION_REMOVESTORAGE:
|
|
|
- removeStorage(dataBean);
|
|
|
+ default:
|
|
|
+
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -317,48 +321,116 @@ public class DevicesInvoker {
|
|
|
if (requestBean == null) {
|
|
|
return;
|
|
|
}
|
|
|
- BaseAmpeRequestBean<AmpeDeviceSaveFileConfigBean> newRequestBean = MyTypeToken
|
|
|
- .toBaseAmpeRequestBean(requestBean, AmpeDeviceSaveFileConfigBean.class);
|
|
|
+ BaseAmpeRequestBean<AmpeRequestDownloadFileBean> newRequestBean = MyTypeToken
|
|
|
+ .toBaseAmpeRequestBean(requestBean, AmpeRequestDownloadFileBean.class);
|
|
|
if (newRequestBean == null || newRequestBean.getParams() == null) {
|
|
|
return;
|
|
|
}
|
|
|
- AmpeDeviceSaveFileConfigBean params= newRequestBean.getParams();
|
|
|
- DownloadFileUtils.getInstance().downLoadFile(params.getUrl(), params.getFileName()
|
|
|
+ AmpeRequestDownloadFileBean params= newRequestBean.getParams();
|
|
|
+ DownloadFileUtils.getInstance().downLoadFile(params.getFileName(), params.getFileName()
|
|
|
, new DownloadFileUtils.DownloadFileListener() {
|
|
|
@Override
|
|
|
- public void saveSuccess(String fileName) {
|
|
|
- Log.i("___________123","saveSuccess:"+fileName);
|
|
|
+ public void saveSuccess( AmpeResultDownloadFileBean data) {
|
|
|
+ saveStorageCallBack(newRequestBean,data,true);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void saveFailed(int code, String errMsg) {
|
|
|
- Log.i("___________123","saveFailed:"+code+" "+errMsg);
|
|
|
+ saveStorageCallBack(newRequestBean,null,false);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
}
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @author xwh
|
|
|
+ * Time 2024/12/6
|
|
|
+ * Description: 保存文件返回事件
|
|
|
+ *
|
|
|
+ **/
|
|
|
+ private void saveStorageCallBack(BaseAmpeRequestBean requestBean, AmpeResultDownloadFileBean data, boolean isSuccess){
|
|
|
+ if(requestBean==null){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ BaseAmpeAppletResultBean result = new BaseAmpeAppletResultBean();
|
|
|
+ result.setTaskId(requestBean.getTaskId());
|
|
|
+ result.setAction(requestBean.getAction());
|
|
|
+ result.setEvent(requestBean.getEvent());
|
|
|
+ result.setSuccess(isSuccess);
|
|
|
+ result.setMessage(isSuccess?"成功":"失败");
|
|
|
+ if(isSuccess){
|
|
|
+ result.setData(data);
|
|
|
+ }
|
|
|
+ JsonObject jsonObject = GsonUtils.getGson().toJsonTree(result).getAsJsonObject();
|
|
|
+ if (requestBean.getBridgeCallback() != null) {
|
|
|
+ requestBean.getBridgeCallback().callback(jsonObject.toString());
|
|
|
+ }
|
|
|
+ String logLine = (new Throwable().getStackTrace())[0].toString();
|
|
|
+ UploadLogUtils.sendLogs(Constants.LogcatValue.LOG_DOWNLOADFILE,
|
|
|
+ Constants.Ampe.ACTION_STORAGE+" "+requestBean.getEvent(),logLine
|
|
|
+ ,jsonObject.toString());
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @author xwh
|
|
|
+ * Time 2024/12/6
|
|
|
+ * Description: 获取缓存文件列表
|
|
|
+ *
|
|
|
+ **/
|
|
|
private void getStorageList(BaseAmpeRequestBean requestBean){
|
|
|
if (requestBean == null) {
|
|
|
return;
|
|
|
}
|
|
|
- Log.i("___________123","getStorageList:"+GsonUtils.getGson()
|
|
|
- .toJson( DownloadFileUtils.getInstance().getFileList()));
|
|
|
+ BaseAmpeAppletResultBean result = new BaseAmpeAppletResultBean();
|
|
|
+ result.setTaskId(requestBean.getTaskId());
|
|
|
+ result.setAction(requestBean.getAction());
|
|
|
+ result.setEvent(requestBean.getEvent());
|
|
|
+ result.setSuccess(true);
|
|
|
+ result.setMessage("成功");
|
|
|
+ result.setData(DownloadFileUtils.getInstance().getFileList());
|
|
|
+ JsonObject jsonObject = GsonUtils.getGson().toJsonTree(result).getAsJsonObject();
|
|
|
+ if (requestBean.getBridgeCallback() != null) {
|
|
|
+ requestBean.getBridgeCallback().callback(jsonObject.toString());
|
|
|
+ }
|
|
|
+ String logLine = (new Throwable().getStackTrace())[0].toString();
|
|
|
+ UploadLogUtils.sendLogs(Constants.LogcatValue.LOG_DOWNLOADFILE,
|
|
|
+ Constants.Ampe.ACTION_STORAGE+" "+requestBean.getEvent(),logLine
|
|
|
+ ,jsonObject.toString());
|
|
|
}
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @author xwh
|
|
|
+ * Time 2024/12/6
|
|
|
+ * Description: 删除文件
|
|
|
+ *
|
|
|
+ **/
|
|
|
private void removeStorage(BaseAmpeRequestBean requestBean){
|
|
|
if (requestBean == null) {
|
|
|
return;
|
|
|
}
|
|
|
- BaseAmpeRequestBean<AmpeDeviceSaveFileConfigBean> newRequestBean = MyTypeToken
|
|
|
- .toBaseAmpeRequestBean(requestBean, AmpeDeviceSaveFileConfigBean.class);
|
|
|
+ BaseAmpeRequestBean<AmpeRequestDownloadFileBean> newRequestBean = MyTypeToken
|
|
|
+ .toBaseAmpeRequestBean(requestBean, AmpeRequestDownloadFileBean.class);
|
|
|
if (newRequestBean == null || newRequestBean.getParams() == null) {
|
|
|
return;
|
|
|
}
|
|
|
- AmpeDeviceSaveFileConfigBean params= newRequestBean.getParams();
|
|
|
- boolean isDeleted= DownloadFileUtils.getInstance().deleteFile(params.getRemovePath());
|
|
|
- Log.i("___________123","removeStorage:"+isDeleted);
|
|
|
- Log.i("___________123","removeStorage:"+GsonUtils.getGson()
|
|
|
- .toJson( DownloadFileUtils.getInstance().getFileList()));
|
|
|
+ AmpeRequestDownloadFileBean params= newRequestBean.getParams();
|
|
|
+ boolean isDeleted= DownloadFileUtils.getInstance().deleteFile(params.getPath());
|
|
|
+
|
|
|
+ BaseAmpeAppletResultBean result = new BaseAmpeAppletResultBean();
|
|
|
+ result.setTaskId(requestBean.getTaskId());
|
|
|
+ result.setAction(requestBean.getAction());
|
|
|
+ result.setEvent(requestBean.getEvent());
|
|
|
+ result.setSuccess(isDeleted);
|
|
|
+ result.setMessage(isDeleted?"成功":"失败");
|
|
|
+ JsonObject jsonObject = GsonUtils.getGson().toJsonTree(result).getAsJsonObject();
|
|
|
+ if (requestBean.getBridgeCallback() != null) {
|
|
|
+ requestBean.getBridgeCallback().callback(jsonObject.toString());
|
|
|
+ }
|
|
|
+ String logLine = (new Throwable().getStackTrace())[0].toString();
|
|
|
+ UploadLogUtils.sendLogs(Constants.LogcatValue.LOG_DOWNLOADFILE,
|
|
|
+ Constants.Ampe.ACTION_STORAGE+" "+requestBean.getEvent(),logLine
|
|
|
+ ,jsonObject.toString());
|
|
|
}
|
|
|
|
|
|
public static DevicesInvoker getInstance() {
|