Revert "Random device for per account"

This commit is contained in:
世界 2021-03-21 18:38:56 +08:00
parent 1baae62f97
commit 6770e0fe3f
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
4 changed files with 13 additions and 13 deletions

View File

@ -3,8 +3,8 @@ import cn.hutool.core.util.RuntimeUtil
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
def verName = "7.6.0-rc02"
def verCode = 200 + 3 * 14
def verName = "7.6.0-rc03"
def verCode = 200 + 3 * 15
if (System.getenv("DEBUG_BUILD") == "true") {
verName += "-" + RuntimeUtil.execForStr("git log --pretty=format:'%h' -n 1)")

View File

@ -9515,7 +9515,6 @@ public class MessagesController extends BaseController implements NotificationCe
if (ConnectionsManager.native_isTestBackend(currentAccount) != 0) {
ConnectionsManager.native_switchBackend(currentAccount);
}
MessagesController.getMainSettings(currentAccount).edit().clear().apply();
SharedConfig.activeAccounts.remove(currentAccount);
SharedConfig.saveAccounts();
}

View File

@ -219,11 +219,11 @@ public class ConnectionsManager extends BaseController {
systemLangCode = "en";
}
if (deviceModel.trim().length() == 0) {
deviceModel = DeviceInfosKt.randomDevice(currentAccount);
if (deviceModel.trim().length() == 0 && getUserConfig().isClientActivated()) {
deviceModel = DeviceInfosKt.randomDevice();
}
if (systemVersion.trim().length() == 0) {
systemVersion = DeviceInfosKt.randomSystemVersion(currentAccount);
if (systemVersion.trim().length() == 0 && getUserConfig().isClientActivated()) {
systemVersion = DeviceInfosKt.randomSystemVersion();
}
String pushString = SharedConfig.pushString;
if (TextUtils.isEmpty(pushString) && !TextUtils.isEmpty(SharedConfig.pushStringStatus)) {

View File

@ -4,20 +4,21 @@ import cn.hutool.core.io.IoUtil
import cn.hutool.core.util.RandomUtil
import org.telegram.messenger.ApplicationLoader
import org.telegram.messenger.MessagesController
import tw.nekomimi.nekogram.NekoConfig
fun randomDevice(accountNum: Int): String {
val currDevice = MessagesController.getMainSettings(accountNum).getString("fake_device", "")
fun randomDevice(): String {
val currDevice = MessagesController.getGlobalEmojiSettings().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"))
MessagesController.getMainSettings(accountNum).edit().putString("fake_device", device).apply()
NekoConfig.preferences.edit().putString("fake_device", device).apply()
return device
}
fun randomSystemVersion(accountNum: Int): String {
val currVer = MessagesController.getMainSettings(accountNum).getString("fake_sdk", "")
fun randomSystemVersion(): String {
val currVer = MessagesController.getGlobalEmojiSettings().getString("fake_sdk", "")
if (!currVer.isNullOrBlank()) return currVer
val version = "SDK " + RandomUtil.randomInt(16, 31)
MessagesController.getMainSettings(accountNum).edit().putString("fake_sdk", version).apply()
NekoConfig.preferences.edit().putString("fake_sdk", version).apply()
return version
}