mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-21 18:26:57 +00:00
Fix ApplicationMigrations UI.
This commit is contained in:
@@ -27,6 +27,8 @@ import androidx.multidex.MultiDexApplication;
|
||||
|
||||
import com.google.android.gms.security.ProviderInstaller;
|
||||
|
||||
import net.sqlcipher.database.SQLiteDatabase;
|
||||
|
||||
import org.conscrypt.Conscrypt;
|
||||
import org.signal.aesgcmprovider.AesGcmProvider;
|
||||
import org.signal.core.util.concurrent.SignalExecutors;
|
||||
@@ -126,11 +128,11 @@ public class ApplicationContext extends MultiDexApplication implements AppForegr
|
||||
Log.i(TAG, "onCreate()");
|
||||
})
|
||||
.addBlocking("crash-handling", this::initializeCrashHandling)
|
||||
.addBlocking("sqlcipher-init", () -> SQLiteDatabase.loadLibs(this))
|
||||
.addBlocking("rx-init", () -> {
|
||||
RxJavaPlugins.setInitIoSchedulerHandler(schedulerSupplier -> Schedulers.from(SignalExecutors.BOUNDED_IO, true, false));
|
||||
RxJavaPlugins.setInitComputationSchedulerHandler(schedulerSupplier -> Schedulers.from(SignalExecutors.BOUNDED, true, false));
|
||||
})
|
||||
.addBlocking("eat-db", () -> DatabaseFactory.getInstance(this))
|
||||
.addBlocking("app-dependencies", this::initializeAppDependencies)
|
||||
.addBlocking("notification-channels", () -> NotificationChannels.create(this))
|
||||
.addBlocking("first-launch", this::initializeFirstEverAppLaunch)
|
||||
|
||||
@@ -227,8 +227,6 @@ public class DatabaseFactory {
|
||||
}
|
||||
|
||||
private DatabaseFactory(@NonNull Context context) {
|
||||
SQLiteDatabase.loadLibs(context);
|
||||
|
||||
DatabaseSecret databaseSecret = DatabaseSecretProvider.getOrCreateDatabaseSecret(context);
|
||||
AttachmentSecret attachmentSecret = AttachmentSecretProvider.getInstance(context).getOrCreateAttachmentSecret();
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.annimon.stream.Stream;
|
||||
import net.sqlcipher.database.SQLiteOpenHelper;
|
||||
import net.sqlcipher.database.SQLiteDatabase;
|
||||
|
||||
import org.signal.core.util.concurrent.SignalExecutors;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.crypto.DatabaseSecret;
|
||||
import org.thoughtcrime.securesms.crypto.DatabaseSecretProvider;
|
||||
@@ -140,9 +141,11 @@ public class JobDatabase extends SQLiteOpenHelper implements SignalDatabase {
|
||||
public void onOpen(SQLiteDatabase db) {
|
||||
Log.i(TAG, "onOpen()");
|
||||
|
||||
dropTableIfPresent("job_spec");
|
||||
dropTableIfPresent("constraint_spec");
|
||||
dropTableIfPresent("dependency_spec");
|
||||
SignalExecutors.BOUNDED.execute(() -> {
|
||||
dropTableIfPresent("job_spec");
|
||||
dropTableIfPresent("constraint_spec");
|
||||
dropTableIfPresent("dependency_spec");
|
||||
});
|
||||
}
|
||||
|
||||
public synchronized void insertJobs(@NonNull List<FullSpec> fullSpecs) {
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.sqlcipher.database.SQLiteDatabase;
|
||||
import net.sqlcipher.database.SQLiteDatabaseHook;
|
||||
import net.sqlcipher.database.SQLiteOpenHelper;
|
||||
|
||||
import org.signal.core.util.concurrent.SignalExecutors;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.crypto.DatabaseSecret;
|
||||
import org.thoughtcrime.securesms.crypto.DatabaseSecretProvider;
|
||||
@@ -88,10 +89,12 @@ public class KeyValueDatabase extends SQLiteOpenHelper implements SignalDatabase
|
||||
public void onOpen(SQLiteDatabase db) {
|
||||
Log.i(TAG, "onOpen()");
|
||||
|
||||
if (DatabaseFactory.getInstance(application).hasTable("key_value")) {
|
||||
Log.i(TAG, "Dropping original key_value table from the main database.");
|
||||
DatabaseFactory.getInstance(application).getRawDatabase().rawExecSQL("DROP TABLE key_value");
|
||||
}
|
||||
SignalExecutors.BOUNDED.execute(() -> {
|
||||
if (DatabaseFactory.getInstance(application).hasTable("key_value")) {
|
||||
Log.i(TAG, "Dropping original key_value table from the main database.");
|
||||
DatabaseFactory.getInstance(application).getRawDatabase().rawExecSQL("DROP TABLE key_value");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public @NonNull KeyValueDataSet getDataSet() {
|
||||
|
||||
@@ -9,6 +9,7 @@ import androidx.annotation.NonNull;
|
||||
import net.sqlcipher.database.SQLiteDatabase;
|
||||
import net.sqlcipher.database.SQLiteOpenHelper;
|
||||
|
||||
import org.signal.core.util.concurrent.SignalExecutors;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.crypto.DatabaseSecret;
|
||||
import org.thoughtcrime.securesms.crypto.DatabaseSecretProvider;
|
||||
@@ -91,10 +92,12 @@ public class MegaphoneDatabase extends SQLiteOpenHelper implements SignalDatabas
|
||||
public void onOpen(SQLiteDatabase db) {
|
||||
Log.i(TAG, "onOpen()");
|
||||
|
||||
if (DatabaseFactory.getInstance(application).hasTable("megaphone")) {
|
||||
Log.i(TAG, "Dropping original megaphone table from the main database.");
|
||||
DatabaseFactory.getInstance(application).getRawDatabase().rawExecSQL("DROP TABLE megaphone");
|
||||
}
|
||||
SignalExecutors.BOUNDED.execute(() -> {
|
||||
if (DatabaseFactory.getInstance(application).hasTable("megaphone")) {
|
||||
Log.i(TAG, "Dropping original megaphone table from the main database.");
|
||||
DatabaseFactory.getInstance(application).getRawDatabase().rawExecSQL("DROP TABLE megaphone");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void insert(@NonNull Collection<Event> events) {
|
||||
|
||||
@@ -62,7 +62,6 @@ public class ApplicationDependencies {
|
||||
|
||||
private static Application application;
|
||||
private static Provider provider;
|
||||
private static MessageNotifier messageNotifier;
|
||||
private static AppForegroundObserver appForegroundObserver;
|
||||
|
||||
private static volatile SignalServiceAccountManager accountManager;
|
||||
@@ -92,6 +91,7 @@ public class ApplicationDependencies {
|
||||
private static volatile PendingRetryReceiptManager pendingRetryReceiptManager;
|
||||
private static volatile PendingRetryReceiptCache pendingRetryReceiptCache;
|
||||
private static volatile SignalWebSocket signalWebSocket;
|
||||
private static volatile MessageNotifier messageNotifier;
|
||||
|
||||
@MainThread
|
||||
public static void init(@NonNull Application application, @NonNull Provider provider) {
|
||||
@@ -102,7 +102,6 @@ public class ApplicationDependencies {
|
||||
|
||||
ApplicationDependencies.application = application;
|
||||
ApplicationDependencies.provider = provider;
|
||||
ApplicationDependencies.messageNotifier = provider.provideMessageNotifier();
|
||||
ApplicationDependencies.appForegroundObserver = provider.provideAppForegroundObserver();
|
||||
|
||||
ApplicationDependencies.appForegroundObserver.begin();
|
||||
@@ -322,6 +321,13 @@ public class ApplicationDependencies {
|
||||
}
|
||||
|
||||
public static @NonNull MessageNotifier getMessageNotifier() {
|
||||
if (messageNotifier == null) {
|
||||
synchronized (LOCK) {
|
||||
if (messageNotifier == null) {
|
||||
messageNotifier = provider.provideMessageNotifier();
|
||||
}
|
||||
}
|
||||
}
|
||||
return messageNotifier;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user