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;
|
2020-08-19 00:06:26 +00:00
|
|
|
import androidx.preference.PreferenceManager;
|
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.view.View;
|
|
|
|
import android.widget.ProgressBar;
|
|
|
|
|
2015-10-13 01:25:05 +00:00
|
|
|
import org.thoughtcrime.securesms.attachments.DatabaseAttachment;
|
2019-07-24 02:30:23 +00:00
|
|
|
import org.thoughtcrime.securesms.color.MaterialColor;
|
|
|
|
import org.thoughtcrime.securesms.contacts.avatars.ContactColorsLegacy;
|
2013-11-10 12:15:29 +00:00
|
|
|
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
|
2014-11-03 23:16:04 +00:00
|
|
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
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-10-21 17:39:25 +00:00
|
|
|
import org.thoughtcrime.securesms.jobs.CreateSignedPreKeyJob;
|
2014-11-21 20:53:40 +00:00
|
|
|
import org.thoughtcrime.securesms.jobs.PushDecryptJob;
|
2015-09-30 23:19:50 +00:00
|
|
|
import org.thoughtcrime.securesms.jobs.RefreshAttributesJob;
|
2019-07-24 02:30:23 +00:00
|
|
|
import org.thoughtcrime.securesms.logging.Log;
|
2018-09-19 23:41:51 +00:00
|
|
|
import org.thoughtcrime.securesms.mms.GlideApp;
|
2018-02-02 03:22:48 +00:00
|
|
|
import org.thoughtcrime.securesms.service.KeyCachingService;
|
2018-04-13 00:17:48 +00:00
|
|
|
import org.thoughtcrime.securesms.util.FileUtils;
|
2017-10-04 01:57:23 +00:00
|
|
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
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
|
|
|
|
2014-04-22 21:33:29 +00:00
|
|
|
import java.io.File;
|
2018-04-13 00:17:48 +00:00
|
|
|
import java.io.IOException;
|
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
|
|
|
|
2014-07-19 03:29:00 +00:00
|
|
|
public static final int NO_MORE_KEY_EXCHANGE_PREFIX_VERSION = 46;
|
|
|
|
public static final int MMS_BODY_VERSION = 46;
|
|
|
|
public static final int TOFU_IDENTITIES_VERSION = 50;
|
|
|
|
public static final int CURVE25519_VERSION = 63;
|
|
|
|
public static final int ASYMMETRIC_MASTER_SECRET_FIX_VERSION = 73;
|
2014-04-22 21:33:29 +00:00
|
|
|
public static final int NO_V1_VERSION = 83;
|
2014-10-21 17:39:25 +00:00
|
|
|
public static final int SIGNED_PREKEY_VERSION = 83;
|
2015-04-21 20:04:00 +00:00
|
|
|
public static final int NO_DECRYPT_QUEUE_VERSION = 113;
|
2015-06-25 18:17:42 +00:00
|
|
|
public static final int PUSH_DECRYPT_SERIAL_ID_VERSION = 131;
|
2015-07-16 18:17:04 +00:00
|
|
|
public static final int MIGRATE_SESSION_PLAINTEXT = 136;
|
|
|
|
public static final int CONTACTS_ACCOUNT_VERSION = 136;
|
2015-09-11 02:48:10 +00:00
|
|
|
public static final int MEDIA_DOWNLOAD_CONTROLS_VERSION = 151;
|
2015-09-30 23:19:50 +00:00
|
|
|
public static final int REDPHONE_SUPPORT_VERSION = 157;
|
2017-07-26 16:59:15 +00:00
|
|
|
public static final int NO_MORE_CANONICAL_DB_VERSION = 276;
|
2017-09-06 22:49:10 +00:00
|
|
|
public static final int PROFILES = 289;
|
2017-10-04 01:57:23 +00:00
|
|
|
public static final int SCREENSHOTS = 300;
|
2017-11-30 21:30:15 +00:00
|
|
|
public static final int PERSISTENT_BLOBS = 317;
|
|
|
|
public static final int INTERNALIZE_CONTACTS = 317;
|
2018-01-25 03:17:44 +00:00
|
|
|
public static final int SQLCIPHER = 334;
|
2018-04-04 12:09:43 +00:00
|
|
|
public static final int SQLCIPHER_COMPLETE = 352;
|
2018-04-05 10:50:33 +00:00
|
|
|
public static final int REMOVE_JOURNAL = 353;
|
2018-04-13 00:17:48 +00:00
|
|
|
public static final int REMOVE_CACHE = 354;
|
2018-04-07 01:15:24 +00:00
|
|
|
public static final int FULL_TEXT_SEARCH = 358;
|
2018-06-21 23:48:46 +00:00
|
|
|
public static final int BAD_IMPORT_CLEANUP = 373;
|
2018-09-19 23:41:51 +00:00
|
|
|
public static final int IMAGE_CACHE_CLEANUP = 406;
|
2018-08-09 14:15:43 +00:00
|
|
|
public static final int WORKMANAGER_MIGRATION = 408;
|
2018-09-25 22:41:42 +00:00
|
|
|
public static final int COLOR_MIGRATION = 412;
|
2018-10-11 23:45:22 +00:00
|
|
|
public static final int UNIDENTIFIED_DELIVERY = 422;
|
2019-01-17 23:36:53 +00:00
|
|
|
public static final int SIGNALING_KEY_DEPRECATION = 447;
|
2019-02-01 17:06:59 +00:00
|
|
|
public static final int CONVERSATION_SEARCH = 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>() {{
|
|
|
|
add(NO_MORE_KEY_EXCHANGE_PREFIX_VERSION);
|
2013-05-23 23:36:24 +00:00
|
|
|
add(TOFU_IDENTITIES_VERSION);
|
2013-11-10 12:15:29 +00:00
|
|
|
add(CURVE25519_VERSION);
|
2014-07-19 03:29:00 +00:00
|
|
|
add(ASYMMETRIC_MASTER_SECRET_FIX_VERSION);
|
2014-10-21 17:39:25 +00:00
|
|
|
add(NO_V1_VERSION);
|
|
|
|
add(SIGNED_PREKEY_VERSION);
|
2014-11-03 23:16:04 +00:00
|
|
|
add(NO_DECRYPT_QUEUE_VERSION);
|
2015-06-25 18:17:42 +00:00
|
|
|
add(PUSH_DECRYPT_SERIAL_ID_VERSION);
|
2015-07-07 00:36:49 +00:00
|
|
|
add(MIGRATE_SESSION_PLAINTEXT);
|
2015-08-24 22:24:31 +00:00
|
|
|
add(MEDIA_DOWNLOAD_CONTROLS_VERSION);
|
2015-09-30 23:19:50 +00:00
|
|
|
add(REDPHONE_SUPPORT_VERSION);
|
2017-07-26 16:59:15 +00:00
|
|
|
add(NO_MORE_CANONICAL_DB_VERSION);
|
2017-10-04 01:57:23 +00:00
|
|
|
add(SCREENSHOTS);
|
2017-11-30 21:30:15 +00:00
|
|
|
add(INTERNALIZE_CONTACTS);
|
|
|
|
add(PERSISTENT_BLOBS);
|
2018-01-25 03:17:44 +00:00
|
|
|
add(SQLCIPHER);
|
2018-04-04 12:09:43 +00:00
|
|
|
add(SQLCIPHER_COMPLETE);
|
2018-04-13 00:17:48 +00:00
|
|
|
add(REMOVE_CACHE);
|
2018-04-07 01:15:24 +00:00
|
|
|
add(FULL_TEXT_SEARCH);
|
2018-06-21 23:48:46 +00:00
|
|
|
add(BAD_IMPORT_CLEANUP);
|
2018-09-19 23:41:51 +00:00
|
|
|
add(IMAGE_CACHE_CLEANUP);
|
2018-08-09 14:15:43 +00:00
|
|
|
add(WORKMANAGER_MIGRATION);
|
2018-09-25 22:41:42 +00:00
|
|
|
add(COLOR_MIGRATION);
|
2018-10-11 23:45:22 +00:00
|
|
|
add(UNIDENTIFIED_DELIVERY);
|
2019-01-17 23:36:53 +00:00
|
|
|
add(SIGNALING_KEY_DEPRECATION);
|
2019-02-01 17:06:59 +00:00
|
|
|
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
|
|
|
}};
|
|
|
|
|
|
|
|
private MasterSecret masterSecret;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCreate(Bundle bundle) {
|
|
|
|
super.onCreate(bundle);
|
2018-02-02 03:22:48 +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..");
|
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
|
|
|
DatabaseFactory.getInstance(DatabaseUpgradeActivity.this)
|
2013-11-10 12:15:29 +00:00
|
|
|
.onApplicationLevelUpgrade(context, masterSecret, params[0], this);
|
|
|
|
|
|
|
|
if (params[0] < CURVE25519_VERSION) {
|
2015-07-07 00:36:49 +00:00
|
|
|
IdentityKeyUtil.migrateIdentityKeys(context, masterSecret);
|
2013-11-10 12:15:29 +00:00
|
|
|
}
|
|
|
|
|
2014-04-22 21:33:29 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-21 17:39:25 +00:00
|
|
|
if (params[0] < SIGNED_PREKEY_VERSION) {
|
|
|
|
ApplicationContext.getInstance(getApplicationContext())
|
|
|
|
.getJobManager()
|
2015-07-07 00:36:49 +00:00
|
|
|
.add(new CreateSignedPreKeyJob(context));
|
2014-10-21 17:39:25 +00:00
|
|
|
}
|
|
|
|
|
2014-11-03 23:16:04 +00:00
|
|
|
if (params[0] < NO_DECRYPT_QUEUE_VERSION) {
|
2015-07-07 00:36:49 +00:00
|
|
|
scheduleMessagesInPushDatabase(context);
|
|
|
|
}
|
2014-11-21 20:53:40 +00:00
|
|
|
|
2015-07-07 00:36:49 +00:00
|
|
|
if (params[0] < PUSH_DECRYPT_SERIAL_ID_VERSION) {
|
|
|
|
scheduleMessagesInPushDatabase(context);
|
|
|
|
}
|
2014-11-21 20:53:40 +00:00
|
|
|
|
2015-07-07 00:36:49 +00:00
|
|
|
if (params[0] < MIGRATE_SESSION_PLAINTEXT) {
|
2018-02-16 04:33:10 +00:00
|
|
|
// new TextSecureSessionStore(context, masterSecret).migrateSessions();
|
|
|
|
// new TextSecurePreKeyStore(context, masterSecret).migrateRecords();
|
2014-11-03 23:16:04 +00:00
|
|
|
|
2015-07-07 00:36:49 +00:00
|
|
|
IdentityKeyUtil.migrateIdentityKeys(context, masterSecret);
|
|
|
|
scheduleMessagesInPushDatabase(context);;
|
|
|
|
}
|
2014-11-03 23:16:04 +00:00
|
|
|
|
2015-08-24 22:24:31 +00:00
|
|
|
if (params[0] < MEDIA_DOWNLOAD_CONTROLS_VERSION) {
|
|
|
|
schedulePendingIncomingParts(context);
|
|
|
|
}
|
|
|
|
|
2015-09-30 23:19:50 +00:00
|
|
|
if (params[0] < REDPHONE_SUPPORT_VERSION) {
|
|
|
|
ApplicationContext.getInstance(getApplicationContext())
|
|
|
|
.getJobManager()
|
2019-03-28 15:56:35 +00:00
|
|
|
.add(new RefreshAttributesJob());
|
2015-09-30 23:19:50 +00:00
|
|
|
}
|
|
|
|
|
2017-10-04 01:57:23 +00:00
|
|
|
if (params[0] < SCREENSHOTS) {
|
2017-10-04 19:37:53 +00:00
|
|
|
boolean screenSecurity = PreferenceManager.getDefaultSharedPreferences(context).getBoolean(TextSecurePreferences.SCREEN_SECURITY_PREF, true);
|
|
|
|
TextSecurePreferences.setScreenSecurityEnabled(getApplicationContext(), screenSecurity);
|
2017-10-04 01:57:23 +00:00
|
|
|
}
|
|
|
|
|
2017-11-03 17:53:37 +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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-30 21:30:15 +00:00
|
|
|
if (params[0] < INTERNALIZE_CONTACTS) {
|
|
|
|
if (TextSecurePreferences.isPushRegistered(getApplicationContext())) {
|
|
|
|
TextSecurePreferences.setHasSuccessfullyRetrievedDirectory(getApplicationContext(), true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-04 19:26:02 +00:00
|
|
|
if (params[0] < SQLCIPHER) {
|
|
|
|
scheduleMessagesInPushDatabase(context);
|
|
|
|
}
|
|
|
|
|
2018-04-04 12:09:43 +00:00
|
|
|
if (params[0] < SQLCIPHER_COMPLETE) {
|
|
|
|
File file = context.getDatabasePath("messages.db");
|
|
|
|
if (file != null && file.exists()) file.delete();
|
|
|
|
}
|
|
|
|
|
2018-04-05 10:50:33 +00:00
|
|
|
if (params[0] < REMOVE_JOURNAL) {
|
|
|
|
File file = context.getDatabasePath("messages.db-journal");
|
|
|
|
if (file != null && file.exists()) file.delete();
|
|
|
|
}
|
|
|
|
|
2018-04-13 00:17:48 +00:00
|
|
|
if (params[0] < REMOVE_CACHE) {
|
|
|
|
try {
|
|
|
|
FileUtils.deleteDirectoryContents(context.getCacheDir());
|
|
|
|
} catch (IOException e) {
|
|
|
|
Log.w(TAG, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-19 23:41:51 +00:00
|
|
|
if (params[0] < IMAGE_CACHE_CLEANUP) {
|
|
|
|
try {
|
|
|
|
FileUtils.deleteDirectoryContents(context.getExternalCacheDir());
|
|
|
|
GlideApp.get(context).clearDiskCache();
|
|
|
|
} catch (IOException e) {
|
|
|
|
Log.w(TAG, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-28 15:56:35 +00:00
|
|
|
// 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.");
|
|
|
|
// }
|
|
|
|
// }
|
2018-08-09 14:15:43 +00:00
|
|
|
|
2018-09-25 22:41:42 +00:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
2018-10-11 23:45:22 +00:00
|
|
|
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.");
|
2019-01-17 23:36:53 +00:00
|
|
|
ApplicationContext.getInstance(context)
|
|
|
|
.getJobManager()
|
2019-03-28 15:56:35 +00:00
|
|
|
.add(new RefreshAttributesJob());
|
2019-01-17 23:36:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (params[0] < SIGNALING_KEY_DEPRECATION) {
|
|
|
|
Log.i(TAG, "Scheduling a RefreshAttributesJob to remove the signaling key remotely.");
|
2018-10-11 23:45:22 +00:00
|
|
|
ApplicationContext.getInstance(context)
|
|
|
|
.getJobManager()
|
2019-03-28 15:56:35 +00:00
|
|
|
.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));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|