Allow to check if an update is of type AB from anywhere

This commit is contained in:
Gabriele M
2017-07-16 22:28:11 +02:00
parent 4182e3d30e
commit 12688ba761
4 changed files with 20 additions and 14 deletions

View File

@@ -21,6 +21,7 @@ import android.util.Log;
import org.lineageos.updater.UpdateDownload;
import org.lineageos.updater.UpdateStatus;
import org.lineageos.updater.misc.Constants;
import org.lineageos.updater.misc.Utils;
import java.io.BufferedReader;
@@ -39,9 +40,6 @@ class ABUpdateInstaller {
private static String sDownloadId;
private static final String PAYLOAD_BIN_PATH = "payload.bin";
private static final String PAYLOAD_PROPERTIES_PATH = "payload_properties.txt";
private final UpdaterController mUpdaterController;
private final String mDownloadId;
@@ -131,8 +129,8 @@ class ABUpdateInstaller {
String[] headerKeyValuePairs;
try {
ZipFile zipFile = new ZipFile(file);
offset = Utils.getZipEntryOffset(zipFile, PAYLOAD_BIN_PATH);
ZipEntry payloadPropEntry = zipFile.getEntry(PAYLOAD_PROPERTIES_PATH);
offset = Utils.getZipEntryOffset(zipFile, Constants.AB_PAYLOAD_BIN_PATH);
ZipEntry payloadPropEntry = zipFile.getEntry(Constants.AB_PAYLOAD_PROPERTIES_PATH);
try (InputStream is = zipFile.getInputStream(payloadPropEntry);
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr)) {
@@ -159,9 +157,4 @@ class ABUpdateInstaller {
return true;
}
static boolean isABUpdate(ZipFile zipFile) {
return zipFile.getEntry(PAYLOAD_BIN_PATH) != null &&
zipFile.getEntry(PAYLOAD_PROPERTIES_PATH) != null;
}
}