Commit 5a8b3ca0 authored by Administrator's avatar Administrator

update

parent d78ac14e
...@@ -78,13 +78,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe ...@@ -78,13 +78,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
textView.setText(deviceMsg.toString()); textView.setText(deviceMsg.toString());
String serverUrl = "https://hotelcrawl.qunar.com/api/phone/report"; textView.setText(SchedulerTaskService.msgReportlUrl);
textView.setText(serverUrl);
textView.append("\r\n" + deviceMsg); textView.append("\r\n" + deviceMsg);
// Request request = HttpClientUtils.postRequest("http://taskcenter.beta.qunar.com/api/phone/report", deviceMsg); // Request request = HttpClientUtils.postRequest("http://taskcenter.beta.qunar.com/api/phone/report", deviceMsg);
//https://hotelcrawl.qunar.com/api/phone/report //https://hotelcrawl.qunar.com/api/phone/report
Request request = HttpClientUtils.postRequest("https://hotelcrawl.qunar.com/api/phone/report", deviceMsg); Request request = HttpClientUtils.postRequest(SchedulerTaskService.msgReportlUrl, deviceMsg);
HttpClientUtils.getClient().newCall(request).enqueue(new Callback() { HttpClientUtils.getClient().newCall(request).enqueue(new Callback() {
@Override @Override
......
package com.virjar.g4proxy.service; package com.virjar.g4proxy.service;
import android.app.Activity;
import android.app.AlarmManager; import android.app.AlarmManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.app.Service; import android.app.Service;
...@@ -13,9 +14,12 @@ import android.os.Looper; ...@@ -13,9 +14,12 @@ import android.os.Looper;
import android.os.SystemClock; import android.os.SystemClock;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.util.Log; import android.util.Log;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.tencent.mm.R;
import com.virjar.g4proxy.Constant; import com.virjar.g4proxy.Constant;
import com.virjar.g4proxy.MainActivity;
import com.virjar.g4proxy.utils.DeviceMessageUtil; import com.virjar.g4proxy.utils.DeviceMessageUtil;
import com.virjar.g4proxy.utils.HttpClientUtils; import com.virjar.g4proxy.utils.HttpClientUtils;
...@@ -28,6 +32,7 @@ import okhttp3.Call; ...@@ -28,6 +32,7 @@ import okhttp3.Call;
import okhttp3.Callback; import okhttp3.Callback;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
import okhttp3.ResponseBody;
import top.wuhaojie.installerlibrary.AutoInstaller; import top.wuhaojie.installerlibrary.AutoInstaller;
import static com.virjar.g4proxy.Constant.schedulerTAG; import static com.virjar.g4proxy.Constant.schedulerTAG;
...@@ -40,7 +45,8 @@ public class SchedulerTaskService extends Service { ...@@ -40,7 +45,8 @@ public class SchedulerTaskService extends Service {
public static final int reportInterval = 5; public static final int reportInterval = 5;
public static final String getNewestModifiedApkUrl = "http://www.scumall.com:5597/hermes/ModifiedApp/getNewestModifiedApk?appPackageName="; public static final String getNewestModifiedApkUrl = "http://www.scumall.com:5597/hermes/ModifiedApp/getNewestModifiedApk?appPackageName=";
public static final String msgReportlUrl = "http://taskcenter.beta.qunar.com/api/phone/report"; //public static final String msgReportlUrl ="http://taskcenter.beta.qunar.com/api/phone/report"
public static final String msgReportlUrl = "https://hotelcrawl.qunar.com/api/phone/report";
private long lastCheckUpdateTimestamp = 0; private long lastCheckUpdateTimestamp = 0;
private long lastCheckReportTimestamp = 0; private long lastCheckReportTimestamp = 0;
...@@ -73,20 +79,20 @@ public class SchedulerTaskService extends Service { ...@@ -73,20 +79,20 @@ public class SchedulerTaskService extends Service {
Log.e(schedulerTAG, "checkAndRunTask"); Log.e(schedulerTAG, "checkAndRunTask");
if (System.currentTimeMillis() - lastCheckUpdateTimestamp > (updateInterval * 1000 * 60) / 3) { if (System.currentTimeMillis() - lastCheckUpdateTimestamp > (updateInterval * 1000 * 60) / 3) {
runAppInstallTask(); runAppInstallTask();
}else { } else {
lastCheckUpdateTimestamp = System.currentTimeMillis(); lastCheckUpdateTimestamp = System.currentTimeMillis();
} }
if (System.currentTimeMillis() - lastCheckReportTimestamp > (reportInterval * 1000 * 60) / 3){ if (System.currentTimeMillis() - lastCheckReportTimestamp > (reportInterval * 1000 * 60) / 3) {
runReportMessageTask(); runReportMessageTask(this);
}else { } else {
lastCheckReportTimestamp = System.currentTimeMillis(); lastCheckReportTimestamp = System.currentTimeMillis();
} }
} }
private void runReportMessageTask() { public static void runReportMessageTask(final Context context) {
Log.e(schedulerTAG, "runUploadMessageTask"); Log.e(schedulerTAG, "runUploadMessageTask");
JSONObject deviceMessage = DeviceMessageUtil.getDeviceMessage(this); JSONObject deviceMessage = DeviceMessageUtil.getDeviceMessage(context);
Request request = HttpClientUtils.postRequest(msgReportlUrl, deviceMessage); Request request = HttpClientUtils.postRequest(msgReportlUrl, deviceMessage);
...@@ -100,9 +106,22 @@ public class SchedulerTaskService extends Service { ...@@ -100,9 +106,22 @@ public class SchedulerTaskService extends Service {
public void onResponse(@javax.annotation.Nullable Call call, @javax.annotation.Nullable Response response) { public void onResponse(@javax.annotation.Nullable Call call, @javax.annotation.Nullable Response response) {
try { try {
if (response != null) { if (response != null) {
Log.e("report response", response.body().string()); ResponseBody body = response.body();
} if (body != null) {
final String responseStr = body.string();
if (context instanceof MainActivity) {
((MainActivity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
TextView textView = ((MainActivity) context).findViewById(R.id.text);
textView.append("\r\n" + responseStr);
}
});
}
Log.e("report response", responseStr);
}
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment