OpenDelta: Update config and json to meet our current configuration

change the code accordingly to be able to use sourceforge and our
current json generator
This commit is contained in:
Ido Ben-Hur 2020-01-08 15:27:26 +02:00
parent 60fecc971d
commit 208c289870
3 changed files with 65 additions and 53 deletions

View File

@ -5,43 +5,46 @@
<item name="debug_output" type="bool">true</item>
<!-- Property to read for ROM version -->
<string name="property_version">ro.omni.version</string>
<string name="property_version">ro.modversion</string>
<!-- Property to read for device identifier -->
<string name="property_device">ro.omni.device</string>
<string name="property_device">ro.derp.device</string>
<!-- %s is expanded to property_version value. .zip, .delta, .update, .sign extensions added when needed -->
<string name="filename_base">omni-%s</string>
<string name="filename_base">DerpFest-%s</string>
<!-- Path deltas are stored, relative to sdcard root -->
<string name="path_base">OpenDelta</string>
<!-- URL base to find .delta files, %s is expanded to property_device value. Path is suffixed by (expanded) filename_base -->
<string name="url_base_delta">https://delta.omnirom.org/weeklies/%s/</string>
<string name="url_base_delta"></string>
<!-- URL base to find .update and .sign files, %s is expanded to property_device value. Path is suffixed by (expanded) filename_base -->
<string name="url_base_update">https://delta.omnirom.org/weeklies/%s/</string>
<string name="url_base_update"></string>
<!-- URL base to find the full zip files, %s is expanded to property_device value. Path is suffixed by (expanded) filename_base -->
<string name="url_base_full">https://dl.omnirom.org/%s/</string>
<!-- URL base to find the full zip files, %s is replaced to be property_device value. -->
<string name="url_base_full">https://sourceforge.net/projects/derpfest/files/%s/</string>
<!-- URL base to fetch all builds -->
<string name="url_base_json">https://dl.omnirom.org/json.php"</string>
<!-- URL base suffix - Used only for download -->
<string name="url_base_suffix">/download</string>
<!-- URL base to fetch all builds. %s is replaced by (expanded) property_device -->
<string name="url_base_json">https://raw.githubusercontent.com/DerpLab/Updater-Stuff/master/%s/%s.json</string>
<!-- Applies whole-file signature delta. Adds one extra delta step. Required if recovery verifies signatures -->
<item name="apply_signature" type="bool">true</item>
<item name="apply_signature" type="bool">false</item>
<!-- (TWRP) Set this to false if the keys below aren't your ROM's -->
<item name="inject_signature_enable" type="bool">true</item>
<item name="inject_signature_enable" type="bool">false</item>
<!-- (TWRP) Verification signatures to inject. Produced by 'dumpkey.jar' (out/host) of the platform.x509 key used to sign the ZIP file -->
<string name="inject_signature_keys"><![CDATA[v2 {64,0x9d3ef4e7,{3451855145,2574857780,2212470067,2065828617,2220798544,1453138002,3035953543,349537325,3471576065,3709424322,1499657722,626083680,3508502098,135982109,2406850010,2674691998,3903782739,3673009508,3196976129,124737966,3727608735,3698514242,2926317182,2598715876,2200551045,3324466456,2027872794,1316834497,3538558575,4094723182,3091112109,152419065,961268200,2817719766,2542630774,735678394,2025086356,3319743251,3482513753,3754037486,2186326636,2162920719,1933319201,1362420666,3093979107,3944963833,3173846995,3307766644,4239176696,3380551792,3189093155,3679104199,4159403556,3373361362,737822358,2043192588,3446724037,2184123451,3680508975,492248740,1654088879,3739912969,188663922,4074712169},{2400585854,3884144496,312737665,3547448515,3596760612,2953776441,190371072,1980790627,3681130262,827104214,1597200957,1333455720,1391423898,4233042842,3284284880,50168935,2424437529,2771213818,3715896496,3320142743,3649069246,2702994054,839870558,1257344415,3116165843,4195920375,2497396347,1334871168,3550010104,64795091,3042249326,4155098628,123980023,3500559217,1825888674,443352554,3891428201,2484397377,4136956616,4201065713,2547196505,3411971111,2135688607,393830937,4198844531,3826748593,3979050977,1220766766,3592470842,2278136,1841247501,3507376964,3313320668,3849023694,2185649624,3043141327,1601153541,939583339,2083130022,3508853409,2068728550,3713282728,2402412627,1764295415}}]]></string>
<!-- (TWRP) Add secure mode setting. Requires 'apply_signature' and 'inject_signature_enable'. Limits flashing to TWRP only, verifies ZIP signature in TWRP, disables auto-flashing of additional ZIPs -->
<item name="secure_mode_enable" type="bool">true</item>
<item name="secure_mode_enable" type="bool">false</item>
<!-- (TWRP) Requires 'secure_mode_enable'. Decides whether the default setting for secure mode is enabled (true) or disabled (false) -->
<item name="secure_mode_default" type="bool">true</item>
<item name="secure_mode_default" type="bool">false</item>
<!--
Devices (detected using property_device) which may crash while downloading/patching/verifying when the screen is off.
@ -54,8 +57,8 @@
<item>i777</item>
</string-array>
<string name="official_version_tag">NIGHTLY</string>
<string name="weekly_version_tag">WEEKLY</string>
<string name="official_version_tag">Official</string>
<string name="weekly_version_tag">CI</string>
<string name="security_version_tag">SECURITY_RELEASE</string>
<string name="android_version">ro.build.version.release</string>

View File

@ -1,20 +1,20 @@
/*
/*
* Copyright (C) 2013-2014 Jorrit "Chainfire" Jongma
* Copyright (C) 2013-2015 The OmniROM Project
*/
/*
/*
* This file is part of OpenDelta.
*
*
* OpenDelta is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* OpenDelta is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with OpenDelta. If not, see <http://www.gnu.org/licenses/>.
*/
@ -62,6 +62,7 @@ public class Config {
private final String url_base_delta;
private final String url_base_update;
private final String url_base_full;
private final String url_base_suffix;
private final boolean apply_signature;
private final boolean inject_signature_enable;
private final String inject_signature_keys;
@ -116,15 +117,18 @@ public class Config {
res.getString(R.string.url_base_delta), property_device);
url_base_update = String.format(Locale.ENGLISH,
res.getString(R.string.url_base_update), property_device);
url_base_full = String.format(Locale.ENGLISH,
url_base_full = String.format(
res.getString(R.string.url_base_full), property_device);
url_base_suffix = res.getString(R.string.url_base_suffix);
apply_signature = res.getBoolean(R.bool.apply_signature);
inject_signature_enable = res
.getBoolean(R.bool.inject_signature_enable);
inject_signature_keys = res.getString(R.string.inject_signature_keys);
secure_mode_enable = res.getBoolean(R.bool.secure_mode_enable);
secure_mode_default = res.getBoolean(R.bool.secure_mode_default);
url_base_json = res.getString(R.string.url_base_json);
url_base_json = String.format(
res.getString(R.string.url_base_json),
property_device, property_device);
official_version_tag = res.getString(R.string.official_version_tag);
weekly_version_tag = res.getString(R.string.weekly_version_tag);
security_version_tag = res.getString(R.string.security_version_tag);
@ -190,6 +194,10 @@ public class Config {
return url_base_full;
}
public String getUrlSuffix() {
return url_base_suffix;
}
public boolean getApplySignature() {
return apply_signature;
}

View File

@ -1,20 +1,20 @@
/*
/*
* Copyright (C) 2013-2014 Jorrit "Chainfire" Jongma
* Copyright (C) 2013-2015 The OmniROM Project
*/
/*
/*
* This file is part of OpenDelta.
*
*
* OpenDelta is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* OpenDelta is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with OpenDelta. If not, see <http://www.gnu.org/licenses/>.
*/
@ -26,6 +26,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -469,7 +470,7 @@ OnWantUpdateCheckListener, OnSharedPreferenceChangeListener {
}
if (stopDownload) {
// stop download is only possible in the download step
// that means must have done a check step before
// that means must have done a check step before
// so just fall back to this instead to show none state
// which is just confusing
checkOnly = PREF_AUTO_DOWNLOAD_CHECK;
@ -692,17 +693,17 @@ OnWantUpdateCheckListener, OnSharedPreferenceChangeListener {
InputStream is = urlConnection.getInputStream();
ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
int byteInt;
while((byteInt = is.read()) >= 0){
byteArray.write(byteInt);
}
byte[] bytes = byteArray.toByteArray();
if(bytes == null){
return null;
}
String responseBody = new String(bytes, StandardCharsets.UTF_8);
return responseBody;
} catch (Exception e) {
// Download failed for any number of reasons, timeouts, connection
@ -961,23 +962,24 @@ OnWantUpdateCheckListener, OnSharedPreferenceChangeListener {
JSONObject object = null;
try {
object = new JSONObject(buildData);
Iterator<String> nextKey = object.keys();
JSONArray updatesList = object.getJSONArray("response");
String latestBuild = null;
long latestTimestamp = 0;
while (nextKey.hasNext()) {
String key = nextKey.next();
if (key.equals("./" + config.getDevice())) {
JSONArray builds = object.getJSONArray(key);
for (int i = 0; i < builds.length(); i++) {
JSONObject build = builds.getJSONObject(i);
String fileName = new File(build.getString("filename")).getName();
long timestamp = build.getLong("timestamp");
// latest build can have a larger micro version then what we run now
if (isMatchingImage(fileName) && timestamp>latestTimestamp) {
latestBuild = fileName;
latestTimestamp = timestamp;
}
for (int i = 0; i < updatesList.length(); i++) {
if (updatesList.isNull(i)) {
continue;
}
try {
JSONObject build = updatesList.getJSONObject(i);
String fileName = new File(build.getString("filename")).getName();
long timestamp = build.getLong("datetime");
// latest build can have a larger micro version then what we run now
if (isMatchingImage(fileName) && timestamp>latestTimestamp) {
latestBuild = fileName;
latestTimestamp = timestamp;
}
} catch (JSONException e) {
Logger.ex(e);
}
}
if (latestBuild != null) {
@ -1804,7 +1806,7 @@ OnWantUpdateCheckListener, OnSharedPreferenceChangeListener {
}
private String getLatestFullMd5Sum(String latestFullFetch) {
String md5Url = latestFullFetch + ".md5sum";
String md5Url = latestFullFetch.replace(".zip", ".md5sum");
String latestFullMd5 = downloadUrlMemoryAsString(md5Url);
if (latestFullMd5 != null){
String md5Part = null;
@ -2011,13 +2013,12 @@ OnWantUpdateCheckListener, OnSharedPreferenceChangeListener {
// if we dont even find a build on dl no sense to continue
if (latestFullBuild == null) {
Logger.d("no latest build found at " + config.getUrlBaseJson() +
" for " + config.getDevice() + " prefix " + config.getFileBaseNamePrefix());
" for " + config.getDevice());
return;
}
String latestFullFetch = String.format(Locale.ENGLISH, "%s%s",
config.getUrlBaseFull(),
latestFullBuild);
String latestFullFetch = config.getUrlBaseFull() +
latestFullBuild + config.getUrlSuffix();
Logger.d("latest full build for device " + config.getDevice() + " is " + latestFullFetch);
prefs.edit().putString(PREF_LATEST_FULL_NAME, latestFullBuild).commit();
@ -2299,7 +2300,7 @@ OnWantUpdateCheckListener, OnSharedPreferenceChangeListener {
if (force || networkState.getState()) {
String latestFullMd5 = getLatestFullMd5Sum(latestFullFetch);
if (latestFullMd5 != null){
downloadFullBuild(latestFullFetch, latestFullMd5, latestFullBuild);
downloadFullBuild(latestFullFetch, latestFullMd5, latestFullBuild); // download full
} else {
Logger.d("aborting download due to md5sum not found");
}
@ -2348,7 +2349,7 @@ OnWantUpdateCheckListener, OnSharedPreferenceChangeListener {
if (oldFlashFilename != PREF_READY_FILENAME_DEFAULT && !oldFlashFilename.equals(newFlashFilename)
&& oldFlashFilename.startsWith(config.getPathBase())) {
File file = new File(oldFlashFilename);
if (file.exists() && file.getName().startsWith(config.getFileBaseNamePrefix())) {
if (file.exists()) {
Logger.d("delete oldFlashFilename " + oldFlashFilename);
file.delete();
}
@ -2361,7 +2362,7 @@ OnWantUpdateCheckListener, OnSharedPreferenceChangeListener {
File[] contents = new File(dataFolder).listFiles();
if (contents != null) {
for (File file : contents) {
if (file.isFile() && file.getName().startsWith(config.getFileBaseNamePrefix())) {
if (file.isFile()) {
Logger.d("image file: " + file.getName());
}
}