mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 19:58:34 +00:00
Attempt to fix crash in ClassicOpenHelper.
These users must have > 1.5-year-old installs that haven't been updated, but it's still a top crash for whatever reason, so gotta try to fix it.
This commit is contained in:
parent
db19077834
commit
93deee6824
@ -789,7 +789,7 @@ public class ClassicOpenHelper extends SQLiteOpenHelper {
|
|||||||
db.execSQL("UPDATE part SET pending_push = '2' WHERE pending_push = '1'");
|
db.execSQL("UPDATE part SET pending_push = '2' WHERE pending_push = '1'");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldVersion < NO_MORE_CANONICAL_ADDRESS_DATABASE && !TextUtils.isEmpty(TextSecurePreferences.getLocalNumber(context))) {
|
if (oldVersion < NO_MORE_CANONICAL_ADDRESS_DATABASE && isValidNumber(TextSecurePreferences.getLocalNumber(context))) {
|
||||||
SQLiteOpenHelper canonicalAddressDatabaseHelper = new SQLiteOpenHelper(context, "canonical_address.db", null, 1) {
|
SQLiteOpenHelper canonicalAddressDatabaseHelper = new SQLiteOpenHelper(context, "canonical_address.db", null, 1) {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(SQLiteDatabase db) {
|
public void onCreate(SQLiteDatabase db) {
|
||||||
@ -1186,7 +1186,7 @@ public class ClassicOpenHelper extends SQLiteOpenHelper {
|
|||||||
if (oldVersion < INTERNAL_DIRECTORY) {
|
if (oldVersion < INTERNAL_DIRECTORY) {
|
||||||
db.execSQL("ALTER TABLE recipient_preferences ADD COLUMN registered INTEGER DEFAULT 0");
|
db.execSQL("ALTER TABLE recipient_preferences ADD COLUMN registered INTEGER DEFAULT 0");
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(TextSecurePreferences.getLocalNumber(context))) {
|
if (isValidNumber(TextSecurePreferences.getLocalNumber(context))) {
|
||||||
OldDirectoryDatabaseHelper directoryDatabaseHelper = new OldDirectoryDatabaseHelper(context);
|
OldDirectoryDatabaseHelper directoryDatabaseHelper = new OldDirectoryDatabaseHelper(context);
|
||||||
SQLiteDatabase directoryDatabase = directoryDatabaseHelper.getWritableDatabase();
|
SQLiteDatabase directoryDatabase = directoryDatabaseHelper.getWritableDatabase();
|
||||||
|
|
||||||
@ -1376,6 +1376,19 @@ public class ClassicOpenHelper extends SQLiteOpenHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isValidNumber(@Nullable String number) {
|
||||||
|
if (TextUtils.isEmpty(number)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
PhoneNumberUtil.getInstance().parse(number, null);
|
||||||
|
return true;
|
||||||
|
} catch (NumberParseException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static class NumberMigrator {
|
private static class NumberMigrator {
|
||||||
|
|
||||||
private static final String TAG = NumberMigrator.class.getSimpleName();
|
private static final String TAG = NumberMigrator.class.getSimpleName();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user