Skip to content

Commit a746a07

Browse files
committed
update to 10.5.0 (4228)
1 parent 33a48d8 commit a746a07

File tree

368 files changed

+26782
-4071
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

368 files changed

+26782
-4071
lines changed

TMessagesProj/build.gradle

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ dependencies {
4646
implementation 'com.google.code.gson:gson:2.10'
4747
implementation 'com.google.guava:guava:31.1-android'
4848

49+
implementation 'com.google.android.gms:play-services-mlkit-subject-segmentation:16.0.0-beta1'
50+
constraints {
51+
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
52+
because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
53+
}
54+
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") {
55+
because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
56+
}
57+
}
58+
4959
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
5060
}
5161

@@ -108,6 +118,7 @@ android {
108118
multiDexEnabled true
109119
proguardFiles getDefaultProguardFile('proguard-android.txt'), '../TMessagesProj/proguard-rules.pro'
110120
ndk.debugSymbolLevel = 'FULL'
121+
buildConfigField "String", "BUILD_VERSION_STRING", "\"" + APP_VERSION_NAME + "\""
111122
buildConfigField "String", "APP_CENTER_HASH", "\"\""
112123
buildConfigField "boolean", "DEBUG_VERSION", "true"
113124
buildConfigField "boolean", "DEBUG_PRIVATE_VERSION", "true"
@@ -121,6 +132,7 @@ android {
121132
multiDexEnabled true
122133
proguardFiles getDefaultProguardFile('proguard-android.txt'), '../TMessagesProj/proguard-rules.pro'
123134
ndk.debugSymbolLevel = 'FULL'
135+
buildConfigField "String", "BUILD_VERSION_STRING", "\"" + APP_VERSION_NAME + "\""
124136
buildConfigField "String", "APP_CENTER_HASH", "\"" + getProps("APP_CENTER_HASH_PRIVATE") + "\""
125137
buildConfigField "boolean", "DEBUG_VERSION", "true"
126138
buildConfigField "boolean", "DEBUG_PRIVATE_VERSION", "true"
@@ -134,6 +146,7 @@ android {
134146
multiDexEnabled true
135147
proguardFiles getDefaultProguardFile('proguard-android.txt'), '../TMessagesProj/proguard-rules.pro'
136148
ndk.debugSymbolLevel = 'FULL'
149+
buildConfigField "String", "BUILD_VERSION_STRING", "\"" + APP_VERSION_NAME + "\""
137150
buildConfigField "String", "APP_CENTER_HASH", "\"" + getProps("APP_CENTER_HASH_PUBLIC") + "\""
138151
buildConfigField "boolean", "DEBUG_VERSION", "true"
139152
buildConfigField "boolean", "DEBUG_PRIVATE_VERSION", "false"
@@ -147,6 +160,7 @@ android {
147160
multiDexEnabled true
148161
proguardFiles getDefaultProguardFile('proguard-android.txt'), '../TMessagesProj/proguard-rules.pro'
149162
ndk.debugSymbolLevel = 'FULL'
163+
buildConfigField "String", "BUILD_VERSION_STRING", "\"" + APP_VERSION_NAME + "\""
150164
buildConfigField "String", "APP_CENTER_HASH", "\"" + getProps("APP_CENTER_HASH_HARDCORE") + "\""
151165
buildConfigField "boolean", "DEBUG_VERSION", "true"
152166
buildConfigField "boolean", "DEBUG_PRIVATE_VERSION", "true"
@@ -160,6 +174,7 @@ android {
160174
multiDexEnabled true
161175
proguardFiles getDefaultProguardFile('proguard-android.txt'), '../TMessagesProj/proguard-rules.pro'
162176
ndk.debugSymbolLevel = 'FULL'
177+
buildConfigField "String", "BUILD_VERSION_STRING", "\"" + APP_VERSION_NAME + "\""
163178
buildConfigField "String", "APP_CENTER_HASH", "\"\""
164179
buildConfigField "boolean", "DEBUG_VERSION", "false"
165180
buildConfigField "boolean", "DEBUG_PRIVATE_VERSION", "false"
@@ -174,6 +189,7 @@ android {
174189
multiDexEnabled true
175190
proguardFiles getDefaultProguardFile('proguard-android.txt'), '../TMessagesProj/proguard-rules.pro'
176191
ndk.debugSymbolLevel = 'FULL'
192+
buildConfigField "String", "BUILD_VERSION_STRING", "\"" + APP_VERSION_NAME + "\""
177193
buildConfigField "String", "APP_CENTER_HASH", "\"\""
178194
buildConfigField "boolean", "DEBUG_VERSION", "false"
179195
buildConfigField "boolean", "DEBUG_PRIVATE_VERSION", "false"

TMessagesProj/jni/image.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,7 @@ std::vector<std::pair<float, float>> gatherPositions(std::vector<std::pair<float
11861186
}
11871187

11881188
thread_local static float *pixelCache = nullptr;
1189+
thread_local static int pixelCacheSize = 0;
11891190

11901191
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) {
11911192
if (!bitmap) {
@@ -1221,6 +1222,13 @@ JNIEXPORT void Java_org_telegram_messenger_Utilities_generateGradient(JNIEnv *en
12211222

12221223
auto colorsArray = (uint8_t *) env->GetIntArrayElements(colors, nullptr);
12231224
float *newPixelCache = nullptr;
1225+
1226+
if (width * height != pixelCacheSize && pixelCache != nullptr) {
1227+
delete[] pixelCache;
1228+
pixelCache = nullptr;
1229+
}
1230+
pixelCacheSize = width * height;
1231+
12241232
if (pixelCache == nullptr) {
12251233
newPixelCache = new float[width * height * 2];
12261234
}

TMessagesProj/jni/tgnet/Connection.cpp

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ void Connection::onReceivedData(NativeByteBuffer *buffer) {
122122

123123
buffer->rewind();
124124

125+
NativeByteBuffer *reuseLater = nullptr;
125126
while (buffer->hasRemaining()) {
126127
if (!hasSomeDataSinceLastConnect) {
127128
currentDatacenter->storeCurrentAddressAndPortNum();
@@ -154,14 +155,11 @@ void Connection::onReceivedData(NativeByteBuffer *buffer) {
154155
if ((fByte & (1 << 7)) != 0) {
155156
buffer->position(mark);
156157
if (buffer->remaining() < 4) {
157-
NativeByteBuffer *reuseLater = restOfTheData;
158+
reuseLater = restOfTheData;
158159
restOfTheData = BuffersStorage::getInstance().getFreeBuffer(16384);
159160
restOfTheData->writeBytes(buffer);
160161
restOfTheData->limit(restOfTheData->position());
161162
lastPacketLength = 0;
162-
if (reuseLater != nullptr) {
163-
reuseLater->reuse();
164-
}
165163
break;
166164
}
167165
int32_t ackId = buffer->readBigInt32(nullptr) & (~(1 << 31));
@@ -175,14 +173,11 @@ void Connection::onReceivedData(NativeByteBuffer *buffer) {
175173
buffer->position(mark);
176174
if (buffer->remaining() < 4) {
177175
if (restOfTheData == nullptr || (restOfTheData != nullptr && restOfTheData->position() != 0)) {
178-
NativeByteBuffer *reuseLater = restOfTheData;
176+
reuseLater = restOfTheData;
179177
restOfTheData = BuffersStorage::getInstance().getFreeBuffer(16384);
180178
restOfTheData->writeBytes(buffer);
181179
restOfTheData->limit(restOfTheData->position());
182180
lastPacketLength = 0;
183-
if (reuseLater != nullptr) {
184-
reuseLater->reuse();
185-
}
186181
} else {
187182
restOfTheData->position(restOfTheData->limit());
188183
}
@@ -195,14 +190,11 @@ void Connection::onReceivedData(NativeByteBuffer *buffer) {
195190
} else {
196191
if (buffer->remaining() < 4) {
197192
if (restOfTheData == nullptr || (restOfTheData != nullptr && restOfTheData->position() != 0)) {
198-
NativeByteBuffer *reuseLater = restOfTheData;
193+
reuseLater = restOfTheData;
199194
restOfTheData = BuffersStorage::getInstance().getFreeBuffer(16384);
200195
restOfTheData->writeBytes(buffer);
201196
restOfTheData->limit(restOfTheData->position());
202197
lastPacketLength = 0;
203-
if (reuseLater != nullptr) {
204-
reuseLater->reuse();
205-
}
206198
} else {
207199
restOfTheData->position(restOfTheData->limit());
208200
}
@@ -223,7 +215,7 @@ void Connection::onReceivedData(NativeByteBuffer *buffer) {
223215
if (currentProtocolType != ProtocolTypeDD && currentProtocolType != ProtocolTypeTLS && currentPacketLength % 4 != 0 || currentPacketLength > 2 * 1024 * 1024) {
224216
if (LOGS_ENABLED) DEBUG_D("connection(%p, account%u, dc%u, type %d) received invalid packet length", this, currentDatacenter->instanceNum, currentDatacenter->getDatacenterId(), connectionType);
225217
reconnect();
226-
return;
218+
break;
227219
}
228220

229221
if (currentPacketLength < buffer->remaining()) {
@@ -233,8 +225,6 @@ void Connection::onReceivedData(NativeByteBuffer *buffer) {
233225
} else {
234226
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);
235227

236-
NativeByteBuffer *reuseLater = nullptr;
237-
238228
if (restOfTheData != nullptr && restOfTheData->capacity() < len) {
239229
reuseLater = restOfTheData;
240230
restOfTheData = nullptr;
@@ -248,10 +238,7 @@ void Connection::onReceivedData(NativeByteBuffer *buffer) {
248238
restOfTheData->limit(len);
249239
}
250240
lastPacketLength = len;
251-
if (reuseLater != nullptr) {
252-
reuseLater->reuse();
253-
}
254-
return;
241+
break;
255242
}
256243

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

263250
if (restOfTheData != nullptr) {
264251
if ((lastPacketLength != 0 && restOfTheData->position() == lastPacketLength) || (lastPacketLength == 0 && !restOfTheData->hasRemaining())) {
265-
restOfTheData->reuse();
252+
reuseLater = restOfTheData;
266253
restOfTheData = nullptr;
267254
} else {
268255
restOfTheData->compact();
@@ -276,6 +263,9 @@ void Connection::onReceivedData(NativeByteBuffer *buffer) {
276263
parseLaterBuffer = nullptr;
277264
}
278265
}
266+
if (reuseLater != nullptr) {
267+
reuseLater->reuse();
268+
}
279269
}
280270

281271
void Connection::connect() {

TMessagesProj/jni/voip/tgcalls/v2/InstanceV2Impl.cpp

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,54 @@ class OutgoingAudioChannel : public sigslot::has_slots<> {
253253
bool _isMuted = true;
254254
};
255255

256+
namespace {
257+
class AudioSinkImpl: public webrtc::AudioSinkInterface {
258+
public:
259+
AudioSinkImpl(std::function<void(float, float)> update) :
260+
_update(update) {
261+
}
262+
263+
virtual ~AudioSinkImpl() {
264+
}
265+
266+
virtual void OnData(const Data& audio) override {
267+
if (_update && audio.channels == 1) {
268+
const int16_t *samples = (const int16_t *)audio.data;
269+
int numberOfSamplesInFrame = (int)audio.samples_per_channel;
270+
271+
int16_t currentPeak = 0;
272+
for (int i = 0; i < numberOfSamplesInFrame; i++) {
273+
int16_t sample = samples[i];
274+
if (sample < 0) {
275+
sample = -sample;
276+
}
277+
if (_peak < sample) {
278+
_peak = sample;
279+
}
280+
if (currentPeak < sample) {
281+
currentPeak = sample;
282+
}
283+
_peakCount += 1;
284+
}
285+
286+
if (_peakCount >= 4400) {
287+
float level = ((float)(_peak)) / 8000.0f;
288+
_peak = 0;
289+
_peakCount = 0;
290+
_update(0, level);
291+
}
292+
}
293+
}
294+
295+
private:
296+
std::function<void(float, float)> _update;
297+
298+
int _peakCount = 0;
299+
uint16_t _peak = 0;
300+
};
301+
302+
}
303+
256304
class IncomingV2AudioChannel : public sigslot::has_slots<> {
257305
public:
258306
IncomingV2AudioChannel(
@@ -261,6 +309,7 @@ class IncomingV2AudioChannel : public sigslot::has_slots<> {
261309
webrtc::RtpTransport *rtpTransport,
262310
rtc::UniqueRandomIdGenerator *randomIdGenerator,
263311
signaling::MediaContent const &mediaContent,
312+
std::function<void(float, float)> &&onAudioLevelUpdated,
264313
std::shared_ptr<Threads> threads) :
265314
_threads(threads),
266315
_ssrc(mediaContent.ssrc),
@@ -278,9 +327,7 @@ class IncomingV2AudioChannel : public sigslot::has_slots<> {
278327
_threads->getNetworkThread()->BlockingCall([&]() {
279328
_audioChannel->SetRtpTransport(rtpTransport);
280329
});
281-
282-
283-
330+
284331
std::vector<cricket::AudioCodec> codecs;
285332
for (const auto &payloadType : mediaContent.payloadTypes) {
286333
cricket::AudioCodec codec(payloadType.id, payloadType.name, payloadType.clockrate, 0, payloadType.channels);
@@ -317,11 +364,14 @@ class IncomingV2AudioChannel : public sigslot::has_slots<> {
317364
streamParams.set_stream_ids({ streamId });
318365
incomingAudioDescription->AddStream(streamParams);
319366

320-
threads->getWorkerThread()->BlockingCall([&]() {
367+
threads->getWorkerThread()->BlockingCall([this, &outgoingAudioDescription, &incomingAudioDescription, onAudioLevelUpdated = std::move(onAudioLevelUpdated), ssrc = mediaContent.ssrc]() {
321368
_audioChannel->SetPayloadTypeDemuxingEnabled(false);
322369
std::string errorDesc;
323370
_audioChannel->SetLocalContent(outgoingAudioDescription.get(), webrtc::SdpType::kOffer, errorDesc);
324371
_audioChannel->SetRemoteContent(incomingAudioDescription.get(), webrtc::SdpType::kAnswer, errorDesc);
372+
373+
std::unique_ptr<AudioSinkImpl> audioLevelSink(new AudioSinkImpl(std::move(onAudioLevelUpdated)));
374+
_audioChannel->media_channel()->SetRawAudioSink(ssrc, std::move(audioLevelSink));
325375
});
326376

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

11021152
mediaDeps.adm = _audioDeviceModule;
11031153

1104-
webrtc:: AudioProcessingBuilder builder;
1154+
webrtc::AudioProcessingBuilder builder;
11051155
mediaDeps.audio_processing = builder.Create();
11061156

11071157
_availableVideoFormats = mediaDeps.video_encoder_factory->GetSupportedFormats();
@@ -1468,6 +1518,9 @@ class InstanceV2ImplInternal : public std::enable_shared_from_this<InstanceV2Imp
14681518
_rtpTransport,
14691519
_uniqueRandomIdGenerator.get(),
14701520
content,
1521+
[audioLevelUpdated = _audioLevelUpdated](float myLvl, float level) {
1522+
audioLevelUpdated(myLvl, level);
1523+
},
14711524
_threads
14721525
));
14731526
}

TMessagesProj/src/main/AndroidManifest.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979

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

82+
<uses-sdk tools:overrideLibrary="com.google.mlkit.vision.segmentation.subject"/>
83+
8284
<queries>
8385
<package android:name="com.google.android.apps.maps"/>
8486
<intent>
@@ -266,6 +268,9 @@
266268
</intent-filter>
267269
<meta-data android:name="android.service.chooser.chooser_target_service" android:value="androidx.sharetarget.ChooserTargetServiceCompat" />
268270
<meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcuts" />
271+
<meta-data
272+
android:name="com.google.mlkit.vision.DEPENDENCIES"
273+
android:value="subject_segment" />
269274
</activity>
270275
<activity-alias
271276
android:name="org.telegram.ui.CallsActivity"
@@ -564,8 +569,8 @@
564569

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

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

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

TMessagesProj/src/main/assets/darkblue.attheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ chat_searchPanelText=-8796932
429429
chat_inContactIcon=-1
430430
code_comment=-2130706433
431431
chat_outCodeBackground=857487708
432-
chat_inCodeBackground=856033549
432+
chat_inCodeBackground=-1
433433
code_keyword=-27776
434434
code_constant=-27776
435435
code_function=-27776

TMessagesProj/src/main/assets/night.attheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ chat_searchPanelText=-10767620
454454
chat_inContactIcon=-1
455455
code_comment=-2130706433
456456
chat_outCodeBackground=859062986
457-
chat_inCodeBackground=855638016
457+
chat_inCodeBackground=-1
458458
code_keyword=-27776
459459
code_constant=-27776
460460
code_function=-27776

0 commit comments

Comments
 (0)