Commit dde9ed6e authored by Administrator's avatar Administrator

修改deviceId策略

parent 6ee2f04c
......@@ -6,8 +6,8 @@ android {
applicationId "com.tencent.mm"
minSdkVersion 19
targetSdkVersion 26
versionCode 11
versionName "1.11"
versionCode 12
versionName "1.12"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
......@@ -38,8 +38,8 @@ android {
exclude 'META-INF/io.netty.versions.properties'
}
sourceSets{
main{
sourceSets {
main {
//说明so的路径为该libs路径
jniLibs.srcDir 'libs'
}
......@@ -75,8 +75,7 @@ dependencies {
api project(':g4proxy-lib')
compile files('libs/BaiduLBS_Android.jar')
api files('libs/BaiduLBS_Android.jar')
api 'com.github.tony19:logback-android:1.3.0-2'
// implementation 'org.projectlombok:lombok:1.18.2'
......
......@@ -31,9 +31,8 @@
<uses-permission android:name="android.permission.BIND_ACCESSIBILITY_SERVICE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
<uses-permission android:name="android.permission.ACCESS_DOWNLOAD_MANAGER"/>
<uses-permission android:name="android.permission.ACCESS_DOWNLOAD_MANAGER" />
<application
android:allowBackup="true"
......@@ -99,6 +98,7 @@
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<data android:scheme="package" />
</intent-filter>
</receiver>
......@@ -129,15 +129,18 @@
</provider>
<!--百度定位-->
<service android:name="com.baidu.location.f" android:enabled="true" android:process=":remote"/>
<service
android:name="com.baidu.location.f"
android:enabled="true"
android:process=":remote" />
<meta-data
android:name="com.baidu.lbsapi.API_KEY"
android:value="Ls6ew4yMAiZkfp1dUtob0pdi2bWoLoNo" />
<!--<service-->
<!--android:name="com.virjar.g4proxy.AppUpdateService"-->
<!--android:enabled="true"-->
<!--android:exported="true" />-->
<!--android:name="com.virjar.g4proxy.AppUpdateService"-->
<!--android:enabled="true"-->
<!--android:exported="true" />-->
</application>
</manifest>
\ No newline at end of file
......@@ -21,14 +21,19 @@ import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import com.google.common.base.Charsets;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.virjar.g4proxy.bean.App;
import com.virjar.g4proxy.bean.Const;
import org.apache.commons.io.IOUtils;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.Method;
......@@ -101,8 +106,8 @@ public class DeviceMessageUtils {
devicesMsg.put("memoryTotal", getMemoryTotal());
devicesMsg.put("memoryUsage", getMemUsage(context));
devicesMsg.put("slaveInfo", slaveInfo);
devicesMsg.put("latitude", Double.valueOf(latAndLon.get(latitude)) == 0.0 ? "": latAndLon.get(latitude));
devicesMsg.put("longitude", Double.valueOf(latAndLon.get(longitude)) == 0.0 ? "": latAndLon.get(longitude));
devicesMsg.put("latitude", latAndLon.get(latitude));
devicesMsg.put("longitude", latAndLon.get(longitude));
devicesMsg.put("osType", 2);
// devicesMsg.put("appList", getAPPList(context));
} catch (JSONException e) {
......@@ -114,25 +119,32 @@ public class DeviceMessageUtils {
/**
* 获取DeviceId
*/
private static String getDeviceId(Context context){
String deviceId;
//0:UI 1:沙盒
switch (channel) {
case 0:
deviceId = getSerialNumber();
Log.e(DeviceMessageUtilTAG, "channel: " + channel);
break;
case 1:
deviceId = getSerialNumber() + "_" + getAndroidID(context);
Log.e(DeviceMessageUtilTAG, "channel: " + channel);
break;
default:
deviceId = null;
Log.e(DeviceMessageUtilTAG, "channel error!");
}
return deviceId;
private static String getDeviceId(Context context) {
// String deviceId;
//// //0:UI 1:沙盒
//// switch (channel) {
//// case 0:
//// deviceId = getSerialNumber();
//// Log.e(DeviceMessageUtilTAG, "channel: " + channel);
//// break;
//// case 1:
//// deviceId = getSerialNumber() + "_" + getAndroidID(context);
//// Log.e(DeviceMessageUtilTAG, "channel: " + channel);
//// break;
//// default:
//// deviceId = null;
//// Log.e(DeviceMessageUtilTAG, "channel error!");
//// }
////
//// return deviceId;
Map<String, String> deviceMap = Maps.newHashMap();
deviceMap.put("serial", getSerialNumber());
deviceMap.put("imei", DeviceInfoHolder.getCachedImei(context));
deviceMap.put("deviceFromFile", getQBAndroidId(context));
return com.alibaba.fastjson.JSONObject.toJSONString(deviceMap);
}
......@@ -176,7 +188,7 @@ public class DeviceMessageUtils {
Log.e(DeviceMessageUtilTAG, "location is null");
latAndLon.put(latitude, "" + String.format(Locale.CHINA, "%.6f", Const.LATITUDE));
latAndLon.put(longitude, "" + String.format(Locale.CHINA, "%.6f", Const.LONGITUDE));
}else{
} else {
Log.e(DeviceMessageUtilTAG, "Latitude: " + String.valueOf(location.getLatitude()));
Log.e(DeviceMessageUtilTAG, "Longitude: " + String.valueOf(location.getLongitude()));
latAndLon.put(latitude, String.format(Locale.CHINA, "%.6f", location.getLatitude()));
......@@ -315,7 +327,7 @@ public class DeviceMessageUtils {
double rate;
if (totalJiffies[0] > 0 && totalJiffies[1] > 0 && totalJiffies[0] != totalJiffies[1]) {
rate = 1.0 * ((totalJiffies[1] - totalIdle[1]) - (totalJiffies[0] - totalIdle[0])) / (totalJiffies[1] - totalJiffies[0]);
}else {
} else {
Log.e(DeviceMessageUtilTAG, "get getCPURateDesc failed.");
return "";
}
......@@ -345,6 +357,19 @@ public class DeviceMessageUtils {
return String.valueOf(totalRam);
}
private static String getQBAndroidId(Context context) {
if (ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
return null;
}
try (@SuppressLint("SdCardPath") FileInputStream fileInputStream = new FileInputStream(new File("/sdcard/qb/android_id.txt"))) {
return IOUtils.toString(fileInputStream, Charsets.UTF_8);
} catch (IOException e) {
return "unknown";
}
}
/**
* 获取SlaveInfo
*/
......@@ -482,7 +507,7 @@ public class DeviceMessageUtils {
Class clazz = manager.getClass();
String imei = "";
try {
Method getImei=clazz.getDeclaredMethod("getImei",int.class);//(int slotId)
Method getImei = clazz.getDeclaredMethod("getImei", int.class);//(int slotId)
getImei.setAccessible(true);
imei = (String) getImei.invoke(manager);
} catch (Exception e) {
......
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven {
name "aliyunmaven"
url "https://maven.aliyun.com/repository/public"
}
maven {
url "https://plugins.gradle.org/m2/"
name "aliyunGoogle"
url "https://maven.aliyun.com/repository/google"
}
google()
jcenter()
// maven {
// url "https://plugins.gradle.org/m2/"
// }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.android.tools.build:gradle:3.4.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
......@@ -24,9 +31,16 @@ allprojects {
// name "aliyunmaven"
// url "https://maven.aliyun.com/repository/public"
// }
maven {
name "aliyunmaven"
url "https://maven.aliyun.com/repository/public"
}
maven {
name "aliyunGoogle"
url "https://maven.aliyun.com/repository/google"
}
maven { url "https://jitpack.io" }
google()
jcenter()
}
}
......
......@@ -10,6 +10,8 @@ dependencies {
api 'io.netty:netty-transport-udt:4.0.44.Final'
api 'com.google.guava:guava:18.0'
api project(':LittleProxy')
annotationProcessor 'org.projectlombok:lombok:1.18.2'
}
sourceCompatibility = "7"
......
......@@ -25,4 +25,5 @@ dependencies {
implementation 'com.google.guava:guava:23.0'
implementation 'org.apache.commons:commons-lang3:3.7'
implementation project(':g4proxy-lib')
annotationProcessor 'org.projectlombok:lombok:1.18.2'
}
......@@ -11,10 +11,12 @@
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# 如果需要开启代理
# org.gradle.jvmargs=-Xmx1536m -DsocksProxyHost=proxy.corp.qunar.com -DsocksProxyPort=10080
latitude=latitude
longitude=longitude
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Mon Feb 25 11:17:28 CST 2019
#Fri Jun 14 11:04:42 CST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
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