Fix hide device info

This commit is contained in:
世界 2021-03-01 20:22:25 +08:00
parent bda178a833
commit ac3cd25765
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
4 changed files with 23923 additions and 18 deletions

View File

@ -3,16 +3,16 @@ import cn.hutool.core.util.RuntimeUtil
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
def verName = "7.5.0-rc03"
def verCode = 206
def verName = "7.5.0-rc04"
def verCode = 200 + 3 * 3
if (System.getenv("DEBUG_BUILD") == "true") {
verName += "-" + RuntimeUtil.execForStr("git log --pretty=format:'%h' -n 1)")
}
def officialVer = "7.4.2"
def officialCode = 2227
def officialVer = "7.5.0"
def officialCode = 2246
def serviceAccountCredentialsFile = rootProject.file("service_account_credentials.json")
@ -26,21 +26,17 @@ if (serviceAccountCredentialsFile.isFile()) {
}
void setupPlay(boolean beta) {
apply plugin: 'com.github.triplet.play'
play {
track = beta ? "beta" : "production"
defaultToAppBundles = true
}
}
configurations {
compile.exclude module: 'support-v4'
}
def keystorePwd = null
def alias = null
def pwd = null
@ -111,9 +107,9 @@ dependencies {
implementation 'dnsjava:dnsjava:3.3.1'
implementation 'org.dizitart:nitrite:3.4.3'
implementation 'cn.hutool:hutool-core:5.5.8'
implementation 'cn.hutool:hutool-crypto:5.5.8'
implementation 'cn.hutool:hutool-http:5.5.8'
implementation 'cn.hutool:hutool-core:5.5.9'
implementation 'cn.hutool:hutool-crypto:5.5.9'
implementation 'cn.hutool:hutool-http:5.5.9'
implementation 'org.yaml:snakeyaml:1.28'
implementation 'com.jakewharton:process-phoenix:2.0.0'
@ -137,7 +133,7 @@ dependencies {
testImplementation 'androidx.test:core:1.3.0'
testImplementation 'org.robolectric:robolectric:4.5.1'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.1'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
if (!targetAbi.isBlank()) {
implementation project(":ss-rust")

File diff suppressed because it is too large Load Diff

View File

@ -47,7 +47,9 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import cn.hutool.core.util.StrUtil;
import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.parts.DeviceInfosKt;
import tw.nekomimi.nekogram.parts.ProxySwitcher;
import tw.nekomimi.nekogram.utils.DnsFactory;
@ -195,24 +197,26 @@ public class ConnectionsManager extends BaseController {
version = BuildConfig.OFFICIAL_VERSION_CODE * 10 + 9;
appId = BuildVars.OFFICAL_APP_ID;
appVersion = BuildConfig.OFFICIAL_VERSION + " (" + (BuildConfig.OFFICIAL_VERSION_CODE * 10 + 9) + ")";
if (BuildVars.DEBUG_VERSION) {
appVersion += " beta";
}
} else {
fingerprint = AndroidUtilities.getCertificateSHA256Fingerprint();
version = BuildConfig.VERSION_CODE;
appId = BuildConfig.APP_ID;
appVersion = BuildConfig.VERSION_NAME + " (" + BuildConfig.VERSION_CODE + ")";
String versionName = BuildConfig.VERSION_NAME;
if (versionName.contains("-")) {
versionName = StrUtil.subBefore(versionName, "-", false);
}
appVersion = versionName + " (" + BuildConfig.VERSION_CODE + ")";
}
if (systemLangCode.trim().length() == 0) {
systemLangCode = "en";
}
if (deviceModel.trim().length() == 0) {
deviceModel = "Unknown";
deviceModel = DeviceInfosKt.randomDevice();
}
if (systemVersion.trim().length() == 0) {
systemVersion = "Unknown";
systemVersion = DeviceInfosKt.randomSystemVersion();
}
String pushString = SharedConfig.pushString;
if (TextUtils.isEmpty(pushString) && !TextUtils.isEmpty(SharedConfig.pushStringStatus)) {

View File

@ -0,0 +1,23 @@
package tw.nekomimi.nekogram.parts
import cn.hutool.core.io.IoUtil
import cn.hutool.core.util.RandomUtil
import org.telegram.messenger.ApplicationLoader
import tw.nekomimi.nekogram.NekoConfig
fun randomDevice(): String {
val currDevice = NekoConfig.preferences.getString("fake_device", "")
if (!currDevice.isNullOrBlank()) return currDevice
val devices = IoUtil.readUtf8(ApplicationLoader.applicationContext.assets.open("devices.csv"))
val device = RandomUtil.randomEle(devices.split("\n"))
NekoConfig.preferences.edit().putString("fake_device", device).apply()
return device
}
fun randomSystemVersion(): String {
val currVer = NekoConfig.preferences.getString("fake_sdk", "")
if (!currVer.isNullOrBlank()) return currVer
val version = "SDK " + RandomUtil.randomInt(16, 31)
NekoConfig.preferences.edit().putString("fake_sdk", version).apply()
return version
}