Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 762a8038 authored by Rohit Sekhar's avatar Rohit Sekhar
Browse files

Updater: Parse & store android_version to db

* Bump the DATABASE_VERSION to 3 as well
parent 82ef1134
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ import java.util.List;

public class UpdatesDbHelper extends SQLiteOpenHelper {

    public static final int DATABASE_VERSION = 2;
    public static final int DATABASE_VERSION = 3;
    public static final String DATABASE_NAME = "updates.db";

    public static class UpdateEntry implements BaseColumns {
@@ -42,6 +42,7 @@ public class UpdatesDbHelper extends SQLiteOpenHelper {
        public static final String COLUMN_NAME_TYPE = "type";
        public static final String COLUMN_NAME_VERSION = "version";
        public static final String COLUMN_NAME_DISPLAY_VERSION = "display_version";
        public static final String COLUMN_NAME_ANDROID_VERSION = "android_version";
        public static final String COLUMN_NAME_SIZE = "size";
    }

@@ -55,6 +56,7 @@ public class UpdatesDbHelper extends SQLiteOpenHelper {
                    UpdateEntry.COLUMN_NAME_TYPE + " TEXT," +
                    UpdateEntry.COLUMN_NAME_VERSION + " TEXT," +
                    UpdateEntry.COLUMN_NAME_DISPLAY_VERSION + " TEXT," +
                    UpdateEntry.COLUMN_NAME_ANDROID_VERSION + " TEXT," +
                    UpdateEntry.COLUMN_NAME_SIZE + " INTEGER)";

    private static final String SQL_DELETE_ENTRIES =
@@ -87,6 +89,7 @@ public class UpdatesDbHelper extends SQLiteOpenHelper {
        values.put(UpdateEntry.COLUMN_NAME_TYPE, update.getType());
        values.put(UpdateEntry.COLUMN_NAME_VERSION, update.getVersion());
        values.put(UpdateEntry.COLUMN_NAME_DISPLAY_VERSION, update.getDisplayVersion());
        values.put(UpdateEntry.COLUMN_NAME_ANDROID_VERSION, update.getAndroidVersion());
        values.put(UpdateEntry.COLUMN_NAME_SIZE, update.getFileSize());
        return db.insert(UpdateEntry.TABLE_NAME, null, values);
    }
@@ -101,6 +104,7 @@ public class UpdatesDbHelper extends SQLiteOpenHelper {
        values.put(UpdateEntry.COLUMN_NAME_TYPE, update.getType());
        values.put(UpdateEntry.COLUMN_NAME_VERSION, update.getVersion());
        values.put(UpdateEntry.COLUMN_NAME_DISPLAY_VERSION, update.getDisplayVersion());
        values.put(UpdateEntry.COLUMN_NAME_ANDROID_VERSION, update.getAndroidVersion());
        values.put(UpdateEntry.COLUMN_NAME_SIZE, update.getFileSize());
        return db.insertWithOnConflict(UpdateEntry.TABLE_NAME, null, values, conflictAlgorithm);
    }
@@ -166,6 +170,7 @@ public class UpdatesDbHelper extends SQLiteOpenHelper {
                UpdateEntry.COLUMN_NAME_TYPE,
                UpdateEntry.COLUMN_NAME_VERSION,
                UpdateEntry.COLUMN_NAME_DISPLAY_VERSION,
                UpdateEntry.COLUMN_NAME_ANDROID_VERSION,
                UpdateEntry.COLUMN_NAME_STATUS,
                UpdateEntry.COLUMN_NAME_SIZE,
        };
@@ -189,6 +194,8 @@ public class UpdatesDbHelper extends SQLiteOpenHelper {
                update.setVersion(cursor.getString(index));
                index = cursor.getColumnIndex(UpdateEntry.COLUMN_NAME_DISPLAY_VERSION);
                update.setDisplayVersion(cursor.getString(index));
                index = cursor.getColumnIndex(UpdateEntry.COLUMN_NAME_ANDROID_VERSION);
                update.setAndroidVersion(cursor.getString(index));
                index = cursor.getColumnIndex(UpdateEntry.COLUMN_NAME_STATUS);
                update.setPersistentStatus(cursor.getInt(index));
                index = cursor.getColumnIndex(UpdateEntry.COLUMN_NAME_SIZE);
+1 −0
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ public class Utils {
        update.setDownloadUrl(object.getString("url"));
        update.setVersion(object.getString("version"));
        update.setDisplayVersion(object.getString("display_version"));
        update.setAndroidVersion(object.getString("android_version"));
        return update;
    }

+11 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ public class UpdateBase implements UpdateBaseInfo {
    private long mTimestamp;
    private String mType;
    private String mVersion;
    private String mAndroidVersion;
    private String mDisplayVersion;
    private long mFileSize;

@@ -37,6 +38,7 @@ public class UpdateBase implements UpdateBaseInfo {
        mType = update.getType();
        mVersion = update.getVersion();
        mDisplayVersion = update.getDisplayVersion();
        mAndroidVersion = update.getAndroidVersion();
        mFileSize = update.getFileSize();
    }

@@ -94,6 +96,15 @@ public class UpdateBase implements UpdateBaseInfo {
        mDisplayVersion = displayVersion;
    }

    @Override
    public String getAndroidVersion() {
        return mAndroidVersion;
    }

    public void setAndroidVersion(String androidVersion) {
        mAndroidVersion = androidVersion;
    }

    @Override
    public String getDownloadUrl() {
        return mDownloadUrl;
+2 −0
Original line number Diff line number Diff line
@@ -28,6 +28,8 @@ public interface UpdateBaseInfo {

    String getDisplayVersion();

    String getAndroidVersion();

    String getDownloadUrl();

    long getFileSize();