mirror of
https://github.com/wrwrabbit/Partisan-Telegram-Android.git
synced 2026-04-29 04:29:33 +00:00
update to 2.9.1
This commit is contained in:
parent
2b8304ebf4
commit
2b81b7f01e
180 changed files with 13675 additions and 8826 deletions
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* This is the source code of Telegram for Android v. 1.3.2.
|
||||
* This is the source code of Telegram for Android v. 2.x.x.
|
||||
* It is licensed under GNU GPL v. 2 or later.
|
||||
* You should have received a copy of the license in this archive (see LICENSE).
|
||||
*
|
||||
* Copyright Nikolai Kudashov, 2013.
|
||||
* Copyright Nikolai Kudashov, 2013-2015.
|
||||
*/
|
||||
|
||||
package org.telegram.messenger;
|
||||
|
|
@ -17,6 +17,7 @@ import org.telegram.android.MessagesStorage;
|
|||
import java.io.File;
|
||||
|
||||
public class UserConfig {
|
||||
|
||||
private static TLRPC.User currentUser;
|
||||
public static boolean registeredForPush = false;
|
||||
public static boolean registeredForInternalPush = false;
|
||||
|
|
@ -31,6 +32,7 @@ public class UserConfig {
|
|||
public static boolean saveIncomingPhotos = false;
|
||||
public static int contactsVersion = 1;
|
||||
public static String passcodeHash = "";
|
||||
public static byte[] passcodeSalt = new byte[0];
|
||||
public static boolean appLocked = false;
|
||||
public static int passcodeType = 0;
|
||||
public static int autoLockIn = 60 * 60;
|
||||
|
|
@ -68,6 +70,7 @@ public class UserConfig {
|
|||
editor.putBoolean("registeredForInternalPush", registeredForInternalPush);
|
||||
editor.putBoolean("blockedUsersLoaded", blockedUsersLoaded);
|
||||
editor.putString("passcodeHash1", passcodeHash);
|
||||
editor.putString("passcodeSalt", passcodeSalt.length > 0 ? Base64.encodeToString(passcodeSalt, Base64.DEFAULT) : "");
|
||||
editor.putBoolean("appLocked", appLocked);
|
||||
editor.putInt("passcodeType", passcodeType);
|
||||
editor.putInt("autoLockIn", autoLockIn);
|
||||
|
|
@ -85,6 +88,7 @@ public class UserConfig {
|
|||
} else {
|
||||
editor.remove("user");
|
||||
}
|
||||
|
||||
editor.commit();
|
||||
if (oldFile != null) {
|
||||
oldFile.delete();
|
||||
|
|
@ -211,10 +215,51 @@ public class UserConfig {
|
|||
data.cleanup();
|
||||
}
|
||||
}
|
||||
String passcodeSaltString = preferences.getString("passcodeSalt", "");
|
||||
if (passcodeSaltString.length() > 0) {
|
||||
passcodeSalt = Base64.decode(passcodeSaltString, Base64.DEFAULT);
|
||||
} else {
|
||||
passcodeSalt = new byte[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean checkPasscode(String passcode) {
|
||||
if (passcodeSalt.length == 0) {
|
||||
boolean result = Utilities.MD5(passcode).equals(passcodeHash);
|
||||
if (result) {
|
||||
try {
|
||||
passcodeSalt = new byte[16];
|
||||
Utilities.random.nextBytes(passcodeSalt);
|
||||
byte[] passcodeBytes = passcode.getBytes("UTF-8");
|
||||
byte[] bytes = new byte[32 + passcodeBytes.length];
|
||||
System.arraycopy(passcodeSalt, 0, bytes, 0, 16);
|
||||
System.arraycopy(passcodeBytes, 0, bytes, 16, passcodeBytes.length);
|
||||
System.arraycopy(passcodeSalt, 0, bytes, passcodeBytes.length + 16, 16);
|
||||
passcodeHash = Utilities.bytesToHex(Utilities.computeSHA256(bytes, 0, bytes.length));
|
||||
saveConfig(false);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
try {
|
||||
byte[] passcodeBytes = passcode.getBytes("UTF-8");
|
||||
byte[] bytes = new byte[32 + passcodeBytes.length];
|
||||
System.arraycopy(passcodeSalt, 0, bytes, 0, 16);
|
||||
System.arraycopy(passcodeBytes, 0, bytes, 16, passcodeBytes.length);
|
||||
System.arraycopy(passcodeSalt, 0, bytes, passcodeBytes.length + 16, 16);
|
||||
String hash = Utilities.bytesToHex(Utilities.computeSHA256(bytes, 0, bytes.length));
|
||||
return passcodeHash.equals(hash);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void clearConfig() {
|
||||
currentUser = null;
|
||||
registeredForInternalPush = false;
|
||||
|
|
@ -229,6 +274,7 @@ public class UserConfig {
|
|||
appLocked = false;
|
||||
passcodeType = 0;
|
||||
passcodeHash = "";
|
||||
passcodeSalt = new byte[0];
|
||||
autoLockIn = 60 * 60;
|
||||
lastPauseTime = 0;
|
||||
isWaitingForPasscodeEnter = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue