Skip to content

Commit

Permalink
update to 10.5.0 (4228)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkaraush committed Dec 31, 2023
1 parent 33a48d8 commit a746a07
Show file tree
Hide file tree
Showing 368 changed files with 26,782 additions and 4,071 deletions.
16 changes: 16 additions & 0 deletions TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ dependencies {
implementation 'com.google.code.gson:gson:2.10'
implementation 'com.google.guava:guava:31.1-android'

implementation 'com.google.android.gms:play-services-mlkit-subject-segmentation:16.0.0-beta1'
constraints {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
}
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") {
because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
}
}

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

Expand Down Expand Up @@ -108,6 +118,7 @@ android {
multiDexEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), '../TMessagesProj/proguard-rules.pro'
ndk.debugSymbolLevel = 'FULL'
buildConfigField "String", "BUILD_VERSION_STRING", "\"" + APP_VERSION_NAME + "\""
buildConfigField "String", "APP_CENTER_HASH", "\"\""
buildConfigField "boolean", "DEBUG_VERSION", "true"
buildConfigField "boolean", "DEBUG_PRIVATE_VERSION", "true"
Expand All @@ -121,6 +132,7 @@ android {
multiDexEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), '../TMessagesProj/proguard-rules.pro'
ndk.debugSymbolLevel = 'FULL'
buildConfigField "String", "BUILD_VERSION_STRING", "\"" + APP_VERSION_NAME + "\""
buildConfigField "String", "APP_CENTER_HASH", "\"" + getProps("APP_CENTER_HASH_PRIVATE") + "\""
buildConfigField "boolean", "DEBUG_VERSION", "true"
buildConfigField "boolean", "DEBUG_PRIVATE_VERSION", "true"
Expand All @@ -134,6 +146,7 @@ android {
multiDexEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), '../TMessagesProj/proguard-rules.pro'
ndk.debugSymbolLevel = 'FULL'
buildConfigField "String", "BUILD_VERSION_STRING", "\"" + APP_VERSION_NAME + "\""
buildConfigField "String", "APP_CENTER_HASH", "\"" + getProps("APP_CENTER_HASH_PUBLIC") + "\""
buildConfigField "boolean", "DEBUG_VERSION", "true"
buildConfigField "boolean", "DEBUG_PRIVATE_VERSION", "false"
Expand All @@ -147,6 +160,7 @@ android {
multiDexEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), '../TMessagesProj/proguard-rules.pro'
ndk.debugSymbolLevel = 'FULL'
buildConfigField "String", "BUILD_VERSION_STRING", "\"" + APP_VERSION_NAME + "\""
buildConfigField "String", "APP_CENTER_HASH", "\"" + getProps("APP_CENTER_HASH_HARDCORE") + "\""
buildConfigField "boolean", "DEBUG_VERSION", "true"
buildConfigField "boolean", "DEBUG_PRIVATE_VERSION", "true"
Expand All @@ -160,6 +174,7 @@ android {
multiDexEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), '../TMessagesProj/proguard-rules.pro'
ndk.debugSymbolLevel = 'FULL'
buildConfigField "String", "BUILD_VERSION_STRING", "\"" + APP_VERSION_NAME + "\""
buildConfigField "String", "APP_CENTER_HASH", "\"\""
buildConfigField "boolean", "DEBUG_VERSION", "false"
buildConfigField "boolean", "DEBUG_PRIVATE_VERSION", "false"
Expand All @@ -174,6 +189,7 @@ android {
multiDexEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), '../TMessagesProj/proguard-rules.pro'
ndk.debugSymbolLevel = 'FULL'
buildConfigField "String", "BUILD_VERSION_STRING", "\"" + APP_VERSION_NAME + "\""
buildConfigField "String", "APP_CENTER_HASH", "\"\""
buildConfigField "boolean", "DEBUG_VERSION", "false"
buildConfigField "boolean", "DEBUG_PRIVATE_VERSION", "false"
Expand Down
8 changes: 8 additions & 0 deletions TMessagesProj/jni/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,7 @@ std::vector<std::pair<float, float>> gatherPositions(std::vector<std::pair<float
}

thread_local static float *pixelCache = nullptr;
thread_local static int pixelCacheSize = 0;

JNIEXPORT void Java_org_telegram_messenger_Utilities_generateGradient(JNIEnv *env, jclass clazz, jobject bitmap, jboolean unpin, jint phase, jfloat progress, jint width, jint height, jint stride, jintArray colors) {
if (!bitmap) {
Expand Down Expand Up @@ -1221,6 +1222,13 @@ JNIEXPORT void Java_org_telegram_messenger_Utilities_generateGradient(JNIEnv *en

auto colorsArray = (uint8_t *) env->GetIntArrayElements(colors, nullptr);
float *newPixelCache = nullptr;

if (width * height != pixelCacheSize && pixelCache != nullptr) {
delete[] pixelCache;
pixelCache = nullptr;
}
pixelCacheSize = width * height;

if (pixelCache == nullptr) {
newPixelCache = new float[width * height * 2];
}
Expand Down
30 changes: 10 additions & 20 deletions TMessagesProj/jni/tgnet/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ void Connection::onReceivedData(NativeByteBuffer *buffer) {

buffer->rewind();

NativeByteBuffer *reuseLater = nullptr;
while (buffer->hasRemaining()) {
if (!hasSomeDataSinceLastConnect) {
currentDatacenter->storeCurrentAddressAndPortNum();
Expand Down Expand Up @@ -154,14 +155,11 @@ void Connection::onReceivedData(NativeByteBuffer *buffer) {
if ((fByte & (1 << 7)) != 0) {
buffer->position(mark);
if (buffer->remaining() < 4) {
NativeByteBuffer *reuseLater = restOfTheData;
reuseLater = restOfTheData;
restOfTheData = BuffersStorage::getInstance().getFreeBuffer(16384);
restOfTheData->writeBytes(buffer);
restOfTheData->limit(restOfTheData->position());
lastPacketLength = 0;
if (reuseLater != nullptr) {
reuseLater->reuse();
}
break;
}
int32_t ackId = buffer->readBigInt32(nullptr) & (~(1 << 31));
Expand All @@ -175,14 +173,11 @@ void Connection::onReceivedData(NativeByteBuffer *buffer) {
buffer->position(mark);
if (buffer->remaining() < 4) {
if (restOfTheData == nullptr || (restOfTheData != nullptr && restOfTheData->position() != 0)) {
NativeByteBuffer *reuseLater = restOfTheData;
reuseLater = restOfTheData;
restOfTheData = BuffersStorage::getInstance().getFreeBuffer(16384);
restOfTheData->writeBytes(buffer);
restOfTheData->limit(restOfTheData->position());
lastPacketLength = 0;
if (reuseLater != nullptr) {
reuseLater->reuse();
}
} else {
restOfTheData->position(restOfTheData->limit());
}
Expand All @@ -195,14 +190,11 @@ void Connection::onReceivedData(NativeByteBuffer *buffer) {
} else {
if (buffer->remaining() < 4) {
if (restOfTheData == nullptr || (restOfTheData != nullptr && restOfTheData->position() != 0)) {
NativeByteBuffer *reuseLater = restOfTheData;
reuseLater = restOfTheData;
restOfTheData = BuffersStorage::getInstance().getFreeBuffer(16384);
restOfTheData->writeBytes(buffer);
restOfTheData->limit(restOfTheData->position());
lastPacketLength = 0;
if (reuseLater != nullptr) {
reuseLater->reuse();
}
} else {
restOfTheData->position(restOfTheData->limit());
}
Expand All @@ -223,7 +215,7 @@ void Connection::onReceivedData(NativeByteBuffer *buffer) {
if (currentProtocolType != ProtocolTypeDD && currentProtocolType != ProtocolTypeTLS && currentPacketLength % 4 != 0 || currentPacketLength > 2 * 1024 * 1024) {
if (LOGS_ENABLED) DEBUG_D("connection(%p, account%u, dc%u, type %d) received invalid packet length", this, currentDatacenter->instanceNum, currentDatacenter->getDatacenterId(), connectionType);
reconnect();
return;
break;
}

if (currentPacketLength < buffer->remaining()) {
Expand All @@ -233,8 +225,6 @@ void Connection::onReceivedData(NativeByteBuffer *buffer) {
} else {
if (LOGS_ENABLED) DEBUG_D("connection(%p, account%u, dc%u, type %d) received packet size less(%u) then message size(%u)", this, currentDatacenter->instanceNum, currentDatacenter->getDatacenterId(), connectionType, buffer->remaining(), currentPacketLength);

NativeByteBuffer *reuseLater = nullptr;

if (restOfTheData != nullptr && restOfTheData->capacity() < len) {
reuseLater = restOfTheData;
restOfTheData = nullptr;
Expand All @@ -248,10 +238,7 @@ void Connection::onReceivedData(NativeByteBuffer *buffer) {
restOfTheData->limit(len);
}
lastPacketLength = len;
if (reuseLater != nullptr) {
reuseLater->reuse();
}
return;
break;
}

uint32_t old = buffer->limit();
Expand All @@ -262,7 +249,7 @@ void Connection::onReceivedData(NativeByteBuffer *buffer) {

if (restOfTheData != nullptr) {
if ((lastPacketLength != 0 && restOfTheData->position() == lastPacketLength) || (lastPacketLength == 0 && !restOfTheData->hasRemaining())) {
restOfTheData->reuse();
reuseLater = restOfTheData;
restOfTheData = nullptr;
} else {
restOfTheData->compact();
Expand All @@ -276,6 +263,9 @@ void Connection::onReceivedData(NativeByteBuffer *buffer) {
parseLaterBuffer = nullptr;
}
}
if (reuseLater != nullptr) {
reuseLater->reuse();
}
}

void Connection::connect() {
Expand Down
63 changes: 58 additions & 5 deletions TMessagesProj/jni/voip/tgcalls/v2/InstanceV2Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,54 @@ class OutgoingAudioChannel : public sigslot::has_slots<> {
bool _isMuted = true;
};

namespace {
class AudioSinkImpl: public webrtc::AudioSinkInterface {
public:
AudioSinkImpl(std::function<void(float, float)> update) :
_update(update) {
}

virtual ~AudioSinkImpl() {
}

virtual void OnData(const Data& audio) override {
if (_update && audio.channels == 1) {
const int16_t *samples = (const int16_t *)audio.data;
int numberOfSamplesInFrame = (int)audio.samples_per_channel;

int16_t currentPeak = 0;
for (int i = 0; i < numberOfSamplesInFrame; i++) {
int16_t sample = samples[i];
if (sample < 0) {
sample = -sample;
}
if (_peak < sample) {
_peak = sample;
}
if (currentPeak < sample) {
currentPeak = sample;
}
_peakCount += 1;
}

if (_peakCount >= 4400) {
float level = ((float)(_peak)) / 8000.0f;
_peak = 0;
_peakCount = 0;
_update(0, level);
}
}
}

private:
std::function<void(float, float)> _update;

int _peakCount = 0;
uint16_t _peak = 0;
};

}

class IncomingV2AudioChannel : public sigslot::has_slots<> {
public:
IncomingV2AudioChannel(
Expand All @@ -261,6 +309,7 @@ class IncomingV2AudioChannel : public sigslot::has_slots<> {
webrtc::RtpTransport *rtpTransport,
rtc::UniqueRandomIdGenerator *randomIdGenerator,
signaling::MediaContent const &mediaContent,
std::function<void(float, float)> &&onAudioLevelUpdated,
std::shared_ptr<Threads> threads) :
_threads(threads),
_ssrc(mediaContent.ssrc),
Expand All @@ -278,9 +327,7 @@ class IncomingV2AudioChannel : public sigslot::has_slots<> {
_threads->getNetworkThread()->BlockingCall([&]() {
_audioChannel->SetRtpTransport(rtpTransport);
});




std::vector<cricket::AudioCodec> codecs;
for (const auto &payloadType : mediaContent.payloadTypes) {
cricket::AudioCodec codec(payloadType.id, payloadType.name, payloadType.clockrate, 0, payloadType.channels);
Expand Down Expand Up @@ -317,11 +364,14 @@ class IncomingV2AudioChannel : public sigslot::has_slots<> {
streamParams.set_stream_ids({ streamId });
incomingAudioDescription->AddStream(streamParams);

threads->getWorkerThread()->BlockingCall([&]() {
threads->getWorkerThread()->BlockingCall([this, &outgoingAudioDescription, &incomingAudioDescription, onAudioLevelUpdated = std::move(onAudioLevelUpdated), ssrc = mediaContent.ssrc]() {
_audioChannel->SetPayloadTypeDemuxingEnabled(false);
std::string errorDesc;
_audioChannel->SetLocalContent(outgoingAudioDescription.get(), webrtc::SdpType::kOffer, errorDesc);
_audioChannel->SetRemoteContent(incomingAudioDescription.get(), webrtc::SdpType::kAnswer, errorDesc);

std::unique_ptr<AudioSinkImpl> audioLevelSink(new AudioSinkImpl(std::move(onAudioLevelUpdated)));
_audioChannel->media_channel()->SetRawAudioSink(ssrc, std::move(audioLevelSink));
});

outgoingAudioDescription.reset();
Expand Down Expand Up @@ -1101,7 +1151,7 @@ class InstanceV2ImplInternal : public std::enable_shared_from_this<InstanceV2Imp

mediaDeps.adm = _audioDeviceModule;

webrtc:: AudioProcessingBuilder builder;
webrtc::AudioProcessingBuilder builder;
mediaDeps.audio_processing = builder.Create();

_availableVideoFormats = mediaDeps.video_encoder_factory->GetSupportedFormats();
Expand Down Expand Up @@ -1468,6 +1518,9 @@ class InstanceV2ImplInternal : public std::enable_shared_from_this<InstanceV2Imp
_rtpTransport,
_uniqueRandomIdGenerator.get(),
content,
[audioLevelUpdated = _audioLevelUpdated](float myLvl, float level) {
audioLevelUpdated(myLvl, level);
},
_threads
));
}
Expand Down
9 changes: 7 additions & 2 deletions TMessagesProj/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@

<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />

<uses-sdk tools:overrideLibrary="com.google.mlkit.vision.segmentation.subject"/>

<queries>
<package android:name="com.google.android.apps.maps"/>
<intent>
Expand Down Expand Up @@ -266,6 +268,9 @@
</intent-filter>
<meta-data android:name="android.service.chooser.chooser_target_service" android:value="androidx.sharetarget.ChooserTargetServiceCompat" />
<meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcuts" />
<meta-data
android:name="com.google.mlkit.vision.DEPENDENCIES"
android:value="subject_segment" />
</activity>
<activity-alias
android:name="org.telegram.ui.CallsActivity"
Expand Down Expand Up @@ -564,8 +569,8 @@

<meta-data android:name="com.google.android.gms.wallet.api.enabled" android:value="true" />

<meta-data android:name="com.google.android.gms.car.notification.SmallIcon" android:resource="@drawable/ic_player" />
<meta-data android:name="com.google.android.gms.car.application" android:resource="@xml/automotive_app_desc" />
<!-- <meta-data android:name="com.google.android.gms.car.notification.SmallIcon" android:resource="@drawable/ic_player" />-->
<!-- <meta-data android:name="com.google.android.gms.car.application" android:resource="@xml/automotive_app_desc" />-->

<meta-data android:name="com.google.android.gms.vision.DEPENDENCIES" android:value="face,barcode" />

Expand Down
2 changes: 1 addition & 1 deletion TMessagesProj/src/main/assets/darkblue.attheme
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ chat_searchPanelText=-8796932
chat_inContactIcon=-1
code_comment=-2130706433
chat_outCodeBackground=857487708
chat_inCodeBackground=856033549
chat_inCodeBackground=-1
code_keyword=-27776
code_constant=-27776
code_function=-27776
Expand Down
2 changes: 1 addition & 1 deletion TMessagesProj/src/main/assets/night.attheme
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ chat_searchPanelText=-10767620
chat_inContactIcon=-1
code_comment=-2130706433
chat_outCodeBackground=859062986
chat_inCodeBackground=855638016
chat_inCodeBackground=-1
code_keyword=-27776
code_constant=-27776
code_function=-27776
Expand Down

0 comments on commit a746a07

Please sign in to comment.