Skip to content

Commit 4b588b9

Browse files
committed
Update to 7.3.0 (2196)
1 parent d52b2c9 commit 4b588b9

File tree

69 files changed

+4280
-1841
lines changed

Some content is hidden

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

69 files changed

+4280
-1841
lines changed

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ RUN $ANDROID_HOME/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS_VERSIO
2424
ENV PATH ${ANDROID_NDK_HOME}:$PATH
2525
ENV PATH ${ANDROID_NDK_HOME}/prebuilt/linux-x86_64/bin/:$PATH
2626

27-
CMD mkdir -p /home/source/TMessagesProj/build/outputs/apk && mkdir -p /home/source/TMessagesProj/build/intermediates/ndkBuild && cp -R /home/source/. /home/gradle && cd /home/gradle && gradle assembleRelease && cp -R /home/gradle/TMessagesProj/build/outputs/apk/. /home/source/TMessagesProj/build/outputs/apk && cp -R /home/gradle/TMessagesProj/build/intermediates/ndkBuild/. /home/source/TMessagesProj/build/intermediates/ndkBuild
27+
CMD mkdir -p /home/source/TMessagesProj/build/outputs/apk && mkdir -p /home/source/TMessagesProj/build/outputs/native-debug-symbols && cp -R /home/source/. /home/gradle && cd /home/gradle && gradle assembleRelease && cp -R /home/gradle/TMessagesProj/build/outputs/apk/. /home/source/TMessagesProj/build/outputs/apk && cp -R /home/gradle/TMessagesProj/build/outputs/native-debug-symbols/. /home/source/TMessagesProj/build/outputs/native-debug-symbols

TMessagesProj/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ android {
290290
}
291291
}
292292

293-
defaultConfig.versionCode = 2195
293+
defaultConfig.versionCode = 2196
294294

295295
applicationVariants.all { variant ->
296296
variant.outputs.all { output ->

TMessagesProj/jni/sqlite/sqlite3.c

+1,957-720
Large diffs are not rendered by default.

TMessagesProj/jni/sqlite/sqlite3.h

+71-8
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ extern "C" {
123123
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124124
** [sqlite_version()] and [sqlite_source_id()].
125125
*/
126-
#define SQLITE_VERSION "3.33.0"
127-
#define SQLITE_VERSION_NUMBER 3033000
128-
#define SQLITE_SOURCE_ID "2020-08-14 13:23:32 fca8dc8b578f215a969cd899336378966156154710873e68b3d9ac5881b0ff3f"
126+
#define SQLITE_VERSION "3.34.0"
127+
#define SQLITE_VERSION_NUMBER 3034000
128+
#define SQLITE_SOURCE_ID "2020-12-01 16:14:00 a26b6597e3ae272231b96f9982c3bcc17ddec2f2b6eb4df06a224b91089fed5b"
129129

130130
/*
131131
** CAPI3REF: Run-Time Library Version Numbers
@@ -504,6 +504,7 @@ SQLITE_API int sqlite3_exec(
504504
#define SQLITE_IOERR_COMMIT_ATOMIC (SQLITE_IOERR | (30<<8))
505505
#define SQLITE_IOERR_ROLLBACK_ATOMIC (SQLITE_IOERR | (31<<8))
506506
#define SQLITE_IOERR_DATA (SQLITE_IOERR | (32<<8))
507+
#define SQLITE_IOERR_CORRUPTFS (SQLITE_IOERR | (33<<8))
507508
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
508509
#define SQLITE_LOCKED_VTAB (SQLITE_LOCKED | (2<<8))
509510
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
@@ -6186,6 +6187,57 @@ SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);
61866187
*/
61876188
SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
61886189

6190+
/*
6191+
** CAPI3REF: Determine the transaction state of a database
6192+
** METHOD: sqlite3
6193+
**
6194+
** ^The sqlite3_txn_state(D,S) interface returns the current
6195+
** [transaction state] of schema S in database connection D. ^If S is NULL,
6196+
** then the highest transaction state of any schema on database connection D
6197+
** is returned. Transaction states are (in order of lowest to highest):
6198+
** <ol>
6199+
** <li value="0"> SQLITE_TXN_NONE
6200+
** <li value="1"> SQLITE_TXN_READ
6201+
** <li value="2"> SQLITE_TXN_WRITE
6202+
** </ol>
6203+
** ^If the S argument to sqlite3_txn_state(D,S) is not the name of
6204+
** a valid schema, then -1 is returned.
6205+
*/
6206+
SQLITE_API int sqlite3_txn_state(sqlite3*,const char *zSchema);
6207+
6208+
/*
6209+
** CAPI3REF: Allowed return values from [sqlite3_txn_state()]
6210+
** KEYWORDS: {transaction state}
6211+
**
6212+
** These constants define the current transaction state of a database file.
6213+
** ^The [sqlite3_txn_state(D,S)] interface returns one of these
6214+
** constants in order to describe the transaction state of schema S
6215+
** in [database connection] D.
6216+
**
6217+
** <dl>
6218+
** [[SQLITE_TXN_NONE]] <dt>SQLITE_TXN_NONE</dt>
6219+
** <dd>The SQLITE_TXN_NONE state means that no transaction is currently
6220+
** pending.</dd>
6221+
**
6222+
** [[SQLITE_TXN_READ]] <dt>SQLITE_TXN_READ</dt>
6223+
** <dd>The SQLITE_TXN_READ state means that the database is currently
6224+
** in a read transaction. Content has been read from the database file
6225+
** but nothing in the database file has changed. The transaction state
6226+
** will advanced to SQLITE_TXN_WRITE if any changes occur and there are
6227+
** no other conflicting concurrent write transactions. The transaction
6228+
** state will revert to SQLITE_TXN_NONE following a [ROLLBACK] or
6229+
** [COMMIT].</dd>
6230+
**
6231+
** [[SQLITE_TXN_WRITE]] <dt>SQLITE_TXN_WRITE</dt>
6232+
** <dd>The SQLITE_TXN_WRITE state means that the database is currently
6233+
** in a write transaction. Content has been written to the database file
6234+
** but has not yet committed. The transaction state will change to
6235+
** to SQLITE_TXN_NONE at the next [ROLLBACK] or [COMMIT].</dd>
6236+
*/
6237+
#define SQLITE_TXN_NONE 0
6238+
#define SQLITE_TXN_READ 1
6239+
#define SQLITE_TXN_WRITE 2
6240+
61896241
/*
61906242
** CAPI3REF: Find the next prepared statement
61916243
** METHOD: sqlite3
@@ -7712,7 +7764,8 @@ SQLITE_API int sqlite3_test_control(int op, ...);
77127764
#define SQLITE_TESTCTRL_RESULT_INTREAL 27
77137765
#define SQLITE_TESTCTRL_PRNG_SEED 28
77147766
#define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29
7715-
#define SQLITE_TESTCTRL_LAST 29 /* Largest TESTCTRL */
7767+
#define SQLITE_TESTCTRL_SEEK_COUNT 30
7768+
#define SQLITE_TESTCTRL_LAST 30 /* Largest TESTCTRL */
77167769

77177770
/*
77187771
** CAPI3REF: SQL Keyword Checking
@@ -9192,10 +9245,11 @@ SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
91929245
** CAPI3REF: Determine If Virtual Table Column Access Is For UPDATE
91939246
**
91949247
** If the sqlite3_vtab_nochange(X) routine is called within the [xColumn]
9195-
** method of a [virtual table], then it returns true if and only if the
9248+
** method of a [virtual table], then it might return true if the
91969249
** column is being fetched as part of an UPDATE operation during which the
9197-
** column value will not change. Applications might use this to substitute
9198-
** a return value that is less expensive to compute and that the corresponding
9250+
** column value will not change. The virtual table implementation can use
9251+
** this hint as permission to substitute a return value that is less
9252+
** expensive to compute and that the corresponding
91999253
** [xUpdate] method understands as a "no-change" value.
92009254
**
92019255
** If the [xColumn] method calls sqlite3_vtab_nochange() and finds that
@@ -9204,6 +9258,12 @@ SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
92049258
** any of the [sqlite3_result_int|sqlite3_result_xxxxx() interfaces].
92059259
** In that case, [sqlite3_value_nochange(X)] will return true for the
92069260
** same column in the [xUpdate] method.
9261+
**
9262+
** The sqlite3_vtab_nochange() routine is an optimization. Virtual table
9263+
** implementations should continue to give a correct answer even if the
9264+
** sqlite3_vtab_nochange() interface were to always return false. In the
9265+
** current implementation, the sqlite3_vtab_nochange() interface does always
9266+
** returns false for the enhanced [UPDATE FROM] statement.
92079267
*/
92089268
SQLITE_API int sqlite3_vtab_nochange(sqlite3_context*);
92099269

@@ -9345,6 +9405,7 @@ SQLITE_API void sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
93459405

93469406
/*
93479407
** CAPI3REF: Flush caches to disk mid-transaction
9408+
** METHOD: sqlite3
93489409
**
93499410
** ^If a write-transaction is open on [database connection] D when the
93509411
** [sqlite3_db_cacheflush(D)] interface invoked, any dirty
@@ -9377,6 +9438,7 @@ SQLITE_API int sqlite3_db_cacheflush(sqlite3*);
93779438

93789439
/*
93799440
** CAPI3REF: The pre-update hook.
9441+
** METHOD: sqlite3
93809442
**
93819443
** ^These interfaces are only available if SQLite is compiled using the
93829444
** [SQLITE_ENABLE_PREUPDATE_HOOK] compile-time option.
@@ -9417,7 +9479,7 @@ SQLITE_API int sqlite3_db_cacheflush(sqlite3*);
94179479
** seventh parameter is the final rowid value of the row being inserted
94189480
** or updated. The value of the seventh parameter passed to the callback
94199481
** function is not defined for operations on WITHOUT ROWID tables, or for
9420-
** INSERT operations on rowid tables.
9482+
** DELETE operations on rowid tables.
94219483
**
94229484
** The [sqlite3_preupdate_old()], [sqlite3_preupdate_new()],
94239485
** [sqlite3_preupdate_count()], and [sqlite3_preupdate_depth()] interfaces
@@ -9479,6 +9541,7 @@ SQLITE_API int sqlite3_preupdate_new(sqlite3 *, int, sqlite3_value **);
94799541

94809542
/*
94819543
** CAPI3REF: Low-level system error code
9544+
** METHOD: sqlite3
94829545
**
94839546
** ^Attempt to return the underlying operating system error code or error
94849547
** number that caused the most recent I/O error or failure to open a file.

TMessagesProj/jni/voip/org_telegram_messenger_voip_Instance.cpp

+31-24
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ class JavaObject {
7373
struct InstanceHolder {
7474
std::unique_ptr<Instance> nativeInstance;
7575
std::unique_ptr<GroupInstanceImpl> groupNativeInstance;
76-
jobject javaInstance;
7776
std::shared_ptr<tgcalls::VideoCaptureInterface> _videoCapture;
7877
std::shared_ptr<PlatformContext> _platformContext;
7978
};
@@ -254,17 +253,17 @@ void initWebRTC(JNIEnv *env) {
254253
JNIEXPORT jlong JNICALL Java_org_telegram_messenger_voip_NativeInstance_makeGroupNativeInstance(JNIEnv *env, jclass clazz, jobject instanceObj, jboolean highQuality) {
255254
initWebRTC(env);
256255

257-
jobject globalRef = env->NewGlobalRef(instanceObj);
258-
std::shared_ptr<PlatformContext> platformContext = std::make_shared<AndroidContext>(env);
256+
std::shared_ptr<PlatformContext> platformContext = std::make_shared<AndroidContext>(env, instanceObj);
259257

260258
GroupInstanceDescriptor descriptor = {
261-
.networkStateUpdated = [globalRef](bool state) {
262-
tgvoip::jni::DoWithJNI([globalRef, state](JNIEnv *env) {
259+
.networkStateUpdated = [platformContext](bool state) {
260+
tgvoip::jni::DoWithJNI([platformContext, state](JNIEnv *env) {
261+
jobject globalRef = ((AndroidContext *) platformContext.get())->getJavaInstance();
263262
env->CallVoidMethod(globalRef, env->GetMethodID(NativeInstanceClass, "onNetworkStateUpdated", "(Z)V"), state);
264263
});
265264
},
266-
.audioLevelsUpdated = [globalRef](GroupLevelsUpdate const &update) {
267-
tgvoip::jni::DoWithJNI([globalRef, update](JNIEnv *env) {
265+
.audioLevelsUpdated = [platformContext](GroupLevelsUpdate const &update) {
266+
tgvoip::jni::DoWithJNI([platformContext, update](JNIEnv *env) {
268267
unsigned int size = update.updates.size();
269268
jintArray intArray = env->NewIntArray(size);
270269
jfloatArray floatArray = env->NewFloatArray(size);
@@ -282,6 +281,7 @@ JNIEXPORT jlong JNICALL Java_org_telegram_messenger_voip_NativeInstance_makeGrou
282281
env->SetFloatArrayRegion(floatArray, 0, size, floatFill);
283282
env->SetBooleanArrayRegion(boolArray, 0, size, boolFill);
284283

284+
jobject globalRef = ((AndroidContext *) platformContext.get())->getJavaInstance();
285285
env->CallVoidMethod(globalRef, env->GetMethodID(NativeInstanceClass, "onAudioLevelsUpdated", "([I[F[Z)V"), intArray, floatArray, boolArray);
286286
env->DeleteLocalRef(intArray);
287287
env->DeleteLocalRef(floatArray);
@@ -293,14 +293,14 @@ JNIEXPORT jlong JNICALL Java_org_telegram_messenger_voip_NativeInstance_makeGrou
293293

294294
auto *holder = new InstanceHolder;
295295
holder->groupNativeInstance = std::make_unique<GroupInstanceImpl>(std::move(descriptor));
296-
holder->javaInstance = globalRef;
297296
holder->_platformContext = platformContext;
298-
holder->groupNativeInstance->emitJoinPayload([globalRef](const GroupJoinPayload& payload) {
297+
holder->groupNativeInstance->emitJoinPayload([platformContext](const GroupJoinPayload& payload) {
299298
JNIEnv *env = webrtc::AttachCurrentThreadIfNeeded();
300299
jobjectArray array = env->NewObjectArray(payload.fingerprints.size(), FingerprintClass, 0);
301300
for (int a = 0; a < payload.fingerprints.size(); a++) {
302301
env->SetObjectArrayElement(array, a, asJavaFingerprint(env, payload.fingerprints[a].hash, payload.fingerprints[a].setup, payload.fingerprints[a].fingerprint));
303302
}
303+
jobject globalRef = ((AndroidContext *) platformContext.get())->getJavaInstance();
304304
env->CallVoidMethod(globalRef, env->GetMethodID(NativeInstanceClass, "onEmitJoinPayload", "(Ljava/lang/String;Ljava/lang/String;[Lorg/telegram/messenger/voip/Instance$Fingerprint;I)V"), env->NewStringUTF(payload.ufrag.c_str()), env->NewStringUTF(payload.pwd.c_str()), array, (jint) payload.ssrc);
305305
});
306306
return reinterpret_cast<jlong>(holder);
@@ -382,56 +382,65 @@ JNIEXPORT jlong JNICALL Java_org_telegram_messenger_voip_NativeInstance_makeNati
382382
memcpy(encryptionKeyValue->data(), valueBytes, 256);
383383
env->ReleaseByteArrayElements(valueByteArray, (jbyte *) valueBytes, JNI_ABORT);
384384

385-
jobject globalRef = env->NewGlobalRef(instanceObj);
386385
std::shared_ptr<VideoCaptureInterface> videoCapture = videoCapturer ? std::shared_ptr<VideoCaptureInterface>(reinterpret_cast<VideoCaptureInterface *>(videoCapturer)) : nullptr;
387386

388-
std::shared_ptr<PlatformContext> platformContext = videoCapture ? videoCapture->getPlatformContext() : std::make_shared<AndroidContext>(env);
387+
std::shared_ptr<PlatformContext> platformContext;
388+
if (videoCapture) {
389+
platformContext = videoCapture->getPlatformContext();
390+
((AndroidContext *) platformContext.get())->setJavaInstance(env, instanceObj);
391+
} else {
392+
platformContext = std::make_shared<AndroidContext>(env, instanceObj);
393+
}
389394

390395
Descriptor descriptor = {
391396
.config = Config{
392397
.initializationTimeout = configObject.getDoubleField("initializationTimeout"),
393398
.receiveTimeout = configObject.getDoubleField("receiveTimeout"),
394399
.dataSaving = parseDataSaving(env, configObject.getIntField("dataSaving")),
395400
.enableP2P = configObject.getBooleanField("enableP2p") == JNI_TRUE,
401+
.enableStunMarking = configObject.getBooleanField("enableSm") == JNI_TRUE,
396402
.enableAEC = configObject.getBooleanField("enableAec") == JNI_TRUE,
397403
.enableNS = configObject.getBooleanField("enableNs") == JNI_TRUE,
398404
.enableAGC = configObject.getBooleanField("enableAgc") == JNI_TRUE,
399-
.enableStunMarking = configObject.getBooleanField("enableSm") == JNI_TRUE,
400405
.enableVolumeControl = true,
401406
.logPath = tgvoip::jni::JavaStringToStdString(env, configObject.getStringField("logPath")),
407+
.statsLogPath = tgvoip::jni::JavaStringToStdString(env, configObject.getStringField("statsLogPath")),
402408
.maxApiLayer = configObject.getIntField("maxApiLayer"),
403409
.enableHighBitrateVideo = true,
404-
.statsLogPath = tgvoip::jni::JavaStringToStdString(env, configObject.getStringField("statsLogPath")),
405410
.preferredVideoCodecs = {cricket::kVp9CodecName}
406411
},
407412
.encryptionKey = EncryptionKey(
408413
std::move(encryptionKeyValue),
409414
encryptionKeyObject.getBooleanField("isOutgoing") == JNI_TRUE),
410415
.videoCapture = videoCapture,
411-
.stateUpdated = [globalRef](State state) {
416+
.stateUpdated = [platformContext](State state) {
412417
jint javaState = asJavaState(state);
418+
jobject globalRef = ((AndroidContext *) platformContext.get())->getJavaInstance();
413419
tgvoip::jni::DoWithJNI([globalRef, javaState](JNIEnv *env) {
414420
env->CallVoidMethod(globalRef, env->GetMethodID(NativeInstanceClass, "onStateUpdated", "(I)V"), javaState);
415421
});
416422
},
417-
.platformContext = platformContext,
418-
.signalBarsUpdated = [globalRef](int count) {
423+
.signalBarsUpdated = [platformContext](int count) {
424+
jobject globalRef = ((AndroidContext *) platformContext.get())->getJavaInstance();
419425
tgvoip::jni::DoWithJNI([globalRef, count](JNIEnv *env) {
420426
env->CallVoidMethod(globalRef, env->GetMethodID(NativeInstanceClass, "onSignalBarsUpdated", "(I)V"), count);
421427
});
422428
},
423-
.remoteMediaStateUpdated = [globalRef](AudioState audioState, VideoState videoState) {
429+
.remoteMediaStateUpdated = [platformContext](AudioState audioState, VideoState videoState) {
430+
jobject globalRef = ((AndroidContext *) platformContext.get())->getJavaInstance();
424431
tgvoip::jni::DoWithJNI([globalRef, audioState, videoState](JNIEnv *env) {
425432
env->CallVoidMethod(globalRef, env->GetMethodID(NativeInstanceClass, "onRemoteMediaStateUpdated", "(II)V"), (jint) audioState, (jint )videoState);
426433
});
427434
},
428-
.signalingDataEmitted = [globalRef](const std::vector<uint8_t> &data) {
435+
.signalingDataEmitted = [platformContext](const std::vector<uint8_t> &data) {
436+
jobject globalRef = ((AndroidContext *) platformContext.get())->getJavaInstance();
429437
tgvoip::jni::DoWithJNI([globalRef, data](JNIEnv *env) {
430438
jbyteArray arr = copyVectorToJavaByteArray(env, data);
431439
env->CallVoidMethod(globalRef, env->GetMethodID(NativeInstanceClass, "onSignalingData", "([B)V"), arr);
432440
env->DeleteLocalRef(arr);
433441
});
434442
},
443+
.platformContext = platformContext,
435444
};
436445

437446
for (int i = 0, size = env->GetArrayLength(endpoints); i < size; i++) {
@@ -474,7 +483,6 @@ JNIEXPORT jlong JNICALL Java_org_telegram_messenger_voip_NativeInstance_makeNati
474483

475484
auto *holder = new InstanceHolder;
476485
holder->nativeInstance = tgcalls::Meta::Create(v, std::move(descriptor));
477-
holder->javaInstance = globalRef;
478486
holder->_videoCapture = videoCapture;
479487
holder->_platformContext = platformContext;
480488
holder->nativeInstance->setIncomingVideoOutput(webrtc::JavaToNativeVideoSink(env, remoteSink));
@@ -576,10 +584,10 @@ JNIEXPORT void JNICALL Java_org_telegram_messenger_voip_NativeInstance_stopNativ
576584
}
577585
instance->nativeInstance->stop([instance](FinalState finalState) {
578586
JNIEnv *env = webrtc::AttachCurrentThreadIfNeeded();
579-
const std::string &path = tgvoip::jni::JavaStringToStdString(env, JavaObject(env, instance->javaInstance).getStringField("persistentStateFilePath"));
587+
jobject globalRef = ((AndroidContext *) instance->_platformContext.get())->getJavaInstance();
588+
const std::string &path = tgvoip::jni::JavaStringToStdString(env, JavaObject(env, globalRef).getStringField("persistentStateFilePath"));
580589
savePersistentState(path.c_str(), finalState.persistentState);
581-
env->CallVoidMethod(instance->javaInstance, env->GetMethodID(NativeInstanceClass, "onStop", "(Lorg/telegram/messenger/voip/Instance$FinalState;)V"), asJavaFinalState(env, finalState));
582-
env->DeleteGlobalRef(instance->javaInstance);
590+
env->CallVoidMethod(globalRef, env->GetMethodID(NativeInstanceClass, "onStop", "(Lorg/telegram/messenger/voip/Instance$FinalState;)V"), asJavaFinalState(env, finalState));
583591
delete instance;
584592
});
585593
}
@@ -591,13 +599,12 @@ JNIEXPORT void JNICALL Java_org_telegram_messenger_voip_NativeInstance_stopGroup
591599
}
592600
instance->groupNativeInstance->stop();
593601
instance->groupNativeInstance.reset();
594-
env->DeleteGlobalRef(instance->javaInstance);
595602
delete instance;
596603
}
597604

598605
JNIEXPORT jlong JNICALL Java_org_telegram_messenger_voip_NativeInstance_createVideoCapturer(JNIEnv *env, jclass clazz, jobject localSink, jboolean front) {
599606
initWebRTC(env);
600-
std::unique_ptr<VideoCaptureInterface> capture = tgcalls::VideoCaptureInterface::Create(front ? "front" : "back", std::make_shared<AndroidContext>(env));
607+
std::unique_ptr<VideoCaptureInterface> capture = tgcalls::VideoCaptureInterface::Create(front ? "front" : "back", std::make_shared<AndroidContext>(env, nullptr));
601608
capture->setOutput(webrtc::JavaToNativeVideoSink(env, localSink));
602609
capture->setState(VideoState::Active);
603610
return reinterpret_cast<intptr_t>(capture.release());

0 commit comments

Comments
 (0)