Skip to content

Commit

Permalink
Fix ApplicationMigrations UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
greyson-signal committed Jul 15, 2021
1 parent 83086a5 commit b04ca20
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 58 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>

<activity android:name=".migrations.ApplicationMigrationActivity"
android:theme="@style/NoAnimation.Theme.AppCompat.Light.DarkActionBar"
android:theme="@style/Theme.Signal.DayNight.NoActionBar"
android:launchMode="singleTask"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

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;
Expand Down Expand Up @@ -126,11 +128,11 @@ public void onCreate() {
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,6 @@ public static boolean inTransaction(Context context) {
}

private DatabaseFactory(@NonNull Context context) {
SQLiteDatabase.loadLibs(context);

DatabaseSecret databaseSecret = DatabaseSecretProvider.getOrCreateDatabaseSecret(context);
AttachmentSecret attachmentSecret = AttachmentSecretProvider.getInstance(context).getOrCreateAttachmentSecret();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
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;
Expand Down Expand Up @@ -140,9 +141,11 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
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;
Expand Down Expand Up @@ -88,10 +89,12 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
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;
Expand Down Expand Up @@ -91,10 +92,12 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -102,7 +102,6 @@ public static void init(@NonNull Application application, @NonNull Provider prov

ApplicationDependencies.application = application;
ApplicationDependencies.provider = provider;
ApplicationDependencies.messageNotifier = provider.provideMessageNotifier();
ApplicationDependencies.appForegroundObserver = provider.provideAppForegroundObserver();

ApplicationDependencies.appForegroundObserver.begin();
Expand Down Expand Up @@ -322,6 +321,13 @@ public static void resetNetworkConnectionsAfterProxyChange() {
}

public static @NonNull MessageNotifier getMessageNotifier() {
if (messageNotifier == null) {
synchronized (LOCK) {
if (messageNotifier == null) {
messageNotifier = provider.provideMessageNotifier();
}
}
}
return messageNotifier;
}

Expand Down
68 changes: 27 additions & 41 deletions app/src/main/res/layout/application_migration_activity.xml
Original file line number Diff line number Diff line change
@@ -1,46 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:background="@drawable/background_pattern_repeat">
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">

<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center" >
<TextView
android:id="@+id/app_migration_text"
android:layout_height="wrap_content"
android:layout_width="match_parent"
style="@style/Signal.Text.Headline"
android:text="@string/ApplicationMigrationActivity__signal_is_updating"
android:gravity="center"
android:textSize="22sp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />

<LinearLayout android:paddingEnd="16dip"
android:paddingStart="16dip"
android:paddingTop="10dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="visible"
android:orientation="vertical">
<ProgressBar
android:id="@+id/indeterminate_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="16dp"
android:indeterminate="true"
app:layout_constraintTop_toBottomOf="@id/app_migration_text"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>

<TextView style="@style/Registration.BigLabel"
android:layout_width="fill_parent"
android:layout_marginBottom="16dip"
android:layout_marginTop="16dip"
android:gravity="center"
android:text="@string/ApplicationMigrationActivity__signal_is_updating"/>

<ProgressBar android:id="@+id/indeterminate_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"
android:layout_gravity="center"/>

<ProgressBar android:id="@+id/determinate_progress"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:indeterminate="false"
android:visibility="gone"
android:layout_gravity="center"/>

</LinearLayout>
</FrameLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit b04ca20

Please sign in to comment.