Skip to content

Commit

Permalink
Update to 8.8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
xaxtix committed Jun 21, 2022
1 parent 32aef72 commit 96dce2c
Show file tree
Hide file tree
Showing 2,710 changed files with 40,262 additions and 11,863 deletions.
87 changes: 12 additions & 75 deletions TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ dependencies {
implementation 'com.googlecode.mp4parser:isoparser:1.0.6'
implementation 'com.stripe:stripe-android:2.0.2'
implementation 'com.google.mlkit:language-id:16.1.1'
implementation 'com.android.billingclient:billing:5.0.0'
implementation files('libs/libgsaverification-client.aar')

implementation "com.android.billingclient:billing:5.0.0"

coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
}

Expand Down Expand Up @@ -189,96 +192,30 @@ android {
flavorDimensions "minApi"

productFlavors {
armv7 {
bundleAfat {
ndk {
abiFilters "armeabi-v7a"
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
}
ext {
abiVersionCode = 1
}
}
x86 {
ndk {
abiFilters "x86"
}
ext {
abiVersionCode = 2
}
}
armv7_SDK23 {
bundleAfat_SDK23 {
ndk {
abiFilters "armeabi-v7a"
}
sourceSets.debug {
manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml'
}
sourceSets.release {
manifest.srcFile 'config/release/AndroidManifest_SDK23.xml'
}
minSdkVersion 23
ext {
abiVersionCode = 3
}
}
x86_SDK23 {
ndk {
abiFilters "x86"
}
sourceSets.debug {
manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml'
}
sourceSets.release {
manifest.srcFile 'config/release/AndroidManifest_SDK23.xml'
}
minSdkVersion 23
ext {
abiVersionCode = 4
}
}
arm64 {
ndk {
abiFilters "arm64-v8a"
}
ext {
abiVersionCode = 5
}
}
x64 {
ndk {
abiFilters "x86_64"
}
ext {
abiVersionCode = 6
}
}
arm64_SDK23 {
ndk {
abiFilters "arm64-v8a"
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
}
sourceSets.debug {
manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml'
}
sourceSets.release {
manifest.srcFile 'config/release/AndroidManifest_SDK23.xml'
}
minSdkVersion 23
ext {
abiVersionCode = 7
}
}
x64_SDK23 {
ndk {
abiFilters "x86_64"
}
sourceSets.debug {
manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml'
}
sourceSets.release {
manifest.srcFile 'config/release/AndroidManifest_SDK23.xml'
sourceSets.standalone {
manifest.srcFile 'config/release/AndroidManifest_standalone.xml'
}
minSdkVersion 23
ext {
abiVersionCode = 8
abiVersionCode = 2
}
}
afat {
Expand All @@ -300,7 +237,7 @@ android {
}
}

defaultConfig.versionCode = 2636
defaultConfig.versionCode = 2702

applicationVariants.all { variant ->
variant.outputs.all { output ->
Expand All @@ -319,7 +256,7 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 30
versionName "8.7.4"
versionName "8.8.2"

vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']

Expand Down
4 changes: 2 additions & 2 deletions TMessagesProj/jni/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ static int writeOggPage(ogg_page *page, FILE *os) {
return written;
}

const opus_int32 bitrate = 30 * 1024;
const opus_int32 bitrate = OPUS_BITRATE_MAX;
const opus_int32 frame_size = 960;
const int with_cvbr = 1;
const int max_ogg_delay = 0;
Expand Down Expand Up @@ -322,7 +322,7 @@ int initRecorder(const char *path, opus_int32 sampleRate) {
header.nb_streams = 1;

int result = OPUS_OK;
_encoder = opus_encoder_create(coding_rate, 1, OPUS_APPLICATION_AUDIO, &result);
_encoder = opus_encoder_create(coding_rate, 1, OPUS_APPLICATION_VOIP, &result);
if (result != OPUS_OK) {
LOGE("Error cannot create encoder: %s", opus_strerror(result));
return 0;
Expand Down
30 changes: 30 additions & 0 deletions TMessagesProj/jni/lottie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ typedef struct LottieInfo {
volatile uint32_t maxFrameSize = 0;
uint32_t imageSize = 0;
uint32_t fileOffset = 0;
uint32_t fileFrame = 0;
bool nextFrameIsCacheFrame = false;

FILE *precacheFile = nullptr;
Expand Down Expand Up @@ -146,6 +147,7 @@ JNIEXPORT jlong Java_org_telegram_ui_Components_RLottieDrawable_create(JNIEnv *e
info->maxFrameSize = maxFrameSize;
fread(&(info->imageSize), sizeof(uint32_t), 1, precacheFile);
info->fileOffset = 9;
info->fileFrame = 0;
utimensat(0, info->cacheFile.c_str(), nullptr, 0);
}
fclose(precacheFile);
Expand All @@ -162,6 +164,18 @@ JNIEXPORT jlong Java_org_telegram_ui_Components_RLottieDrawable_create(JNIEnv *e
return (jlong) (intptr_t) info;
}

JNIEXPORT jstring Java_org_telegram_ui_Components_RLottieDrawable_getCacheFile(JNIEnv *env, jclass clazz, jlong ptr) {
if (!ptr) {
return NULL;
}
auto info = (LottieInfo *) (intptr_t) ptr;
if (info->precache) {
return env->NewStringUTF(info->cacheFile.c_str());
}
return NULL;
}


JNIEXPORT jlong Java_org_telegram_ui_Components_RLottieDrawable_createWithJson(JNIEnv *env, jclass clazz, jstring json, jstring name, jintArray data, jintArray colorReplacement) {
std::map<int32_t, int32_t> *colors = nullptr;
if (colorReplacement != nullptr) {
Expand Down Expand Up @@ -271,6 +285,7 @@ void CacheWriteThreadProc() {
if (task->firstFrame) {
task->firstFrameSize = size;
task->fileOffset = 9 + sizeof(uint32_t) + task->firstFrameSize;
task->fileFrame = 1;
}
task->maxFrameSize = MAX(task->maxFrameSize, size);
fwrite(&size, sizeof(uint32_t), 1, task->precacheFile);
Expand Down Expand Up @@ -310,6 +325,7 @@ JNIEXPORT void Java_org_telegram_ui_Components_RLottieDrawable_createCache(JNIEn
info->precacheFile = fopen(info->cacheFile.c_str(), "w+");
if (info->precacheFile != nullptr) {
fseek(info->precacheFile, info->fileOffset = 9, SEEK_SET);
info->fileFrame = 0;
info->maxFrameSize = 0;
info->bufferSize = w * h * 4;
info->imageSize = (uint32_t) w * h * 4;
Expand Down Expand Up @@ -393,18 +409,32 @@ JNIEXPORT jint Java_org_telegram_ui_Components_RLottieDrawable_getFrame(JNIEnv *
}
info->decompressBuffer = new uint8_t[info->decompressBufferSize];
}
int currentFrame = frame / framesPerUpdate;
if (info->fileFrame != frame) {
info->fileOffset = 9;
info->fileFrame = 0;
while (info->fileFrame != currentFrame) {
fseek(precacheFile, info->fileOffset, SEEK_SET);
uint32_t frameSize;
fread(&frameSize, sizeof(uint32_t), 1, precacheFile);
info->fileOffset += 4 + frameSize;
info->fileFrame++;
}
}
fseek(precacheFile, info->fileOffset, SEEK_SET);
uint32_t frameSize;
fread(&frameSize, sizeof(uint32_t), 1, precacheFile);
if (frameSize > 0 && frameSize <= info->decompressBufferSize) {
fread(info->decompressBuffer, sizeof(uint8_t), frameSize, precacheFile);
info->fileOffset += 4 + frameSize;
info->fileFrame = currentFrame + 1;
LZ4_decompress_safe((const char *) info->decompressBuffer, (char *) pixels, frameSize, w * h * 4);
loadedFromCache = true;
}
fclose(precacheFile);
if (frame + framesPerUpdate >= info->frameCount) {
info->fileOffset = 9;
info->fileFrame = 0;
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions TMessagesProj/jni/tgnet/ApiScheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void TL_dcOption::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool
tcpo_only = (flags & 4) != 0;
cdn = (flags & 8) != 0;
isStatic = (flags & 16) != 0;
thisPortOnly = (flags & 32) != 0;
id = stream->readInt32(&error);
ip_address = stream->readString(&error);
port = stream->readInt32(&error);
Expand All @@ -70,6 +71,7 @@ void TL_dcOption::serializeToStream(NativeByteBuffer *stream) {
flags = tcpo_only ? (flags | 4) : (flags &~ 4);
flags = cdn ? (flags | 8) : (flags &~ 8);
flags = isStatic ? (flags | 16) : (flags &~ 16);
flags = thisPortOnly ? (flags | 32) : (flags &~ 32);
stream->writeInt32(flags);
stream->writeInt32(id);
stream->writeString(ip_address);
Expand Down
1 change: 1 addition & 0 deletions TMessagesProj/jni/tgnet/ApiScheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class TL_dcOption : public TLObject {
bool tcpo_only;
bool cdn;
bool isStatic;
bool thisPortOnly;
int32_t id;
std::string ip_address;
int32_t port;
Expand Down
4 changes: 4 additions & 0 deletions TMessagesProj/jni/tgnet/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,10 @@ void Connection::onDisconnectedInternal(int32_t reason, int32_t error) {
isTryingNextPort = true;
if (failedConnectionCount > willRetryConnectCount || switchToNextPort) {
currentDatacenter->nextAddressOrPort(currentAddressFlags);
if (currentDatacenter->isRepeatCheckingAddresses() && (ConnectionsManager::getInstance(currentDatacenter->instanceNum).getIpStratagy() == USE_IPV4_ONLY || ConnectionsManager::getInstance(currentDatacenter->instanceNum).getIpStratagy() == USE_IPV6_ONLY)) {
if (LOGS_ENABLED) DEBUG_D("started retrying connection, set ipv4 ipv6 random strategy");
ConnectionsManager::getInstance(currentDatacenter->instanceNum).setIpStrategy(USE_IPV4_IPV6_RANDOM);
}
failedConnectionCount = 0;
}
}
Expand Down
17 changes: 14 additions & 3 deletions TMessagesProj/jni/tgnet/ConnectionsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,15 @@ ConnectionsManager& ConnectionsManager::getInstance(int32_t instanceNum) {
static ConnectionsManager instance1(1);
return instance1;
case 2:
default:
static ConnectionsManager instance2(2);
return instance2;
case 3:
static ConnectionsManager instance3(3);
return instance3;
case 4:
default:
static ConnectionsManager instance4(4);
return instance4;
}
}

Expand Down Expand Up @@ -3005,8 +3011,13 @@ void ConnectionsManager::updateDcSettings(uint32_t dcNum, bool workaround) {
if (dcOption->secret != nullptr) {
secret = std::string((const char *) dcOption->secret->bytes, dcOption->secret->length);
}
if (LOGS_ENABLED) DEBUG_D("getConfig add %s:%d to dc%d, flags %d, has secret = %d[%d]", dcOption->ip_address.c_str(), dcOption->port, dcOption->id, dcOption->flags, dcOption->secret != nullptr ? 1 : 0, dcOption->secret != nullptr ? dcOption->secret->length : 0);
addresses->push_back(TcpAddress(dcOption->ip_address, dcOption->port, dcOption->flags, secret));
if (LOGS_ENABLED) DEBUG_D("getConfig add %s:%d to dc%d, flags %d, has_secret = %d[%d], try_this_port_only = %d", dcOption->ip_address.c_str(), dcOption->port, dcOption->id, dcOption->flags, dcOption->secret != nullptr ? 1 : 0, dcOption->secret != nullptr ? dcOption->secret->length : 0, dcOption->thisPortOnly ? 1 : 0);
if (dcOption->thisPortOnly) {
addresses->insert(addresses->begin(), TcpAddress(dcOption->ip_address, dcOption->port, dcOption->flags, secret));
} else {
addresses->push_back(TcpAddress(dcOption->ip_address, dcOption->port, dcOption->flags, secret));
}

}
};

Expand Down
7 changes: 7 additions & 0 deletions TMessagesProj/jni/tgnet/Datacenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ void Datacenter::nextAddressOrPort(uint32_t flags) {
if (currentAddressNum + 1 < addresses->size()) {
currentAddressNum++;
} else {
repeatCheckingAddresses = true;
currentAddressNum = 0;
}
currentPortNum = 0;
Expand Down Expand Up @@ -1477,6 +1478,12 @@ void Datacenter::resetInitVersion() {
lastInitMediaVersion = 0;
}

bool Datacenter::isRepeatCheckingAddresses() {
bool b = repeatCheckingAddresses;
repeatCheckingAddresses = false;
return b;
}

TL_help_configSimple *Datacenter::decodeSimpleConfig(NativeByteBuffer *buffer) {
TL_help_configSimple *result = nullptr;

Expand Down
2 changes: 2 additions & 0 deletions TMessagesProj/jni/tgnet/Datacenter.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class Datacenter : public HandshakeDelegate {
bool isExportingAuthorization();
bool hasMediaAddress();
void resetInitVersion();
bool isRepeatCheckingAddresses();

Connection *getDownloadConnection(uint8_t num, bool create);
Connection *getProxyConnection(uint8_t num, bool create, bool connect);
Expand Down Expand Up @@ -121,6 +122,7 @@ class Datacenter : public HandshakeDelegate {
int64_t authKeyMediaTempId = 0;
Config *config = nullptr;
bool isCdnDatacenter = false;
bool repeatCheckingAddresses = false;

std::vector<std::unique_ptr<Handshake>> handshakes;

Expand Down
2 changes: 1 addition & 1 deletion TMessagesProj/jni/tgnet/Defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#define DOWNLOAD_CONNECTIONS_COUNT 2
#define UPLOAD_CONNECTIONS_COUNT 4
#define CONNECTION_BACKGROUND_KEEP_TIME 10000
#define MAX_ACCOUNT_COUNT 3
#define MAX_ACCOUNT_COUNT 5
#define USE_DELEGATE_HOST_RESOLVE

#define USE_IPV4_ONLY 0
Expand Down
4 changes: 2 additions & 2 deletions TMessagesProj/jni/voip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ target_compile_options(tgvoip PUBLIC
set_target_properties(tgvoip PROPERTIES
ANDROID_ARM_MODE arm)
target_compile_definitions(tgvoip PUBLIC
HAVE_PTHREAD __STDC_LIMIT_MACROS BSD=1 USE_KISS_FFT TGVOIP_NO_VIDEO NULL=0 SOCKLEN_T=socklen_t LOCALE_NOT_USED _LARGEFILE_SOURCE=1 _FILE_OFFSET_BITS=64 restrict= __EMX__ OPUS_BUILD FIXED_POINT USE_ALLOCA HAVE_LRINT HAVE_LRINTF)
HAVE_PTHREAD __STDC_LIMIT_MACROS BSD=1 USE_KISS_FFT TGVOIP_NO_VIDEO NULL=0 SOCKLEN_T=socklen_t LOCALE_NOT_USED _LARGEFILE_SOURCE=1 _FILE_OFFSET_BITS=64 restrict= __EMX__ OPUS_BUILD FIXED_POINT USE_ALLOCA HAVE_LRINT HAVE_LRINTF TGVOIP_NO_DSP)
target_compile_definitions(tgvoip PUBLIC
RTC_DISABLE_TRACE_EVENTS WEBRTC_OPUS_SUPPORT_120MS_PTIME=1 BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=0 ABSL_ALLOCATOR_NOTHROW=1 RTC_ENABLE_VP9 WEBRTC_POSIX WEBRTC_LINUX WEBRTC_ANDROID WEBRTC_USE_H264 NDEBUG WEBRTC_HAVE_USRSCTP WEBRTC_HAVE_SCTP WEBRTC_APM_DEBUG_DUMP=0 WEBRTC_USE_BUILTIN_ISAC_FLOAT WEBRTC_OPUS_VARIABLE_COMPLEXITY=0 HAVE_NETINET_IN_H WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE __Userspace__ SCTP_SIMPLE_ALLOCATOR SCTP_PROCESS_LEVEL_LOCKS __Userspace_os_Linux)
target_include_directories(tgvoip PUBLIC
Expand Down Expand Up @@ -404,7 +404,7 @@ target_compile_options(tgcalls_tp PUBLIC
set_target_properties(tgcalls_tp PROPERTIES
ANDROID_ARM_MODE arm)
target_compile_definitions(tgcalls_tp PUBLIC
RTC_DISABLE_TRACE_EVENTS WEBRTC_OPUS_SUPPORT_120MS_PTIME=1 BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=0 ABSL_ALLOCATOR_NOTHROW=1 HAVE_PTHREAD RTC_ENABLE_VP9 WEBRTC_POSIX WEBRTC_LINUX WEBRTC_ANDROID WEBRTC_USE_H264 NDEBUG WEBRTC_HAVE_USRSCTP WEBRTC_HAVE_SCTP WEBRTC_APM_DEBUG_DUMP=0 WEBRTC_USE_BUILTIN_ISAC_FLOAT WEBRTC_OPUS_VARIABLE_COMPLEXITY=0 HAVE_NETINET_IN_H WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE __Userspace__ SCTP_SIMPLE_ALLOCATOR SCTP_PROCESS_LEVEL_LOCKS __Userspace_os_Linux HAVE_WEBRTC_VIDEO __ANDROID__)
RTC_DISABLE_TRACE_EVENTS WEBRTC_OPUS_SUPPORT_120MS_PTIME=1 BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=0 ABSL_ALLOCATOR_NOTHROW=1 HAVE_PTHREAD RTC_ENABLE_VP9 WEBRTC_POSIX WEBRTC_LINUX WEBRTC_ANDROID WEBRTC_USE_H264 NDEBUG WEBRTC_HAVE_USRSCTP WEBRTC_HAVE_SCTP WEBRTC_APM_DEBUG_DUMP=0 WEBRTC_USE_BUILTIN_ISAC_FLOAT WEBRTC_OPUS_VARIABLE_COMPLEXITY=0 HAVE_NETINET_IN_H WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE __Userspace__ SCTP_SIMPLE_ALLOCATOR SCTP_PROCESS_LEVEL_LOCKS __Userspace_os_Linux HAVE_WEBRTC_VIDEO __ANDROID__ TGVOIP_NO_DSP)
target_include_directories(tgcalls_tp PUBLIC
./
voip
Expand Down
Loading

0 comments on commit 96dce2c

Please sign in to comment.