Rename UpdateDownload and Update classes
This commit is contained in:
@@ -22,7 +22,7 @@ import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.provider.BaseColumns;
|
||||
|
||||
import org.lineageos.updater.model.UpdateDownload;
|
||||
import org.lineageos.updater.model.Update;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -75,7 +75,7 @@ public class UpdatesDbHelper extends SQLiteOpenHelper {
|
||||
onUpgrade(db, oldVersion, newVersion);
|
||||
}
|
||||
|
||||
public long addUpdate(UpdateDownload update) {
|
||||
public long addUpdate(Update update) {
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(UpdateEntry.COLUMN_NAME_STATUS, update.getPersistentStatus());
|
||||
@@ -88,7 +88,7 @@ public class UpdatesDbHelper extends SQLiteOpenHelper {
|
||||
return db.insert(UpdateEntry.TABLE_NAME, null, values);
|
||||
}
|
||||
|
||||
public long addUpdateWithOnConflict(UpdateDownload update, int conflictAlgorithm) {
|
||||
public long addUpdateWithOnConflict(Update update, int conflictAlgorithm) {
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(UpdateEntry.COLUMN_NAME_STATUS, update.getPersistentStatus());
|
||||
@@ -114,7 +114,7 @@ public class UpdatesDbHelper extends SQLiteOpenHelper {
|
||||
return db.delete(UpdateEntry.TABLE_NAME, selection, null) != 0;
|
||||
}
|
||||
|
||||
public boolean changeUpdateStatus(UpdateDownload update) {
|
||||
public boolean changeUpdateStatus(Update update) {
|
||||
String selection = UpdateEntry.COLUMN_NAME_DOWNLOAD_ID + " = ?";
|
||||
String[] selectionArgs = {update.getDownloadId()};
|
||||
return changeUpdateStatus(selection, selectionArgs, update.getPersistentStatus());
|
||||
@@ -133,27 +133,27 @@ public class UpdatesDbHelper extends SQLiteOpenHelper {
|
||||
return db.update(UpdateEntry.TABLE_NAME, values, selection, selectionArgs) != 0;
|
||||
}
|
||||
|
||||
public UpdateDownload getUpdate(long rowId) {
|
||||
public Update getUpdate(long rowId) {
|
||||
String selection = UpdateEntry._ID + " = " + rowId;
|
||||
return getUpdate(selection, null);
|
||||
}
|
||||
|
||||
public UpdateDownload getUpdate(String downloadId) {
|
||||
public Update getUpdate(String downloadId) {
|
||||
String selection = UpdateEntry.COLUMN_NAME_DOWNLOAD_ID + " = ?";
|
||||
String[] selectionArgs = {downloadId};
|
||||
return getUpdate(selection, selectionArgs);
|
||||
}
|
||||
|
||||
private UpdateDownload getUpdate(String selection, String[] selectionArgs) {
|
||||
List<UpdateDownload> updates = getUpdates(selection, selectionArgs);
|
||||
private Update getUpdate(String selection, String[] selectionArgs) {
|
||||
List<Update> updates = getUpdates(selection, selectionArgs);
|
||||
return updates != null ? updates.get(0) : null;
|
||||
}
|
||||
|
||||
public List<UpdateDownload> getUpdates() {
|
||||
public List<Update> getUpdates() {
|
||||
return getUpdates(null, null);
|
||||
}
|
||||
|
||||
public List<UpdateDownload> getUpdates(String selection, String[] selectionArgs) {
|
||||
public List<Update> getUpdates(String selection, String[] selectionArgs) {
|
||||
SQLiteDatabase db = getReadableDatabase();
|
||||
String[] projection = {
|
||||
UpdateEntry.COLUMN_NAME_PATH,
|
||||
@@ -167,10 +167,10 @@ public class UpdatesDbHelper extends SQLiteOpenHelper {
|
||||
String sort = UpdateEntry.COLUMN_NAME_TIMESTAMP + " DESC";
|
||||
Cursor cursor = db.query(UpdateEntry.TABLE_NAME, projection, selection, selectionArgs,
|
||||
null, null, sort);
|
||||
List<UpdateDownload> updates = new ArrayList<>();
|
||||
List<Update> updates = new ArrayList<>();
|
||||
if (cursor != null) {
|
||||
while (cursor.moveToNext()) {
|
||||
UpdateDownload update = new UpdateDownload();
|
||||
Update update = new Update();
|
||||
int index = cursor.getColumnIndex(UpdateEntry.COLUMN_NAME_PATH);
|
||||
update.setFile(new File(cursor.getString(index)));
|
||||
update.setName(update.getFile().getName());
|
||||
|
@@ -21,7 +21,7 @@ import android.util.Log;
|
||||
|
||||
import org.lineageos.updater.misc.Constants;
|
||||
import org.lineageos.updater.misc.Utils;
|
||||
import org.lineageos.updater.model.UpdateDownload;
|
||||
import org.lineageos.updater.model.Update;
|
||||
import org.lineageos.updater.model.UpdateStatus;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@@ -57,7 +57,7 @@ class ABUpdateInstaller {
|
||||
break;
|
||||
|
||||
case UpdateEngine.UpdateStatusConstants.REPORTING_ERROR_EVENT: {
|
||||
UpdateDownload update = mUpdaterController.getActualUpdate(mDownloadId);
|
||||
Update update = mUpdaterController.getActualUpdate(mDownloadId);
|
||||
update.setInstallProgress(0);
|
||||
update.setStatus(UpdateStatus.INSTALLATION_FAILED);
|
||||
mUpdaterController.notifyUpdateChange(mDownloadId);
|
||||
@@ -71,7 +71,7 @@ class ABUpdateInstaller {
|
||||
sDownloadId = null;
|
||||
switch (errorCode) {
|
||||
case UpdateEngine.ErrorCodeConstants.SUCCESS: {
|
||||
UpdateDownload update = mUpdaterController.getActualUpdate(mDownloadId);
|
||||
Update update = mUpdaterController.getActualUpdate(mDownloadId);
|
||||
update.setInstallProgress(0);
|
||||
update.setStatus(UpdateStatus.INSTALLED);
|
||||
mUpdaterController.notifyUpdateChange(mDownloadId);
|
||||
@@ -79,7 +79,7 @@ class ABUpdateInstaller {
|
||||
break;
|
||||
|
||||
default: {
|
||||
UpdateDownload update = mUpdaterController.getActualUpdate(mDownloadId);
|
||||
Update update = mUpdaterController.getActualUpdate(mDownloadId);
|
||||
update.setInstallProgress(0);
|
||||
update.setStatus(UpdateStatus.INSTALLATION_FAILED);
|
||||
mUpdaterController.notifyUpdateChange(mDownloadId);
|
||||
|
@@ -26,7 +26,7 @@ import android.util.Log;
|
||||
import org.lineageos.updater.UpdatesDbHelper;
|
||||
import org.lineageos.updater.download.DownloadClient;
|
||||
import org.lineageos.updater.misc.Utils;
|
||||
import org.lineageos.updater.model.UpdateDownload;
|
||||
import org.lineageos.updater.model.Update;
|
||||
import org.lineageos.updater.model.UpdateInfo;
|
||||
import org.lineageos.updater.model.UpdateStatus;
|
||||
|
||||
@@ -83,15 +83,15 @@ public class UpdaterController implements Controller {
|
||||
|
||||
Utils.cleanupDownloadsDir(context);
|
||||
|
||||
for (UpdateDownload update : mUpdatesDbHelper.getUpdates()) {
|
||||
for (Update update : mUpdatesDbHelper.getUpdates()) {
|
||||
addUpdate(update, false);
|
||||
}
|
||||
}
|
||||
|
||||
private class DownloadEntry {
|
||||
final UpdateDownload mUpdate;
|
||||
final Update mUpdate;
|
||||
DownloadClient mDownloadClient;
|
||||
private DownloadEntry(UpdateDownload update) {
|
||||
private DownloadEntry(Update update) {
|
||||
mUpdate = update;
|
||||
}
|
||||
}
|
||||
@@ -153,7 +153,7 @@ public class UpdaterController implements Controller {
|
||||
|
||||
@Override
|
||||
public void onResponse(int statusCode, String url, DownloadClient.Headers headers) {
|
||||
final UpdateDownload update = mDownloads.get(downloadId).mUpdate;
|
||||
final Update update = mDownloads.get(downloadId).mUpdate;
|
||||
if (update.getFileSize() <= 0) {
|
||||
String contentLength = headers.get("Content-Length");
|
||||
if (contentLength != null) {
|
||||
@@ -182,7 +182,7 @@ public class UpdaterController implements Controller {
|
||||
@Override
|
||||
public void onSuccess(File destination) {
|
||||
Log.d(TAG, "Download complete");
|
||||
UpdateDownload update = mDownloads.get(downloadId).mUpdate;
|
||||
Update update = mDownloads.get(downloadId).mUpdate;
|
||||
update.setStatus(UpdateStatus.VERIFYING);
|
||||
removeDownloadClient(mDownloads.get(downloadId));
|
||||
verifyUpdateAsync(downloadId);
|
||||
@@ -192,7 +192,7 @@ public class UpdaterController implements Controller {
|
||||
|
||||
@Override
|
||||
public void onFailure(boolean cancelled) {
|
||||
UpdateDownload update = mDownloads.get(downloadId).mUpdate;
|
||||
Update update = mDownloads.get(downloadId).mUpdate;
|
||||
if (cancelled) {
|
||||
Log.d(TAG, "Download cancelled");
|
||||
update.setStatus(UpdateStatus.PAUSED);
|
||||
@@ -216,7 +216,7 @@ public class UpdaterController implements Controller {
|
||||
@Override
|
||||
public void update(long bytesRead, long contentLength, long speed, long eta,
|
||||
boolean done) {
|
||||
UpdateDownload update = mDownloads.get(downloadId).mUpdate;
|
||||
Update update = mDownloads.get(downloadId).mUpdate;
|
||||
if (contentLength <= 0) {
|
||||
if (update.getFileSize() <= 0) {
|
||||
return;
|
||||
@@ -246,7 +246,7 @@ public class UpdaterController implements Controller {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
UpdateDownload update = mDownloads.get(downloadId).mUpdate;
|
||||
Update update = mDownloads.get(downloadId).mUpdate;
|
||||
File file = update.getFile();
|
||||
if (file.exists() && verifyPackage(file)) {
|
||||
update.setPersistentStatus(UpdateStatus.Persistent.VERIFIED);
|
||||
@@ -281,7 +281,7 @@ public class UpdaterController implements Controller {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean fixUpdateStatus(UpdateDownload update) {
|
||||
private boolean fixUpdateStatus(Update update) {
|
||||
switch (update.getPersistentStatus()) {
|
||||
case UpdateStatus.Persistent.VERIFIED:
|
||||
case UpdateStatus.Persistent.INCOMPLETE:
|
||||
@@ -336,12 +336,12 @@ public class UpdaterController implements Controller {
|
||||
Log.d(TAG, "Adding download: " + updateInfo.getDownloadId());
|
||||
if (mDownloads.containsKey(updateInfo.getDownloadId())) {
|
||||
Log.d(TAG, "Download (" + updateInfo.getDownloadId() + ") already added");
|
||||
UpdateDownload updateAdded = mDownloads.get(updateInfo.getDownloadId()).mUpdate;
|
||||
Update updateAdded = mDownloads.get(updateInfo.getDownloadId()).mUpdate;
|
||||
updateAdded.setAvailableOnline(availableOnline && updateAdded.getAvailableOnline());
|
||||
updateAdded.setDownloadUrl(updateInfo.getDownloadUrl());
|
||||
return false;
|
||||
}
|
||||
UpdateDownload update = new UpdateDownload(updateInfo);
|
||||
Update update = new Update(updateInfo);
|
||||
if (!fixUpdateStatus(update) && !availableOnline) {
|
||||
update.setPersistentStatus(UpdateStatus.Persistent.UNKNOWN);
|
||||
deleteUpdateAsync(update);
|
||||
@@ -359,7 +359,7 @@ public class UpdaterController implements Controller {
|
||||
if (!mDownloads.containsKey(downloadId) || isDownloading(downloadId)) {
|
||||
return false;
|
||||
}
|
||||
UpdateDownload update = mDownloads.get(downloadId).mUpdate;
|
||||
Update update = mDownloads.get(downloadId).mUpdate;
|
||||
File destination = new File(mDownloadRoot, update.getName());
|
||||
if (destination.exists()) {
|
||||
destination = Utils.appendSequentialNumber(destination);
|
||||
@@ -386,7 +386,7 @@ public class UpdaterController implements Controller {
|
||||
if (!mDownloads.containsKey(downloadId) || isDownloading(downloadId)) {
|
||||
return false;
|
||||
}
|
||||
UpdateDownload update = mDownloads.get(downloadId).mUpdate;
|
||||
Update update = mDownloads.get(downloadId).mUpdate;
|
||||
File file = update.getFile();
|
||||
if (file == null || !file.exists()) {
|
||||
Log.e(TAG, "The destination file of " + downloadId + " doesn't exist, can't resume");
|
||||
@@ -432,7 +432,7 @@ public class UpdaterController implements Controller {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void deleteUpdateAsync(final UpdateDownload update) {
|
||||
private void deleteUpdateAsync(final Update update) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -451,7 +451,7 @@ public class UpdaterController implements Controller {
|
||||
if (!mDownloads.containsKey(downloadId) || isDownloading(downloadId)) {
|
||||
return false;
|
||||
}
|
||||
UpdateDownload update = mDownloads.get(downloadId).mUpdate;
|
||||
Update update = mDownloads.get(downloadId).mUpdate;
|
||||
update.setStatus(UpdateStatus.DELETED);
|
||||
update.setProgress(0);
|
||||
update.setPersistentStatus(UpdateStatus.Persistent.UNKNOWN);
|
||||
@@ -488,7 +488,7 @@ public class UpdaterController implements Controller {
|
||||
return entry != null ? entry.mUpdate : null;
|
||||
}
|
||||
|
||||
UpdateDownload getActualUpdate(String downloadId) {
|
||||
Update getActualUpdate(String downloadId) {
|
||||
DownloadEntry entry = mDownloads.get(downloadId);
|
||||
return entry != null ? entry.mUpdate : null;
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import org.lineageos.updater.UpdatesDbHelper;
|
||||
import org.lineageos.updater.model.UpdateDownload;
|
||||
import org.lineageos.updater.model.Update;
|
||||
import org.lineageos.updater.model.UpdateInfo;
|
||||
import org.lineageos.updater.model.UpdateStatus;
|
||||
|
||||
@@ -87,7 +87,7 @@ public final class LegacySupport {
|
||||
Log.d(TAG, "Importing " + file.getAbsolutePath());
|
||||
Integer index = updatesMap.get(file.getName());
|
||||
if (index != null) {
|
||||
UpdateDownload update = new UpdateDownload(updatesJson.get(index));
|
||||
Update update = new Update(updatesJson.get(index));
|
||||
update.setFile(file);
|
||||
update.setFileSize(file.length());
|
||||
update.setStatus(UpdateStatus.DOWNLOADED);
|
||||
@@ -95,7 +95,7 @@ public final class LegacySupport {
|
||||
dbHelper.addUpdate(update);
|
||||
} else {
|
||||
try {
|
||||
UpdateDownload update = createUpdateFromFile(file);
|
||||
Update update = createUpdateFromFile(file);
|
||||
notReplacing.add(update.getDownloadId());
|
||||
updatesJson.add(update);
|
||||
dbHelper.addUpdate(update);
|
||||
@@ -112,8 +112,8 @@ public final class LegacySupport {
|
||||
return notReplacing;
|
||||
}
|
||||
|
||||
private static UpdateDownload createUpdateFromFile(File file) throws IllegalFilenameException {
|
||||
UpdateDownload update = new UpdateDownload();
|
||||
private static Update createUpdateFromFile(File file) throws IllegalFilenameException {
|
||||
Update update = new Update();
|
||||
update.setDownloadId(UUID.randomUUID().toString());
|
||||
update.setFile(file);
|
||||
update.setFileSize(file.length());
|
||||
|
@@ -36,7 +36,7 @@ import org.lineageos.updater.R;
|
||||
import org.lineageos.updater.UpdatesDbHelper;
|
||||
import org.lineageos.updater.controller.UpdaterService;
|
||||
import org.lineageos.updater.model.UpdateBaseInfo;
|
||||
import org.lineageos.updater.model.UpdateDownload;
|
||||
import org.lineageos.updater.model.Update;
|
||||
import org.lineageos.updater.model.UpdateInfo;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@@ -80,7 +80,7 @@ public class Utils {
|
||||
// This should really return an UpdateBaseInfo object, but currently this only
|
||||
// used to initialize UpdateInfo objects
|
||||
private static UpdateInfo parseJsonUpdate(JSONObject object) throws JSONException {
|
||||
UpdateDownload update = new UpdateDownload();
|
||||
Update update = new Update();
|
||||
update.setTimestamp(object.getLong("datetime"));
|
||||
update.setName(object.getString("filename"));
|
||||
update.setDownloadId(object.getString("id"));
|
||||
|
@@ -15,78 +15,118 @@
|
||||
*/
|
||||
package org.lineageos.updater.model;
|
||||
|
||||
public class Update implements UpdateBaseInfo {
|
||||
import java.io.File;
|
||||
|
||||
private String mName;
|
||||
private String mDownloadUrl;
|
||||
private String mDownloadId;
|
||||
private long mTimestamp;
|
||||
private String mType;
|
||||
private String mVersion;
|
||||
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;
|
||||
private int mInstallProgress;
|
||||
private boolean mAvailableOnline;
|
||||
|
||||
public Update() {
|
||||
}
|
||||
|
||||
public Update(UpdateBaseInfo update) {
|
||||
mName = update.getName();
|
||||
mDownloadUrl = update.getDownloadUrl();
|
||||
mDownloadId = update.getDownloadId();
|
||||
mTimestamp = update.getTimestamp();
|
||||
mType = update.getType();
|
||||
mVersion = update.getVersion();
|
||||
super(update);
|
||||
}
|
||||
|
||||
public Update(UpdateInfo update) {
|
||||
super(update);
|
||||
mStatus = update.getStatus();
|
||||
mPersistentStatus = update.getPersistentStatus();
|
||||
mFile = update.getFile();
|
||||
mFileSize = update.getFileSize();
|
||||
mProgress = update.getProgress();
|
||||
mEta = update.getEta();
|
||||
mSpeed = update.getSpeed();
|
||||
mInstallProgress = update.getInstallProgress();
|
||||
mAvailableOnline = update.getAvailableOnline();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return mName;
|
||||
public UpdateStatus getStatus() {
|
||||
return mStatus;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
mName = name;
|
||||
public void setStatus(UpdateStatus status) {
|
||||
mStatus = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDownloadId() {
|
||||
return mDownloadId;
|
||||
public int getPersistentStatus() {
|
||||
return mPersistentStatus;
|
||||
}
|
||||
|
||||
public void setDownloadId(String downloadId) {
|
||||
mDownloadId = downloadId;
|
||||
public void setPersistentStatus(int status) {
|
||||
mPersistentStatus = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTimestamp() {
|
||||
return mTimestamp;
|
||||
public File getFile() {
|
||||
return mFile;
|
||||
}
|
||||
|
||||
public void setTimestamp(long timestamp) {
|
||||
mTimestamp = timestamp;
|
||||
public void setFile(File file) {
|
||||
mFile = file;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return mType;
|
||||
public long getFileSize() {
|
||||
return mFileSize;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
mType = type;
|
||||
public void setFileSize(long fileSize) {
|
||||
mFileSize = fileSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return mVersion;
|
||||
public int getProgress() {
|
||||
return mProgress;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
mVersion = version;
|
||||
public void setProgress(int progress) {
|
||||
mProgress = progress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDownloadUrl() {
|
||||
return mDownloadUrl;
|
||||
public long getEta() {
|
||||
return mEta;
|
||||
}
|
||||
|
||||
public void setDownloadUrl(String downloadUrl) {
|
||||
mDownloadUrl = downloadUrl;
|
||||
public void setEta(long eta) {
|
||||
mEta = eta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSpeed() {
|
||||
return mSpeed;
|
||||
}
|
||||
|
||||
public void setSpeed(long speed) {
|
||||
mSpeed = speed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstallProgress() {
|
||||
return mInstallProgress;
|
||||
}
|
||||
|
||||
public void setInstallProgress(int progress) {
|
||||
mInstallProgress = progress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAvailableOnline() {
|
||||
return mAvailableOnline;
|
||||
}
|
||||
|
||||
public void setAvailableOnline(boolean availableOnline) {
|
||||
mAvailableOnline = availableOnline;
|
||||
}
|
||||
}
|
||||
|
92
src/org/lineageos/updater/model/UpdateBase.java
Normal file
92
src/org/lineageos/updater/model/UpdateBase.java
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.lineageos.updater.model;
|
||||
|
||||
public class UpdateBase implements UpdateBaseInfo {
|
||||
|
||||
private String mName;
|
||||
private String mDownloadUrl;
|
||||
private String mDownloadId;
|
||||
private long mTimestamp;
|
||||
private String mType;
|
||||
private String mVersion;
|
||||
|
||||
public UpdateBase() {
|
||||
}
|
||||
|
||||
public UpdateBase(UpdateBaseInfo update) {
|
||||
mName = update.getName();
|
||||
mDownloadUrl = update.getDownloadUrl();
|
||||
mDownloadId = update.getDownloadId();
|
||||
mTimestamp = update.getTimestamp();
|
||||
mType = update.getType();
|
||||
mVersion = update.getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
mName = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDownloadId() {
|
||||
return mDownloadId;
|
||||
}
|
||||
|
||||
public void setDownloadId(String downloadId) {
|
||||
mDownloadId = downloadId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTimestamp() {
|
||||
return mTimestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(long timestamp) {
|
||||
mTimestamp = timestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return mType;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
mType = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return mVersion;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
mVersion = version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDownloadUrl() {
|
||||
return mDownloadUrl;
|
||||
}
|
||||
|
||||
public void setDownloadUrl(String downloadUrl) {
|
||||
mDownloadUrl = downloadUrl;
|
||||
}
|
||||
}
|
@@ -1,132 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.lineageos.updater.model;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class UpdateDownload extends Update 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;
|
||||
private int mInstallProgress;
|
||||
private boolean mAvailableOnline;
|
||||
|
||||
public UpdateDownload() {
|
||||
}
|
||||
|
||||
public UpdateDownload(UpdateBaseInfo update) {
|
||||
super(update);
|
||||
}
|
||||
|
||||
public UpdateDownload(UpdateInfo update) {
|
||||
super(update);
|
||||
mStatus = update.getStatus();
|
||||
mPersistentStatus = update.getPersistentStatus();
|
||||
mFile = update.getFile();
|
||||
mFileSize = update.getFileSize();
|
||||
mProgress = update.getProgress();
|
||||
mEta = update.getEta();
|
||||
mSpeed = update.getSpeed();
|
||||
mInstallProgress = update.getInstallProgress();
|
||||
mAvailableOnline = update.getAvailableOnline();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UpdateStatus getStatus() {
|
||||
return mStatus;
|
||||
}
|
||||
|
||||
public void setStatus(UpdateStatus status) {
|
||||
mStatus = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPersistentStatus() {
|
||||
return mPersistentStatus;
|
||||
}
|
||||
|
||||
public void setPersistentStatus(int status) {
|
||||
mPersistentStatus = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getFile() {
|
||||
return mFile;
|
||||
}
|
||||
|
||||
public void setFile(File file) {
|
||||
mFile = file;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getFileSize() {
|
||||
return mFileSize;
|
||||
}
|
||||
|
||||
public void setFileSize(long fileSize) {
|
||||
mFileSize = fileSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProgress() {
|
||||
return mProgress;
|
||||
}
|
||||
|
||||
public void setProgress(int progress) {
|
||||
mProgress = progress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEta() {
|
||||
return mEta;
|
||||
}
|
||||
|
||||
public void setEta(long eta) {
|
||||
mEta = eta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSpeed() {
|
||||
return mSpeed;
|
||||
}
|
||||
|
||||
public void setSpeed(long speed) {
|
||||
mSpeed = speed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstallProgress() {
|
||||
return mInstallProgress;
|
||||
}
|
||||
|
||||
public void setInstallProgress(int progress) {
|
||||
mInstallProgress = progress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAvailableOnline() {
|
||||
return mAvailableOnline;
|
||||
}
|
||||
|
||||
public void setAvailableOnline(boolean availableOnline) {
|
||||
mAvailableOnline = availableOnline;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user