OpenDelta: Add some logger entries and fix md5sum fetcher logic

This commit is contained in:
Ido Ben-Hur 2020-01-08 20:08:34 +02:00
parent 208c289870
commit 01de55694b
9 changed files with 337 additions and 13 deletions

24
.idea/OpenDelta.iml Normal file
View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android" name="Android">
<configuration>
<option name="GEN_FOLDER_RELATIVE_PATH_APT" value="/../../OpenDelta/gen" />
<option name="GEN_FOLDER_RELATIVE_PATH_AIDL" value="/../../OpenDelta/gen" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/../../OpenDelta/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/../../OpenDelta/res" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/../../OpenDelta/assets" />
<option name="LIBS_FOLDER_RELATIVE_PATH" value="/../../OpenDelta/libs" />
<option name="PROGUARD_LOGS_FOLDER_RELATIVE_PATH" value="/../../OpenDelta/proguard_logs" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
</content>
<orderEntry type="jdk" jdkName="Android API 27 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,116 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<codeStyleSettings language="XML">
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
<arrangement>
<rules>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:android</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:id</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>style</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>ANDROID_ATTRIBUTE_ORDER</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>.*</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
</code_scheme>
</component>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/OpenDelta.iml" filepath="$PROJECT_DIR$/.idea/OpenDelta.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

128
.idea/workspace.xml Normal file
View File

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="c4ab6677-0bb4-4c67-9d84-e6a65bb656a0" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/res/drawable/derp_logo.xml" beforeDir="false" afterPath="$PROJECT_DIR$/res/drawable/derp_logo.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/res/drawable/ic_derp_small.xml" beforeDir="false" afterPath="$PROJECT_DIR$/res/drawable/ic_derp_small.xml" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileEditorManager">
<leaf>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/.gitignore">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="20">
<caret line="1" selection-start-line="1" selection-end-line="1" />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="203" />
<option name="y" value="30" />
<option name="width" value="1400" />
<option name="height" value="1000" />
</component>
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="OpenDelta" type="b2602c69:ProjectViewProjectNode" />
<item name="OpenDelta" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="OpenDelta" type="b2602c69:ProjectViewProjectNode" />
<item name="External Libraries" type="cb654da1:ExternalLibrariesNode" />
</path>
<path>
<item name="OpenDelta" type="b2602c69:ProjectViewProjectNode" />
<item name="External Libraries" type="cb654da1:ExternalLibrariesNode" />
<item name="&lt; Android API 27 Platform &gt;" type="70bed36:NamedLibraryElementNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="PackagesPane" />
<pane id="AndroidView" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="android.sdk.path" value="$PROJECT_DIR$/../../../../Sdk" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="c4ab6677-0bb4-4c67-9d84-e6a65bb656a0" name="Default Changelist" comment="" />
<created>1578316046423</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1578316046423</updated>
</task>
<servers />
</component>
<component name="ToolWindowManager">
<frame x="-1" y="1" width="1922" height="1080" extended-state="6" />
<layout>
<window_info active="true" content_ui="combo" id="Project" visible="true" weight="0.3340448" />
<window_info id="Structure" side_tool="true" />
<window_info id="Image Layers" />
<window_info id="Designer" />
<window_info id="Build Variants" side_tool="true" />
<window_info id="Resources Explorer" />
<window_info id="Capture Tool" />
<window_info id="Favorites" side_tool="true" />
<window_info id="Captures" order="0" side_tool="true" weight="0.25" />
<window_info anchor="bottom" id="Version Control" />
<window_info anchor="bottom" id="TODO" />
<window_info anchor="bottom" id="Android Profiler" show_stripe_button="false" />
<window_info anchor="bottom" id="Logcat" />
<window_info anchor="bottom" id="Terminal" />
<window_info anchor="bottom" id="Event Log" side_tool="true" />
<window_info anchor="right" id="Device File Explorer" side_tool="true" />
<window_info anchor="right" id="Capture Analysis" />
<window_info anchor="right" id="Theme Preview" />
<window_info anchor="right" id="Palette&#9;" />
</layout>
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/.gitignore">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="20">
<caret line="1" selection-start-line="1" selection-end-line="1" />
</state>
</provider>
</entry>
</component>
</project>

View File

@ -0,0 +1,8 @@
/*___Generated_by_IDEA___*/
package eu.chainfire.opendelta;
/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */
public final class BuildConfig {
public final static boolean DEBUG = Boolean.parseBoolean(null);
}

View File

@ -0,0 +1,7 @@
/*___Generated_by_IDEA___*/
package eu.chainfire.opendelta;
/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */
public final class Manifest {
}

View File

@ -0,0 +1,7 @@
/*___Generated_by_IDEA___*/
package eu.chainfire.opendelta;
/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */
public final class R {
}

View File

@ -773,6 +773,9 @@ OnWantUpdateCheckListener, OnSharedPreferenceChangeListener {
while (MD5.length() < 32)
MD5 = "0" + MD5;
boolean md5Check = MD5.equals(matchMD5);
Logger.d("MD5=" + MD5 + " matchMD5=" + matchMD5);
Logger.d("MD5.length=" + Integer.toString(MD5.length()) +
" matchMD5.length=" + Integer.toString(matchMD5.length()));
if (!md5Check) {
Logger.i("MD5 check failed for " + url);
}
@ -886,6 +889,9 @@ OnWantUpdateCheckListener, OnSharedPreferenceChangeListener {
while (MD5.length() < 32)
MD5 = "0" + MD5;
boolean md5Check = MD5.equals(matchMD5);
Logger.d("MD5=" + MD5 + " matchMD5=" + matchMD5);
Logger.d("MD5.length=" + Integer.toString(MD5.length()) +
" matchMD5.length=" + Integer.toString(matchMD5.length()));
if (!md5Check) {
Logger.i("MD5 check failed for " + url);
}
@ -932,6 +938,7 @@ OnWantUpdateCheckListener, OnSharedPreferenceChangeListener {
private boolean isMatchingImage(String fileName) {
try {
Logger.d("Image check for file name: " + fileName);
if(fileName.endsWith(".zip") && fileName.indexOf(config.getDevice()) != -1) {
String[] parts = fileName.split("-");
if (parts.length > 1) {
@ -939,6 +946,7 @@ OnWantUpdateCheckListener, OnSharedPreferenceChangeListener {
Version current = new Version(config.getAndroidVersion());
Version fileVersion = new Version(version);
if (fileVersion.compareTo(current) >= 0) {
Logger.d("Image check: newer version!");
return true;
}
}
@ -974,6 +982,9 @@ OnWantUpdateCheckListener, OnSharedPreferenceChangeListener {
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
Logger.d("parsed from json:");
Logger.d("fileName= " + fileName);
Logger.d("timeStamp= " + Long.toString(timestamp));
if (isMatchingImage(fileName) && timestamp>latestTimestamp) {
latestBuild = fileName;
latestTimestamp = timestamp;
@ -1417,11 +1428,16 @@ OnWantUpdateCheckListener, OnSharedPreferenceChangeListener {
}
private boolean checkFullBuildMd5Sum(String url, String fn) {
String md5Url = url + ".md5sum";
String urlSuffix = config.getUrlSuffix();
String md5Url = "";
if (urlSuffix.length() > 0)
md5Url = url.replace(urlSuffix, ".md5sum");
else
md5Url = url + ".md5sum";
String latestFullMd5 = downloadUrlMemoryAsString(md5Url);
if (latestFullMd5 != null){
try {
String md5Part = latestFullMd5.split(" ")[0];
String md5Part = latestFullMd5;
String fileMd5 =getFileMD5(new File(fn), getMD5Progress(STATE_ACTION_CHECKING_MD5, new File(fn).getName()));
if (md5Part.equals(fileMd5)) {
return true;
@ -1806,15 +1822,17 @@ OnWantUpdateCheckListener, OnSharedPreferenceChangeListener {
}
private String getLatestFullMd5Sum(String latestFullFetch) {
String md5Url = latestFullFetch.replace(".zip", ".md5sum");
String urlSuffix = config.getUrlSuffix();
String md5Url = "";
if (urlSuffix.length() > 0)
md5Url = latestFullFetch.replace(config.getUrlSuffix(), ".md5sum");
else
md5Url = latestFullFetch + ".md5sum";
String latestFullMd5 = downloadUrlMemoryAsString(md5Url);
if (latestFullMd5 != null){
String md5Part = null;
try {
md5Part = latestFullMd5.split(" ")[0];
} catch (Exception e) {
md5Part = latestFullMd5;
}
String md5Part = latestFullMd5;
while (md5Part.length() > 32)
md5Part = md5Part.substring(0, md5Part.length() - 1);
Logger.d("getLatestFullMd5Sum - md5sum = " + md5Part);
return md5Part;
}
@ -1852,9 +1870,10 @@ OnWantUpdateCheckListener, OnSharedPreferenceChangeListener {
String MD5 = new BigInteger(1, digest.digest()).
toString(16).toLowerCase(Locale.ENGLISH);
while (MD5.length() < 32)
MD5 = "0" + MD5;
//while (MD5.length() < 32)
// MD5 = "0" + MD5;
ret = MD5;
Logger.d("md5sum from file is: " + ret);
} finally {
is.close();
}
@ -2137,6 +2156,7 @@ OnWantUpdateCheckListener, OnSharedPreferenceChangeListener {
if (downloadFullBuild) {
String fn = config.getPathBase() + latestFullBuild;
if (new File(fn).exists()) {
Logger.d("latestFullB4md5=" + latestFullFetch);
if (checkFullBuildMd5Sum(latestFullFetch, fn)) {
Logger.d("match found (full): " + fn);
prefs.edit().putString(PREF_READY_FILENAME_NAME, fn).commit();