diff --git a/README.md b/README.md index 1c608216..ecb06f4b 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ a JSON with the following structure: "filename": "ota-package.zip", "id": "5eb63bbbe01eeed093cb22bb8f5acdc3", "romtype": "nightly", + "size": 314572800, "url": "https://example.com/ota-package.zip", "version": "15.1" } @@ -27,6 +28,7 @@ The `datetime` attribute is the build date expressed as UNIX timestamp. The `filename` attribute is the name of the file to be downloaded. The `id` attribute is a string that uniquely identifies the update. The `romtype` attribute is the string to be compared with the `ro.lineage.releasetype` property. +The `size` attribute is the size of the update expressed in bytes. The `url` attribute is the URL of the file to be downloaded. The `version` attribute is the string to be compared with the `ro.lineage.build.version` property. diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index c2c8df61..8ce368e1 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -88,6 +88,7 @@ public class Utils { update.setName(object.getString("filename")); update.setDownloadId(object.getString("id")); update.setType(object.getString("romtype")); + update.setFileSize(object.getLong("size")); update.setDownloadUrl(object.getString("url")); update.setVersion(object.getString("version")); return update; diff --git a/src/org/lineageos/updater/model/Update.java b/src/org/lineageos/updater/model/Update.java index d9296c3b..3ad17dea 100644 --- a/src/org/lineageos/updater/model/Update.java +++ b/src/org/lineageos/updater/model/Update.java @@ -22,7 +22,6 @@ public class Update extends UpdateBase implements UpdateInfo { private UpdateStatus mStatus = UpdateStatus.UNKNOWN; private int mPersistentStatus = UpdateStatus.Persistent.UNKNOWN; private File mFile; - private long mFileSize; private int mProgress; private long mEta; private long mSpeed; @@ -42,7 +41,6 @@ public class Update extends UpdateBase implements UpdateInfo { mStatus = update.getStatus(); mPersistentStatus = update.getPersistentStatus(); mFile = update.getFile(); - mFileSize = update.getFileSize(); mProgress = update.getProgress(); mEta = update.getEta(); mSpeed = update.getSpeed(); @@ -78,15 +76,6 @@ public class Update extends UpdateBase implements UpdateInfo { mFile = file; } - @Override - public long getFileSize() { - return mFileSize; - } - - public void setFileSize(long fileSize) { - mFileSize = fileSize; - } - @Override public int getProgress() { return mProgress; diff --git a/src/org/lineageos/updater/model/UpdateBase.java b/src/org/lineageos/updater/model/UpdateBase.java index 12bc9fe6..8fcf09c8 100644 --- a/src/org/lineageos/updater/model/UpdateBase.java +++ b/src/org/lineageos/updater/model/UpdateBase.java @@ -23,6 +23,7 @@ public class UpdateBase implements UpdateBaseInfo { private long mTimestamp; private String mType; private String mVersion; + private long mFileSize; public UpdateBase() { } @@ -34,6 +35,7 @@ public class UpdateBase implements UpdateBaseInfo { mTimestamp = update.getTimestamp(); mType = update.getType(); mVersion = update.getVersion(); + mFileSize = update.getFileSize(); } @Override @@ -89,4 +91,13 @@ public class UpdateBase implements UpdateBaseInfo { public void setDownloadUrl(String downloadUrl) { mDownloadUrl = downloadUrl; } + + @Override + public long getFileSize() { + return mFileSize; + } + + public void setFileSize(long fileSize) { + mFileSize = fileSize; + } } diff --git a/src/org/lineageos/updater/model/UpdateBaseInfo.java b/src/org/lineageos/updater/model/UpdateBaseInfo.java index b5aad8be..2041582a 100644 --- a/src/org/lineageos/updater/model/UpdateBaseInfo.java +++ b/src/org/lineageos/updater/model/UpdateBaseInfo.java @@ -27,4 +27,6 @@ public interface UpdateBaseInfo { String getVersion(); String getDownloadUrl(); + + long getFileSize(); }