Commit 4bacd24d authored by Gabriele M's avatar Gabriele M

Remove Controller interface

This is just useless as is.

Change-Id: I957ea3bda4097ccb8d730943639cd5e74b1b2440
parent 78e69c05
......@@ -49,7 +49,6 @@ import android.widget.Switch;
import android.widget.TextView;
import org.json.JSONException;
import org.lineageos.updater.controller.Controller;
import org.lineageos.updater.controller.UpdaterController;
import org.lineageos.updater.controller.UpdaterService;
import org.lineageos.updater.download.DownloadClient;
......@@ -238,7 +237,7 @@ public class UpdatesActivity extends UpdatesListActivity {
private void loadUpdatesList(File jsonFile, boolean manualRefresh)
throws IOException, JSONException {
Log.d(TAG, "Adding remote updates");
Controller controller = mUpdaterService.getUpdaterController();
UpdaterController controller = mUpdaterService.getUpdaterController();
boolean newUpdates = false;
List<UpdateInfo> updates = Utils.parseJson(jsonFile, true);
......
......@@ -40,7 +40,7 @@ import android.widget.CheckBox;
import android.widget.ProgressBar;
import android.widget.TextView;
import org.lineageos.updater.controller.Controller;
import org.lineageos.updater.controller.UpdaterController;
import org.lineageos.updater.controller.UpdaterService;
import org.lineageos.updater.misc.BuildInfoUtils;
import org.lineageos.updater.misc.Constants;
......@@ -64,7 +64,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
private List<String> mDownloadIds;
private String mSelectedDownload;
private Controller mUpdaterController;
private UpdaterController mUpdaterController;
private UpdatesListActivity mActivity;
private enum Action {
......@@ -115,7 +115,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
return new ViewHolder(view);
}
public void setUpdaterController(Controller updaterController) {
public void setUpdaterController(UpdaterController updaterController) {
mUpdaterController = updaterController;
notifyDataSetChanged();
}
......
/*
* 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.controller;
import org.lineageos.updater.model.UpdateInfo;
import java.util.List;
import java.util.Set;
public interface Controller {
boolean addUpdate(UpdateInfo update);
List<UpdateInfo> getUpdates();
Set<String> getIds();
UpdateInfo getUpdate(String downloadId);
void setUpdatesAvailableOnline(List<String> downloadIds, boolean purgeList);
void setUpdatesNotAvailableOnline(List<String> downloadIds);
boolean startDownload(String downloadId);
boolean pauseDownload(String downloadId);
boolean deleteUpdate(String downloadId);
boolean resumeDownload(String downloadId);
boolean isDownloading(String downloadId);
boolean hasActiveDownloads();
boolean isVerifyingUpdate(String downloadId);
boolean isVerifyingUpdate();
boolean isInstallingUpdate(String downloadId);
boolean isInstallingUpdate();
boolean isInstallingABUpdate();
}
......@@ -39,7 +39,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
public class UpdaterController implements Controller {
public class UpdaterController {
public static final String ACTION_DOWNLOAD_PROGRESS = "action_download_progress";
public static final String ACTION_INSTALL_PROGRESS = "action_install_progress";
......@@ -292,7 +292,6 @@ public class UpdaterController implements Controller {
return true;
}
@Override
public void setUpdatesNotAvailableOnline(List<String> downloadIds) {
for (String downloadId : downloadIds) {
DownloadEntry update = mDownloads.get(downloadId);
......@@ -302,7 +301,6 @@ public class UpdaterController implements Controller {
}
}
@Override
public void setUpdatesAvailableOnline(List<String> downloadIds, boolean purgeList) {
List<String> toRemove = new ArrayList<>();
for (DownloadEntry entry : mDownloads.values()) {
......@@ -320,7 +318,6 @@ public class UpdaterController implements Controller {
}
}
@Override
public boolean addUpdate(UpdateInfo update) {
return addUpdate(update, true);
}
......@@ -346,7 +343,6 @@ public class UpdaterController implements Controller {
return true;
}
@Override
public boolean startDownload(String downloadId) {
Log.d(TAG, "Starting " + downloadId);
if (!mDownloads.containsKey(downloadId) || isDownloading(downloadId)) {
......@@ -382,7 +378,6 @@ public class UpdaterController implements Controller {
return true;
}
@Override
public boolean resumeDownload(String downloadId) {
Log.d(TAG, "Resuming " + downloadId);
if (!mDownloads.containsKey(downloadId) || isDownloading(downloadId)) {
......@@ -426,7 +421,6 @@ public class UpdaterController implements Controller {
return true;
}
@Override
public boolean pauseDownload(String downloadId) {
Log.d(TAG, "Pausing " + downloadId);
if (!isDownloading(downloadId)) {
......@@ -453,7 +447,6 @@ public class UpdaterController implements Controller {
}).start();
}
@Override
public boolean deleteUpdate(String downloadId) {
Log.d(TAG, "Cancelling " + downloadId);
if (!mDownloads.containsKey(downloadId) || isDownloading(downloadId)) {
......@@ -476,12 +469,10 @@ public class UpdaterController implements Controller {
return true;
}
@Override
public Set<String> getIds() {
return mDownloads.keySet();
}
@Override
public List<UpdateInfo> getUpdates() {
List<UpdateInfo> updates = new ArrayList<>();
for (DownloadEntry entry : mDownloads.values()) {
......@@ -490,7 +481,6 @@ public class UpdaterController implements Controller {
return updates;
}
@Override
public UpdateInfo getUpdate(String downloadId) {
DownloadEntry entry = mDownloads.get(downloadId);
return entry != null ? entry.mUpdate : null;
......@@ -501,41 +491,38 @@ public class UpdaterController implements Controller {
return entry != null ? entry.mUpdate : null;
}
@Override
public boolean isDownloading(String downloadId) {
return mDownloads.containsKey(downloadId) &&
mDownloads.get(downloadId).mDownloadClient != null;
}
@Override
public boolean hasActiveDownloads() {
return mActiveDownloads > 0;
}
@Override
public boolean isVerifyingUpdate() {
return mVerifyingUpdates.size() > 0;
}
@Override
public boolean isVerifyingUpdate(String downloadId) {
return mVerifyingUpdates.contains(downloadId);
}
@Override
public boolean isInstallingUpdate() {
return UpdateInstaller.isInstalling() ||
ABUpdateInstaller.isInstallingUpdate(mContext);
}
@Override
public boolean isInstallingUpdate(String downloadId) {
return UpdateInstaller.isInstalling(downloadId) ||
ABUpdateInstaller.isInstallingUpdate(mContext, downloadId);
}
@Override
public boolean isInstallingABUpdate() {
return ABUpdateInstaller.isInstallingUpdate(mContext);
}
public boolean isWaitingForReboot(String downloadId) {
return ABUpdateInstaller.isWaitingForReboot(mContext, downloadId);
}
}
......@@ -214,7 +214,7 @@ public class UpdaterService extends Service {
return ABUpdateInstaller.isInstallingUpdate(this) ? START_STICKY : START_NOT_STICKY;
}
public Controller getUpdaterController() {
public UpdaterController getUpdaterController() {
return mUpdaterController;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment