From 47724d4d61c96a0c7d5381b5d01396a9876bbec3 Mon Sep 17 00:00:00 2001 From: luvletter2333 Date: Sun, 6 Feb 2022 22:06:57 +0800 Subject: [PATCH] Fix test dc --- .../java/org/telegram/ui/LoginActivity.java | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java index 168af91d8..3060c8e78 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java @@ -698,15 +698,13 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No exportLoginTokenRequest.api_id = NekoXConfig.currentAppId(); exportLoginTokenRequest.api_hash = NekoXConfig.currentAppHash(); exportLoginTokenRequest.except_ids = new ArrayList<>(); -// if (NekoXConfig.customApi == 0) { -// for (int a : SharedConfig.activeAccounts) { -// UserConfig userConfig = UserConfig.getInstance(a); -// if (!userConfig.isClientActivated()) { -// continue; -// } -// exportLoginTokenRequest.except_ids.add(a); -// } -// } + for (int a : SharedConfig.activeAccounts) { + UserConfig userConfig = UserConfig.getInstance(a); + if (!userConfig.isClientActivated()) { + continue; + } + exportLoginTokenRequest.except_ids.add(userConfig.clientUserId); + } } getNotificationCenter().addObserver(this, NotificationCenter.updateLoginToken); @@ -1958,12 +1956,19 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No TLRPC.TL_help_getCountriesList req = new TLRPC.TL_help_getCountriesList(); req.lang_code = ""; + CountrySelectActivity.Country testNumber = codesMap.get("999"); + String testNumberFormat = phoneFormatMap.get("999"); getConnectionsManager().sendRequest(req, (response, error) -> { AndroidUtilities.runOnUIThread(() -> { if (error == null) { countriesArray.clear(); codesMap.clear(); phoneFormatMap.clear(); + if (testNumber != null) { + countriesArray.add(testNumber); + codesMap.put(testNumber.code, testNumber); + phoneFormatMap.put(testNumber.code, testNumberFormat); + } TLRPC.TL_help_countriesList help_countriesList = (TLRPC.TL_help_countriesList) response; for (int i = 0; i < help_countriesList.countries.size(); i++) { TLRPC.TL_help_country c = help_countriesList.countries.get(i); @@ -2055,11 +2060,13 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No return; } String phone = PhoneFormat.stripExceptNumbers("" + codeField.getText() + phoneField.getText()); -// boolean isTestBakcend = getConnectionsManager().isTestBackend(); -// if (isTestBakcend != testBackend) { -// getConnectionsManager().switchBackend(false); -// isTestBakcend = testBackend; -// } + boolean isTestPhone = codeField.getText().toString().equals("999"); + if (isTestPhone) { + FileLog.w("Login with test numbers"); + DataCenter.applyTestDataCenter(currentAccount); + } else { + DataCenter.applyOfficalDataCanter(currentAccount); + } if (getParentActivity() instanceof LaunchActivity) { for (int a : SharedConfig.activeAccounts) { UserConfig userConfig = UserConfig.getInstance(a);