mirror of
https://github.com/DrKLO/Telegram.git
synced 2024-12-22 14:35:03 +01:00
update to 1.3.4
This commit is contained in:
parent
5aee72ee33
commit
02c8efb0df
10 changed files with 96 additions and 17 deletions
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="org.telegram.messenger"
|
package="org.telegram.messenger"
|
||||||
android:versionCode="122"
|
android:versionCode="126"
|
||||||
android:versionName="1.3.2">
|
android:versionName="1.3.4">
|
||||||
|
|
||||||
<supports-screens android:anyDensity="true"
|
<supports-screens android:anyDensity="true"
|
||||||
android:smallScreens="true"
|
android:smallScreens="true"
|
||||||
|
|
|
@ -37,6 +37,9 @@ public class ExportAuthorizationAction extends Action {
|
||||||
ConnectionsManager.Instance.performRpc(exportAuthorization, new RPCRequest.RPCRequestDelegate() {
|
ConnectionsManager.Instance.performRpc(exportAuthorization, new RPCRequest.RPCRequestDelegate() {
|
||||||
@Override
|
@Override
|
||||||
public void run(TLObject response, TLRPC.TL_error error) {
|
public void run(TLObject response, TLRPC.TL_error error) {
|
||||||
|
if (delegate == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (error == null) {
|
if (error == null) {
|
||||||
exportedAuthorization = (TLRPC.TL_auth_exportedAuthorization)response;
|
exportedAuthorization = (TLRPC.TL_auth_exportedAuthorization)response;
|
||||||
beginImport();
|
beginImport();
|
||||||
|
@ -65,6 +68,9 @@ public class ExportAuthorizationAction extends Action {
|
||||||
ConnectionsManager.Instance.performRpc(importAuthorization, new RPCRequest.RPCRequestDelegate() {
|
ConnectionsManager.Instance.performRpc(importAuthorization, new RPCRequest.RPCRequestDelegate() {
|
||||||
@Override
|
@Override
|
||||||
public void run(TLObject response, TLRPC.TL_error error) {
|
public void run(TLObject response, TLRPC.TL_error error) {
|
||||||
|
if (delegate == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (error == null) {
|
if (error == null) {
|
||||||
delegate.ActionDidFinishExecution(ExportAuthorizationAction.this, null);
|
delegate.ActionDidFinishExecution(ExportAuthorizationAction.this, null);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -178,6 +178,7 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti
|
||||||
Utilities.globalQueue.postRunnable(new Runnable() {
|
Utilities.globalQueue.postRunnable(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
final Utilities.TPFactorizedValue factorizedPq = Utilities.getFactorizedValue(pqf);
|
final Utilities.TPFactorizedValue factorizedPq = Utilities.getFactorizedValue(pqf);
|
||||||
|
|
||||||
Utilities.stageQueue.postRunnable(new Runnable() {
|
Utilities.stageQueue.postRunnable(new Runnable() {
|
||||||
|
@ -323,6 +324,10 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Utilities.isGoodPrime(dhInnerData.dh_prime)) {
|
||||||
|
throw new RuntimeException("bad prime");
|
||||||
|
}
|
||||||
|
|
||||||
if (!Arrays.equals(authNonce, dhInnerData.nonce)) {
|
if (!Arrays.equals(authNonce, dhInnerData.nonce)) {
|
||||||
FileLog.e("tmessages", "***** Invalid DH nonce");
|
FileLog.e("tmessages", "***** Invalid DH nonce");
|
||||||
beginHandshake(false);
|
beginHandshake(false);
|
||||||
|
@ -339,12 +344,13 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti
|
||||||
b[a] = (byte)(MessagesController.random.nextDouble() * 255);
|
b[a] = (byte)(MessagesController.random.nextDouble() * 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BigInteger dhBI = new BigInteger(1, dhInnerData.dh_prime);
|
||||||
BigInteger i_g_b = BigInteger.valueOf(dhInnerData.g);
|
BigInteger i_g_b = BigInteger.valueOf(dhInnerData.g);
|
||||||
i_g_b = i_g_b.modPow(new BigInteger(1, b), new BigInteger(1, dhInnerData.dh_prime));
|
i_g_b = i_g_b.modPow(new BigInteger(1, b), dhBI);
|
||||||
byte[] g_b = i_g_b.toByteArray();
|
byte[] g_b = i_g_b.toByteArray();
|
||||||
|
|
||||||
BigInteger i_authKey = new BigInteger(1, dhInnerData.g_a);
|
BigInteger i_authKey = new BigInteger(1, dhInnerData.g_a);
|
||||||
i_authKey = i_authKey.modPow(new BigInteger(1, b), new BigInteger(1, dhInnerData.dh_prime));
|
i_authKey = i_authKey.modPow(new BigInteger(1, b), dhBI);
|
||||||
|
|
||||||
authKey = i_authKey.toByteArray();
|
authKey = i_authKey.toByteArray();
|
||||||
if (authKey.length > 256) {
|
if (authKey.length > 256) {
|
||||||
|
|
|
@ -1224,6 +1224,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||||
|
|
||||||
for (TLRPC.TL_contact value : contactsArr) {
|
for (TLRPC.TL_contact value : contactsArr) {
|
||||||
TLRPC.User user = usersDict.get(value.user_id);
|
TLRPC.User user = usersDict.get(value.user_id);
|
||||||
|
if (user == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
contactsDictionery.put(value.user_id, value);
|
contactsDictionery.put(value.user_id, value);
|
||||||
contactsPhones.put(user.phone, value);
|
contactsPhones.put(user.phone, value);
|
||||||
|
|
||||||
|
@ -4880,6 +4883,12 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||||
if (error == null) {
|
if (error == null) {
|
||||||
TLRPC.messages_DhConfig res = (TLRPC.messages_DhConfig)response;
|
TLRPC.messages_DhConfig res = (TLRPC.messages_DhConfig)response;
|
||||||
if (response instanceof TLRPC.TL_messages_dhConfig) {
|
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.secretPBytes = res.p;
|
||||||
MessagesStorage.secretG = res.g;
|
MessagesStorage.secretG = res.g;
|
||||||
MessagesStorage.lastSecretVersion = res.version;
|
MessagesStorage.lastSecretVersion = res.version;
|
||||||
|
@ -4967,6 +4976,17 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||||
if (error == null) {
|
if (error == null) {
|
||||||
TLRPC.messages_DhConfig res = (TLRPC.messages_DhConfig)response;
|
TLRPC.messages_DhConfig res = (TLRPC.messages_DhConfig)response;
|
||||||
if (response instanceof TLRPC.TL_messages_dhConfig) {
|
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.secretPBytes = res.p;
|
||||||
MessagesStorage.secretG = res.g;
|
MessagesStorage.secretG = res.g;
|
||||||
MessagesStorage.lastSecretVersion = res.version;
|
MessagesStorage.lastSecretVersion = res.version;
|
||||||
|
|
|
@ -85,6 +85,14 @@ public class TcpConnection extends PyroClientAdapter {
|
||||||
|
|
||||||
connectionState = TcpConnectionState.TcpConnectionStageConnecting;
|
connectionState = TcpConnectionState.TcpConnectionStageConnecting;
|
||||||
try {
|
try {
|
||||||
|
try {
|
||||||
|
if (reconnectTimer != null) {
|
||||||
|
reconnectTimer.cancel();
|
||||||
|
reconnectTimer = null;
|
||||||
|
}
|
||||||
|
} catch (Exception e2) {
|
||||||
|
FileLog.e("tmessages", e2);
|
||||||
|
}
|
||||||
Datacenter datacenter = ConnectionsManager.Instance.datacenterWithId(datacenterId);
|
Datacenter datacenter = ConnectionsManager.Instance.datacenterWithId(datacenterId);
|
||||||
hostAddress = datacenter.getCurrentAddress();
|
hostAddress = datacenter.getCurrentAddress();
|
||||||
hostPort = datacenter.getCurrentPort();
|
hostPort = datacenter.getCurrentPort();
|
||||||
|
|
|
@ -55,6 +55,10 @@ public class Utilities {
|
||||||
public static int statusBarHeight = 0;
|
public static int statusBarHeight = 0;
|
||||||
private final static Integer lock = 1;
|
private final static Integer lock = 1;
|
||||||
|
|
||||||
|
public static String[] goodPrimes = {
|
||||||
|
"C71CAEB9C6B1C9048E6C522F70F13F73980D40238E3E21C14934D037563D930F48198A0AA7C14058229493D22530F4DBFA336F6E0AC925139543AED44CCE7C3720FD51F69458705AC68CD4FE6B6B13ABDC9746512969328454F18FAF8C595F642477FE96BB2A941D5BCD1D4AC8CC49880708FA9B378E3C4F3A9060BEE67CF9A4A4A695811051907E162753B56B0F6B410DBA74D8A84B2A14B3144E0EF1284754FD17ED950D5965B4B9DD46582DB1178D169C6BC465B0D6FF9CA3928FEF5B9AE4E418FC15E83EBEA0F87FA9FF5EED70050DED2849F47BF959D956850CE929851F0D8115F635B105EE2E4E15D04B2454BF6F4FADF034B10403119CD8E3B92FCC5B"
|
||||||
|
};
|
||||||
|
|
||||||
public static class TPFactorizedValue {
|
public static class TPFactorizedValue {
|
||||||
public long p, q;
|
public long p, q;
|
||||||
}
|
}
|
||||||
|
@ -84,6 +88,39 @@ public class Utilities {
|
||||||
return ApplicationLoader.applicationContext.getCacheDir();
|
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) {
|
public static TPFactorizedValue getFactorizedValue(long what) {
|
||||||
long g = doPQNative(what);
|
long g = doPQNative(what);
|
||||||
if (g > 1 && g < what) {
|
if (g > 1 && g < what) {
|
||||||
|
|
|
@ -410,6 +410,9 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
||||||
|
|
||||||
private void processPhotoMenu(int action) {
|
private void processPhotoMenu(int action) {
|
||||||
if (action == 0) {
|
if (action == 0) {
|
||||||
|
if (parentActivity == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
TLRPC.Chat chat = MessagesController.Instance.chats.get(chat_id);
|
TLRPC.Chat chat = MessagesController.Instance.chats.get(chat_id);
|
||||||
if (chat.photo != null && chat.photo.photo_big != null) {
|
if (chat.photo != null && chat.photo.photo_big != null) {
|
||||||
NotificationCenter.Instance.addToMemCache(53, chat.photo.photo_big);
|
NotificationCenter.Instance.addToMemCache(53, chat.photo.photo_big);
|
||||||
|
|
|
@ -157,14 +157,10 @@ public class LoginActivity extends ActionBarActivity implements SlideView.SlideV
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPage(int page, boolean animated, Bundle params, boolean back) {
|
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();
|
Point displaySize = new Point();
|
||||||
Display display = getWindowManager().getDefaultDisplay();
|
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 outView = views[currentViewNum];
|
||||||
final SlideView newView = views[page];
|
final SlideView newView = views[page];
|
||||||
|
|
|
@ -257,9 +257,11 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
||||||
String name = null;
|
String name = null;
|
||||||
if (ringtone != null) {
|
if (ringtone != null) {
|
||||||
Ringtone rng = RingtoneManager.getRingtone(ApplicationLoader.applicationContext, ringtone);
|
Ringtone rng = RingtoneManager.getRingtone(ApplicationLoader.applicationContext, ringtone);
|
||||||
|
if (rng != null) {
|
||||||
name = rng.getTitle(ApplicationLoader.applicationContext);
|
name = rng.getTitle(ApplicationLoader.applicationContext);
|
||||||
rng.stop();
|
rng.stop();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||||
SharedPreferences.Editor editor = preferences.edit();
|
SharedPreferences.Editor editor = preferences.edit();
|
||||||
|
@ -276,7 +278,6 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
||||||
editor.commit();
|
editor.commit();
|
||||||
listView.invalidateViews();
|
listView.invalidateViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void didReceivedNotification(int id, Object... args) {
|
public void didReceivedNotification(int id, Object... args) {
|
||||||
|
|
|
@ -39,9 +39,11 @@ public class SizeNotifierRelativeLayout extends RelativeLayout {
|
||||||
@Override
|
@Override
|
||||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||||
super.onLayout(changed, l, t, r, b);
|
super.onLayout(changed, l, t, r, b);
|
||||||
|
if (delegate != null) {
|
||||||
int usableViewHeight = this.getRootView().getHeight() - Utilities.statusBarHeight;
|
int usableViewHeight = this.getRootView().getHeight() - Utilities.statusBarHeight;
|
||||||
this.getWindowVisibleDisplayFrame(rect);
|
this.getWindowVisibleDisplayFrame(rect);
|
||||||
int keyboardHeight = usableViewHeight - (rect.bottom - rect.top);
|
int keyboardHeight = usableViewHeight - (rect.bottom - rect.top);
|
||||||
delegate.onSizeChanged(keyboardHeight);
|
delegate.onSizeChanged(keyboardHeight);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue