Get file size from JSON
The server now reports the size of the file, so use it and require it. Change-Id: I2248347431b65ae54dd7295872d70aba456ed8d8
This commit is contained in:
parent
6fd45962c1
commit
a72b78c31e
@ -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.
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -27,4 +27,6 @@ public interface UpdateBaseInfo {
|
||||
String getVersion();
|
||||
|
||||
String getDownloadUrl();
|
||||
|
||||
long getFileSize();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user