Commit a4af1fb2 authored by DrKLO's avatar DrKLO

Bug fixes

parent 3cd9b847
...@@ -80,7 +80,7 @@ android { ...@@ -80,7 +80,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 8 minSdkVersion 8
targetSdkVersion 19 targetSdkVersion 19
versionCode 374 versionCode 377
versionName "1.9.6" versionName "1.9.7"
} }
} }
...@@ -5,7 +5,7 @@ LOCAL_PRELINK_MODULE := false ...@@ -5,7 +5,7 @@ LOCAL_PRELINK_MODULE := false
LOCAL_MODULE := tmessages.1 LOCAL_MODULE := tmessages.1
LOCAL_CFLAGS := -w -std=gnu99 -O2 -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 LOCAL_CFLAGS := -w -std=gnu99 -O2 -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64
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 LOCAL_CFLAGS += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT -DHAVE_STRCHRNUL=0
LOCAL_CPPFLAGS := -DBSD=1 -ffast-math -O2 -funroll-loops LOCAL_CPPFLAGS := -DBSD=1 -ffast-math -O2 -funroll-loops
#LOCAL_LDLIBS := -llog #LOCAL_LDLIBS := -llog
LOCAL_LDLIBS := -ljnigraphics -llog LOCAL_LDLIBS := -ljnigraphics -llog
......
This diff is collapsed.
This diff is collapsed.
...@@ -110,6 +110,7 @@ public class MessagesStorage { ...@@ -110,6 +110,7 @@ public class MessagesStorage {
database.executeFast("CREATE TABLE download_queue(uid INTEGER, type INTEGER, date INTEGER, data BLOB, PRIMARY KEY (uid, type));").stepThis().dispose(); database.executeFast("CREATE TABLE download_queue(uid INTEGER, type INTEGER, date INTEGER, data BLOB, PRIMARY KEY (uid, type));").stepThis().dispose();
database.executeFast("CREATE TABLE dialog_settings(did INTEGER PRIMARY KEY, flags INTEGER);").stepThis().dispose(); database.executeFast("CREATE TABLE dialog_settings(did INTEGER PRIMARY KEY, flags INTEGER);").stepThis().dispose();
database.executeFast("CREATE TABLE messages_seq(mid INTEGER PRIMARY KEY, seq_in INTEGER, seq_out INTEGER);").stepThis().dispose(); database.executeFast("CREATE TABLE messages_seq(mid INTEGER PRIMARY KEY, seq_in INTEGER, seq_out INTEGER);").stepThis().dispose();
database.executeFast("CREATE TABLE secret_holes(uid INTEGER, seq_in INTEGER, seq_out INTEGER, data BLOB, PRIMARY KEY (uid, seq_in, seq_out));").stepThis().dispose();
//database.executeFast("CREATE TABLE attach_data(uid INTEGER, id INTEGER, data BLOB, PRIMARY KEY (uid, id))").stepThis().dispose(); //database.executeFast("CREATE TABLE attach_data(uid INTEGER, id INTEGER, data BLOB, PRIMARY KEY (uid, id))").stepThis().dispose();
...@@ -141,7 +142,7 @@ public class MessagesStorage { ...@@ -141,7 +142,7 @@ public class MessagesStorage {
database.executeFast("CREATE INDEX IF NOT EXISTS seq_idx_messages_seq ON messages_seq(seq_in, seq_out);").stepThis().dispose(); database.executeFast("CREATE INDEX IF NOT EXISTS seq_idx_messages_seq ON messages_seq(seq_in, seq_out);").stepThis().dispose();
database.executeFast("PRAGMA user_version = 7").stepThis().dispose(); database.executeFast("PRAGMA user_version = 8").stepThis().dispose();
} else { } else {
try { try {
SQLiteCursor cursor = database.queryFinalized("SELECT seq, pts, date, qts, lsv, sg, pbytes FROM params WHERE id = 1"); SQLiteCursor cursor = database.queryFinalized("SELECT seq, pts, date, qts, lsv, sg, pbytes FROM params WHERE id = 1");
...@@ -173,7 +174,7 @@ public class MessagesStorage { ...@@ -173,7 +174,7 @@ public class MessagesStorage {
} }
int version = database.executeInt("PRAGMA user_version"); int version = database.executeInt("PRAGMA user_version");
if (version < 7) { if (version < 8) {
updateDbToLastVersion(version); updateDbToLastVersion(version);
} }
} }
...@@ -303,6 +304,11 @@ public class MessagesStorage { ...@@ -303,6 +304,11 @@ public class MessagesStorage {
database.executeFast("PRAGMA user_version = 7").stepThis().dispose(); database.executeFast("PRAGMA user_version = 7").stepThis().dispose();
version = 7; version = 7;
} }
if (version == 7 && version < 8) {
database.executeFast("CREATE TABLE IF NOT EXISTS secret_holes(uid INTEGER, seq_in INTEGER, seq_out INTEGER, data BLOB, PRIMARY KEY (uid, seq_in, seq_out));").stepThis().dispose();
database.executeFast("PRAGMA user_version = 8").stepThis().dispose();
version = 8;
}
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
...@@ -665,6 +671,7 @@ public class MessagesStorage { ...@@ -665,6 +671,7 @@ public class MessagesStorage {
} }
} else { } else {
database.executeFast("DELETE FROM enc_chats WHERE uid = " + high_id).stepThis().dispose(); database.executeFast("DELETE FROM enc_chats WHERE uid = " + high_id).stepThis().dispose();
database.executeFast("DELETE FROM secret_holes WHERE uid = " + high_id).stepThis().dispose();
} }
} }
database.executeFast("UPDATE dialogs SET unread_count = 0 WHERE did = " + did).stepThis().dispose(); database.executeFast("UPDATE dialogs SET unread_count = 0 WHERE did = " + did).stepThis().dispose();
...@@ -2798,6 +2805,60 @@ public class MessagesStorage { ...@@ -2798,6 +2805,60 @@ public class MessagesStorage {
}); });
} }
public void getHoleMessages() {
storageQueue.postRunnable(new Runnable() {
@Override
public void run() {
try {
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
});
}
public void clearHoleMessages(final int enc_id) {
storageQueue.postRunnable(new Runnable() {
@Override
public void run() {
try {
database.executeFast("DELETE FROM secret_holes WHERE uid = " + enc_id).stepThis().dispose();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
});
}
public void putHoleMessage(final int enc_id, final TLRPC.Message message) {
if (message == null) {
return;
}
storageQueue.postRunnable(new Runnable() {
@Override
public void run() {
try {
SQLitePreparedStatement state = database.executeFast("REPLACE INTO secret_holes VALUES(?, ?, ?, ?)");
state.requery();
ByteBufferDesc data = buffersStorage.getFreeBuffer(message.getObjectSize());
message.serializeToStream(data);
state.bindInteger(1, enc_id);
state.bindInteger(2, message.seq_in);
state.bindInteger(3, message.seq_out);
state.bindByteBuffer(4, data.buffer);
state.step();
buffersStorage.reuseFreeBuffer(data);
state.dispose();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
});
}
public void setMessageSeq(final int mid, final int seq_in, final int seq_out) { public void setMessageSeq(final int mid, final int seq_in, final int seq_out) {
storageQueue.postRunnable(new Runnable() { storageQueue.postRunnable(new Runnable() {
@Override @Override
......
...@@ -14,7 +14,6 @@ import android.content.pm.PackageInfo; ...@@ -14,7 +14,6 @@ import android.content.pm.PackageInfo;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.NetworkInfo; import android.net.NetworkInfo;
import android.os.Build; import android.os.Build;
import android.os.PowerManager;
import android.util.Base64; import android.util.Base64;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
...@@ -83,8 +82,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -83,8 +82,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
private volatile long nextCallToken = 1; private volatile long nextCallToken = 1;
private PowerManager.WakeLock wakeLock = null;
private static volatile ConnectionsManager Instance = null; private static volatile ConnectionsManager Instance = null;
public static ConnectionsManager getInstance() { public static ConnectionsManager getInstance() {
ConnectionsManager localInstance = Instance; ConnectionsManager localInstance = Instance;
...@@ -217,10 +214,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -217,10 +214,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
} }
Utilities.stageQueue.postRunnable(stageRunnable, 1000); Utilities.stageQueue.postRunnable(stageRunnable, 1000);
PowerManager pm = (PowerManager)ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "lock");
wakeLock.setReferenceCounted(false);
} }
public int getConnectionState() { public int getConnectionState() {
...@@ -2139,14 +2132,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -2139,14 +2132,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
} else { } else {
if (resultContainer.result instanceof TLRPC.updates_Difference) { if (resultContainer.result instanceof TLRPC.updates_Difference) {
pushMessagesReceived = true; pushMessagesReceived = true;
AndroidUtilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
if (wakeLock.isHeld()) {
wakeLock.release();
}
}
});
} }
request.completionBlock.run(resultContainer.result, null); request.completionBlock.run(resultContainer.result, null);
} }
...@@ -2317,23 +2302,9 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -2317,23 +2302,9 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
if (paused) { if (paused) {
pushMessagesReceived = false; pushMessagesReceived = false;
} }
AndroidUtilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
wakeLock.acquire(20000);
}
});
resumeNetworkInternal(); resumeNetworkInternal();
} else { } else {
pushMessagesReceived = true; pushMessagesReceived = true;
AndroidUtilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
if (wakeLock.isHeld()) {
wakeLock.release();
}
}
});
MessagesController.getInstance().processUpdates((TLRPC.Updates) message, false); MessagesController.getInstance().processUpdates((TLRPC.Updates) message, false);
} }
} else { } else {
......
...@@ -371,6 +371,7 @@ public class TLClassStore { ...@@ -371,6 +371,7 @@ public class TLClassStore {
classStore.put(TLRPC.TL_userForeign_old.constructor, TLRPC.TL_userForeign_old.class); classStore.put(TLRPC.TL_userForeign_old.constructor, TLRPC.TL_userForeign_old.class);
classStore.put(TLRPC.TL_userDeleted_old.constructor, TLRPC.TL_userDeleted_old.class); classStore.put(TLRPC.TL_userDeleted_old.constructor, TLRPC.TL_userDeleted_old.class);
classStore.put(TLRPC.TL_messageEncryptedAction.constructor, TLRPC.TL_messageEncryptedAction.class); classStore.put(TLRPC.TL_messageEncryptedAction.constructor, TLRPC.TL_messageEncryptedAction.class);
classStore.put(TLRPC.TL_decryptedMessageHolder.constructor, TLRPC.TL_decryptedMessageHolder.class);
} }
static TLClassStore store = null; static TLClassStore store = null;
......
...@@ -8431,6 +8431,35 @@ public class TLRPC { ...@@ -8431,6 +8431,35 @@ public class TLRPC {
//manually created //manually created
public static class TL_decryptedMessageHolder extends TLObject {
public static int constructor = 0x555555F9;
public long random_id;
public int date;
public TL_decryptedMessageLayer layer;
public EncryptedFile file;
public void readParams(AbsSerializedData stream) {
random_id = stream.readInt64();
date = stream.readInt32();
layer = (TL_decryptedMessageLayer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
if (stream.readBool()) {
file = (EncryptedFile) TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
}
}
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);
stream.writeInt64(random_id);
stream.writeInt32(date);
layer.serializeToStream(stream);
stream.writeBool(file != null);
if (file != null) {
file.serializeToStream(stream);
}
}
}
public static class TL_messages_sendEncryptedService extends TLObject { public static class TL_messages_sendEncryptedService extends TLObject {
public static int constructor = 0x32d439a4; public static int constructor = 0x32d439a4;
......
...@@ -1685,9 +1685,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not ...@@ -1685,9 +1685,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
maxMessageId = Math.max(obj.messageOwner.id, maxMessageId); maxMessageId = Math.max(obj.messageOwner.id, maxMessageId);
minMessageId = Math.min(obj.messageOwner.id, minMessageId); minMessageId = Math.min(obj.messageOwner.id, minMessageId);
} }
maxDate = Math.max(maxDate, obj.messageOwner.date); if (obj.messageOwner.date != 0) {
if (minDate == 0 || obj.messageOwner.date < minDate) { maxDate = Math.max(maxDate, obj.messageOwner.date);
minDate = obj.messageOwner.date; if (minDate == 0 || obj.messageOwner.date < minDate) {
minDate = obj.messageOwner.date;
}
} }
if (obj.type < 0) { if (obj.type < 0) {
......
...@@ -207,8 +207,11 @@ public class CountrySelectActivity extends BaseFragment { ...@@ -207,8 +207,11 @@ public class CountrySelectActivity extends BaseFragment {
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
if (i < 0) {
return;
}
if (searching && searchWas) { if (searching && searchWas) {
if (i < searchResult.size()) { if (i >= 0 && i < searchResult.size()) {
Country c = searchResult.get(i); Country c = searchResult.get(i);
if (delegate != null) { if (delegate != null) {
delegate.didSelectCountry(c.name); delegate.didSelectCountry(c.name);
...@@ -218,10 +221,10 @@ public class CountrySelectActivity extends BaseFragment { ...@@ -218,10 +221,10 @@ public class CountrySelectActivity extends BaseFragment {
} else { } else {
int section = listViewAdapter.getSectionForPosition(i); int section = listViewAdapter.getSectionForPosition(i);
int row = listViewAdapter.getPositionInSectionForPosition(i); int row = listViewAdapter.getPositionInSectionForPosition(i);
if (section < sortedCountries.size()) { if (section >= 0 && section < sortedCountries.size()) {
String n = sortedCountries.get(section); String n = sortedCountries.get(section);
ArrayList<Country> arr = countries.get(n); ArrayList<Country> arr = countries.get(n);
if (row < arr.size()) { if (row >= 0 && row < arr.size()) {
Country c = arr.get(row); Country c = arr.get(row);
if (delegate != null) { if (delegate != null) {
delegate.didSelectCountry(c.name); delegate.didSelectCountry(c.name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment