Update to 6.3.0 (2042)

This commit is contained in:
DrKLO 2020-07-27 00:11:01 +03:00
parent 520592b43d
commit 320710366d
17 changed files with 222 additions and 211 deletions

View file

@ -277,7 +277,7 @@ android {
} }
} }
defaultConfig.versionCode = 2040 defaultConfig.versionCode = 2042
def tgVoipDexFileName = "libtgvoip.dex" def tgVoipDexFileName = "libtgvoip.dex"
def tgVoipDexClasses = ["AudioRecordJNI", "AudioTrackJNI", "NativeTgVoipDelegate", "NativeTgVoipInstance", "TgVoipNativeLoader", "Resampler", "VLog"] def tgVoipDexClasses = ["AudioRecordJNI", "AudioTrackJNI", "NativeTgVoipDelegate", "NativeTgVoipInstance", "TgVoipNativeLoader", "Resampler", "VLog"]

View file

@ -353,7 +353,7 @@ include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_PRELINK_MODULE := false LOCAL_PRELINK_MODULE := false
LOCAL_MODULE := tmessages.30 LOCAL_MODULE := tmessages.31
LOCAL_CFLAGS := -w -std=c11 -Os -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1 LOCAL_CFLAGS := -w -std=c11 -Os -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1
LOCAL_CFLAGS += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -fno-math-errno LOCAL_CFLAGS += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -fno-math-errno
LOCAL_CFLAGS += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT -ffast-math -D__STDC_CONSTANT_MACROS LOCAL_CFLAGS += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT -ffast-math -D__STDC_CONSTANT_MACROS

View file

@ -19,7 +19,7 @@ public class BuildVars {
public static boolean USE_CLOUD_STRINGS = true; public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true; public static boolean CHECK_UPDATES = true;
public static boolean TON_WALLET_STANDALONE = false; public static boolean TON_WALLET_STANDALONE = false;
public static int BUILD_VERSION = 2040; public static int BUILD_VERSION = 2042;
public static String BUILD_VERSION_STRING = "6.3.0"; public static String BUILD_VERSION_STRING = "6.3.0";
public static int APP_ID = 4; public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103"; public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";

View file

@ -65,21 +65,21 @@ public class DispatchQueue extends Thread {
} }
} }
public void postRunnable(Runnable runnable) { public boolean postRunnable(Runnable runnable) {
postRunnable(runnable, 0);
lastTaskTime = SystemClock.elapsedRealtime(); lastTaskTime = SystemClock.elapsedRealtime();
return postRunnable(runnable, 0);
} }
public void postRunnable(Runnable runnable, long delay) { public boolean postRunnable(Runnable runnable, long delay) {
try { try {
syncLatch.await(); syncLatch.await();
} catch (Exception e) { } catch (Exception e) {
FileLog.e(e); FileLog.e(e);
} }
if (delay <= 0) { if (delay <= 0) {
handler.post(runnable); return handler.post(runnable);
} else { } else {
handler.postDelayed(runnable, delay); return handler.postDelayed(runnable, delay);
} }
} }

View file

@ -75,6 +75,9 @@ public class FileLoadOperation {
private final static int preloadMaxBytes = 2 * 1024 * 1024; private final static int preloadMaxBytes = 2 * 1024 * 1024;
private String fileName;
private int currentQueueType;
private SparseArray<PreloadRange> preloadedBytesRanges; private SparseArray<PreloadRange> preloadedBytesRanges;
private SparseIntArray requestedPreloadedBytesRanges; private SparseIntArray requestedPreloadedBytesRanges;
private RandomAccessFile preloadStream; private RandomAccessFile preloadStream;
@ -130,6 +133,8 @@ public class FileLoadOperation {
private SparseArray<TLRPC.TL_fileHash> cdnHashes; private SparseArray<TLRPC.TL_fileHash> cdnHashes;
private boolean forceBig;
private byte[] encryptKey; private byte[] encryptKey;
private byte[] encryptIv; private byte[] encryptIv;
@ -174,6 +179,7 @@ public class FileLoadOperation {
public FileLoadOperation(ImageLocation imageLocation, Object parent, String extension, int size) { public FileLoadOperation(ImageLocation imageLocation, Object parent, String extension, int size) {
parentObject = parent; parentObject = parent;
forceBig = imageLocation.imageType == FileLoader.IMAGE_TYPE_ANIMATION;
if (imageLocation.isEncrypted()) { if (imageLocation.isEncrypted()) {
location = new TLRPC.TL_inputEncryptedFileLocation(); location = new TLRPC.TL_inputEncryptedFileLocation();
location.id = imageLocation.location.volume_id; location.id = imageLocation.location.volume_id;
@ -357,10 +363,16 @@ public class FileLoadOperation {
return priority; return priority;
} }
public void setPaths(int instance, File store, File temp) { public void setPaths(int instance, String name, int queueType, File store, File temp) {
storePath = store; storePath = store;
tempPath = temp; tempPath = temp;
currentAccount = instance; currentAccount = instance;
fileName = name;
currentQueueType = queueType;
}
public int getQueueType() {
return currentQueueType;
} }
public boolean wasStarted() { public boolean wasStarted() {
@ -555,11 +567,7 @@ public class FileLoadOperation {
} }
public String getFileName() { public String getFileName() {
if (location != null) { return fileName;
return location.volume_id + "_" + location.local_id + "." + ext;
} else {
return Utilities.MD5(webFile.url) + "." + ext;
}
} }
protected void removeStreamListener(final FileLoadOperationStream operation) { protected void removeStreamListener(final FileLoadOperationStream operation) {
@ -591,8 +599,8 @@ public class FileLoadOperation {
public boolean start(final FileLoadOperationStream stream, final int streamOffset, final boolean steamPriority) { public boolean start(final FileLoadOperationStream stream, final int streamOffset, final boolean steamPriority) {
if (currentDownloadChunkSize == 0) { if (currentDownloadChunkSize == 0) {
currentDownloadChunkSize = totalBytesCount >= bigFileSizeFrom ? downloadChunkSizeBig : downloadChunkSize; currentDownloadChunkSize = totalBytesCount >= bigFileSizeFrom || forceBig ? downloadChunkSizeBig : downloadChunkSize;
currentMaxDownloadRequests = totalBytesCount >= bigFileSizeFrom ? maxDownloadRequestsBig : maxDownloadRequests; currentMaxDownloadRequests = totalBytesCount >= bigFileSizeFrom || forceBig ? maxDownloadRequestsBig : maxDownloadRequests;
} }
final boolean alreadyStarted = state != stateIdle; final boolean alreadyStarted = state != stateIdle;
final boolean wasPaused = paused; final boolean wasPaused = paused;
@ -1449,7 +1457,7 @@ public class FileLoadOperation {
if (location != null) { if (location != null) {
FileLog.e("invalid cdn hash " + location + " id = " + location.id + " local_id = " + location.local_id + " access_hash = " + location.access_hash + " volume_id = " + location.volume_id + " secret = " + location.secret); FileLog.e("invalid cdn hash " + location + " id = " + location.id + " local_id = " + location.local_id + " access_hash = " + location.access_hash + " volume_id = " + location.volume_id + " secret = " + location.secret);
} else if (webLocation != null) { } else if (webLocation != null) {
FileLog.e("invalid cdn hash " + webLocation + " id = " + getFileName()); FileLog.e("invalid cdn hash " + webLocation + " id = " + fileName);
} }
} }
onFail(false, 0); onFail(false, 0);
@ -1536,7 +1544,7 @@ public class FileLoadOperation {
if (location != null) { if (location != null) {
FileLog.e(error.text + " " + location + " id = " + location.id + " local_id = " + location.local_id + " access_hash = " + location.access_hash + " volume_id = " + location.volume_id + " secret = " + location.secret); FileLog.e(error.text + " " + location + " id = " + location.id + " local_id = " + location.local_id + " access_hash = " + location.access_hash + " volume_id = " + location.volume_id + " secret = " + location.secret);
} else if (webLocation != null) { } else if (webLocation != null) {
FileLog.e(error.text + " " + webLocation + " id = " + getFileName()); FileLog.e(error.text + " " + webLocation + " id = " + fileName);
} }
} }
onFail(false, 0); onFail(false, 0);

View file

@ -48,6 +48,10 @@ public class FileLoader extends BaseController {
public static final int IMAGE_TYPE_SVG_WHITE = 4; public static final int IMAGE_TYPE_SVG_WHITE = 4;
public static final int IMAGE_TYPE_THEME_PREVIEW = 5; public static final int IMAGE_TYPE_THEME_PREVIEW = 5;
public static final int QUEUE_TYPE_FILE = 0;
public static final int QUEUE_TYPE_IMAGE = 1;
public static final int QUEUE_TYPE_AUDIO = 2;
public final static long MAX_FILE_SIZE = 1024L * 1024L * 2000L; public final static long MAX_FILE_SIZE = 1024L * 1024L * 2000L;
private volatile static DispatchQueue fileLoaderQueue = new DispatchQueue("fileUploadQueue"); private volatile static DispatchQueue fileLoaderQueue = new DispatchQueue("fileUploadQueue");
@ -59,12 +63,12 @@ public class FileLoader extends BaseController {
private int currentUploadOperationsCount = 0; private int currentUploadOperationsCount = 0;
private int currentUploadSmallOperationsCount = 0; private int currentUploadSmallOperationsCount = 0;
private SparseArray<LinkedList<FileLoadOperation>> loadOperationQueues = new SparseArray<>(); private SparseArray<LinkedList<FileLoadOperation>> fileLoadOperationQueues = new SparseArray<>();
private SparseArray<LinkedList<FileLoadOperation>> audioLoadOperationQueues = new SparseArray<>(); private SparseArray<LinkedList<FileLoadOperation>> audioLoadOperationQueues = new SparseArray<>();
private SparseArray<LinkedList<FileLoadOperation>> photoLoadOperationQueues = new SparseArray<>(); private SparseArray<LinkedList<FileLoadOperation>> imageLoadOperationQueues = new SparseArray<>();
private SparseIntArray currentLoadOperationsCount = new SparseIntArray(); private SparseIntArray fileLoadOperationsCount = new SparseIntArray();
private SparseIntArray currentAudioLoadOperationsCount = new SparseIntArray(); private SparseIntArray audioLoadOperationsCount = new SparseIntArray();
private SparseIntArray currentPhotoLoadOperationsCount = new SparseIntArray(); private SparseIntArray imageLoadOperationsCount = new SparseIntArray();
private ConcurrentHashMap<String, FileLoadOperation> loadOperationPaths = new ConcurrentHashMap<>(); private ConcurrentHashMap<String, FileLoadOperation> loadOperationPaths = new ConcurrentHashMap<>();
private ArrayList<FileLoadOperation> activeFileLoadOperation = new ArrayList<>(); private ArrayList<FileLoadOperation> activeFileLoadOperation = new ArrayList<>();
@ -73,6 +77,8 @@ public class FileLoader extends BaseController {
private HashMap<String, Boolean> loadingVideos = new HashMap<>(); private HashMap<String, Boolean> loadingVideos = new HashMap<>();
private String forceLoadingFile;
private static SparseArray<File> mediaDirs = null; private static SparseArray<File> mediaDirs = null;
private FileLoaderDelegate delegate = null; private FileLoaderDelegate delegate = null;
@ -357,31 +363,73 @@ public class FileLoader extends BaseController {
}); });
} }
private LinkedList<FileLoadOperation> getAudioLoadOperationQueue(int datacenterId) { private LinkedList<FileLoadOperation> getLoadOperationQueue(int datacenterId, int type) {
LinkedList<FileLoadOperation> audioLoadOperationQueue = audioLoadOperationQueues.get(datacenterId); SparseArray<LinkedList<FileLoadOperation>> queues;
if (audioLoadOperationQueue == null) { if (type == QUEUE_TYPE_AUDIO) {
audioLoadOperationQueue = new LinkedList<>(); queues = audioLoadOperationQueues;
audioLoadOperationQueues.put(datacenterId, audioLoadOperationQueue); } else if (type == QUEUE_TYPE_IMAGE) {
queues = imageLoadOperationQueues;
} else {
queues = fileLoadOperationQueues;
} }
return audioLoadOperationQueue; LinkedList<FileLoadOperation> queue = queues.get(datacenterId);
if (queue == null) {
queue = new LinkedList<>();
queues.put(datacenterId, queue);
}
return queue;
} }
private LinkedList<FileLoadOperation> getPhotoLoadOperationQueue(int datacenterId) { private SparseIntArray getLoadOperationCount(int type) {
LinkedList<FileLoadOperation> photoLoadOperationQueue = photoLoadOperationQueues.get(datacenterId); SparseArray<LinkedList<FileLoadOperation>> queues;
if (photoLoadOperationQueue == null) { if (type == QUEUE_TYPE_AUDIO) {
photoLoadOperationQueue = new LinkedList<>(); return audioLoadOperationsCount;
photoLoadOperationQueues.put(datacenterId, photoLoadOperationQueue); } else if (type == QUEUE_TYPE_IMAGE) {
return imageLoadOperationsCount;
} else {
return fileLoadOperationsCount;
} }
return photoLoadOperationQueue;
} }
private LinkedList<FileLoadOperation> getLoadOperationQueue(int datacenterId) { public void setForceStreamLoadingFile(TLRPC.FileLocation location, String ext) {
LinkedList<FileLoadOperation> loadOperationQueue = loadOperationQueues.get(datacenterId); if (location == null) {
if (loadOperationQueue == null) { return;
loadOperationQueue = new LinkedList<>();
loadOperationQueues.put(datacenterId, loadOperationQueue);
} }
return loadOperationQueue; fileLoaderQueue.postRunnable(() -> {
forceLoadingFile = getAttachFileName(location, ext);
FileLoadOperation operation = loadOperationPaths.get(forceLoadingFile);
if (operation != null) {
if (operation.isPreloadVideoOperation()) {
operation.setIsPreloadVideoOperation(false);
}
operation.setForceRequest(true);
int datacenterId = operation.getDatacenterId();
int queueType = operation.getQueueType();
LinkedList<FileLoadOperation> downloadQueue = getLoadOperationQueue(datacenterId, queueType);
SparseIntArray count = getLoadOperationCount(queueType);
if (downloadQueue != null) {
int index = downloadQueue.indexOf(operation);
if (index >= 0) {
downloadQueue.remove(index);
if (operation.start()) {
count.put(datacenterId, count.get(datacenterId) + 1);
}
if (queueType == QUEUE_TYPE_FILE) {
if (operation.wasStarted() && !activeFileLoadOperation.contains(operation)) {
pauseCurrentFileLoadOperations(operation);
activeFileLoadOperation.add(operation);
}
}
} else {
pauseCurrentFileLoadOperations(operation);
operation.start();
if (queueType == QUEUE_TYPE_FILE && !activeFileLoadOperation.contains(operation)) {
activeFileLoadOperation.add(operation);
}
}
}
}
});
} }
public void cancelLoadFile(TLRPC.Document document) { public void cancelLoadFile(TLRPC.Document document) {
@ -427,22 +475,14 @@ public class FileLoader extends BaseController {
fileLoaderQueue.postRunnable(() -> { fileLoaderQueue.postRunnable(() -> {
FileLoadOperation operation = loadOperationPaths.remove(fileName); FileLoadOperation operation = loadOperationPaths.remove(fileName);
if (operation != null) { if (operation != null) {
int queueType = operation.getQueueType();
int datacenterId = operation.getDatacenterId(); int datacenterId = operation.getDatacenterId();
if (MessageObject.isVoiceDocument(document) || MessageObject.isVoiceWebDocument(webDocument)) { LinkedList<FileLoadOperation> queue = getLoadOperationQueue(datacenterId, queueType);
LinkedList<FileLoadOperation> audioLoadOperationQueue = getAudioLoadOperationQueue(datacenterId); if (!queue.remove(operation)) {
if (!audioLoadOperationQueue.remove(operation)) { SparseIntArray count = getLoadOperationCount(queueType);
currentAudioLoadOperationsCount.put(datacenterId, currentAudioLoadOperationsCount.get(datacenterId) - 1); count.put(datacenterId, count.get(datacenterId) - 1);
}
} else if (secureDocument != null || location != null || MessageObject.isImageWebDocument(webDocument)) {
LinkedList<FileLoadOperation> photoLoadOperationQueue = getPhotoLoadOperationQueue(datacenterId);
if (!photoLoadOperationQueue.remove(operation)) {
currentPhotoLoadOperationsCount.put(datacenterId, currentPhotoLoadOperationsCount.get(datacenterId) - 1);
}
} else {
LinkedList<FileLoadOperation> loadOperationQueue = getLoadOperationQueue(datacenterId);
if (!loadOperationQueue.remove(operation)) {
currentLoadOperationsCount.put(datacenterId, currentLoadOperationsCount.get(datacenterId) - 1);
} }
if (queueType == QUEUE_TYPE_FILE) {
activeFileLoadOperation.remove(operation); activeFileLoadOperation.remove(operation);
} }
operation.cancel(); operation.cancel();
@ -500,23 +540,25 @@ public class FileLoader extends BaseController {
private void pauseCurrentFileLoadOperations(FileLoadOperation newOperation) { private void pauseCurrentFileLoadOperations(FileLoadOperation newOperation) {
for (int a = 0; a < activeFileLoadOperation.size(); a++) { for (int a = 0; a < activeFileLoadOperation.size(); a++) {
FileLoadOperation operation = activeFileLoadOperation.get(a); FileLoadOperation operation = activeFileLoadOperation.get(a);
if (operation == newOperation || operation.getDatacenterId() != newOperation.getDatacenterId()) { if (operation == newOperation || operation.getDatacenterId() != newOperation.getDatacenterId() || operation.getFileName().equals(forceLoadingFile)) {
continue; continue;
} }
activeFileLoadOperation.remove(operation); activeFileLoadOperation.remove(operation);
a--; a--;
int datacenterId = operation.getDatacenterId(); int datacenterId = operation.getDatacenterId();
LinkedList<FileLoadOperation> loadOperationQueue = getLoadOperationQueue(datacenterId); int queueType = operation.getQueueType();
loadOperationQueue.add(0, operation); LinkedList<FileLoadOperation> downloadQueue = getLoadOperationQueue(datacenterId, queueType);
SparseIntArray count = getLoadOperationCount(queueType);
downloadQueue.add(0, operation);
if (operation.wasStarted()) { if (operation.wasStarted()) {
currentLoadOperationsCount.put(datacenterId, currentLoadOperationsCount.get(datacenterId) - 1); count.put(datacenterId, count.get(datacenterId) - 1);
} }
operation.pause(); operation.pause();
} }
} }
private FileLoadOperation loadFileInternal(final TLRPC.Document document, final SecureDocument secureDocument, final WebFile webDocument, TLRPC.TL_fileLocationToBeDeprecated location, final ImageLocation imageLocation, Object parentObject, final String locationExt, final int locationSize, final int priority, final FileLoadOperationStream stream, final int streamOffset, boolean streamPriority, final int cacheType) { private FileLoadOperation loadFileInternal(final TLRPC.Document document, final SecureDocument secureDocument, final WebFile webDocument, TLRPC.TL_fileLocationToBeDeprecated location, final ImageLocation imageLocation, Object parentObject, final String locationExt, final int locationSize, final int priority, final FileLoadOperationStream stream, final int streamOffset, boolean streamPriority, final int cacheType) {
String fileName = null; String fileName;
if (location != null) { if (location != null) {
fileName = getAttachFileName(location, locationExt); fileName = getAttachFileName(location, locationExt);
} else if (secureDocument != null) { } else if (secureDocument != null) {
@ -525,6 +567,8 @@ public class FileLoader extends BaseController {
fileName = getAttachFileName(document); fileName = getAttachFileName(document);
} else if (webDocument != null) { } else if (webDocument != null) {
fileName = getAttachFileName(webDocument); fileName = getAttachFileName(webDocument);
} else {
fileName = null;
} }
if (fileName == null || fileName.contains("" + Integer.MIN_VALUE)) { if (fileName == null || fileName.contains("" + Integer.MIN_VALUE)) {
return null; return null;
@ -533,45 +577,27 @@ public class FileLoader extends BaseController {
loadOperationPathsUI.put(fileName, true); loadOperationPathsUI.put(fileName, true);
} }
FileLoadOperation operation; FileLoadOperation operation = loadOperationPaths.get(fileName);
operation = loadOperationPaths.get(fileName);
if (operation != null) { if (operation != null) {
if (cacheType != 10 && operation.isPreloadVideoOperation()) { if (cacheType != 10 && operation.isPreloadVideoOperation()) {
operation.setIsPreloadVideoOperation(false); operation.setIsPreloadVideoOperation(false);
} }
if (stream != null || priority > 0) { if (stream != null || priority > 0) {
int datacenterId = operation.getDatacenterId(); int datacenterId = operation.getDatacenterId();
LinkedList<FileLoadOperation> audioLoadOperationQueue = getAudioLoadOperationQueue(datacenterId);
LinkedList<FileLoadOperation> photoLoadOperationQueue = getPhotoLoadOperationQueue(datacenterId);
LinkedList<FileLoadOperation> loadOperationQueue = getLoadOperationQueue(datacenterId);
operation.setForceRequest(true); operation.setForceRequest(true);
LinkedList<FileLoadOperation> downloadQueue;
if (MessageObject.isVoiceDocument(document) || MessageObject.isVoiceWebDocument(webDocument)) { int queueType = operation.getQueueType();
downloadQueue = audioLoadOperationQueue; LinkedList<FileLoadOperation> downloadQueue = getLoadOperationQueue(datacenterId, queueType);
} else if (secureDocument != null || location != null || MessageObject.isImageWebDocument(webDocument)) { SparseIntArray count = getLoadOperationCount(queueType);
downloadQueue = photoLoadOperationQueue;
} else {
downloadQueue = loadOperationQueue;
}
if (downloadQueue != null) { if (downloadQueue != null) {
int index = downloadQueue.indexOf(operation); int index = downloadQueue.indexOf(operation);
if (index >= 0) { if (index >= 0) {
downloadQueue.remove(index); downloadQueue.remove(index);
if (stream != null) { if (stream != null) {
if (downloadQueue == audioLoadOperationQueue) {
if (operation.start(stream, streamOffset, streamPriority)) { if (operation.start(stream, streamOffset, streamPriority)) {
currentAudioLoadOperationsCount.put(datacenterId, currentAudioLoadOperationsCount.get(datacenterId) + 1); count.put(datacenterId, count.get(datacenterId) + 1);
}
} else if (downloadQueue == photoLoadOperationQueue) {
if (operation.start(stream, streamOffset, streamPriority)) {
currentPhotoLoadOperationsCount.put(datacenterId, currentPhotoLoadOperationsCount.get(datacenterId) + 1);
}
} else {
if (operation.start(stream, streamOffset, streamPriority)) {
currentLoadOperationsCount.put(datacenterId, currentLoadOperationsCount.get(datacenterId) + 1);
} }
if (queueType == QUEUE_TYPE_FILE) {
if (operation.wasStarted() && !activeFileLoadOperation.contains(operation)) { if (operation.wasStarted() && !activeFileLoadOperation.contains(operation)) {
if (stream != null) { if (stream != null) {
pauseCurrentFileLoadOperations(operation); pauseCurrentFileLoadOperations(operation);
@ -587,7 +613,7 @@ public class FileLoader extends BaseController {
pauseCurrentFileLoadOperations(operation); pauseCurrentFileLoadOperations(operation);
} }
operation.start(stream, streamOffset, streamPriority); operation.start(stream, streamOffset, streamPriority);
if (downloadQueue == loadOperationQueue && !activeFileLoadOperation.contains(operation)) { if (queueType == QUEUE_TYPE_FILE && !activeFileLoadOperation.contains(operation)) {
activeFileLoadOperation.add(operation); activeFileLoadOperation.add(operation);
} }
} }
@ -600,6 +626,14 @@ public class FileLoader extends BaseController {
File tempDir = getDirectory(MEDIA_DIR_CACHE); File tempDir = getDirectory(MEDIA_DIR_CACHE);
File storeDir = tempDir; File storeDir = tempDir;
int type = MEDIA_DIR_CACHE; int type = MEDIA_DIR_CACHE;
int queueType;
if (type == MEDIA_DIR_AUDIO) {
queueType = QUEUE_TYPE_AUDIO;
} else if (secureDocument != null || location != null && (imageLocation == null || imageLocation.imageType != IMAGE_TYPE_ANIMATION) || MessageObject.isImageWebDocument(webDocument)) {
queueType = QUEUE_TYPE_IMAGE;
} else {
queueType = QUEUE_TYPE_FILE;
}
if (secureDocument != null) { if (secureDocument != null) {
operation = new FileLoadOperation(secureDocument); operation = new FileLoadOperation(secureDocument);
@ -633,12 +667,11 @@ public class FileLoader extends BaseController {
} else if (cacheType == 2) { } else if (cacheType == 2) {
operation.setEncryptFile(true); operation.setEncryptFile(true);
} }
operation.setPaths(currentAccount, storeDir, tempDir); operation.setPaths(currentAccount, fileName, queueType, storeDir, tempDir);
if (cacheType == 10) { if (cacheType == 10) {
operation.setIsPreloadVideoOperation(true); operation.setIsPreloadVideoOperation(true);
} }
final String finalFileName = fileName;
final int finalType = type; final int finalType = type;
FileLoadOperation.FileLoadOperationDelegate fileLoadOperationDelegate = new FileLoadOperation.FileLoadOperationDelegate() { FileLoadOperation.FileLoadOperationDelegate fileLoadOperationDelegate = new FileLoadOperation.FileLoadOperationDelegate() {
@Override @Override
@ -647,27 +680,27 @@ public class FileLoader extends BaseController {
return; return;
} }
if (!operation.isPreloadVideoOperation()) { if (!operation.isPreloadVideoOperation()) {
loadOperationPathsUI.remove(finalFileName); loadOperationPathsUI.remove(fileName);
if (delegate != null) { if (delegate != null) {
delegate.fileDidLoaded(finalFileName, finalFile, finalType); delegate.fileDidLoaded(fileName, finalFile, finalType);
} }
} }
checkDownloadQueue(operation.getDatacenterId(), document, webDocument, location, finalFileName); checkDownloadQueue(operation.getDatacenterId(), queueType, fileName);
} }
@Override @Override
public void didFailedLoadingFile(FileLoadOperation operation, int reason) { public void didFailedLoadingFile(FileLoadOperation operation, int reason) {
loadOperationPathsUI.remove(finalFileName); loadOperationPathsUI.remove(fileName);
checkDownloadQueue(operation.getDatacenterId(), document, webDocument, location, finalFileName); checkDownloadQueue(operation.getDatacenterId(), queueType, fileName);
if (delegate != null) { if (delegate != null) {
delegate.fileDidFailedLoad(finalFileName, reason); delegate.fileDidFailedLoad(fileName, reason);
} }
} }
@Override @Override
public void didChangedLoadProgress(FileLoadOperation operation, long uploadedSize, long totalSize) { public void didChangedLoadProgress(FileLoadOperation operation, long uploadedSize, long totalSize) {
if (delegate != null) { if (delegate != null) {
delegate.fileLoadProgressChanged(finalFileName, uploadedSize, totalSize); delegate.fileLoadProgressChanged(fileName, uploadedSize, totalSize);
} }
} }
}; };
@ -675,47 +708,42 @@ public class FileLoader extends BaseController {
int datacenterId = operation.getDatacenterId(); int datacenterId = operation.getDatacenterId();
LinkedList<FileLoadOperation> audioLoadOperationQueue = getAudioLoadOperationQueue(datacenterId);
LinkedList<FileLoadOperation> photoLoadOperationQueue = getPhotoLoadOperationQueue(datacenterId);
LinkedList<FileLoadOperation> loadOperationQueue = getLoadOperationQueue(datacenterId);
loadOperationPaths.put(fileName, operation); loadOperationPaths.put(fileName, operation);
operation.setPriority(priority); operation.setPriority(priority);
if (type == MEDIA_DIR_AUDIO) {
boolean started;
if (queueType == QUEUE_TYPE_AUDIO) {
int maxCount = priority > 0 ? 3 : 1; int maxCount = priority > 0 ? 3 : 1;
int count = currentAudioLoadOperationsCount.get(datacenterId); int count = audioLoadOperationsCount.get(datacenterId);
if (stream != null || count < maxCount) { if (started = (stream != null || count < maxCount)) {
if (operation.start(stream, streamOffset, streamPriority)) { if (operation.start(stream, streamOffset, streamPriority)) {
currentAudioLoadOperationsCount.put(datacenterId, count + 1); audioLoadOperationsCount.put(datacenterId, count + 1);
} }
} else {
addOperationToQueue(operation, audioLoadOperationQueue);
} }
} else if (location != null || MessageObject.isImageWebDocument(webDocument)) { } else if (queueType == QUEUE_TYPE_IMAGE) {
int maxCount = priority > 0 ? 6 : 2; int maxCount = priority > 0 ? 6 : 2;
int count = currentPhotoLoadOperationsCount.get(datacenterId); int count = imageLoadOperationsCount.get(datacenterId);
if (stream != null || count < maxCount) { if (started = (stream != null || count < maxCount)) {
if (operation.start(stream, streamOffset, streamPriority)) { if (operation.start(stream, streamOffset, streamPriority)) {
currentPhotoLoadOperationsCount.put(datacenterId, count + 1); imageLoadOperationsCount.put(datacenterId, count + 1);
} }
} else {
addOperationToQueue(operation, photoLoadOperationQueue);
} }
} else { } else {
int maxCount = priority > 0 ? 4 : 1; int maxCount = priority > 0 ? 4 : 1;
int count = currentLoadOperationsCount.get(datacenterId); int count = fileLoadOperationsCount.get(datacenterId);
if (stream != null || count < maxCount) { if (started = (stream != null || count < maxCount)) {
if (operation.start(stream, streamOffset, streamPriority)) { if (operation.start(stream, streamOffset, streamPriority)) {
currentLoadOperationsCount.put(datacenterId, count + 1); fileLoadOperationsCount.put(datacenterId, count + 1);
activeFileLoadOperation.add(operation); activeFileLoadOperation.add(operation);
} }
if (operation.wasStarted() && stream != null) { if (operation.wasStarted() && stream != null) {
pauseCurrentFileLoadOperations(operation); pauseCurrentFileLoadOperations(operation);
} }
} else {
addOperationToQueue(operation, loadOperationQueue);
} }
} }
if (!started) {
addOperationToQueue(operation, getLoadOperationQueue(datacenterId, queueType));
}
return operation; return operation;
} }
@ -768,92 +796,53 @@ public class FileLoader extends BaseController {
return result[0]; return result[0];
} }
private void checkDownloadQueue(final int datacenterId, final TLRPC.Document document, final WebFile webDocument, final TLRPC.FileLocation location, final String arg1) { private void checkDownloadQueue(int datacenterId, int queueType, String fileName) {
fileLoaderQueue.postRunnable(() -> { fileLoaderQueue.postRunnable(() -> {
LinkedList<FileLoadOperation> audioLoadOperationQueue = getAudioLoadOperationQueue(datacenterId); FileLoadOperation operation = loadOperationPaths.remove(fileName);
LinkedList<FileLoadOperation> photoLoadOperationQueue = getPhotoLoadOperationQueue(datacenterId); LinkedList<FileLoadOperation> queue = getLoadOperationQueue(datacenterId, queueType);
LinkedList<FileLoadOperation> loadOperationQueue = getLoadOperationQueue(datacenterId); SparseIntArray operationCount = getLoadOperationCount(queueType);
int count = operationCount.get(datacenterId);
FileLoadOperation operation = loadOperationPaths.remove(arg1);
if (MessageObject.isVoiceDocument(document) || MessageObject.isVoiceWebDocument(webDocument)) {
int count = currentAudioLoadOperationsCount.get(datacenterId);
if (operation != null) { if (operation != null) {
if (operation.wasStarted()) { if (operation.wasStarted()) {
count--; count--;
currentAudioLoadOperationsCount.put(datacenterId, count); operationCount.put(datacenterId, count);
} else { } else {
audioLoadOperationQueue.remove(operation); queue.remove(operation);
}
}
while (!audioLoadOperationQueue.isEmpty()) {
operation = audioLoadOperationQueue.get(0);
int maxCount = operation.getPriority() != 0 ? 3 : 1;
if (count < maxCount) {
operation = audioLoadOperationQueue.poll();
if (operation != null && operation.start()) {
count++;
currentAudioLoadOperationsCount.put(datacenterId, count);
}
} else {
break;
}
}
} else if (location != null || MessageObject.isImageWebDocument(webDocument)) {
int count = currentPhotoLoadOperationsCount.get(datacenterId);
if (operation != null) {
if (operation.wasStarted()) {
count--;
currentPhotoLoadOperationsCount.put(datacenterId, count);
} else {
photoLoadOperationQueue.remove(operation);
}
}
while (!photoLoadOperationQueue.isEmpty()) {
operation = photoLoadOperationQueue.get(0);
int maxCount = operation.getPriority() != 0 ? 6 : 2;
if (count < maxCount) {
operation = photoLoadOperationQueue.poll();
if (operation != null && operation.start()) {
count++;
currentPhotoLoadOperationsCount.put(datacenterId, count);
}
} else {
break;
}
}
} else {
int count = currentLoadOperationsCount.get(datacenterId);
if (operation != null) {
if (operation.wasStarted()) {
count--;
currentLoadOperationsCount.put(datacenterId, count);
} else {
loadOperationQueue.remove(operation);
} }
if (queueType == QUEUE_TYPE_FILE) {
activeFileLoadOperation.remove(operation); activeFileLoadOperation.remove(operation);
} }
while (!loadOperationQueue.isEmpty()) { }
operation = loadOperationQueue.get(0); while (!queue.isEmpty()) {
int maxCount = operation.isForceRequest() ? 3 : 1; operation = queue.get(0);
int maxCount;
if (queueType == QUEUE_TYPE_AUDIO) {
maxCount = operation.getPriority() != 0 ? 3 : 1;
} else if (queueType == QUEUE_TYPE_IMAGE) {
maxCount = operation.getPriority() != 0 ? 6 : 2;
} else {
maxCount = operation.isForceRequest() ? 3 : 1;
}
if (count < maxCount) { if (count < maxCount) {
operation = loadOperationQueue.poll(); operation = queue.poll();
if (operation != null && operation.start()) { if (operation != null && operation.start()) {
count++; count++;
currentLoadOperationsCount.put(datacenterId, count); operationCount.put(datacenterId, count);
if (queueType == QUEUE_TYPE_FILE) {
if (!activeFileLoadOperation.contains(operation)) { if (!activeFileLoadOperation.contains(operation)) {
activeFileLoadOperation.add(operation); activeFileLoadOperation.add(operation);
} }
} }
}
} else { } else {
break; break;
} }
} }
}
}); });
} }
public void setDelegate(FileLoaderDelegate delegate) { public void setDelegate(FileLoaderDelegate fileLoaderDelegate) {
this.delegate = delegate; delegate = fileLoaderDelegate;
} }
public static String getMessageFileName(TLRPC.Message message) { public static String getMessageFileName(TLRPC.Message message) {

View file

@ -1270,7 +1270,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
} }
} else if (id == NotificationCenter.mediaDidLoad) { } else if (id == NotificationCenter.mediaDidLoad) {
int guid = (Integer) args[3]; int guid = (Integer) args[3];
if (guid == playlistClassGuid) { if (guid == playlistClassGuid && playingMessageObject != null) {
long did = (Long) args[0]; long did = (Long) args[0];
int type = (Integer) args[4]; int type = (Integer) args[4];

View file

@ -943,9 +943,6 @@ public class MessagesStorage extends BaseController {
} }
public void cleanup(final boolean isLogin) { public void cleanup(final boolean isLogin) {
if (!isLogin) {
storageQueue.cleanupQueue();
}
storageQueue.postRunnable(() -> { storageQueue.postRunnable(() -> {
cleanupInternal(true); cleanupInternal(true);
openDatabase(1); openDatabase(1);

View file

@ -22,7 +22,7 @@ import java.util.zip.ZipFile;
public class NativeLoader { public class NativeLoader {
private final static int LIB_VERSION = 30; private final static int LIB_VERSION = 31;
private final static String LIB_NAME = "tmessages." + LIB_VERSION; private final static String LIB_NAME = "tmessages." + LIB_VERSION;
private final static String LIB_SO_NAME = "lib" + LIB_NAME + ".so"; private final static String LIB_SO_NAME = "lib" + LIB_NAME + ".so";
private final static String LOCALE_LIB_SO_NAME = "lib" + LIB_NAME + "loc.so"; private final static String LOCALE_LIB_SO_NAME = "lib" + LIB_NAME + "loc.so";

View file

@ -226,7 +226,11 @@ public class NotificationsController extends BaseController {
notificationChannel.enableLights(false); notificationChannel.enableLights(false);
notificationChannel.enableVibration(false); notificationChannel.enableVibration(false);
notificationChannel.setSound(null, null); notificationChannel.setSound(null, null);
try {
systemNotificationManager.createNotificationChannel(notificationChannel); systemNotificationManager.createNotificationChannel(notificationChannel);
} catch (Exception e) {
FileLog.e(e);
}
} }
} }

View file

@ -244,9 +244,16 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
protected void onDetachedFromWindow() { protected void onDetachedFromWindow() {
super.onDetachedFromWindow(); super.onDetachedFromWindow();
DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this); DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this);
imageReceiver.onDetachedFromWindow();
wasLayout = false; wasLayout = false;
} }
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
imageReceiver.onAttachedToWindow();
}
@Override @Override
public boolean onTouchEvent(MotionEvent event) { public boolean onTouchEvent(MotionEvent event) {
if (currentMessageObject == null) { if (currentMessageObject == null) {

View file

@ -73,7 +73,7 @@ public class StatisticPostInfoCell extends FrameLayout {
linearLayout.addView(date, LayoutHelper.createLinear(0, LayoutHelper.WRAP_CONTENT, 1f, Gravity.NO_GRAVITY, 0, 0, 8, 0)); linearLayout.addView(date, LayoutHelper.createLinear(0, LayoutHelper.WRAP_CONTENT, 1f, Gravity.NO_GRAVITY, 0, 0, 8, 0));
linearLayout.addView(shares, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT)); linearLayout.addView(shares, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
contentLayout.addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.START | Gravity.TOP, 0, 2, 0, 0)); contentLayout.addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.START | Gravity.TOP, 0, 2, 0, 8));
addView(contentLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.NO_GRAVITY, 72, 0, 12, 0)); addView(contentLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.NO_GRAVITY, 72, 0, 12, 0));
@ -83,12 +83,6 @@ public class StatisticPostInfoCell extends FrameLayout {
shares.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText3)); shares.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText3));
} }
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(56), MeasureSpec.EXACTLY));
}
public void setData(StatisticActivity.RecentPostInfo postInfo) { public void setData(StatisticActivity.RecentPostInfo postInfo) {
MessageObject messageObject = postInfo.message; MessageObject messageObject = postInfo.message;
if (messageObject.photoThumbs != null) { if (messageObject.photoThumbs != null) {

View file

@ -780,7 +780,7 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
}; };
AndroidUtilities.lockOrientation(parentAlert.baseFragment.getParentActivity()); AndroidUtilities.lockOrientation(parentAlert.baseFragment.getParentActivity());
CameraController.getInstance().recordVideo(cameraView.getCameraSession(), outputFile, parentAlert.avatarPicker != 0, (thumbPath, duration) -> { CameraController.getInstance().recordVideo(cameraView.getCameraSession(), outputFile, parentAlert.avatarPicker != 0, (thumbPath, duration) -> {
if (outputFile == null || parentAlert.baseFragment == null) { if (outputFile == null || parentAlert.baseFragment == null || cameraView == null) {
return; return;
} }
mediaFromExternalCamera = false; mediaFromExternalCamera = false;

View file

@ -379,13 +379,13 @@ public class FilterGLThread extends DispatchQueue {
} }
public Bitmap getTexture() { public Bitmap getTexture() {
if (!initied) { if (!initied || !isAlive()) {
return null; return null;
} }
final CountDownLatch countDownLatch = new CountDownLatch(1); final CountDownLatch countDownLatch = new CountDownLatch(1);
final Bitmap[] object = new Bitmap[1]; final Bitmap[] object = new Bitmap[1];
try { try {
postRunnable(() -> { if (postRunnable(() -> {
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, filterShaders.getRenderFrameBuffer()); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, filterShaders.getRenderFrameBuffer());
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, filterShaders.getRenderTexture(blurred ? 0 : 1), 0); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, filterShaders.getRenderTexture(blurred ? 0 : 1), 0);
GLES20.glClear(0); GLES20.glClear(0);
@ -393,8 +393,9 @@ public class FilterGLThread extends DispatchQueue {
countDownLatch.countDown(); countDownLatch.countDown();
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
GLES20.glClear(0); GLES20.glClear(0);
}); })) {
countDownLatch.await(); countDownLatch.await();
}
} catch (Exception e) { } catch (Exception e) {
FileLog.e(e); FileLog.e(e);
} }

View file

@ -111,6 +111,10 @@ public class ProfileGalleryView extends CircularViewPager implements Notificatio
imageReceiver.setAllowStartAnimation(true); imageReceiver.setAllowStartAnimation(true);
imageReceiver.startAnimation(); imageReceiver.startAnimation();
} }
ImageLocation location = videoLocations.get(p);
if (location != null) {
FileLoader.getInstance(currentAccount).setForceStreamLoadingFile(location.location, "mp4");
}
} else { } else {
if (currentAllow) { if (currentAllow) {
AnimatedFileDrawable fileDrawable = imageReceiver.getAnimation(); AnimatedFileDrawable fileDrawable = imageReceiver.getAnimation();

View file

@ -2019,7 +2019,11 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} }
if (layout) { if (layout) {
measureChildWithMargins(listView, widthMeasureSpec, 0, heightMeasureSpec, 0); measureChildWithMargins(listView, widthMeasureSpec, 0, heightMeasureSpec, 0);
try {
listView.layout(0, actionBarHeight, listView.getMeasuredWidth(), actionBarHeight + listView.getMeasuredHeight()); listView.layout(0, actionBarHeight, listView.getMeasuredWidth(), actionBarHeight + listView.getMeasuredHeight());
} catch (Exception e) {
FileLog.e(e);
}
} }
ignoreLayout = false; ignoreLayout = false;
} }

View file

@ -480,7 +480,7 @@ public class StatisticActivity extends BaseFragment implements NotificationCente
recyclerListView.setOnItemLongClickListener((view, position) -> { recyclerListView.setOnItemLongClickListener((view, position) -> {
if (position >= adapter.topAdminsStartRow && position <= adapter.topAdminsEndRow) { if (position >= adapter.topAdminsStartRow && position <= adapter.topAdminsEndRow) {
int i = position - adapter.topAdminsStartRow; int i = position - adapter.topAdminsStartRow;
topMembersVisible.get(i).onLongClick(chat, this, progressDialog); topAdmins.get(i).onLongClick(chat, this, progressDialog);
return true; return true;
} else if (position >= adapter.topMembersStartRow && position <= adapter.topMembersEndRow) { } else if (position >= adapter.topMembersStartRow && position <= adapter.topMembersEndRow) {
int i = position - adapter.topMembersStartRow; int i = position - adapter.topMembersStartRow;
@ -1355,6 +1355,9 @@ public class StatisticActivity extends BaseFragment implements NotificationCente
} }
private void zoomOut(boolean animated) { private void zoomOut(boolean animated) {
if (data.chartData.x == null) {
return;
}
chartHeaderView.zoomOut(chartView, animated); chartHeaderView.zoomOut(chartView, animated);
chartView.legendSignatureView.chevron.setAlpha(1f); chartView.legendSignatureView.chevron.setAlpha(1f);
zoomedChartView.setHeader(null); zoomedChartView.setHeader(null);