version:2.7
fix:修复不会上传设备信息,修复body().String()重复请求 add:
This commit is contained in:
@@ -37,7 +37,7 @@ public class UrlAddress {
|
||||
public final static String QUERY_APP_INSIDE = "control/queryAppInside";
|
||||
/*发送卸载或者安装信息*/
|
||||
public final static String SEND_INSTALLEDORREMOVED = "app/addAppInstall";
|
||||
/*发送卸载或者安装信息*/
|
||||
/*发送设备基本信息*/
|
||||
public final static String UPDATE_SNINFO = "sn/updateAdminSn";
|
||||
/*根据包名获取更新*/
|
||||
public final static String GET_NEWESTAPPUPDATE = "app/newestAppUpdate";
|
||||
|
||||
@@ -16,6 +16,7 @@ import okhttp3.Protocol;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
import okio.Buffer;
|
||||
|
||||
public class RepeatRequestInterceptor implements Interceptor {
|
||||
@@ -28,11 +29,15 @@ public class RepeatRequestInterceptor implements Interceptor {
|
||||
@Override
|
||||
public Response intercept(@NotNull Chain chain) throws IOException {
|
||||
Request request = chain.request();
|
||||
Response response = chain.proceed(request);
|
||||
ResponseBody responseBody = response.body();
|
||||
|
||||
Response response = chain.proceed(chain.request());
|
||||
String content = response.body().string();
|
||||
//会消费请求,导致请求多次
|
||||
String content = responseBody.string();
|
||||
// Response copy = response.newBuilder().body(responseBody).build();
|
||||
ResponseBody copy = ResponseBody.create(responseBody.contentType(), content);
|
||||
if (BuildConfig.DEBUG) {
|
||||
// Log.e(TAG, "请求体返回:| Response:" + content);
|
||||
Log.e(TAG, "请求体返回:| Response: " + request.url().encodedPath() + "\t body: " + content);
|
||||
}
|
||||
//相同的请求
|
||||
String requestKey = MD5Util.getUpperMD5Str(request.method() + request.url().toString() + requestBodyToString(request.body()));
|
||||
@@ -51,7 +56,7 @@ public class RepeatRequestInterceptor implements Interceptor {
|
||||
log("注册请求:", requestKey, request);
|
||||
// RepeatRequestInterceptor.Builder builder = request.newBuilder();
|
||||
// builder.addHeader("header", jsonObject.toString());
|
||||
return chain.proceed(request);
|
||||
return response.newBuilder().body(copy).build();
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "intercept: " + e.getMessage());
|
||||
throw e;
|
||||
|
||||
@@ -9,6 +9,7 @@ public class MainSContact {
|
||||
public interface MainView extends BaseView {
|
||||
void setSnInfo(BaseResponse<SnInfo> response);
|
||||
void setLocked(int lockedStatus);
|
||||
void updateInfoFinish();
|
||||
void checkUpdateFinish();
|
||||
void getAllAppFinish();
|
||||
void setAppInside();
|
||||
@@ -26,6 +27,8 @@ public class MainSContact {
|
||||
void getSnInfo();
|
||||
//获取锁定状态
|
||||
void getLocked();
|
||||
//上传设备信息
|
||||
void updateDeviceInfo();
|
||||
//检查更新
|
||||
void checkUpdate();
|
||||
//获取所有app包名
|
||||
|
||||
@@ -110,6 +110,12 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
mView.setLocked(statu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDeviceInfo() {
|
||||
NetInterfaceManager.getInstance().updateAdminInfo();
|
||||
mView.updateInfoFinish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkUpdate() {
|
||||
NetInterfaceManager.getInstance().checkAllAppUpdate(true, getLifecycle(), new NetInterfaceManager.onCompleteCallback() {
|
||||
|
||||
@@ -407,6 +407,11 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
break;
|
||||
default:
|
||||
}
|
||||
mPresenter.updateDeviceInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateInfoFinish() {
|
||||
mPresenter.checkUpdate();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user