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