Skip to content

Commit 0bcf4fe

Browse files
committed
update to 9.7.6 (3721)
1 parent 6c1e8c1 commit 0bcf4fe

File tree

62 files changed

+1589
-662
lines changed

Some content is hidden

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

62 files changed

+1589
-662
lines changed

‎TMessagesProj/src/main/java/com/google/android/exoplayer2/MediaPeriodQueue.java

+19-16
Original file line numberDiff line numberDiff line change
@@ -368,22 +368,25 @@ public boolean updateQueuedPeriods(
368368
newPeriodInfo.copyWithRequestedContentPositionUs(
369369
oldPeriodInfo.requestedContentPositionUs);
370370

371-
if (!areDurationsCompatible(oldPeriodInfo.durationUs, newPeriodInfo.durationUs)) {
372-
// The period duration changed. Remove all subsequent periods and check whether we read
373-
// beyond the new duration.
374-
periodHolder.updateClipping();
375-
long newDurationInRendererTime =
376-
newPeriodInfo.durationUs == C.TIME_UNSET
377-
? Long.MAX_VALUE
378-
: periodHolder.toRendererTime(newPeriodInfo.durationUs);
379-
boolean isReadingAndReadBeyondNewDuration =
380-
periodHolder == reading
381-
&& !periodHolder.info.isFollowedByTransitionToSameStream
382-
&& (maxRendererReadPositionUs == C.TIME_END_OF_SOURCE
383-
|| maxRendererReadPositionUs >= newDurationInRendererTime);
384-
boolean readingPeriodRemoved = removeAfter(periodHolder);
385-
return !readingPeriodRemoved && !isReadingAndReadBeyondNewDuration;
386-
}
371+
//@xaxtix
372+
//comment cause lead to infinit seek loop in end of video
373+
374+
// if (!areDurationsCompatible(oldPeriodInfo.durationUs, newPeriodInfo.durationUs)) {
375+
// // The period duration changed. Remove all subsequent periods and check whether we read
376+
// // beyond the new duration.
377+
// periodHolder.updateClipping();
378+
// long newDurationInRendererTime =
379+
// newPeriodInfo.durationUs == C.TIME_UNSET
380+
// ? Long.MAX_VALUE
381+
// : periodHolder.toRendererTime(newPeriodInfo.durationUs);
382+
// boolean isReadingAndReadBeyondNewDuration =
383+
// periodHolder == reading
384+
// && !periodHolder.info.isFollowedByTransitionToSameStream
385+
// && (maxRendererReadPositionUs == C.TIME_END_OF_SOURCE
386+
// || maxRendererReadPositionUs >= newDurationInRendererTime);
387+
// boolean readingPeriodRemoved = removeAfter(periodHolder);
388+
// return !readingPeriodRemoved && !isReadingAndReadBeyondNewDuration;
389+
// }
387390

388391
previousPeriodHolder = periodHolder;
389392
periodHolder = periodHolder.getNext();

‎TMessagesProj/src/main/java/com/google/android/exoplayer2/mediacodec/DefaultMediaCodecAdapterFactory.java

+13-13
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,19 @@ public void experimentalSetSynchronizeCodecInteractionsWithQueueingEnabled(boole
9797
@Override
9898
public MediaCodecAdapter createAdapter(MediaCodecAdapter.Configuration configuration)
9999
throws IOException {
100-
// if (Util.SDK_INT >= 23
101-
// && (asynchronousMode == MODE_ENABLED
102-
// || (asynchronousMode == MODE_DEFAULT && Util.SDK_INT >= 31))) {
103-
// int trackType = MimeTypes.getTrackType(configuration.format.sampleMimeType);
104-
// Log.i(
105-
// TAG,
106-
// "Creating an asynchronous MediaCodec adapter for track type "
107-
// + Util.getTrackTypeString(trackType));
108-
// AsynchronousMediaCodecAdapter.Factory factory =
109-
// new AsynchronousMediaCodecAdapter.Factory(
110-
// trackType, enableSynchronizeCodecInteractionsWithQueueing);
111-
// return factory.createAdapter(configuration);
112-
// }
100+
if (Util.SDK_INT >= 23
101+
&& (asynchronousMode == MODE_ENABLED
102+
|| (asynchronousMode == MODE_DEFAULT && Util.SDK_INT >= 31))) {
103+
int trackType = MimeTypes.getTrackType(configuration.format.sampleMimeType);
104+
Log.i(
105+
TAG,
106+
"Creating an asynchronous MediaCodec adapter for track type "
107+
+ Util.getTrackTypeString(trackType));
108+
AsynchronousMediaCodecAdapter.Factory factory =
109+
new AsynchronousMediaCodecAdapter.Factory(
110+
trackType, enableSynchronizeCodecInteractionsWithQueueing);
111+
return factory.createAdapter(configuration);
112+
}
113113
return new SynchronousMediaCodecAdapter.Factory().createAdapter(configuration);
114114
}
115115
}

‎TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java

+17-7
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@
174174
import java.io.InputStreamReader;
175175
import java.io.OutputStream;
176176
import java.io.RandomAccessFile;
177+
import java.lang.ref.WeakReference;
177178
import java.lang.reflect.Field;
178179
import java.lang.reflect.Method;
179180
import java.net.IDN;
@@ -247,9 +248,6 @@ public class AndroidUtilities {
247248
private static int adjustOwnerClassGuid = 0;
248249
private static int altFocusableClassGuid = 0;
249250

250-
private static Paint roundPaint;
251-
private static RectF bitmapRect;
252-
253251
public static final RectF rectTmp = new RectF();
254252
public static final Rect rectTmp2 = new Rect();
255253

@@ -513,9 +511,17 @@ public static void recycleBitmaps(List<Bitmap> bitmapToRecycle) {
513511
return;
514512
}
515513
if (bitmapToRecycle != null && !bitmapToRecycle.isEmpty()) {
514+
ArrayList<WeakReference<Bitmap>> bitmapsToRecycleRef = new ArrayList<>();
515+
for (int i = 0; i < bitmapToRecycle.size(); i++) {
516+
Bitmap bitmap = bitmapToRecycle.get(i);
517+
if (bitmap != null && !bitmap.isRecycled()) {
518+
bitmapsToRecycleRef.add(new WeakReference<>(bitmap));
519+
}
520+
}
516521
AndroidUtilities.runOnUIThread(() -> Utilities.globalQueue.postRunnable(() -> {
517-
for (int i = 0; i < bitmapToRecycle.size(); i++) {
518-
Bitmap bitmap = bitmapToRecycle.get(i);
522+
for (int i = 0; i < bitmapsToRecycleRef.size(); i++) {
523+
Bitmap bitmap = bitmapsToRecycleRef.get(i).get();
524+
bitmapsToRecycleRef.get(i).clear();
519525
if (bitmap != null && !bitmap.isRecycled()) {
520526
try {
521527
bitmap.recycle();
@@ -3202,10 +3208,10 @@ public static File generateVideoPath(boolean secretChat) {
32023208
}
32033209

32043210
public static String formatFileSize(long size) {
3205-
return formatFileSize(size, false);
3211+
return formatFileSize(size, false, false);
32063212
}
32073213

3208-
public static String formatFileSize(long size, boolean removeZero) {
3214+
public static String formatFileSize(long size, boolean removeZero, boolean makeShort) {
32093215
if (size == 0) {
32103216
return String.format("%d KB", 0);
32113217
} else if (size < 1024) {
@@ -3228,6 +3234,8 @@ public static String formatFileSize(long size, boolean removeZero) {
32283234
float value = (int) (size / 1024L / 1024L) / 1000.0f;
32293235
if (removeZero && (value - (int) value) * 10 == 0) {
32303236
return String.format("%d GB", (int) value);
3237+
} else if (makeShort) {
3238+
return String.format("%.1f GB", value);
32313239
} else {
32323240
return String.format("%.2f GB", value);
32333241
}
@@ -5370,10 +5378,12 @@ public static ByteBuffer cloneByteBuffer(ByteBuffer original) {
53705378
System.gc();
53715379
clone = ByteBuffer.allocate(original.capacity());
53725380
}
5381+
int position = original.position();
53735382
original.rewind();
53745383
clone.put(original);
53755384
original.rewind();
53765385
clone.flip();
5386+
clone.position(position);
53775387
return clone;
53785388
}
53795389
}

‎TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public class BuildVars {
2424
public static boolean USE_CLOUD_STRINGS = true;
2525
public static boolean CHECK_UPDATES = true;
2626
public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29;
27-
public static int BUILD_VERSION = 3712;
28-
public static String BUILD_VERSION_STRING = "9.7.4";
27+
public static int BUILD_VERSION = 3721;
28+
public static String BUILD_VERSION_STRING = "9.7.6";
2929
public static int APP_ID = 4;
3030
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";
3131

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package org.telegram.messenger;
2+
3+
import android.content.Context;
4+
import android.content.res.Resources;
5+
import android.graphics.drawable.Drawable;
6+
7+
public class ChatMessageSharedResources {
8+
9+
public Context context;
10+
public Drawable chat_msgAvatarLiveLocationDrawable;
11+
public Drawable chat_redLocationIcon;
12+
13+
public ChatMessageSharedResources(Context context) {
14+
this.context = context;
15+
}
16+
17+
public Drawable getRedLocationIcon() {
18+
if (chat_redLocationIcon == null) {
19+
Resources resources = context.getResources();
20+
chat_redLocationIcon = resources.getDrawable(R.drawable.map_pin).mutate();
21+
}
22+
return chat_redLocationIcon;
23+
}
24+
25+
public Drawable getAvatarLiveLocation() {
26+
if (chat_msgAvatarLiveLocationDrawable == null) {
27+
Resources resources = context.getResources();
28+
chat_msgAvatarLiveLocationDrawable = resources.getDrawable(R.drawable.livepin).mutate();
29+
}
30+
return chat_msgAvatarLiveLocationDrawable;
31+
}
32+
}

‎TMessagesProj/src/main/java/org/telegram/messenger/DispatchQueue.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class DispatchQueue extends Thread {
2525
private long lastTaskTime;
2626
private static int indexPointer = 0;
2727
public final int index = indexPointer++;
28-
private int priority = THREAD_PRIORITY_DEFAULT;
28+
private int threadPriority = THREAD_PRIORITY_DEFAULT;
2929

3030
public DispatchQueue(final String threadName) {
3131
this(threadName, true);
@@ -39,7 +39,7 @@ public DispatchQueue(final String threadName, boolean start) {
3939
}
4040

4141
public DispatchQueue(final String threadName, boolean start, int priority) {
42-
this.priority = priority;
42+
this.threadPriority = priority;
4343
setName(threadName);
4444
if (start) {
4545
start();
@@ -126,8 +126,8 @@ public void run() {
126126
return true;
127127
});
128128
syncLatch.countDown();
129-
if (priority != THREAD_PRIORITY_DEFAULT) {
130-
Process.setThreadPriority(priority);
129+
if (threadPriority != THREAD_PRIORITY_DEFAULT) {
130+
Process.setThreadPriority(threadPriority);
131131
}
132132
Looper.loop();
133133
}

‎TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,12 @@ protected long[] getDownloadedLengthFromOffset(final long offset, final long len
708708
final CountDownLatch countDownLatch = new CountDownLatch(1);
709709
final long[] result = new long[2];
710710
Utilities.stageQueue.postRunnable(() -> {
711-
result[0] = getDownloadedLengthFromOffsetInternal(notLoadedBytesRanges, offset, length);
711+
try {
712+
result[0] = getDownloadedLengthFromOffsetInternal(notLoadedBytesRanges, offset, length);
713+
} catch (Throwable e) {
714+
FileLog.e(e);
715+
result[0] = 0;
716+
}
712717
if (state == stateFinished) {
713718
result[1] = 1;
714719
}

‎TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ private static void checkGson() {
165165
privateFields.add("networkType");
166166
privateFields.add("disableFree");
167167
privateFields.add("mContext");
168+
privateFields.add("priority");
168169

169170
//exclude file loading
170171
excludeRequests = new HashSet<>();
@@ -183,7 +184,7 @@ public boolean shouldSkipField(FieldAttributes f) {
183184

184185
@Override
185186
public boolean shouldSkipClass(Class<?> clazz) {
186-
return clazz.isInstance(AnimatedFileDrawable.class) || clazz.isInstance(ColorStateList.class) || clazz.isInstance(Context.class);
187+
return clazz.isInstance(DispatchQueue.class) || clazz.isInstance(AnimatedFileDrawable.class) || clazz.isInstance(ColorStateList.class) || clazz.isInstance(Context.class);
187188
}
188189
};
189190
gson = new GsonBuilder().addSerializationExclusionStrategy(strategy).registerTypeAdapterFactory(RuntimeClassNameTypeAdapterFactory.of(TLObject.class, "type_", strategy)).create();

‎TMessagesProj/src/main/java/org/telegram/messenger/FileStreamLoadOperation.java

+9-5
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public static int getStreamPrioriy(TLRPC.Document document) {
7171
@Override
7272
public long open(DataSpec dataSpec) throws IOException {
7373
uri = dataSpec.uri;
74+
transferInitializing(dataSpec);
7475
currentAccount = Utilities.parseInt(uri.getQueryParameter("account"));
7576
parentObject = FileLoader.getInstance(currentAccount).getParentObject(Utilities.parseInt(uri.getQueryParameter("rid")));
7677
document = new TLRPC.TL_document();
@@ -124,6 +125,7 @@ public int read(byte[] buffer, int offset, int readLength) throws IOException {
124125
return C.RESULT_END_OF_INPUT;
125126
} else {
126127
int availableLength = 0;
128+
int bytesRead;
127129
try {
128130
if (bytesRemaining < readLength) {
129131
readLength = (int) bytesRemaining;
@@ -165,14 +167,16 @@ public int read(byte[] buffer, int offset, int readLength) throws IOException {
165167
if (!opened) {
166168
return 0;
167169
}
168-
file.readFully(buffer, offset, availableLength);
169-
currentOffset += availableLength;
170-
bytesRemaining -= availableLength;
171-
bytesTransferred(availableLength);
170+
bytesRead = file.read(buffer, offset, availableLength);
171+
if (bytesRead > 0) {
172+
currentOffset += bytesRead;
173+
bytesRemaining -= bytesRead;
174+
bytesTransferred(bytesRead);
175+
}
172176
} catch (Exception e) {
173177
throw new IOException(e);
174178
}
175-
return availableLength;
179+
return bytesRead;
176180
}
177181
}
178182

‎TMessagesProj/src/main/java/org/telegram/messenger/ImageLoader.java

+26-11
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
import org.telegram.ui.Components.MotionBackgroundDrawable;
5353
import org.telegram.ui.Components.Point;
5454
import org.telegram.ui.Components.RLottieDrawable;
55-
import org.telegram.ui.Components.Reactions.HwEmojis;
5655
import org.telegram.ui.Components.SlotsDrawable;
5756
import org.telegram.ui.Components.ThemePreviewDrawable;
5857

@@ -103,6 +102,8 @@
103102
*/
104103
public class ImageLoader {
105104

105+
private static final boolean DEBUG_MODE = false;
106+
106107
private HashMap<String, Integer> bitmapUseCounts = new HashMap<>();
107108
private LruCache<BitmapDrawable> smallImagesMemCache;
108109
private LruCache<BitmapDrawable> memCache;
@@ -1822,7 +1823,9 @@ public static Bitmap getStrippedPhotoBitmap(byte[] photoBytes, String filter) {
18221823
data[164] = photoBytes[1];
18231824
data[166] = photoBytes[2];
18241825

1825-
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, len);
1826+
BitmapFactory.Options options = new BitmapFactory.Options();
1827+
options.inPreferredConfig = SharedConfig.deviceIsHigh() ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565;
1828+
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, len, options);
18261829
if (bitmap != null && !TextUtils.isEmpty(filter) && filter.contains("b")) {
18271830
Utilities.blurBitmap(bitmap, 3, 1, bitmap.getWidth(), bitmap.getHeight(), bitmap.getRowBytes());
18281831
}
@@ -2060,15 +2063,15 @@ public ImageLoader() {
20602063
} else {
20612064
maxSize = 15;
20622065
}
2063-
int cacheSize = Math.min(maxSize, memoryClass / 7) * 1024 * 1024;
2066+
int cacheSize = DEBUG_MODE ? 1 : Math.min(maxSize, memoryClass / 7) * 1024 * 1024;
20642067

2065-
int commonCacheSize = (int) (cacheSize * 0.8f);
2066-
int smallImagesCacheSize = (int) (cacheSize * 0.2f);
2068+
int commonCacheSize = DEBUG_MODE ? 1 : (int) (cacheSize * 0.8f);
2069+
int smallImagesCacheSize = DEBUG_MODE ? 1 : (int) (cacheSize * 0.2f);
20672070

20682071
memCache = new LruCache<BitmapDrawable>(commonCacheSize) {
20692072
@Override
20702073
protected int sizeOf(String key, BitmapDrawable value) {
2071-
return value.getBitmap().getByteCount();
2074+
return sizeOfBitmapDrawable(value);
20722075
}
20732076

20742077
@Override
@@ -2090,7 +2093,7 @@ protected void entryRemoved(boolean evicted, String key, final BitmapDrawable ol
20902093
smallImagesMemCache = new LruCache<BitmapDrawable>(smallImagesCacheSize) {
20912094
@Override
20922095
protected int sizeOf(String key, BitmapDrawable value) {
2093-
return value.getBitmap().getByteCount();
2096+
return sizeOfBitmapDrawable(value);
20942097
}
20952098

20962099
@Override
@@ -2109,18 +2112,18 @@ protected void entryRemoved(boolean evicted, String key, final BitmapDrawable ol
21092112
}
21102113
}
21112114
};
2112-
wallpaperMemCache = new LruCache<BitmapDrawable>(cacheSize / 4) {
2115+
wallpaperMemCache = new LruCache<BitmapDrawable>(DEBUG_MODE ? 1 : cacheSize / 4) {
21132116
@Override
21142117
protected int sizeOf(String key, BitmapDrawable value) {
2115-
return value.getBitmap().getByteCount();
2118+
return sizeOfBitmapDrawable(value);
21162119
}
21172120
};
21182121

2119-
lottieMemCache = new LruCache<BitmapDrawable>(512 * 512 * 2 * 4 * 5) {
2122+
lottieMemCache = new LruCache<BitmapDrawable>(DEBUG_MODE ? 1 : 512 * 512 * 2 * 4 * 5) {
21202123

21212124
@Override
21222125
protected int sizeOf(String key, BitmapDrawable value) {
2123-
return value.getIntrinsicWidth() * value.getIntrinsicHeight() * 4 * 2;
2126+
return sizeOfBitmapDrawable(value);
21242127
}
21252128

21262129
@Override
@@ -2327,6 +2330,18 @@ public void onReceive(Context arg0, Intent intent) {
23272330
checkMediaPaths();
23282331
}
23292332

2333+
private int sizeOfBitmapDrawable(BitmapDrawable value) {
2334+
if (value instanceof AnimatedFileDrawable) {
2335+
AnimatedFileDrawable animatedFileDrawable = (AnimatedFileDrawable) value;
2336+
int maxSize = animatedFileDrawable.getRenderingHeight() * animatedFileDrawable.getRenderingWidth() * 4 * 3;
2337+
maxSize = Math.max(animatedFileDrawable.getIntrinsicHeight() * value.getIntrinsicWidth() * 4 * 3, maxSize);
2338+
return maxSize;
2339+
} if (value instanceof RLottieDrawable) {
2340+
return value.getIntrinsicWidth() * value.getIntrinsicHeight() * 4 * 2;
2341+
}
2342+
return value.getBitmap().getByteCount();
2343+
}
2344+
23302345
public void checkMediaPaths() {
23312346
checkMediaPaths(null);
23322347
}

0 commit comments

Comments
 (0)