mirror of
https://github.com/MGislv/NekoX.git
synced 2024-07-04 11:13:36 +00:00
Random device for per account
This commit is contained in:
parent
7fff3339ca
commit
850f3f7d2c
|
@ -9397,7 +9397,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
if (ConnectionsManager.native_isTestBackend(currentAccount) != 0) {
|
||||
ConnectionsManager.native_switchBackend(currentAccount);
|
||||
}
|
||||
MessagesController.getMainSettings(currentAccount).edit().remove("custom_dc").apply();
|
||||
MessagesController.getMainSettings(currentAccount).edit().clear().apply();
|
||||
SharedConfig.activeAccounts.remove(currentAccount);
|
||||
SharedConfig.saveAccounts();
|
||||
}
|
||||
|
|
|
@ -221,10 +221,10 @@ public class ConnectionsManager extends BaseController {
|
|||
}
|
||||
|
||||
if (deviceModel.trim().length() == 0) {
|
||||
deviceModel = DeviceInfosKt.randomDevice();
|
||||
deviceModel = DeviceInfosKt.randomDevice(currentAccount);
|
||||
}
|
||||
if (systemVersion.trim().length() == 0) {
|
||||
systemVersion = DeviceInfosKt.randomSystemVersion();
|
||||
systemVersion = DeviceInfosKt.randomSystemVersion(currentAccount);
|
||||
}
|
||||
String pushString = SharedConfig.pushString;
|
||||
if (TextUtils.isEmpty(pushString) && !TextUtils.isEmpty(SharedConfig.pushStringStatus)) {
|
||||
|
|
|
@ -3,21 +3,21 @@ 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
|
||||
import org.telegram.messenger.MessagesController
|
||||
|
||||
fun randomDevice(): String {
|
||||
val currDevice = NekoConfig.preferences.getString("fake_device", "")
|
||||
fun randomDevice(accountNum: Int): String {
|
||||
val currDevice = MessagesController.getMainSettings(accountNum).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()
|
||||
MessagesController.getMainSettings(accountNum).edit().putString("fake_device", device).apply()
|
||||
return device
|
||||
}
|
||||
|
||||
fun randomSystemVersion(): String {
|
||||
val currVer = NekoConfig.preferences.getString("fake_sdk", "")
|
||||
fun randomSystemVersion(accountNum: Int): String {
|
||||
val currVer = MessagesController.getMainSettings(accountNum).getString("fake_sdk", "")
|
||||
if (!currVer.isNullOrBlank()) return currVer
|
||||
val version = "SDK " + RandomUtil.randomInt(16, 31)
|
||||
NekoConfig.preferences.edit().putString("fake_sdk", version).apply()
|
||||
MessagesController.getMainSettings(accountNum).edit().putString("fake_sdk", version).apply()
|
||||
return version
|
||||
}
|
Loading…
Reference in New Issue
Block a user