mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Do not use the android cache directory as our 'blob repository'; the cache directory may be treated as a real cache; the files may disappear at any time. Instead, we're using a normal directory beside the database (the directory that is already used by the backend for incoming messages) and delete files ourself as needed.
This commit is contained in:
@@ -188,20 +188,25 @@ JNIEXPORT jlong Java_com_b44t_messenger_MrMailbox_MrMailboxNew(JNIEnv *env, jcla
|
||||
|
||||
/* MrMailbox - open/configure/connect/fetch */
|
||||
|
||||
JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_MrMailboxOpen(JNIEnv *env, jclass c, jlong hMailbox, jstring dbfile, jstring blobdir)
|
||||
JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_open(JNIEnv *env, jclass cls, jstring dbfile)
|
||||
{
|
||||
CHAR_REF(dbfile);
|
||||
CHAR_REF(blobdir);
|
||||
jint ret = mrmailbox_open((mrmailbox_t*)hMailbox, dbfilePtr, blobdirPtr);
|
||||
CHAR_UNREF(blobdir);
|
||||
jint ret = mrmailbox_open(get_mrmailbox_t(env, cls), dbfilePtr, NULL);
|
||||
CHAR_UNREF(dbfile)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void Java_com_b44t_messenger_MrMailbox_MrMailboxClose(JNIEnv *env, jclass c, jlong hMailbox)
|
||||
JNIEXPORT void Java_com_b44t_messenger_MrMailbox_close(JNIEnv *env, jclass cls)
|
||||
{
|
||||
mrmailbox_close((mrmailbox_t*)hMailbox);
|
||||
mrmailbox_close(get_mrmailbox_t(env, cls));
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jstring Java_com_b44t_messenger_MrMailbox_getBlobdir(JNIEnv *env, jclass cls)
|
||||
{
|
||||
mrmailbox_t* ths = get_mrmailbox_t(env, cls);
|
||||
return JSTRING_NEW((ths&&ths->m_blobdir)? ths->m_blobdir : NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -83,10 +83,6 @@ public class AndroidUtilities {
|
||||
|
||||
private static final Hashtable<String, Typeface> typefaceCache = new Hashtable<>();
|
||||
private static int prevOrientation = -10;
|
||||
private static boolean waitingForSms = false;
|
||||
private static boolean waitingForCall = false;
|
||||
private static final Object smsLock = new Object();
|
||||
private static final Object callLock = new Object();
|
||||
|
||||
public static int statusBarHeight = 0;
|
||||
public static float density = 1;
|
||||
@@ -247,6 +243,7 @@ public class AndroidUtilities {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public static boolean isGoogleMapsInstalled(final BaseFragment fragment) {
|
||||
try {
|
||||
ApplicationLoader.applicationContext.getPackageManager().getApplicationInfo("com.google.android.apps.maps", 0);
|
||||
@@ -274,6 +271,7 @@ public class AndroidUtilities {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
public static boolean isInternalUri(Uri uri) {
|
||||
String pathString = uri.getPath();
|
||||
@@ -361,34 +359,6 @@ public class AndroidUtilities {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isWaitingForSms() {
|
||||
boolean value;
|
||||
synchronized (smsLock) {
|
||||
value = waitingForSms;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static void setWaitingForSms(boolean value) {
|
||||
synchronized (smsLock) {
|
||||
waitingForSms = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isWaitingForCall() {
|
||||
boolean value;
|
||||
synchronized (callLock) {
|
||||
value = waitingForCall;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static void setWaitingForCall(boolean value) {
|
||||
synchronized (callLock) {
|
||||
waitingForCall = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static void showKeyboard(View view) {
|
||||
if (view == null) {
|
||||
return;
|
||||
@@ -429,6 +399,7 @@ public class AndroidUtilities {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public static File getCacheDir() {
|
||||
String state = null;
|
||||
try {
|
||||
@@ -456,6 +427,7 @@ public class AndroidUtilities {
|
||||
}
|
||||
return new File("");
|
||||
}
|
||||
*/
|
||||
|
||||
public static int dp(float value) {
|
||||
if (value == 0) {
|
||||
|
||||
@@ -223,23 +223,19 @@ public class ApplicationLoader extends Application {
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
// open() sqlite file (you can inspect the file eg. with "Tools / Android Device Monitor / File Explorer")
|
||||
// open() should be called before MessagesController.getInstance() as this also initilizes directories based upon getBlobdir().
|
||||
File dbfile = new File(getFilesDirFixed(), "messenger.db");
|
||||
MrMailbox.open(dbfile.getAbsolutePath());
|
||||
MrMailbox.connect();
|
||||
|
||||
// create other default objects
|
||||
MessagesController.getInstance();
|
||||
ConnectionsManager.getInstance().init(deviceModel, systemVersion, appVersion, langCode, configPath, FileLog.getNetworkLogPath(), UserConfig.getClientUserId(), enablePushConnection);
|
||||
if (UserConfig.getCurrentUser() != null) {
|
||||
//MessagesController.getInstance().putUser(UserConfig.getCurrentUser(), true);
|
||||
SendMessagesHelper.getInstance().checkUnsentMessages();
|
||||
}
|
||||
|
||||
ApplicationLoader app = (ApplicationLoader)ApplicationLoader.applicationContext;
|
||||
FileLog.e("messenger", "app initied");
|
||||
|
||||
//ContactsController.getInstance().checkAppAccount();
|
||||
MediaController.getInstance();
|
||||
|
||||
// EDIT BY MR - open my sqlite file (you can inspect the file eg. with "Tools / Android Device Monitor / File Explorer")
|
||||
File dbfile = new File(getFilesDirFixed(), "messenger.db");
|
||||
MrMailbox.open(dbfile.getAbsolutePath(), "");
|
||||
MrMailbox.connect();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -275,25 +271,6 @@ public class ApplicationLoader extends Application {
|
||||
startPushService();
|
||||
}
|
||||
|
||||
/*public static void sendRegIdToBackend(final String token) {
|
||||
Utilities.stageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
UserConfig.pushString = token;
|
||||
UserConfig.registeredForPush = false;
|
||||
UserConfig.saveConfig(false);
|
||||
if (UserConfig.getClientUserId() != 0) {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MessagesController.getInstance().registerForPush(token);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}*/
|
||||
|
||||
public static void startPushService() {
|
||||
SharedPreferences preferences = applicationContext.getSharedPreferences("Notifications", MODE_PRIVATE);
|
||||
|
||||
|
||||
@@ -1233,18 +1233,10 @@ public class ImageLoader {
|
||||
|
||||
public void checkMediaPaths() {
|
||||
HashMap<Integer, File> mediaDirs = new HashMap<>();
|
||||
File cachePath = AndroidUtilities.getCacheDir();
|
||||
if (!cachePath.isDirectory()) {
|
||||
try {
|
||||
cachePath.mkdirs();
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
}
|
||||
}
|
||||
File cachePath = new File(MrMailbox.getBlobdir());
|
||||
try {
|
||||
new File(cachePath, ".nomedia").createNewFile();
|
||||
} catch (Exception e) {
|
||||
FileLog.e("messenger", e);
|
||||
}
|
||||
|
||||
mediaDirs.put(FileLoader.MEDIA_DIR_CACHE, cachePath);
|
||||
|
||||
@@ -35,13 +35,9 @@ public class MrMailbox {
|
||||
m_hMailbox = MrMailboxNew();
|
||||
}
|
||||
|
||||
public static int open(String dbfile, String blobdir) {
|
||||
return MrMailboxOpen(m_hMailbox, dbfile, blobdir);
|
||||
}
|
||||
|
||||
public static void close() {
|
||||
MrMailboxClose(m_hMailbox);
|
||||
}
|
||||
public native static int open(String dbfile);
|
||||
public native static void close();
|
||||
public native static String getBlobdir();
|
||||
|
||||
public static int configure() {
|
||||
return MrMailboxConfigure(m_hMailbox);
|
||||
@@ -87,8 +83,6 @@ public class MrMailbox {
|
||||
|
||||
private static long m_hMailbox = 0; // do not rename this, is used in C-part
|
||||
private native static long MrMailboxNew (); // returns hMailbox which must be unref'd after usage (Names as mrmailbox_new don't work due to the additional underscore)
|
||||
private native static int MrMailboxOpen (long hMailbox, String dbfile, String blobdir);
|
||||
private native static void MrMailboxClose (long hMailbox);
|
||||
private native static int MrMailboxConfigure (long hMailbox);
|
||||
private native static int MrMailboxIsConfigured (long hMailbox);
|
||||
private native static int MrMailboxConnect (long hMailbox);
|
||||
|
||||
@@ -113,7 +113,7 @@ public class NativeLoader {
|
||||
return;
|
||||
}
|
||||
|
||||
String crashDir = context.getCacheDir().getAbsolutePath();
|
||||
//String crashDir = context.getCacheDir().getAbsolutePath();
|
||||
|
||||
try {
|
||||
String folder;
|
||||
|
||||
Reference in New Issue
Block a user