|
|
@@ -40,9 +40,11 @@ import com.sheep.gamegroup.greendao.DDProviderHelper;
|
|
|
import com.sheep.gamegroup.greendao.download.DownLoadInfo;
|
|
|
import com.sheep.gamegroup.model.entity.Applications;
|
|
|
import com.sheep.gamegroup.model.entity.TaskEty;
|
|
|
+import com.sheep.gamegroup.util.CommonUtil;
|
|
|
import com.sheep.gamegroup.util.DownloadUtil;
|
|
|
import com.sheep.gamegroup.util.FileUtil;
|
|
|
import com.sheep.gamegroup.util.LogUtil;
|
|
|
+import com.sheep.gamegroup.util.Md5Util;
|
|
|
import com.sheep.gamegroup.util.StringUtils;
|
|
|
import com.sheep.gamegroup.util.TestUtil;
|
|
|
import com.sheep.gamegroup.view.activity.NotificationsUtils;
|
|
|
@@ -53,12 +55,19 @@ import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
import org.greenrobot.eventbus.EventBus;
|
|
|
|
|
|
import java.io.File;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.lang.reflect.Field;
|
|
|
+import java.net.InetSocketAddress;
|
|
|
+import java.net.URL;
|
|
|
+import java.net.URLConnection;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Locale;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
+import okhttp3.Route;
|
|
|
+
|
|
|
import static com.sheep.jiuyan.samllsheep.utils.ClassFileHelper.DIR;
|
|
|
|
|
|
/**
|
|
|
@@ -206,6 +215,7 @@ public class DownloadService extends Service {
|
|
|
}
|
|
|
ApkUtils.installApk(getApplicationContext(), task.getFile().getAbsolutePath());
|
|
|
DownloadNotification.progress(task.getUrl(), -1l);
|
|
|
+ checkMd(downLoadInfo, task);
|
|
|
}
|
|
|
break;
|
|
|
case PRE_ALLOCATE_FAILED://预先分配失败
|
|
|
@@ -265,6 +275,58 @@ public class DownloadService extends Service {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ private void checkMd(DownLoadInfo info, DownloadTask task) {
|
|
|
+ new Thread(() -> {
|
|
|
+ try {
|
|
|
+ String clientMd5 = Md5Util.getFileMD5(task.getFile());
|
|
|
+ String serverMd5 = task.getRedirectLocation().substring(task.getRedirectLocation().lastIndexOf("_") + 1, task.getRedirectLocation().lastIndexOf("."));
|
|
|
+ LogUtil.logE(clientMd5 + " = " + serverMd5);
|
|
|
+ if (serverMd5.length() != 32) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+// if (!clientMd5.equals(serverMd5)) {
|
|
|
+ CommonUtil.getInstance().statGameDownloadError(
|
|
|
+ info.getMGameID() + "",
|
|
|
+ task.getRedirectLocation(),
|
|
|
+ getCdbIp(task.getRedirectLocation()),
|
|
|
+ clientMd5,
|
|
|
+ serverMd5);
|
|
|
+// }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (OutOfMemoryError e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }).start();
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getCdbIp(String url) {
|
|
|
+ try {
|
|
|
+ URLConnection conn = new URL(url).openConnection();
|
|
|
+ InputStream in = conn.getInputStream();
|
|
|
+ try {
|
|
|
+ Field delegateField = conn.getClass().getDeclaredField("delegate");
|
|
|
+ delegateField.setAccessible(true);
|
|
|
+ Object delegate = delegateField.get(conn);
|
|
|
+ Field routeField = delegate.getClass().getDeclaredField("route");
|
|
|
+ routeField.setAccessible(true);
|
|
|
+ Object route = routeField.get(delegate);
|
|
|
+ Field inetField = route.getClass().getDeclaredField("inetSocketAddress");
|
|
|
+ inetField.setAccessible(true);
|
|
|
+ InetSocketAddress address = (InetSocketAddress) inetField.get(route);
|
|
|
+ String ip = address.getAddress().getHostAddress();
|
|
|
+ in.close();
|
|
|
+ return ip;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Nullable
|
|
|
@Override
|
|
|
public IBinder onBind(Intent intent) {
|