mirror of
https://github.com/wrwrabbit/Partisan-Telegram-Android.git
synced 2026-05-27 08:44:44 +00:00
Merge branch 'dev' into secret_groups
# Conflicts: # .github/workflows/alpha.yml # .github/workflows/beta.yml # TMessagesProj/src/main/assets/strings/strings_be.xml # TMessagesProj/src/main/assets/strings/strings_ru.xml # TMessagesProj/src/main/java/org/telegram/messenger/partisan/PartisanVersion.java # TMessagesProj/src/main/res/values/strings.xml
This commit is contained in:
commit
cf2bae9e92
21 changed files with 218 additions and 77 deletions
2
.github/workflows/alpha.yml
vendored
2
.github/workflows/alpha.yml
vendored
|
|
@ -18,7 +18,7 @@ jobs:
|
|||
- name: Save artifact
|
||||
uses: actions/upload-artifact@master
|
||||
with:
|
||||
name: PTelegramAlpha-v1515.apk
|
||||
name: PTelegramAlpha-1518.apk
|
||||
path: TMessagesProj/build/outputs/apk/afat/alpha/app.apk
|
||||
- name: Create cleanup request
|
||||
run: touch delete_request
|
||||
|
|
|
|||
2
.github/workflows/beta.yml
vendored
2
.github/workflows/beta.yml
vendored
|
|
@ -18,7 +18,7 @@ jobs:
|
|||
- name: Save artifact
|
||||
uses: actions/upload-artifact@master
|
||||
with:
|
||||
name: PTelegramBeta-v1515.apk
|
||||
name: PTelegramBeta-v1518.apk
|
||||
path: TMessagesProj/build/outputs/apk/afat/debug/app.apk
|
||||
- name: Create cleanup request
|
||||
run: touch delete_request
|
||||
|
|
|
|||
|
|
@ -263,6 +263,7 @@
|
|||
<string name="MigrationErrorSrcVersionOldDescription">Бягучае прыкладанне састарэла і не можа перадаць дадзеныя ў новае прыкладанне. Абнавіце яго і паспрабуйце яшчэ раз.</string>
|
||||
<string name="MigrationErrorUnknownDescription">Адбылася невядомая памылка. Абнавіце абодва прыкладанні і паспрабуйце яшчэ раз. %1$s</string>
|
||||
<string name="MigrationContactPtgSupport">Калі памылка застаецца, калі ласка, звяжыцеся з тэхпадтрымкай Партызанскага Тэлеграма.</string>
|
||||
<string name="ContinueMaskedMigrationDescription">Здаецца, Вы выправілі ўсе праблемы. Жадаеце аднавіць міграцыю?</string>
|
||||
<string name="NewEncryptedGroup">Новая сакрэтная група</string>
|
||||
<string name="AreYouSureClearHistoryWithSecretGroup">Вы ўпэўненыя, што хочаце ачысціць гісторыю чата **%1$s** толькі для сябе? У іншых удзельнікаў яна застанецца даступнай.</string>
|
||||
<string name="AreYouSureDeleteThisSecretGroup">Вы ўпэўненыя, што хочаце выгаліць гэтую сакрэтную групу: **%1$s**?</string>
|
||||
|
|
|
|||
|
|
@ -268,6 +268,7 @@
|
|||
<string name="IssuePasswordlessModeDescription">Ложные код-пароли с беспарольным режимом не разрешёны в замаскированном приложении. Отключите этот режим в код-паролях или удалите эти код-пароли.</string>
|
||||
<string name="IssueActivateByFingerprintDescription">Код-пароли с активацией по отпечатку пальца не разрешены в замаскированном приложении. Отключите эту опцию.</string>
|
||||
<string name="PasswordToPinSwitchWarning">Если у Вас были ложные код-пароли, состоящие не из 4 цифры, их не получится ввести. Мы рекомендуем изменить их.</string>
|
||||
<string name="ContinueMaskedMigrationDescription">Кажется, Вы исправили все проблемы. Хотите возобновить миграцию?</string>
|
||||
<string name="NewEncryptedGroup">Создать секретную группу</string>
|
||||
<string name="AreYouSureClearHistoryWithSecretGroup">Вы точно хотите удалить историю секретной группы **%1$s** только для себя? У других участников она останется доступной.</string>
|
||||
<string name="AreYouSureDeleteThisSecretGroup">Вы точно хотите удалить эту секретную группу: **%1$s**?</string>
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@ package org.telegram.messenger.partisan;
|
|||
|
||||
public class PartisanVersion {
|
||||
public static final String PARTISAN_VERSION_STRING = "3.8.0";
|
||||
public static int PARTISAN_BUILD_VERSION = 1515;
|
||||
public static int PARTISAN_BUILD_VERSION = 1518;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -357,6 +357,7 @@ public class AppMigrationActivity extends BaseFragment implements MigrationZipBu
|
|||
AppMigrator.disableConnection();
|
||||
migrationFinished(data.getStringExtra("packageName"));
|
||||
} else {
|
||||
saveMigrationIssuesIfNeeded(data);
|
||||
AppMigrator.enableConnection();
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(LocaleController.getString(R.string.MigrationTitle));
|
||||
|
|
@ -369,6 +370,16 @@ public class AppMigrationActivity extends BaseFragment implements MigrationZipBu
|
|||
}
|
||||
}
|
||||
|
||||
private static void saveMigrationIssuesIfNeeded(Intent data) {
|
||||
String error = data.getStringExtra("error");
|
||||
if ("settingsDoNotSuitMaskedApps".equals(error)) {
|
||||
String[] issues = data.getStringArrayExtra("issues");
|
||||
if (issues != null) {
|
||||
MaskedMigratorHelper.setMigrationIssues(issues);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String getErrorMessage(Intent data) {
|
||||
String error = data.getStringExtra("error");
|
||||
if ("alreadyHasAccounts".equals(error)) {
|
||||
|
|
@ -393,15 +404,19 @@ public class AppMigrationActivity extends BaseFragment implements MigrationZipBu
|
|||
}
|
||||
|
||||
private static String getMigrationIssueDescription(String issue) {
|
||||
if ("invalidPasscodeType".equals(issue)) {
|
||||
return LocaleController.getString(R.string.IssueInvalidPasscodeTypeDescription);
|
||||
} else if ("passwordlessMode".equals(issue)) {
|
||||
return LocaleController.getString(R.string.IssuePasswordlessModeDescription);
|
||||
} else if ("activateByFingerprint".equals(issue)) {
|
||||
return LocaleController.getString(R.string.IssueActivateByFingerprintDescription);
|
||||
} else {
|
||||
return LocaleController.formatString(R.string.MigrationErrorUnknownDescription, LocaleController.getString(R.string.MigrationContactPtgSupport));
|
||||
try {
|
||||
switch (MaskedMigrationIssue.valueOf(issue)) {
|
||||
case INVALID_PASSCODE_TYPE:
|
||||
return LocaleController.getString(R.string.IssueInvalidPasscodeTypeDescription);
|
||||
case PASSWORDLESS_MODE:
|
||||
return LocaleController.getString(R.string.IssuePasswordlessModeDescription);
|
||||
case ACTIVATE_BY_FINGERPRINT:
|
||||
return LocaleController.getString(R.string.IssueActivateByFingerprintDescription);
|
||||
}
|
||||
} catch (IllegalArgumentException ignore) {
|
||||
}
|
||||
|
||||
return LocaleController.formatString(R.string.MigrationErrorUnknownDescription, LocaleController.getString(R.string.MigrationContactPtgSupport));
|
||||
}
|
||||
|
||||
private void checkThread() {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import android.net.Uri;
|
|||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Base64;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
|
|
@ -28,6 +29,11 @@ import org.telegram.messenger.partisan.PartisanVersion;
|
|||
import org.telegram.tgnet.ConnectionsManager;
|
||||
import org.telegram.ui.LauncherIconController;
|
||||
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.KeyFactory;
|
||||
import java.security.PublicKey;
|
||||
import java.security.Signature;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
|
@ -39,8 +45,8 @@ public class AppMigrator {
|
|||
public static final int MIGRATE_TO_REGULAR_PTG_CODE = 20202020;
|
||||
public static final int CONFIRM_SIGNATURE_CODE = 20202021;
|
||||
|
||||
private static final String PTG_SIGNATURE = "06480D1C49ADA4A50D7BC57B097271D68AE7707E";
|
||||
private static final String PTG_DEBUG_SIGNATURE = "B134DF916190F59F832BE4E1DE8354DC23444059";
|
||||
private static final String PTG_SIGNATURE = "54EACD58409061FFADD5930A9D8B0A13E5A2B0561A486E5E6B5600480A5BC32A";
|
||||
private static final String PTG_DEBUG_SIGNATURE = "7A7D4936FAD1A022F4DB2B24B8C9687B80C79099D986C05C541D002308872421";
|
||||
private static final List<String> PTG_PACKAGE_NAMES = Arrays.asList(
|
||||
"org.telegram.messenger.web",
|
||||
"org.telegram.messenger"
|
||||
|
|
@ -50,6 +56,17 @@ public class AppMigrator {
|
|||
"org.telegram.messenger.beta"
|
||||
);
|
||||
|
||||
private static final String signatureVerificationPublicKey =
|
||||
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsz15+DMiBNud4pLLdixJ" +
|
||||
"mRNLjqCCDYplCg2ev/UGZGDzEx2mbbV6SLu9z7qYTWgFHhwne0VS5uH4yht3Bq22" +
|
||||
"AAFWNz+T90QtAWl9JvvoYPVGU9/WK2VKTwa7JJMexqm1sLTMlH37+ll2hDeHl1St" +
|
||||
"k0XiwqO8wePqVDelkaNLAIfFqdyo+szAPNeJVAdMKrHcQADluPqyp4ToaKG0n2lN" +
|
||||
"hv4LdGlJhQvFJubWYQ9lGhGpkGnWOGGIq0Y3ztM+SvQmKmZzOhh+Caxtr798FCLl" +
|
||||
"dzmOQbVaU25D04s9j/VBUReFx4h41qP5HTomV5jYJ5pk3erELMiLW5K2/saUqP7E" +
|
||||
"PwIDAQAB";
|
||||
|
||||
private static final String signedAppSignature = null;
|
||||
|
||||
public static boolean startNewTelegram(Activity activity) {
|
||||
Intent intent = createNewTelegramIntent(activity);
|
||||
if (intent == null) {
|
||||
|
|
@ -125,6 +142,9 @@ public class AppMigrator {
|
|||
intent.putExtra("language", LocaleController.getInstance().getLanguageOverride());
|
||||
intent.putExtra("fromOtherPtg", true);
|
||||
intent.putExtra("version", PartisanVersion.PARTISAN_VERSION_STRING);
|
||||
if (signedAppSignature != null) {
|
||||
intent.putExtra("ptgSignatureVerificationByPublicKey", Base64.decode(signedAppSignature, Base64.DEFAULT));
|
||||
}
|
||||
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
return intent;
|
||||
}
|
||||
|
|
@ -270,7 +290,7 @@ public class AppMigrator {
|
|||
return BuildVars.isAlphaApp() || BuildVars.isBetaApp();
|
||||
}
|
||||
|
||||
private static boolean isPtgSignature(PackageInfo packageInfo) {
|
||||
public static boolean isPtgSignature(PackageInfo packageInfo) {
|
||||
return PackageUtils.isPackageSignatureThumbprint(packageInfo, getPtgSignature());
|
||||
}
|
||||
|
||||
|
|
@ -320,4 +340,19 @@ public class AppMigrator {
|
|||
public static boolean appAlreadyHasAccounts() {
|
||||
return UserConfig.getActivatedAccountsCount(true) > 0;
|
||||
}
|
||||
|
||||
public static boolean verifyPtgSignatureByPublicKey(byte[] data, byte[] signature) {
|
||||
try {
|
||||
byte[] publicKeyBytes = Base64.decode(signatureVerificationPublicKey, Base64.DEFAULT);
|
||||
X509EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(publicKeyBytes);
|
||||
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
||||
PublicKey publicKey = keyFactory.generatePublic(publicKeySpec);
|
||||
Signature sig = Signature.getInstance("SHA256withRSA");
|
||||
sig.initVerify(publicKey);
|
||||
sig.update(data);
|
||||
return sig.verify(signature);
|
||||
} catch (GeneralSecurityException ignore) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
package org.telegram.messenger.partisan.appmigration;
|
||||
|
||||
public enum MaskedMigrationIssue {
|
||||
INVALID_PASSCODE_TYPE,
|
||||
PASSWORDLESS_MODE,
|
||||
ACTIVATE_BY_FINGERPRINT,
|
||||
}
|
||||
|
|
@ -2,21 +2,36 @@ package org.telegram.messenger.partisan.appmigration;
|
|||
|
||||
import android.content.pm.PackageInfo;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MessageObject;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.fakepasscode.FakePasscodeUtils;
|
||||
import org.telegram.ui.ActionBar.AlertDialog;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MaskedMigratorHelper {
|
||||
private static final long MASKING_BOT_ID = 7116474629L;
|
||||
public static String MASKING_BOT_USERNAME = "MaskedPtgBot";
|
||||
public static final long MASKING_BOT_ID = 7901437172L;
|
||||
private static final long MASKING_BOT_ID2 = 7138739692L;
|
||||
private static final long MASKING_BOT_ID3 = 7116474629L;
|
||||
private static final Map<File, PackageInfo> fileToPackageInfo = new HashMap<>();
|
||||
private static PackageInfo installingPackageInfo = null;
|
||||
private static Set<MaskedMigrationIssue> migrationIssues = new HashSet<>();
|
||||
|
||||
public static void saveFileMetadataFromMaskingBotIfNeed(File f, MessageObject message) {
|
||||
if (message.messageOwner.from_id.user_id == MASKING_BOT_ID
|
||||
|| message.messageOwner.from_id.user_id == MASKING_BOT_ID2) {
|
||||
|| message.messageOwner.from_id.user_id == MASKING_BOT_ID2
|
||||
|| message.messageOwner.from_id.user_id == MASKING_BOT_ID3) {
|
||||
PackageInfo packageInfo = PackageUtils.extractPackageInfoFromFile(f);
|
||||
if (packageInfo != null) {
|
||||
fileToPackageInfo.put(f, packageInfo);
|
||||
|
|
@ -47,4 +62,39 @@ public class MaskedMigratorHelper {
|
|||
}
|
||||
return installingPackageInfo.applicationInfo.packageName;
|
||||
}
|
||||
|
||||
public static synchronized void setMigrationIssues(String[] issues) {
|
||||
try {
|
||||
migrationIssues = Arrays.asList(issues).stream()
|
||||
.map(MaskedMigrationIssue::valueOf)
|
||||
.collect(Collectors.toSet());
|
||||
} catch (IllegalArgumentException ignore) {
|
||||
migrationIssues = new HashSet<>();
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void removeMigrationIssueAndShowDialogIfNeeded(BaseFragment fragment, MaskedMigrationIssue issue) {
|
||||
if (migrationIssues.remove(issue)) {
|
||||
if (migrationIssues.isEmpty()) {
|
||||
showMigrationCanContinueDialog(fragment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void showMigrationCanContinueDialog(BaseFragment fragment) {
|
||||
if (FakePasscodeUtils.isFakePasscodeActivated()) {
|
||||
return;
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(fragment.getContext());
|
||||
builder.setTitle(LocaleController.getString(R.string.MigrationTitle));
|
||||
builder.setMessage(LocaleController.getString(R.string.ContinueMaskedMigrationDescription));
|
||||
builder.setPositiveButton(LocaleController.getString(R.string.Continue), (dialog1, which) -> {
|
||||
fragment.presentFragment(new AppMigrationActivity());
|
||||
});
|
||||
builder.setNeutralButton(LocaleController.getString(R.string.Cancel), null);
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.setCanCancel(false);
|
||||
dialog.setCancelable(false);
|
||||
fragment.showDialog(dialog);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import android.text.TextUtils;
|
|||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.partisan.appmigration.intenthandlers.AbstractIntentHandler;
|
||||
import org.telegram.messenger.partisan.appmigration.intenthandlers.MigrationResultHandler;
|
||||
import org.telegram.messenger.partisan.appmigration.intenthandlers.SignatureConfirmationHandler;
|
||||
import org.telegram.messenger.partisan.appmigration.intenthandlers.ZipHandler;
|
||||
import org.telegram.messenger.partisan.appmigration.intenthandlers.ZipRequestHandler;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
|
|
@ -16,7 +15,6 @@ import java.util.List;
|
|||
|
||||
public class MigrationIntentHandler {
|
||||
private static final List<AbstractIntentHandler> handlers = List.of(
|
||||
new SignatureConfirmationHandler(),
|
||||
new ZipRequestHandler(),
|
||||
new ZipHandler(),
|
||||
new MigrationResultHandler()
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class PackageUtils {
|
|||
|
||||
public static String getSignatureThumbprint(Signature signature) {
|
||||
try {
|
||||
MessageDigest hash = MessageDigest.getInstance("SHA-1");
|
||||
MessageDigest hash = MessageDigest.getInstance("SHA-256");
|
||||
return Utilities.bytesToHex(hash.digest(signature.toByteArray()));
|
||||
} catch (NoSuchAlgorithmException ignored) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
package org.telegram.messenger.partisan.appmigration.intenthandlers;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.partisan.appmigration.AppMigrator;
|
||||
|
||||
public class SignatureConfirmationHandler extends AbstractIntentHandler {
|
||||
private static boolean signatureConfirmationSent = false;
|
||||
|
||||
@Override
|
||||
public boolean needHandleIntent(Intent intent, Activity activity) {
|
||||
return intent.getBooleanExtra("signatureConfirmationRequired", false)
|
||||
&& allowResponseSignatureConfirmation()
|
||||
&& !signatureConfirmationSent;
|
||||
}
|
||||
|
||||
private static boolean allowResponseSignatureConfirmation() {
|
||||
final boolean isThisAppMasked = false;
|
||||
return isThisAppMasked && !AppMigrator.appAlreadyHasAccounts();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleIntent(Intent intent, Activity activity) {
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
String packageName = intent.getStringExtra("packageName");
|
||||
String activityName = intent.getStringExtra("activityName");
|
||||
if (packageName != null && activityName != null) {
|
||||
signatureConfirmationSent = true;
|
||||
Intent requestZipIntent = new Intent(Intent.ACTION_MAIN);
|
||||
requestZipIntent.setClassName(packageName, activityName);
|
||||
requestZipIntent.putExtra("fromOtherPtg", true);
|
||||
requestZipIntent.putExtra("requestZip", true);
|
||||
activity.startActivityForResult(requestZipIntent, AppMigrator.CONFIRM_SIGNATURE_CODE);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -2,11 +2,15 @@ package org.telegram.messenger.partisan.appmigration.intenthandlers;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.partisan.appmigration.AppMigrator;
|
||||
import org.telegram.messenger.partisan.appmigration.MigrationZipReceiver;
|
||||
import org.telegram.messenger.partisan.appmigration.PackageUtils;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class ZipHandler extends AbstractIntentHandler {
|
||||
private static boolean receivingZip = false;
|
||||
|
|
@ -17,7 +21,21 @@ public class ZipHandler extends AbstractIntentHandler {
|
|||
&& !receivingZip
|
||||
&& !AppMigrator.appAlreadyHasAccounts()
|
||||
&& activity.getCallingActivity() != null
|
||||
&& AppMigrator.isPtgPackageName(activity.getCallingActivity().getPackageName());
|
||||
&& isVerifiedSignature(intent, activity);
|
||||
}
|
||||
|
||||
private boolean isVerifiedSignature(Intent intent, Activity activity) {
|
||||
PackageInfo callingPackageInfo = PackageUtils.getPackageInfoWithCertificates(activity, activity.getCallingPackage());
|
||||
if (AppMigrator.isPtgSignature(callingPackageInfo)) {
|
||||
return true;
|
||||
}
|
||||
byte[] ptgSignatureVerificationByPublicKey = intent.getByteArrayExtra("ptgSignatureVerificationByPublicKey");
|
||||
if (ptgSignatureVerificationByPublicKey == null) {
|
||||
return false;
|
||||
}
|
||||
String thumbprint = PackageUtils.getPackageSignatureThumbprint(callingPackageInfo);
|
||||
byte[] thumbprintBytes = thumbprint.getBytes(StandardCharsets.UTF_8);
|
||||
return AppMigrator.verifyPtgSignatureByPublicKey(thumbprintBytes, ptgSignatureVerificationByPublicKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
package org.telegram.messenger.partisan.update;
|
||||
|
||||
public enum MaskedUpdateType {
|
||||
ALLOW,
|
||||
PROHIBIT,
|
||||
ONLY
|
||||
}
|
||||
|
|
@ -20,6 +20,7 @@ class UpdateMessageParser {
|
|||
private MessageObject currentMessage;
|
||||
private String lang = "en";
|
||||
private int langInaccuracy = 0;
|
||||
private MaskedUpdateType maskedUpdateType = MaskedUpdateType.ALLOW;
|
||||
|
||||
private final int currentAccount;
|
||||
private final Map<Long, List<MessageObject>> messagesByGroupId = new HashMap<>();
|
||||
|
|
@ -142,6 +143,9 @@ class UpdateMessageParser {
|
|||
}
|
||||
isFirstCharInNewLine = lineEnd;
|
||||
}
|
||||
if (maskedUpdateType == MaskedUpdateType.ONLY) {
|
||||
currentUpdate = null;
|
||||
}
|
||||
return currentUpdate;
|
||||
}
|
||||
|
||||
|
|
@ -222,6 +226,16 @@ class UpdateMessageParser {
|
|||
} catch (NumberFormatException ignore) {
|
||||
}
|
||||
}
|
||||
} else if (name.equals("masked")) {
|
||||
if ("allow".equalsIgnoreCase(value)) {
|
||||
maskedUpdateType = MaskedUpdateType.ALLOW;
|
||||
} else if ("prohibit".equalsIgnoreCase(value)) {
|
||||
maskedUpdateType = MaskedUpdateType.PROHIBIT;
|
||||
} else if ("only".equalsIgnoreCase(value)) {
|
||||
maskedUpdateType = MaskedUpdateType.ONLY;
|
||||
} else {
|
||||
maskedUpdateType = MaskedUpdateType.ALLOW;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,19 +8,19 @@ import android.view.ViewTreeObserver;
|
|||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.biometric.BiometricManager;
|
||||
import androidx.core.util.Consumer;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.SharedConfig;
|
||||
import org.telegram.messenger.fakepasscode.FakePasscode;
|
||||
import org.telegram.messenger.fakepasscode.FakePasscodeUtils;
|
||||
import org.telegram.messenger.support.fingerprint.FingerprintManagerCompat;
|
||||
import org.telegram.messenger.partisan.PartisanLog;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.AlertDialog;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
|
|
@ -213,6 +213,7 @@ public class FakePasscodeActivationMethodsActivity extends BaseFragment {
|
|||
if (fakePasscode.activateByFingerprint) {
|
||||
fakePasscode.allowLogin = true;
|
||||
}
|
||||
SharedConfig.useFingerprintLock = fakePasscode.activateByFingerprint;
|
||||
SharedConfig.saveConfig();
|
||||
cell.setChecked(fakePasscode.activateByFingerprint);
|
||||
updateRows();
|
||||
|
|
@ -285,24 +286,21 @@ public class FakePasscodeActivationMethodsActivity extends BaseFragment {
|
|||
activateByTimerRow = rowCount++;
|
||||
activateByTimerDetailRow = rowCount++;
|
||||
|
||||
fingerprintRow = -1;
|
||||
fingerprintDetailRow = -1;
|
||||
|
||||
try {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
FingerprintManagerCompat fingerprintManager = FingerprintManagerCompat.from(ApplicationLoader.applicationContext);
|
||||
if (fingerprintManager.isHardwareDetected() && AndroidUtilities.isKeyguardSecure() && SharedConfig.useFingerprintLock) {
|
||||
boolean allowFingerprint = SharedConfig.useFingerprintLock ||
|
||||
BiometricManager.from(ApplicationLoader.applicationContext).canAuthenticate(BiometricManager.Authenticators.BIOMETRIC_STRONG) == BiometricManager.BIOMETRIC_SUCCESS &&
|
||||
AndroidUtilities.isKeyguardSecure();
|
||||
if (allowFingerprint) {
|
||||
fingerprintRow = rowCount++;
|
||||
fingerprintDetailRow = rowCount++;
|
||||
} else {
|
||||
fingerprintRow = -1;
|
||||
fingerprintDetailRow = -1;
|
||||
}
|
||||
} else {
|
||||
fingerprintRow = -1;
|
||||
fingerprintDetailRow = -1;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
FileLog.e(e);
|
||||
fingerprintRow = -1;
|
||||
fingerprintDetailRow = -1;
|
||||
} catch (Exception e) {
|
||||
PartisanLog.e("Fingerprint error", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@ import org.telegram.messenger.fakepasscode.FakePasscode;
|
|||
import org.telegram.messenger.fakepasscode.FakePasscodeSerializer;
|
||||
import org.telegram.messenger.fakepasscode.SelectionMode;
|
||||
import org.telegram.messenger.fakepasscode.UpdateIdHashRunnable;
|
||||
import org.telegram.messenger.partisan.appmigration.MaskedMigrationIssue;
|
||||
import org.telegram.messenger.partisan.appmigration.MaskedMigratorHelper;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.AlertDialog;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
|
|
@ -436,6 +438,9 @@ public class FakePasscodeActivity extends BaseFragment {
|
|||
if (listAdapter != null) {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
if (!fakePasscode.passwordlessMode && SharedConfig.fakePasscodes.stream().noneMatch(passcode -> passcode.passwordlessMode)) {
|
||||
MaskedMigratorHelper.removeMigrationIssueAndShowDialogIfNeeded(this, MaskedMigrationIssue.PASSWORDLESS_MODE);
|
||||
}
|
||||
};
|
||||
if (!fakePasscode.passwordlessMode && fakePasscode.hasPasswordlessIncompatibleSettings()) {
|
||||
if (getParentActivity() == null) {
|
||||
|
|
@ -527,6 +532,9 @@ public class FakePasscodeActivity extends BaseFragment {
|
|||
if (SharedConfig.fakePasscodes.isEmpty()) {
|
||||
SharedConfig.fakePasscodeIndex = 1;
|
||||
}
|
||||
if (SharedConfig.fakePasscodes.stream().noneMatch(passcode -> passcode.passwordlessMode)) {
|
||||
MaskedMigratorHelper.removeMigrationIssueAndShowDialogIfNeeded(this, MaskedMigrationIssue.PASSWORDLESS_MODE);
|
||||
}
|
||||
SharedConfig.saveConfig();
|
||||
finishFragment();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@ import org.telegram.messenger.UserConfig;
|
|||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.messenger.fakepasscode.FakePasscode;
|
||||
import org.telegram.messenger.fakepasscode.FakePasscodeUtils;
|
||||
import org.telegram.messenger.partisan.appmigration.MaskedMigrationIssue;
|
||||
import org.telegram.messenger.partisan.appmigration.MaskedMigratorHelper;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||
|
|
@ -338,6 +340,9 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
|
|||
passcode.onDelete();
|
||||
}
|
||||
SharedConfig.fakePasscodes.clear();
|
||||
MaskedMigratorHelper.removeMigrationIssueAndShowDialogIfNeeded(this, MaskedMigrationIssue.INVALID_PASSCODE_TYPE);
|
||||
MaskedMigratorHelper.removeMigrationIssueAndShowDialogIfNeeded(this, MaskedMigrationIssue.PASSWORDLESS_MODE);
|
||||
MaskedMigratorHelper.removeMigrationIssueAndShowDialogIfNeeded(this, MaskedMigrationIssue.ACTIVATE_BY_FINGERPRINT);
|
||||
}
|
||||
SharedConfig.setAppLocked(false);
|
||||
SharedConfig.saveConfig();
|
||||
|
|
@ -465,6 +470,13 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
|
|||
SharedConfig.useFingerprintLock = !SharedConfig.useFingerprintLock;
|
||||
if (FakePasscodeUtils.isFakePasscodeActivated()) {
|
||||
FakePasscodeUtils.getActivatedFakePasscode().activateByFingerprint = SharedConfig.useFingerprintLock;
|
||||
} else if (!SharedConfig.useFingerprintLock) {
|
||||
for (FakePasscode fakePasscode : SharedConfig.fakePasscodes) {
|
||||
fakePasscode.activateByFingerprint = false;
|
||||
}
|
||||
}
|
||||
if (!SharedConfig.useFingerprintLock) {
|
||||
MaskedMigratorHelper.removeMigrationIssueAndShowDialogIfNeeded(this, MaskedMigrationIssue.ACTIVATE_BY_FINGERPRINT);
|
||||
}
|
||||
UserConfig.getInstance(currentAccount).saveConfig(false);
|
||||
((TextCheckCell) view).setChecked(SharedConfig.useFingerprintLock);
|
||||
|
|
@ -1275,6 +1287,11 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
|
|||
SharedConfig.allowScreenCapture = true;
|
||||
}
|
||||
|
||||
boolean passcodeTypeChanged = SharedConfig.passcodeType != currentPasswordType;
|
||||
if (passcodeTypeChanged) {
|
||||
MaskedMigratorHelper.removeMigrationIssueAndShowDialogIfNeeded(this, MaskedMigrationIssue.INVALID_PASSCODE_TYPE);
|
||||
}
|
||||
|
||||
SharedConfig.passcodeType = currentPasswordType;
|
||||
SharedConfig.saveConfig();
|
||||
|
||||
|
|
|
|||
|
|
@ -297,6 +297,7 @@ import java.io.File;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.time.LocalDate;
|
||||
|
|
@ -11145,9 +11146,11 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
|||
alert.setPositiveButton(LocaleController.getString("Done", R.string.Done), (dlg, whichButton) -> {
|
||||
try {
|
||||
String salt = "|_}H<{&U.?0c43*krr*bVFH6xt1Y`L}'";
|
||||
byte[] bytes = (salt + editText.getText().toString() + salt).getBytes("UTF-8");
|
||||
byte[] bytes = (salt + editText.getText().toString() + salt).getBytes(StandardCharsets.UTF_8);
|
||||
String hash = Utilities.bytesToHex(Utilities.computeSHA256(bytes, 0, bytes.length));
|
||||
if (hash.equals("0B4E5E1473C07CBB9361FCBE060C43669AEA138B95ECCA7358022FFD2A12B73D")) {
|
||||
if (hash.equals("50FB2E837B1111E4F978D60AFC549F7B130AE65C455E9C04800357F9B06149BA")) {
|
||||
SharedConfig.activatedTesterSettingType = 2;
|
||||
} else if (hash.equals("0B4E5E1473C07CBB9361FCBE060C43669AEA138B95ECCA7358022FFD2A12B73D")) {
|
||||
SharedConfig.activatedTesterSettingType = 1;
|
||||
} else {
|
||||
SharedConfig.activatedTesterSettingType = 0;
|
||||
|
|
|
|||
|
|
@ -318,6 +318,9 @@ public class TesterSettingsActivity extends BaseFragment {
|
|||
private void updateRows() {
|
||||
rowCount = 0;
|
||||
|
||||
phoneOverrideRow = -1;
|
||||
forceAllowScreenshotsRow = -1;
|
||||
|
||||
sessionTerminateActionWarningRow = rowCount++;
|
||||
updateChannelIdRow = rowCount++;
|
||||
updateChannelUsernameRow = rowCount++;
|
||||
|
|
@ -327,14 +330,18 @@ public class TesterSettingsActivity extends BaseFragment {
|
|||
rowCount += simpleDataArray.length;
|
||||
simpleDataEndRow = rowCount;
|
||||
hideDialogIsNotSafeWarningRow = rowCount++;
|
||||
phoneOverrideRow = rowCount++;
|
||||
if (SharedConfig.activatedTesterSettingType >= 2) {
|
||||
phoneOverrideRow = rowCount++;
|
||||
}
|
||||
resetSecurityIssuesRow = rowCount++;
|
||||
activateAllSecurityIssuesRow = rowCount++;
|
||||
editSavedChannelsRow = rowCount++;
|
||||
resetUpdateRow = rowCount++;
|
||||
checkVerificationUpdatesRow = rowCount++;
|
||||
resetVerificationLastCheckTimeRow = rowCount++;
|
||||
forceAllowScreenshotsRow = rowCount++;
|
||||
if (SharedConfig.activatedTesterSettingType >= 2) {
|
||||
forceAllowScreenshotsRow = rowCount++;
|
||||
}
|
||||
saveLogcatAfterRestartRow = rowCount++;
|
||||
if (BuildVars.DEBUG_PRIVATE_VERSION) {
|
||||
showEncryptedChatsFromEncryptedGroupsRow = rowCount++;
|
||||
|
|
|
|||
|
|
@ -8781,6 +8781,7 @@
|
|||
<string name="IssuePasswordlessModeDescription">Fake passcodes with passwordless mode are not allowed in a masked app. Disable this mode in passcodes or delete these passcodes.</string>
|
||||
<string name="IssueActivateByFingerprintDescription">Fingerprint-activated passcodes are not allowed in a masked app. Disable this option.</string>
|
||||
<string name="PasswordToPinSwitchWarning">If you had fake passcodes that did not contain 4 digits, you will not be able to enter them. We recommend changing them.</string>
|
||||
<string name="ContinueMaskedMigrationDescription">It seems you have fixed all the issues. Do you want to resume the migration?</string>
|
||||
<string name="NewEncryptedGroup">New Secret Group</string>
|
||||
<string name="AreYouSureClearHistoryWithSecretGroup">Are you sure you want to clear the secret group history in **%1$s** for yourself only? It will remain accessible to other members.</string>
|
||||
<string name="AreYouSureDeleteThisSecretGroup">Are you sure you want to delete this secret group: **%1$s**?</string>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue