Skip to content

Commit

Permalink
Update to 8.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
xaxtix committed Mar 20, 2022
1 parent 5d55275 commit 0abe454
Show file tree
Hide file tree
Showing 116 changed files with 2,853 additions and 1,665 deletions.
4 changes: 2 additions & 2 deletions TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ android {
}
}

defaultConfig.versionCode = 2594
defaultConfig.versionCode = 2600

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

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

Expand Down
4 changes: 4 additions & 0 deletions TMessagesProj/jni/voip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,10 @@ add_library(tgcalls STATIC
voip/tgcalls/group/AVIOContextImpl.cpp
voip/tgcalls/group/StreamingMediaContext.cpp
voip/tgcalls/group/VideoStreamingPart.cpp
voip/tgcalls/v2/InstanceV2Impl.cpp
voip/tgcalls/v2/NativeNetworkingImpl.cpp
voip/tgcalls/v2/Signaling.cpp
voip/tgcalls/v2/SignalingEncryption.cpp
voip/webrtc/rtc_base/bitstream_reader.cc
voip/webrtc/rtc_base/async_invoker.cc
voip/webrtc/rtc_base/system_time.cc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
#include "libtgvoip/os/android/AudioInputOpenSLES.h"
#include "libtgvoip/os/android/JNIUtilities.h"
#include "tgcalls/VideoCaptureInterface.h"
#include "tgcalls/v2/InstanceV2Impl.h"

using namespace tgcalls;

const auto RegisterTag = Register<InstanceImpl>();
const auto RegisterTagLegacy = Register<InstanceImplLegacy>();
const auto RegisterTagV2 = Register<InstanceV2Impl>();

jclass TrafficStatsClass;
jclass FingerprintClass;
Expand Down
12 changes: 7 additions & 5 deletions TMessagesProj/jni/voip/tgcalls/v2/InstanceV2Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,8 @@ class InstanceV2ImplInternal : public std::enable_shared_from_this<InstanceV2Imp
_createAudioDeviceModule(descriptor.createAudioDeviceModule),
_eventLog(std::make_unique<webrtc::RtcEventLogNull>()),
_taskQueueFactory(webrtc::CreateDefaultTaskQueueFactory()),
_videoCapture(descriptor.videoCapture) {
_videoCapture(descriptor.videoCapture),
_platformContext(descriptor.platformContext) {
}

~InstanceV2ImplInternal() {
Expand Down Expand Up @@ -1293,8 +1294,8 @@ class InstanceV2ImplInternal : public std::enable_shared_from_this<InstanceV2Imp
mediaDeps.audio_encoder_factory = webrtc::CreateAudioEncoderFactory<webrtc::AudioEncoderOpus, webrtc::AudioEncoderL16>();
mediaDeps.audio_decoder_factory = webrtc::CreateAudioDecoderFactory<webrtc::AudioDecoderOpus, webrtc::AudioDecoderL16>();

mediaDeps.video_encoder_factory = PlatformInterface::SharedInstance()->makeVideoEncoderFactory(true);
mediaDeps.video_decoder_factory = PlatformInterface::SharedInstance()->makeVideoDecoderFactory();
mediaDeps.video_encoder_factory = PlatformInterface::SharedInstance()->makeVideoEncoderFactory(_platformContext, true);
mediaDeps.video_decoder_factory = PlatformInterface::SharedInstance()->makeVideoDecoderFactory(_platformContext);

_audioDeviceModule = createAudioDeviceModule();
/*if (!_audioDeviceModule) {
Expand Down Expand Up @@ -1964,7 +1965,7 @@ class InstanceV2ImplInternal : public std::enable_shared_from_this<InstanceV2Imp
}
}

void setIncomingVideoOutput(std::weak_ptr<rtc::VideoSinkInterface<webrtc::VideoFrame>> sink) {
void setIncomingVideoOutput(std::shared_ptr<rtc::VideoSinkInterface<webrtc::VideoFrame>> sink) {
_currentSink = sink;
if (_incomingVideoChannel) {
_incomingVideoChannel->addSink(sink);
Expand Down Expand Up @@ -2095,6 +2096,7 @@ class InstanceV2ImplInternal : public std::enable_shared_from_this<InstanceV2Imp

std::shared_ptr<VideoCaptureInterface> _videoCapture;
std::shared_ptr<VideoCaptureInterface> _screencastCapture;
std::shared_ptr<PlatformContext> _platformContext;
};

InstanceV2Impl::InstanceV2Impl(Descriptor &&descriptor) {
Expand Down Expand Up @@ -2150,7 +2152,7 @@ void InstanceV2Impl::setMuteMicrophone(bool muteMicrophone) {
});
}

void InstanceV2Impl::setIncomingVideoOutput(std::weak_ptr<rtc::VideoSinkInterface<webrtc::VideoFrame>> sink) {
void InstanceV2Impl::setIncomingVideoOutput(std::shared_ptr<rtc::VideoSinkInterface<webrtc::VideoFrame>> sink) {
_internal->perform(RTC_FROM_HERE, [sink](InstanceV2ImplInternal *internal) {
internal->setIncomingVideoOutput(sink);
});
Expand Down
2 changes: 1 addition & 1 deletion TMessagesProj/jni/voip/tgcalls/v2/InstanceV2Impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class InstanceV2Impl final : public Instance {
bool supportsVideo() override {
return true;
}
void setIncomingVideoOutput(std::weak_ptr<rtc::VideoSinkInterface<webrtc::VideoFrame>> sink) override;
void setIncomingVideoOutput(std::shared_ptr<rtc::VideoSinkInterface<webrtc::VideoFrame>> sink) override;
void setAudioOutputGainControlEnabled(bool enabled) override;
void setEchoCancellationStrength(int strength) override;
void setAudioInputDevice(std::string id) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#if defined(WEBRTC_POSIX)

#include <pthread.h>
#include <android/api-level.h>

#if defined(WEBRTC_MAC)
#include <pthread_spis.h>
#endif
Expand All @@ -24,6 +26,14 @@

namespace webrtc {

struct pthread_mutex_internal_t {
std::atomic<uint16_t> state;
} __attribute__((aligned(4)));

static inline pthread_mutex_internal_t* __get_internal_mutex(pthread_mutex_t* mutex_interface) {
return reinterpret_cast<pthread_mutex_internal_t*>(mutex_interface);
}

class RTC_LOCKABLE MutexImpl final {
public:
MutexImpl() {
Expand All @@ -38,10 +48,16 @@ class RTC_LOCKABLE MutexImpl final {
}
MutexImpl(const MutexImpl&) = delete;
MutexImpl& operator=(const MutexImpl&) = delete;
~MutexImpl() { pthread_mutex_destroy(&mutex_); }
~MutexImpl() {
if (mutexEnabled()) {
pthread_mutex_destroy(&mutex_);
}
}

void Lock() RTC_EXCLUSIVE_LOCK_FUNCTION() {
pthread_mutex_lock(&mutex_);
if (mutexEnabled()) {
pthread_mutex_lock(&mutex_);
}
owner_.SetOwner();
}
ABSL_MUST_USE_RESULT bool TryLock() RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true) {
Expand All @@ -54,10 +70,21 @@ class RTC_LOCKABLE MutexImpl final {
void AssertHeld() const RTC_ASSERT_EXCLUSIVE_LOCK() { owner_.AssertOwned(); }
void Unlock() RTC_UNLOCK_FUNCTION() {
owner_.ClearOwner();
pthread_mutex_unlock(&mutex_);
if (mutexEnabled()) {
pthread_mutex_unlock(&mutex_);
}
}

private:
// pthread mutex lead to crash when try use destroyed instance on android 9 and above
bool mutexEnabled() {
if (android_get_device_api_level() >= 28) {
pthread_mutex_internal_t *mutex = __get_internal_mutex(&mutex_);
uint16_t mutex_state = std::atomic_load_explicit(&mutex->state, std::memory_order_relaxed);
return mutex_state != 0xffff;
}
return true;
}
class OwnerRecord {
public:
#if !RTC_DCHECK_IS_ON
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public ChatListItemAnimator(ChatActivity activity, RecyclerListView listView, Th
this.activity = activity;
this.recyclerListView = listView;
translationInterpolator = DEFAULT_INTERPOLATOR;
alwaysCreateMoveAnimationIfPossible = true;
setSupportsChangeAnimations(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public abstract class SimpleItemAnimator extends RecyclerView.ItemAnimator {
private static final String TAG = "SimpleItemAnimator";

boolean mSupportsChangeAnimations = true;
protected boolean alwaysCreateMoveAnimationIfPossible;

/**
* Returns whether this ItemAnimator supports animations of change events.
Expand Down Expand Up @@ -113,8 +114,8 @@ public boolean animateDisappearance(@NonNull RecyclerView.ViewHolder viewHolder,
@Override
public boolean animateAppearance(@NonNull RecyclerView.ViewHolder viewHolder,
@Nullable ItemHolderInfo preLayoutInfo, @NonNull ItemHolderInfo postLayoutInfo) {
if (preLayoutInfo != null && (preLayoutInfo.left != postLayoutInfo.left
|| preLayoutInfo.top != postLayoutInfo.top)) {
if (preLayoutInfo != null && ((preLayoutInfo.left != postLayoutInfo.left
|| preLayoutInfo.top != postLayoutInfo.top) || alwaysCreateMoveAnimationIfPossible)) {
// slide items in if before/after locations differ
if (DEBUG) {
Log.d(TAG, "APPEARING: " + viewHolder + " with view " + viewHolder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ String format(String str, String intlPrefix, String trunkPrefix) {
}
}
if (intlPrefix != null && !hadC) {
res.insert(0, String.format("%s ", intlPrefix));
res.insert(0, intlPrefix + " ");
} else if (trunkPrefix != null && !hadN) {
res.insert(0, trunkPrefix);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.KeyguardManager;
Expand Down Expand Up @@ -119,6 +120,7 @@
import org.telegram.ui.Cells.TextDetailSettingsCell;
import org.telegram.ui.Components.AlertsCreator;
import org.telegram.ui.Components.BackgroundGradientDrawable;
import org.telegram.ui.Components.CubicBezierInterpolator;
import org.telegram.ui.Components.ForegroundColorSpanThemable;
import org.telegram.ui.Components.ForegroundDetector;
import org.telegram.ui.Components.HideViewAfterAnimation;
Expand Down Expand Up @@ -2663,12 +2665,16 @@ public static File generateVideoPath() {
return generateVideoPath(false);
}

private static SimpleDateFormat generatingVideoPathFormat;
public static File generateVideoPath(boolean secretChat) {
try {
File storageDir = getAlbumDir(secretChat);
Date date = new Date();
date.setTime(System.currentTimeMillis() + Utilities.random.nextInt(1000) + 1);
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss_SSS", Locale.US).format(date);
if (generatingVideoPathFormat == null) {
generatingVideoPathFormat = new SimpleDateFormat("yyyyMMdd_HHmmss_SSS", Locale.US);
}
String timeStamp = generatingVideoPathFormat.format(date);
return new File(storageDir, "VID_" + timeStamp + ".mp4");
} catch (Exception e) {
FileLog.e(e);
Expand Down Expand Up @@ -3826,7 +3832,7 @@ private static void updateFlagSecure(Window window) {
final boolean value = flagSecureReasons.containsKey(window) && flagSecureReasons.get(window).size() > 0;
try {
if (value) {
window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
window.addFlags(WindowManager.LayoutParams.FLAG_SECURE);
} else {
window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
}
Expand Down Expand Up @@ -3961,6 +3967,46 @@ public static void setLightNavigationBar(Window window, boolean enable) {
}
}

private static HashMap<Window, ValueAnimator> navigationBarColorAnimators;

public static void setNavigationBarColor(Window window, int color) {
setNavigationBarColor(window, color, true);
}

public static void setNavigationBarColor(Window window, int color, boolean animated) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (navigationBarColorAnimators != null) {
ValueAnimator animator = navigationBarColorAnimators.get(window);
if (animator != null) {
animator.cancel();
navigationBarColorAnimators.remove(window);
}
}

if (!animated) {
window.setNavigationBarColor(color);
} else {
ValueAnimator animator = ValueAnimator.ofArgb(window.getNavigationBarColor(), color);
animator.addUpdateListener(a -> window.setNavigationBarColor((int) a.getAnimatedValue()));
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (navigationBarColorAnimators != null) {
navigationBarColorAnimators.remove(window);
}
}
});
animator.setDuration(200);
animator.setInterpolator(CubicBezierInterpolator.DEFAULT);
animator.start();
if (navigationBarColorAnimators == null) {
navigationBarColorAnimators = new HashMap<>();
}
navigationBarColorAnimators.put(window, animator);
}
}
}

public static boolean checkHostForPunycode(String url) {
if (url == null) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static File getFilesDirFixed() {
}

public static void postInitApplication() {
if (applicationInited) {
if (applicationInited || applicationContext == null) {
return;
}
applicationInited = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public class BuildVars {
public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true;
public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29;
public static int BUILD_VERSION = 2594;
public static String BUILD_VERSION_STRING = "8.6.1";
public static int BUILD_VERSION = 2600;
public static String BUILD_VERSION_STRING = "8.6.2";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";

Expand Down
21 changes: 18 additions & 3 deletions TMessagesProj/src/main/java/org/telegram/messenger/ChatObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import android.text.TextUtils;
import android.util.SparseArray;

import androidx.annotation.IntDef;
import androidx.collection.LongSparseArray;

import com.google.android.exoplayer2.util.Log;
Expand All @@ -22,6 +23,8 @@
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.GroupCallActivity;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
Expand Down Expand Up @@ -59,6 +62,18 @@ public class ChatObject {
private static final int MAX_PARTICIPANTS_COUNT = 5000;

public static class Call {
public final static int RECORD_TYPE_AUDIO = 0,
RECORD_TYPE_VIDEO_PORTAIT = 1,
RECORD_TYPE_VIDEO_LANDSCAPE = 2;

@Retention(RetentionPolicy.SOURCE)
@IntDef({
RECORD_TYPE_AUDIO,
RECORD_TYPE_VIDEO_PORTAIT,
RECORD_TYPE_VIDEO_LANDSCAPE
})
public @interface RecordType {}

public TLRPC.GroupCall call;
public long chatId;
public LongSparseArray<TLRPC.TL_groupCallParticipant> participants = new LongSparseArray<>();
Expand Down Expand Up @@ -1333,7 +1348,7 @@ private void checkOnlineParticipants() {
}
}

public void toggleRecord(String title, int type) {
public void toggleRecord(String title, @RecordType int type) {
recording = !recording;
TLRPC.TL_phone_toggleGroupCallRecord req = new TLRPC.TL_phone_toggleGroupCallRecord();
req.call = getInputGroupCall();
Expand All @@ -1342,10 +1357,10 @@ public void toggleRecord(String title, int type) {
req.title = title;
req.flags |= 2;
}
if (type == 1 || type == 2) {
if (type == RECORD_TYPE_VIDEO_PORTAIT || type == RECORD_TYPE_VIDEO_LANDSCAPE) {
req.flags |= 4;
req.video = true;
req.video_portrait = type == 1;
req.video_portrait = type == RECORD_TYPE_VIDEO_PORTAIT;
}
currentAccount.getConnectionsManager().sendRequest(req, (response, error) -> {
if (response != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,8 @@ public void handleMessage(Message msg) {
syncLatch.countDown();
Looper.loop();
}

public boolean isReady() {
return syncLatch.getCount() == 0;
}
}
Loading

1 comment on commit 0abe454

@fendo8888
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little curious about what technology is used to achieve the ten thousand people in the Telegram group chat. Are there any public resources to learn?

Please sign in to comment.