2013-11-10 12:15:29 +00:00
|
|
|
/**
|
|
|
|
* Copyright (C) 2013 Open Whisper Systems
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
package org.thoughtcrime.securesms;
|
|
|
|
|
2017-11-30 21:30:15 +00:00
|
|
|
import android.annotation.SuppressLint;
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
2014-11-21 20:53:40 +00:00
|
|
|
import android.database.Cursor;
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
import android.os.AsyncTask;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.view.View;
|
|
|
|
import android.widget.ProgressBar;
|
|
|
|
|
2021-01-15 05:51:53 +00:00
|
|
|
import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachment;
|
2017-03-28 19:05:30 +00:00
|
|
|
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
2014-11-03 23:16:04 +00:00
|
|
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
2015-08-24 22:24:31 +00:00
|
|
|
import org.thoughtcrime.securesms.database.MmsDatabase;
|
|
|
|
import org.thoughtcrime.securesms.database.MmsDatabase.Reader;
|
2014-11-21 20:53:40 +00:00
|
|
|
import org.thoughtcrime.securesms.database.PushDatabase;
|
2015-08-24 22:24:31 +00:00
|
|
|
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
|
|
|
import org.thoughtcrime.securesms.jobs.AttachmentDownloadJob;
|
2014-11-21 20:53:40 +00:00
|
|
|
import org.thoughtcrime.securesms.jobs.PushDecryptJob;
|
2021-02-03 01:22:40 +00:00
|
|
|
import org.session.libsignal.utilities.logging.Log;
|
2014-07-23 22:40:45 +00:00
|
|
|
import org.thoughtcrime.securesms.util.Util;
|
2013-05-07 23:31:11 +00:00
|
|
|
import org.thoughtcrime.securesms.util.VersionTracker;
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
|
2015-08-24 22:24:31 +00:00
|
|
|
import java.util.List;
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
import java.util.SortedSet;
|
|
|
|
import java.util.TreeSet;
|
|
|
|
|
2019-07-24 02:30:23 +00:00
|
|
|
import network.loki.messenger.R;
|
|
|
|
|
2015-02-08 21:53:12 +00:00
|
|
|
public class DatabaseUpgradeActivity extends BaseActivity {
|
2015-08-24 22:24:31 +00:00
|
|
|
private static final String TAG = DatabaseUpgradeActivity.class.getSimpleName();
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
|
2020-12-14 07:16:16 +00:00
|
|
|
// public static final int NO_MORE_KEY_EXCHANGE_PREFIX_VERSION = 0; // 46
|
|
|
|
// public static final int MMS_BODY_VERSION = 0; // 46
|
|
|
|
// public static final int TOFU_IDENTITIES_VERSION = 1; // 50
|
|
|
|
// public static final int CURVE25519_VERSION = 2; // 63
|
|
|
|
// public static final int ASYMMETRIC_MASTER_SECRET_FIX_VERSION = 3; // 73
|
|
|
|
// public static final int NO_V1_VERSION = 4; // 83
|
|
|
|
// public static final int SIGNED_PREKEY_VERSION = 4; // 83
|
|
|
|
// public static final int NO_DECRYPT_QUEUE_VERSION = 5; // 113
|
|
|
|
// public static final int PUSH_DECRYPT_SERIAL_ID_VERSION = 6; // 131
|
|
|
|
// public static final int MIGRATE_SESSION_PLAINTEXT = 7; // 136
|
|
|
|
// public static final int CONTACTS_ACCOUNT_VERSION = 7; // 136
|
|
|
|
// public static final int MEDIA_DOWNLOAD_CONTROLS_VERSION = 8; // 151
|
|
|
|
// public static final int REDPHONE_SUPPORT_VERSION = 9; // 157
|
|
|
|
// public static final int NO_MORE_CANONICAL_DB_VERSION = 10; // 276
|
|
|
|
// public static final int PROFILES = 11; // 289
|
|
|
|
// public static final int SCREENSHOTS = 12; // 300
|
|
|
|
// public static final int PERSISTENT_BLOBS = 13; // 317
|
|
|
|
// public static final int INTERNALIZE_CONTACTS = 13; // 317
|
|
|
|
// public static final int SQLCIPHER = 14; // 334
|
|
|
|
// public static final int SQLCIPHER_COMPLETE = 15; // 352
|
|
|
|
// public static final int REMOVE_JOURNAL = 16; // 353
|
|
|
|
// public static final int REMOVE_CACHE = 17; // 354
|
|
|
|
// public static final int FULL_TEXT_SEARCH = 18; // 358
|
|
|
|
// public static final int BAD_IMPORT_CLEANUP = 19; // 373
|
|
|
|
// public static final int IMAGE_CACHE_CLEANUP = 20; // 406
|
|
|
|
// public static final int WORKMANAGER_MIGRATION = 21; // 408
|
|
|
|
// public static final int COLOR_MIGRATION = 22; // 412
|
|
|
|
// public static final int UNIDENTIFIED_DELIVERY = 23; // 422
|
|
|
|
// public static final int SIGNALING_KEY_DEPRECATION = 24; // 447
|
|
|
|
// public static final int CONVERSATION_SEARCH = 25; // 455
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
|
|
|
|
private static final SortedSet<Integer> UPGRADE_VERSIONS = new TreeSet<Integer>() {{
|
2020-12-14 07:16:16 +00:00
|
|
|
// add(NO_MORE_KEY_EXCHANGE_PREFIX_VERSION);
|
|
|
|
// add(TOFU_IDENTITIES_VERSION);
|
|
|
|
// add(CURVE25519_VERSION);
|
|
|
|
// add(ASYMMETRIC_MASTER_SECRET_FIX_VERSION);
|
|
|
|
// add(NO_V1_VERSION);
|
|
|
|
// add(SIGNED_PREKEY_VERSION);
|
|
|
|
// add(NO_DECRYPT_QUEUE_VERSION);
|
|
|
|
// add(PUSH_DECRYPT_SERIAL_ID_VERSION);
|
|
|
|
// add(MIGRATE_SESSION_PLAINTEXT);
|
|
|
|
// add(MEDIA_DOWNLOAD_CONTROLS_VERSION);
|
|
|
|
// add(REDPHONE_SUPPORT_VERSION);
|
|
|
|
// add(NO_MORE_CANONICAL_DB_VERSION);
|
|
|
|
// add(SCREENSHOTS);
|
|
|
|
// add(INTERNALIZE_CONTACTS);
|
|
|
|
// add(PERSISTENT_BLOBS);
|
|
|
|
// add(SQLCIPHER);
|
|
|
|
// add(SQLCIPHER_COMPLETE);
|
|
|
|
// add(REMOVE_CACHE);
|
|
|
|
// add(FULL_TEXT_SEARCH);
|
|
|
|
// add(BAD_IMPORT_CLEANUP);
|
|
|
|
// add(IMAGE_CACHE_CLEANUP);
|
|
|
|
// add(WORKMANAGER_MIGRATION);
|
|
|
|
// add(COLOR_MIGRATION);
|
|
|
|
// add(UNIDENTIFIED_DELIVERY);
|
|
|
|
// add(SIGNALING_KEY_DEPRECATION);
|
|
|
|
// add(CONVERSATION_SEARCH);
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
}};
|
|
|
|
|
2020-12-14 07:16:16 +00:00
|
|
|
// private MasterSecret masterSecret;
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCreate(Bundle bundle) {
|
|
|
|
super.onCreate(bundle);
|
2020-12-14 07:16:16 +00:00
|
|
|
// this.masterSecret = KeyCachingService.getMasterSecret(this);
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
|
2013-11-10 12:15:29 +00:00
|
|
|
if (needsUpgradeTask()) {
|
2018-08-02 13:25:33 +00:00
|
|
|
Log.i("DatabaseUpgradeActivity", "Upgrading...");
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
setContentView(R.layout.database_upgrade_activity);
|
|
|
|
|
2018-01-25 03:17:44 +00:00
|
|
|
ProgressBar indeterminateProgress = findViewById(R.id.indeterminate_progress);
|
|
|
|
ProgressBar determinateProgress = findViewById(R.id.determinate_progress);
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
|
2013-05-07 23:31:11 +00:00
|
|
|
new DatabaseUpgradeTask(indeterminateProgress, determinateProgress)
|
2017-10-23 20:03:32 +00:00
|
|
|
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, VersionTracker.getLastSeenVersion(this));
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
} else {
|
2013-05-07 23:31:11 +00:00
|
|
|
VersionTracker.updateLastSeenVersion(this);
|
2018-01-25 03:17:44 +00:00
|
|
|
updateNotifications(this);
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
startActivity((Intent)getIntent().getParcelableExtra("next_intent"));
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-10 12:15:29 +00:00
|
|
|
private boolean needsUpgradeTask() {
|
2019-05-28 22:57:06 +00:00
|
|
|
int currentVersionCode = Util.getCanonicalVersionCode();
|
2014-07-23 22:40:45 +00:00
|
|
|
int lastSeenVersion = VersionTracker.getLastSeenVersion(this);
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
|
2018-08-02 13:25:33 +00:00
|
|
|
Log.i("DatabaseUpgradeActivity", "LastSeenVersion: " + lastSeenVersion);
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
|
2014-07-23 22:40:45 +00:00
|
|
|
if (lastSeenVersion >= currentVersionCode)
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
return false;
|
2014-07-23 22:40:45 +00:00
|
|
|
|
|
|
|
for (int version : UPGRADE_VERSIONS) {
|
2018-08-02 13:25:33 +00:00
|
|
|
Log.i("DatabaseUpgradeActivity", "Comparing: " + version);
|
2014-07-23 22:40:45 +00:00
|
|
|
if (lastSeenVersion < version)
|
|
|
|
return true;
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
}
|
2014-07-23 22:40:45 +00:00
|
|
|
|
|
|
|
return false;
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean isUpdate(Context context) {
|
2019-05-28 22:57:06 +00:00
|
|
|
int currentVersionCode = Util.getCanonicalVersionCode();
|
|
|
|
int previousVersionCode = VersionTracker.getLastSeenVersion(context);
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
|
2019-05-28 22:57:06 +00:00
|
|
|
return previousVersionCode < currentVersionCode;
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
}
|
|
|
|
|
2017-11-30 21:30:15 +00:00
|
|
|
@SuppressLint("StaticFieldLeak")
|
2018-01-25 03:17:44 +00:00
|
|
|
private void updateNotifications(final Context context) {
|
2015-08-12 17:44:27 +00:00
|
|
|
new AsyncTask<Void, Void, Void>() {
|
|
|
|
@Override
|
|
|
|
protected Void doInBackground(Void... params) {
|
2020-06-26 06:18:19 +00:00
|
|
|
ApplicationContext.getInstance(context).messageNotifier.updateNotification(context);
|
2015-08-12 17:44:27 +00:00
|
|
|
return null;
|
|
|
|
}
|
2017-10-23 20:03:32 +00:00
|
|
|
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
2015-08-12 17:44:27 +00:00
|
|
|
}
|
|
|
|
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
public interface DatabaseUpgradeListener {
|
|
|
|
public void setProgress(int progress, int total);
|
|
|
|
}
|
|
|
|
|
2017-11-30 21:30:15 +00:00
|
|
|
@SuppressLint("StaticFieldLeak")
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
private class DatabaseUpgradeTask extends AsyncTask<Integer, Double, Void>
|
|
|
|
implements DatabaseUpgradeListener
|
|
|
|
{
|
|
|
|
|
|
|
|
private final ProgressBar indeterminateProgress;
|
|
|
|
private final ProgressBar determinateProgress;
|
|
|
|
|
2018-01-25 03:17:44 +00:00
|
|
|
DatabaseUpgradeTask(ProgressBar indeterminateProgress, ProgressBar determinateProgress) {
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
this.indeterminateProgress = indeterminateProgress;
|
|
|
|
this.determinateProgress = determinateProgress;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected Void doInBackground(Integer... params) {
|
2013-11-10 12:15:29 +00:00
|
|
|
Context context = DatabaseUpgradeActivity.this.getApplicationContext();
|
|
|
|
|
2018-08-02 13:25:33 +00:00
|
|
|
Log.i("DatabaseUpgradeActivity", "Running background upgrade..");
|
2020-12-14 07:16:16 +00:00
|
|
|
// DatabaseFactory.getInstance(DatabaseUpgradeActivity.this)
|
|
|
|
// .onApplicationLevelUpgrade(context, params[0], this);
|
2013-11-10 12:15:29 +00:00
|
|
|
|
2020-12-14 07:16:16 +00:00
|
|
|
// if (params[0] < CURVE25519_VERSION) {
|
|
|
|
// IdentityKeyUtil.migrateIdentityKeys(context, masterSecret);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if (params[0] < NO_V1_VERSION) {
|
|
|
|
// File v1sessions = new File(context.getFilesDir(), "sessions");
|
|
|
|
//
|
|
|
|
// if (v1sessions.exists() && v1sessions.isDirectory()) {
|
|
|
|
// File[] contents = v1sessions.listFiles();
|
|
|
|
//
|
|
|
|
// if (contents != null) {
|
|
|
|
// for (File session : contents) {
|
|
|
|
// session.delete();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// v1sessions.delete();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if (params[0] < SIGNED_PREKEY_VERSION) {
|
|
|
|
//// ApplicationContext.getInstance(getApplicationContext())
|
|
|
|
//// .getJobManager()
|
|
|
|
//// .add(new CreateSignedPreKeyJob(context));
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if (params[0] < NO_DECRYPT_QUEUE_VERSION) {
|
|
|
|
// scheduleMessagesInPushDatabase(context);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if (params[0] < PUSH_DECRYPT_SERIAL_ID_VERSION) {
|
|
|
|
// scheduleMessagesInPushDatabase(context);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if (params[0] < MIGRATE_SESSION_PLAINTEXT) {
|
|
|
|
//// new TextSecureSessionStore(context, masterSecret).migrateSessions();
|
|
|
|
//// new TextSecurePreKeyStore(context, masterSecret).migrateRecords();
|
|
|
|
//
|
|
|
|
// IdentityKeyUtil.migrateIdentityKeys(context, masterSecret);
|
|
|
|
// scheduleMessagesInPushDatabase(context);;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if (params[0] < MEDIA_DOWNLOAD_CONTROLS_VERSION) {
|
|
|
|
// schedulePendingIncomingParts(context);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if (params[0] < REDPHONE_SUPPORT_VERSION) {
|
2020-12-09 07:23:05 +00:00
|
|
|
// ApplicationContext.getInstance(getApplicationContext())
|
|
|
|
// .getJobManager()
|
2020-12-14 07:16:16 +00:00
|
|
|
// .add(new RefreshAttributesJob());
|
|
|
|
// }
|
2019-03-28 15:56:35 +00:00
|
|
|
//
|
2020-12-14 07:16:16 +00:00
|
|
|
// if (params[0] < SCREENSHOTS) {
|
|
|
|
// boolean screenSecurity = PreferenceManager.getDefaultSharedPreferences(context).getBoolean(TextSecurePreferences.SCREEN_SECURITY_PREF, true);
|
|
|
|
// TextSecurePreferences.setScreenSecurityEnabled(getApplicationContext(), screenSecurity);
|
|
|
|
// }
|
2019-03-28 15:56:35 +00:00
|
|
|
//
|
2020-12-14 07:16:16 +00:00
|
|
|
// if (params[0] < PERSISTENT_BLOBS) {
|
|
|
|
// File externalDir = context.getExternalFilesDir(null);
|
|
|
|
//
|
|
|
|
// if (externalDir != null && externalDir.isDirectory() && externalDir.exists()) {
|
|
|
|
// for (File blob : externalDir.listFiles()) {
|
|
|
|
// if (blob.exists() && blob.isFile()) blob.delete();
|
|
|
|
// }
|
2019-03-28 15:56:35 +00:00
|
|
|
// }
|
|
|
|
// }
|
2020-12-14 07:16:16 +00:00
|
|
|
//
|
|
|
|
// if (params[0] < INTERNALIZE_CONTACTS) {
|
|
|
|
// if (TextSecurePreferences.isPushRegistered(getApplicationContext())) {
|
|
|
|
// TextSecurePreferences.setHasSuccessfullyRetrievedDirectory(getApplicationContext(), true);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if (params[0] < SQLCIPHER) {
|
|
|
|
// scheduleMessagesInPushDatabase(context);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if (params[0] < SQLCIPHER_COMPLETE) {
|
|
|
|
// File file = context.getDatabasePath("messages.db");
|
|
|
|
// if (file != null && file.exists()) file.delete();
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if (params[0] < REMOVE_JOURNAL) {
|
|
|
|
// File file = context.getDatabasePath("messages.db-journal");
|
|
|
|
// if (file != null && file.exists()) file.delete();
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if (params[0] < REMOVE_CACHE) {
|
|
|
|
// try {
|
|
|
|
// FileUtils.deleteDirectoryContents(context.getCacheDir());
|
|
|
|
// } catch (IOException e) {
|
|
|
|
// Log.w(TAG, e);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if (params[0] < IMAGE_CACHE_CLEANUP) {
|
|
|
|
// try {
|
|
|
|
// FileUtils.deleteDirectoryContents(context.getExternalCacheDir());
|
|
|
|
// GlideApp.get(context).clearDiskCache();
|
|
|
|
// } catch (IOException e) {
|
|
|
|
// Log.w(TAG, e);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// // This migration became unnecessary after switching away from WorkManager
|
|
|
|
//// if (params[0] < WORKMANAGER_MIGRATION) {
|
|
|
|
//// Log.i(TAG, "Beginning migration of existing jobs to WorkManager");
|
|
|
|
////
|
|
|
|
//// JobManager jobManager = ApplicationContext.getInstance(getApplicationContext()).getJobManager();
|
|
|
|
//// PersistentStorage storage = new PersistentStorage(getApplicationContext(), "TextSecureJobs", new JavaJobSerializer());
|
|
|
|
////
|
|
|
|
//// for (Job job : storage.getAllUnencrypted()) {
|
|
|
|
//// jobManager.add(job);
|
|
|
|
//// Log.i(TAG, "Migrated job with class '" + job.getClass().getSimpleName() + "' to run on new JobManager.");
|
|
|
|
//// }
|
|
|
|
//// }
|
|
|
|
//
|
|
|
|
// if (params[0] < COLOR_MIGRATION) {
|
|
|
|
// long startTime = System.currentTimeMillis();
|
|
|
|
// DatabaseFactory.getRecipientDatabase(context).updateSystemContactColors((name, color) -> {
|
|
|
|
// if (color != null) {
|
|
|
|
// try {
|
|
|
|
// return MaterialColor.fromSerialized(color);
|
|
|
|
// } catch (MaterialColor.UnknownColorException e) {
|
|
|
|
// Log.w(TAG, "Encountered an unknown color during legacy color migration.", e);
|
|
|
|
// return ContactColorsLegacy.generateFor(name);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// return ContactColorsLegacy.generateFor(name);
|
|
|
|
// });
|
|
|
|
// Log.i(TAG, "Color migration took " + (System.currentTimeMillis() - startTime) + " ms");
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if (params[0] < UNIDENTIFIED_DELIVERY) {
|
|
|
|
// if (TextSecurePreferences.isMultiDevice(context)) {
|
|
|
|
// Log.i(TAG, "MultiDevice: Disabling UD (will be re-enabled if possible after pending refresh).");
|
|
|
|
// TextSecurePreferences.setIsUnidentifiedDeliveryEnabled(context, false);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// Log.i(TAG, "Scheduling UD attributes refresh.");
|
|
|
|
// ApplicationContext.getInstance(context)
|
|
|
|
// .getJobManager()
|
|
|
|
// .add(new RefreshAttributesJob());
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if (params[0] < SIGNALING_KEY_DEPRECATION) {
|
|
|
|
// Log.i(TAG, "Scheduling a RefreshAttributesJob to remove the signaling key remotely.");
|
|
|
|
// ApplicationContext.getInstance(context)
|
|
|
|
// .getJobManager()
|
|
|
|
// .add(new RefreshAttributesJob());
|
|
|
|
// }
|
2018-10-11 23:45:22 +00:00
|
|
|
|
2015-07-07 00:36:49 +00:00
|
|
|
return null;
|
|
|
|
}
|
2014-11-21 20:53:40 +00:00
|
|
|
|
2015-08-24 22:24:31 +00:00
|
|
|
private void schedulePendingIncomingParts(Context context) {
|
2015-10-13 01:25:05 +00:00
|
|
|
final AttachmentDatabase attachmentDb = DatabaseFactory.getAttachmentDatabase(context);
|
|
|
|
final MmsDatabase mmsDb = DatabaseFactory.getMmsDatabase(context);
|
2018-01-25 03:17:44 +00:00
|
|
|
final List<DatabaseAttachment> pendingAttachments = DatabaseFactory.getAttachmentDatabase(context).getPendingAttachments();
|
2015-08-24 22:24:31 +00:00
|
|
|
|
2018-08-02 13:25:33 +00:00
|
|
|
Log.i(TAG, pendingAttachments.size() + " pending parts.");
|
2015-10-13 01:25:05 +00:00
|
|
|
for (DatabaseAttachment attachment : pendingAttachments) {
|
2018-01-25 03:17:44 +00:00
|
|
|
final Reader reader = mmsDb.readerFor(mmsDb.getMessage(attachment.getMmsId()));
|
2015-08-24 22:24:31 +00:00
|
|
|
final MessageRecord record = reader.getNext();
|
|
|
|
|
2015-10-13 01:25:05 +00:00
|
|
|
if (attachment.hasData()) {
|
2018-08-02 13:25:33 +00:00
|
|
|
Log.i(TAG, "corrected a pending media part " + attachment.getAttachmentId() + "that already had data.");
|
2015-10-13 01:25:05 +00:00
|
|
|
attachmentDb.setTransferState(attachment.getMmsId(), attachment.getAttachmentId(), AttachmentDatabase.TRANSFER_PROGRESS_DONE);
|
2015-09-04 17:56:59 +00:00
|
|
|
} else if (record != null && !record.isOutgoing() && record.isPush()) {
|
2018-08-02 13:25:33 +00:00
|
|
|
Log.i(TAG, "queuing new attachment download job for incoming push part " + attachment.getAttachmentId() + ".");
|
2015-08-24 22:24:31 +00:00
|
|
|
ApplicationContext.getInstance(context)
|
|
|
|
.getJobManager()
|
2019-03-28 15:56:35 +00:00
|
|
|
.add(new AttachmentDownloadJob(attachment.getMmsId(), attachment.getAttachmentId(), false));
|
2015-08-24 22:24:31 +00:00
|
|
|
}
|
|
|
|
reader.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-07 00:36:49 +00:00
|
|
|
private void scheduleMessagesInPushDatabase(Context context) {
|
|
|
|
PushDatabase pushDatabase = DatabaseFactory.getPushDatabase(context);
|
|
|
|
Cursor pushReader = null;
|
2014-11-21 20:53:40 +00:00
|
|
|
|
2015-07-07 00:36:49 +00:00
|
|
|
try {
|
|
|
|
pushReader = pushDatabase.getPending();
|
2014-11-03 23:16:04 +00:00
|
|
|
|
2015-07-07 00:36:49 +00:00
|
|
|
while (pushReader != null && pushReader.moveToNext()) {
|
|
|
|
ApplicationContext.getInstance(getApplicationContext())
|
|
|
|
.getJobManager()
|
|
|
|
.add(new PushDecryptJob(getApplicationContext(),
|
2017-07-26 16:59:15 +00:00
|
|
|
pushReader.getLong(pushReader.getColumnIndexOrThrow(PushDatabase.ID))));
|
2015-06-25 18:17:42 +00:00
|
|
|
}
|
2015-07-07 00:36:49 +00:00
|
|
|
} finally {
|
|
|
|
if (pushReader != null)
|
|
|
|
pushReader.close();
|
2015-06-25 18:17:42 +00:00
|
|
|
}
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onProgressUpdate(Double... update) {
|
|
|
|
indeterminateProgress.setVisibility(View.GONE);
|
|
|
|
determinateProgress.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
double scaler = update[0];
|
|
|
|
determinateProgress.setProgress((int)Math.floor(determinateProgress.getMax() * scaler));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onPostExecute(Void result) {
|
2013-05-07 23:31:11 +00:00
|
|
|
VersionTracker.updateLastSeenVersion(DatabaseUpgradeActivity.this);
|
2018-01-25 03:17:44 +00:00
|
|
|
updateNotifications(DatabaseUpgradeActivity.this);
|
2014-02-26 04:57:18 +00:00
|
|
|
|
Major storage layer refactoring to set the stage for clean GCM.
1) We now try to hand out cursors at a minimum. There has always been
a fairly clean insertion layer that handles encrypting message bodies,
but the process of decrypting message bodies has always been less than
ideal. Here we introduce a "Reader" interface that will decrypt message
bodies when appropriate and return objects that encapsulate record state.
No more MessageDisplayHelper. The MmsSmsDatabase interface is also more
sane.
2) We finally rid ourselves of the technical debt associated with TextSecure's
initial usage of the default SMS DB. In that world, we weren't able to use
anything other than the default "Inbox, Outbox, Sent" types to describe a
message, and had to overload the message content itself with a set of
local "prefixes" to describe what it was (encrypted, asymetric encrypted,
remote encrypted, a key exchange, procssed key exchange), and so on.
This includes a major schema update that transforms the "type" field into
a bitmask that describes everything that used to be encoded in a prefix,
and prefixes have been completely eliminated from the system.
No more Prefix.java
3) Refactoring of the MultipartMessageHandler code. It's less of a mess, and
hopefully more clear as to what's going on.
The next step is to remove what we can from SmsTransportDetails and genericize
that interface for a GCM equivalent.
2013-04-20 19:22:04 +00:00
|
|
|
startActivity((Intent)getIntent().getParcelableExtra("next_intent"));
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setProgress(int progress, int total) {
|
|
|
|
publishProgress(((double)progress / (double)total));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|