increase cursor window size on Android P when restoring messages
This commit is contained in:
parent
31c16b0f8f
commit
e0e158e5fc
3 changed files with 25 additions and 5 deletions
|
@ -112,7 +112,7 @@ public final class Config {
|
|||
public static final boolean PUT_AUTH_TAG_INTO_KEY = true;
|
||||
|
||||
public static final int MAX_DISPLAY_MESSAGE_CHARS = 4096;
|
||||
public static final int MAX_STORAGE_MESSAGE_CHARS = 1024 * 1024; //1MB
|
||||
public static final int MAX_STORAGE_MESSAGE_CHARS = 2 * 1024 * 1024; //2MB
|
||||
|
||||
public static final boolean ExportLogs = true; // automatically export logs
|
||||
public static final int ExportLogs_Hour = 4; //Time - hours: valid values from 0 to 23
|
||||
|
|
|
@ -51,6 +51,7 @@ import de.pixart.messenger.entities.Roster;
|
|||
import de.pixart.messenger.entities.ServiceDiscoveryResult;
|
||||
import de.pixart.messenger.services.ShortcutService;
|
||||
import de.pixart.messenger.utils.CryptoHelper;
|
||||
import de.pixart.messenger.utils.CursorUtils;
|
||||
import de.pixart.messenger.utils.FtsUtils;
|
||||
import de.pixart.messenger.utils.Resolver;
|
||||
import de.pixart.messenger.xmpp.InvalidJid;
|
||||
|
@ -793,12 +794,10 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
|||
null, null, Message.TIME_SENT + " DESC",
|
||||
String.valueOf(limit));
|
||||
}
|
||||
CursorUtils.upgradeCursorWindowSize(cursor);
|
||||
while (cursor.moveToNext()) {
|
||||
try {
|
||||
final Message message = Message.fromCursor(cursor, conversation);
|
||||
if (message != null && !message.isMessageDeleted()) {
|
||||
list.add(0, message);
|
||||
}
|
||||
list.add(0, Message.fromCursor(cursor, conversation));
|
||||
} catch (Exception e) {
|
||||
Log.e(Config.LOGTAG, "unable to restore message");
|
||||
}
|
||||
|
|
21
src/main/java/de/pixart/messenger/utils/CursorUtils.java
Normal file
21
src/main/java/de/pixart/messenger/utils/CursorUtils.java
Normal file
|
@ -0,0 +1,21 @@
|
|||
package de.pixart.messenger.utils;
|
||||
|
||||
import android.database.AbstractWindowedCursor;
|
||||
import android.database.Cursor;
|
||||
import android.database.CursorWindow;
|
||||
import android.database.sqlite.SQLiteCursor;
|
||||
|
||||
public class CursorUtils {
|
||||
|
||||
public static void upgradeCursorWindowSize(final Cursor cursor) {
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P) {
|
||||
if (cursor instanceof AbstractWindowedCursor) {
|
||||
final AbstractWindowedCursor windowedCursor = (AbstractWindowedCursor) cursor;
|
||||
windowedCursor.setWindow(new CursorWindow("8k", 8 * 1024 * 1024));
|
||||
}
|
||||
if (cursor instanceof SQLiteCursor) {
|
||||
((SQLiteCursor) cursor).setFillWindowForwardOnly(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in a new issue