From 02c8efb0df36a50185a36a03c1af862a9f130392 Mon Sep 17 00:00:00 2001 From: DrKLO Date: Mon, 23 Dec 2013 03:47:35 +0400 Subject: [PATCH] update to 1.3.4 --- TMessagesProj/src/main/AndroidManifest.xml | 4 +- .../messenger/ExportAuthorizationAction.java | 6 +++ .../telegram/messenger/HandshakeAction.java | 10 ++++- .../messenger/MessagesController.java | 20 ++++++++++ .../org/telegram/messenger/TcpConnection.java | 8 ++++ .../org/telegram/messenger/Utilities.java | 37 +++++++++++++++++++ .../org/telegram/ui/ChatProfileActivity.java | 3 ++ .../java/org/telegram/ui/LoginActivity.java | 8 +--- .../org/telegram/ui/UserProfileActivity.java | 7 ++-- .../ui/Views/SizeNotifierRelativeLayout.java | 10 +++-- 10 files changed, 96 insertions(+), 17 deletions(-) diff --git a/TMessagesProj/src/main/AndroidManifest.xml b/TMessagesProj/src/main/AndroidManifest.xml index 4f15baba..af71a62b 100644 --- a/TMessagesProj/src/main/AndroidManifest.xml +++ b/TMessagesProj/src/main/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="126" + android:versionName="1.3.4"> 256) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java index a82c030f..62ae0bae 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java @@ -1224,6 +1224,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter for (TLRPC.TL_contact value : contactsArr) { TLRPC.User user = usersDict.get(value.user_id); + if (user == null) { + continue; + } contactsDictionery.put(value.user_id, value); contactsPhones.put(user.phone, value); @@ -4880,6 +4883,12 @@ public class MessagesController implements NotificationCenter.NotificationCenter if (error == null) { TLRPC.messages_DhConfig res = (TLRPC.messages_DhConfig)response; if (response instanceof TLRPC.TL_messages_dhConfig) { + if (!Utilities.isGoodPrime(res.p)) { + acceptingChats.remove(encryptedChat.id); + declineSecretChat(encryptedChat.id); + return; + } + MessagesStorage.secretPBytes = res.p; MessagesStorage.secretG = res.g; MessagesStorage.lastSecretVersion = res.version; @@ -4967,6 +4976,17 @@ public class MessagesController implements NotificationCenter.NotificationCenter if (error == null) { TLRPC.messages_DhConfig res = (TLRPC.messages_DhConfig)response; if (response instanceof TLRPC.TL_messages_dhConfig) { + if (!Utilities.isGoodPrime(res.p)) { + Utilities.RunOnUIThread(new Runnable() { + @Override + public void run() { + if (!((ActionBarActivity)context).isFinishing()) { + progressDialog.dismiss(); + } + } + }); + return; + } MessagesStorage.secretPBytes = res.p; MessagesStorage.secretG = res.g; MessagesStorage.lastSecretVersion = res.version; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/TcpConnection.java b/TMessagesProj/src/main/java/org/telegram/messenger/TcpConnection.java index 48deb6d3..7711fe47 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/TcpConnection.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/TcpConnection.java @@ -85,6 +85,14 @@ public class TcpConnection extends PyroClientAdapter { connectionState = TcpConnectionState.TcpConnectionStageConnecting; try { + try { + if (reconnectTimer != null) { + reconnectTimer.cancel(); + reconnectTimer = null; + } + } catch (Exception e2) { + FileLog.e("tmessages", e2); + } Datacenter datacenter = ConnectionsManager.Instance.datacenterWithId(datacenterId); hostAddress = datacenter.getCurrentAddress(); hostPort = datacenter.getCurrentPort(); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java b/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java index 372f14bb..d86543bb 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java @@ -55,6 +55,10 @@ public class Utilities { public static int statusBarHeight = 0; private final static Integer lock = 1; + public static String[] goodPrimes = { + "C71CAEB9C6B1C9048E6C522F70F13F73980D40238E3E21C14934D037563D930F48198A0AA7C14058229493D22530F4DBFA336F6E0AC925139543AED44CCE7C3720FD51F69458705AC68CD4FE6B6B13ABDC9746512969328454F18FAF8C595F642477FE96BB2A941D5BCD1D4AC8CC49880708FA9B378E3C4F3A9060BEE67CF9A4A4A695811051907E162753B56B0F6B410DBA74D8A84B2A14B3144E0EF1284754FD17ED950D5965B4B9DD46582DB1178D169C6BC465B0D6FF9CA3928FEF5B9AE4E418FC15E83EBEA0F87FA9FF5EED70050DED2849F47BF959D956850CE929851F0D8115F635B105EE2E4E15D04B2454BF6F4FADF034B10403119CD8E3B92FCC5B" + }; + public static class TPFactorizedValue { public long p, q; } @@ -84,6 +88,39 @@ public class Utilities { return ApplicationLoader.applicationContext.getCacheDir(); } + final protected static char[] hexArray = "0123456789ABCDEF".toCharArray(); + public static String bytesToHex(byte[] bytes) { + char[] hexChars = new char[bytes.length * 2]; + int v; + for ( int j = 0; j < bytes.length; j++ ) { + v = bytes[j] & 0xFF; + hexChars[j * 2] = hexArray[v >>> 4]; + hexChars[j * 2 + 1] = hexArray[v & 0x0F]; + } + return new String(hexChars); + } + + public static boolean isGoodPrime(byte[] prime) { + String hex = bytesToHex(prime); + for (String cached : goodPrimes) { + if (cached.equals(hex)) { + return true; + } + } + + if (prime.length != 256 || prime[0] >= 0) { + return false; + } + + BigInteger dhBI = new BigInteger(1, prime); + BigInteger dhBI2 = dhBI.subtract(BigInteger.valueOf(1)).divide(BigInteger.valueOf(2)); + if (!dhBI.isProbablePrime(30) || !dhBI2.isProbablePrime(30)) { + return false; + } + + return true; + } + public static TPFactorizedValue getFactorizedValue(long what) { long g = doPQNative(what); if (g > 1 && g < what) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatProfileActivity.java index 38bcd618..69c4ffc7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatProfileActivity.java @@ -410,6 +410,9 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen private void processPhotoMenu(int action) { if (action == 0) { + if (parentActivity == null) { + return; + } TLRPC.Chat chat = MessagesController.Instance.chats.get(chat_id); if (chat.photo != null && chat.photo.photo_big != null) { NotificationCenter.Instance.addToMemCache(53, chat.photo.photo_big); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java index 68043f12..ef93b8ed 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java @@ -157,14 +157,10 @@ public class LoginActivity extends ActionBarActivity implements SlideView.SlideV } public void setPage(int page, boolean animated, Bundle params, boolean back) { - if(android.os.Build.VERSION.SDK_INT > 11) { + if(android.os.Build.VERSION.SDK_INT > 13) { Point displaySize = new Point(); Display display = getWindowManager().getDefaultDisplay(); - if(android.os.Build.VERSION.SDK_INT < 13) { - displaySize.set(display.getWidth(), display.getHeight()); - } else { - display.getSize(displaySize); - } + display.getSize(displaySize); final SlideView outView = views[currentViewNum]; final SlideView newView = views[page]; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java index 0a38f67f..45c0266f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java @@ -257,8 +257,10 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen String name = null; if (ringtone != null) { Ringtone rng = RingtoneManager.getRingtone(ApplicationLoader.applicationContext, ringtone); - name = rng.getTitle(ApplicationLoader.applicationContext); - rng.stop(); + if (rng != null) { + name = rng.getTitle(ApplicationLoader.applicationContext); + rng.stop(); + } } SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); @@ -276,7 +278,6 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen editor.commit(); listView.invalidateViews(); } - } public void didReceivedNotification(int id, Object... args) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/SizeNotifierRelativeLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/SizeNotifierRelativeLayout.java index 76257452..a2b81dd2 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/SizeNotifierRelativeLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/SizeNotifierRelativeLayout.java @@ -39,9 +39,11 @@ public class SizeNotifierRelativeLayout extends RelativeLayout { @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); - int usableViewHeight = this.getRootView().getHeight() - Utilities.statusBarHeight; - this.getWindowVisibleDisplayFrame(rect); - int keyboardHeight = usableViewHeight - (rect.bottom - rect.top); - delegate.onSizeChanged(keyboardHeight); + if (delegate != null) { + int usableViewHeight = this.getRootView().getHeight() - Utilities.statusBarHeight; + this.getWindowVisibleDisplayFrame(rect); + int keyboardHeight = usableViewHeight - (rect.bottom - rect.top); + delegate.onSizeChanged(keyboardHeight); + } } }