From 00c138e42fbb52535378d54e1ba2cb5cd2b019b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sun, 17 Apr 2016 11:39:00 +0100 Subject: [PATCH 1/9] PMD: enable and obey java-unusedcode --- app/build.gradle | 2 +- app/src/main/java/org/fdroid/fdroid/AndroidXMLDecompress.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 51dc677df..b680dcd98 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -210,7 +210,7 @@ pmd { task pmd(type: Pmd, dependsOn: assembleDebug) { ruleSets = [ //'java-basic', - //'java-unusedcode', + 'java-unusedcode', 'java-android', 'java-clone', 'java-finalizers', diff --git a/app/src/main/java/org/fdroid/fdroid/AndroidXMLDecompress.java b/app/src/main/java/org/fdroid/fdroid/AndroidXMLDecompress.java index b8569f246..c801106ca 100644 --- a/app/src/main/java/org/fdroid/fdroid/AndroidXMLDecompress.java +++ b/app/src/main/java/org/fdroid/fdroid/AndroidXMLDecompress.java @@ -91,7 +91,6 @@ public class AndroidXMLDecompress { while (offset < binaryXml.length) { int tag0 = littleEndianWord(binaryXml, offset); - int nameStringIndex = littleEndianWord(binaryXml, offset + 5 * 4); if (tag0 == startTag) { int numbAttrs = littleEndianWord(binaryXml, offset + 7 * 4); From a8c5d8e7650949d80bac85a8d5bb98841f91f42e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sun, 17 Apr 2016 11:39:23 +0100 Subject: [PATCH 2/9] Convert java file to unix format via dos2unix I assume this file was copied over from a windows machine or created on one. Use unix-style line endings throughout. --- .../fdroid/fdroid/AndroidXMLDecompress.java | 352 +++++++++--------- 1 file changed, 176 insertions(+), 176 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/AndroidXMLDecompress.java b/app/src/main/java/org/fdroid/fdroid/AndroidXMLDecompress.java index c801106ca..69ad04f40 100644 --- a/app/src/main/java/org/fdroid/fdroid/AndroidXMLDecompress.java +++ b/app/src/main/java/org/fdroid/fdroid/AndroidXMLDecompress.java @@ -1,176 +1,176 @@ -/* - * Copyright (C) 2016 Hans-Christoph Steiner - * - * This program 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. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - */ - -/* - Copyright (c) 2016, Liu Dong - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * Neither the name of apk-parser nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.fdroid.fdroid; - -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -/** - * Parse the 'compressed' binary form of Android XML docs such as for - * {@code AndroidManifest.xml} in APK files. This is a very truncated - * version of apk-parser since currently, we only need the header from - * the binary XML AndroidManifest.xml. apk-parser provides full APK - * parsing, which is a lot more than what is needed. - * - * @see apk-parser - * @see Android Internals: Binary XML - * @see a binary XML parser - */ -public class AndroidXMLDecompress { - public static int startTag = 0x00100102; - - /** - * Just get the XML attributes from the {@code } element. - * - * @return A key value map of the attributes, with values as {@link Object}s - */ - public static Map getManifestHeaderAttributes(String filename) throws IOException { - byte[] binaryXml = getManifestFromFilename(filename); - int numbStrings = littleEndianWord(binaryXml, 4 * 4); - int stringIndexTableOffset = 0x24; - int stringTableOffset = stringIndexTableOffset + numbStrings * 4; - int xmlTagOffset = littleEndianWord(binaryXml, 3 * 4); - for (int i = xmlTagOffset; i < binaryXml.length - 4; i += 4) { - if (littleEndianWord(binaryXml, i) == startTag) { - xmlTagOffset = i; - break; - } - } - int offset = xmlTagOffset; - - while (offset < binaryXml.length) { - int tag0 = littleEndianWord(binaryXml, offset); - - if (tag0 == startTag) { - int numbAttrs = littleEndianWord(binaryXml, offset + 7 * 4); - offset += 9 * 4; - - HashMap attributes = new HashMap(3); - for (int i = 0; i < numbAttrs; i++) { - int attributeNameStringIndex = littleEndianWord(binaryXml, offset + 1 * 4); - int attributeValueStringIndex = littleEndianWord(binaryXml, offset + 2 * 4); - int attributeResourceId = littleEndianWord(binaryXml, offset + 4 * 4); - offset += 5 * 4; - - String attributeName = getString(binaryXml, stringIndexTableOffset, stringTableOffset, attributeNameStringIndex); - Object attributeValue; - if (attributeValueStringIndex != -1) { - attributeValue = getString(binaryXml, stringIndexTableOffset, stringTableOffset, attributeValueStringIndex); - } else { - attributeValue = attributeResourceId; - } - attributes.put(attributeName, attributeValue); - } - return attributes; - } else { - // we only need the first start tag - break; - } - } - return new HashMap(0); - } - - public static byte[] getManifestFromFilename(String filename) throws IOException { - InputStream is = null; - ZipFile zip = null; - int size = 0; - - if (filename.endsWith(".apk")) { - zip = new ZipFile(filename); - ZipEntry ze = zip.getEntry("AndroidManifest.xml"); - is = zip.getInputStream(ze); - size = (int) ze.getSize(); - } else { - throw new RuntimeException("This only works on APK files!"); - } - byte[] buf = new byte[size]; - is.read(buf); - - is.close(); - if (zip != null) { - zip.close(); - } - return buf; - } - - public static String getString(byte[] bytes, int stringIndexTableOffset, int stringTableOffset, int stringIndex) { - if (stringIndex < 0) { - return null; - } - int stringOffset = stringTableOffset + littleEndianWord(bytes, stringIndexTableOffset + stringIndex * 4); - return getStringAt(bytes, stringOffset); - } - - public static String getStringAt(byte[] bytes, int stringOffset) { - int length = bytes[stringOffset + 1] << 8 & 0xff00 | bytes[stringOffset] & 0xff; - byte[] chars = new byte[length]; - for (int i = 0; i < length; i++) { - chars[i] = bytes[stringOffset + 2 + i * 2]; - } - return new String(chars); - } - - /** - * Return the little endian 32-bit word from the byte array at offset - */ - public static int littleEndianWord(byte[] bytes, int offset) { - return bytes[offset + 3] - << 24 & 0xff000000 - | bytes[offset + 2] - << 16 & 0xff0000 - | bytes[offset + 1] - << 8 & 0xff00 - | bytes[offset] & 0xFF; - } -} +/* + * Copyright (C) 2016 Hans-Christoph Steiner + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +/* + Copyright (c) 2016, Liu Dong + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name of apk-parser nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.fdroid.fdroid; + +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +/** + * Parse the 'compressed' binary form of Android XML docs such as for + * {@code AndroidManifest.xml} in APK files. This is a very truncated + * version of apk-parser since currently, we only need the header from + * the binary XML AndroidManifest.xml. apk-parser provides full APK + * parsing, which is a lot more than what is needed. + * + * @see apk-parser + * @see Android Internals: Binary XML + * @see a binary XML parser + */ +public class AndroidXMLDecompress { + public static int startTag = 0x00100102; + + /** + * Just get the XML attributes from the {@code } element. + * + * @return A key value map of the attributes, with values as {@link Object}s + */ + public static Map getManifestHeaderAttributes(String filename) throws IOException { + byte[] binaryXml = getManifestFromFilename(filename); + int numbStrings = littleEndianWord(binaryXml, 4 * 4); + int stringIndexTableOffset = 0x24; + int stringTableOffset = stringIndexTableOffset + numbStrings * 4; + int xmlTagOffset = littleEndianWord(binaryXml, 3 * 4); + for (int i = xmlTagOffset; i < binaryXml.length - 4; i += 4) { + if (littleEndianWord(binaryXml, i) == startTag) { + xmlTagOffset = i; + break; + } + } + int offset = xmlTagOffset; + + while (offset < binaryXml.length) { + int tag0 = littleEndianWord(binaryXml, offset); + + if (tag0 == startTag) { + int numbAttrs = littleEndianWord(binaryXml, offset + 7 * 4); + offset += 9 * 4; + + HashMap attributes = new HashMap(3); + for (int i = 0; i < numbAttrs; i++) { + int attributeNameStringIndex = littleEndianWord(binaryXml, offset + 1 * 4); + int attributeValueStringIndex = littleEndianWord(binaryXml, offset + 2 * 4); + int attributeResourceId = littleEndianWord(binaryXml, offset + 4 * 4); + offset += 5 * 4; + + String attributeName = getString(binaryXml, stringIndexTableOffset, stringTableOffset, attributeNameStringIndex); + Object attributeValue; + if (attributeValueStringIndex != -1) { + attributeValue = getString(binaryXml, stringIndexTableOffset, stringTableOffset, attributeValueStringIndex); + } else { + attributeValue = attributeResourceId; + } + attributes.put(attributeName, attributeValue); + } + return attributes; + } else { + // we only need the first start tag + break; + } + } + return new HashMap(0); + } + + public static byte[] getManifestFromFilename(String filename) throws IOException { + InputStream is = null; + ZipFile zip = null; + int size = 0; + + if (filename.endsWith(".apk")) { + zip = new ZipFile(filename); + ZipEntry ze = zip.getEntry("AndroidManifest.xml"); + is = zip.getInputStream(ze); + size = (int) ze.getSize(); + } else { + throw new RuntimeException("This only works on APK files!"); + } + byte[] buf = new byte[size]; + is.read(buf); + + is.close(); + if (zip != null) { + zip.close(); + } + return buf; + } + + public static String getString(byte[] bytes, int stringIndexTableOffset, int stringTableOffset, int stringIndex) { + if (stringIndex < 0) { + return null; + } + int stringOffset = stringTableOffset + littleEndianWord(bytes, stringIndexTableOffset + stringIndex * 4); + return getStringAt(bytes, stringOffset); + } + + public static String getStringAt(byte[] bytes, int stringOffset) { + int length = bytes[stringOffset + 1] << 8 & 0xff00 | bytes[stringOffset] & 0xff; + byte[] chars = new byte[length]; + for (int i = 0; i < length; i++) { + chars[i] = bytes[stringOffset + 2 + i * 2]; + } + return new String(chars); + } + + /** + * Return the little endian 32-bit word from the byte array at offset + */ + public static int littleEndianWord(byte[] bytes, int offset) { + return bytes[offset + 3] + << 24 & 0xff000000 + | bytes[offset + 2] + << 16 & 0xff0000 + | bytes[offset + 1] + << 8 & 0xff00 + | bytes[offset] & 0xFF; + } +} From 2eea94e5eab4091e3118d0ccb278231cfdb7efb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sun, 17 Apr 2016 11:41:42 +0100 Subject: [PATCH 3/9] gradlew: bump to 2.12 Also remove the 2.11 restriction on the root build.gradle file. It's unnecessary, as the Android plugin will already error if the version is too old. This means that the build will work on any version that is new enough, which should be 2.10-2.12 at the time of writing. --- build.gradle | 4 ---- gradle/wrapper/gradle-wrapper.jar | Bin 53638 -> 53639 bytes gradle/wrapper/gradle-wrapper.properties | 5 ++--- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index cf0c82b7d..e4f43b486 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,3 @@ buildscript { classpath files('libs/gradle-witness.jar') } } - -task wrapper(type: Wrapper) { - gradleVersion = '2.11' -} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 5ccda13e9cb94678ba179b32452cf3d60dc36353..2c6137b87896c8f70315ae454e00a969ef5f6019 100644 GIT binary patch delta 1762 zcmY*Z3rv$&6u$inv`UK;1cg>AAP<3I*QyZ#iC_c)5wQ50V{{aR$v}Zv1viU2n4rAw zHXk9|7`Qrh0WIp7z(AnoQJ^@Taf|a2Ky)&#+2S6eyZ^ZaY?J0Y_xrzd&i9{t+M-%+ zaV=LE7tOVri4dQUq%m2QLN7jn$jkc8K9xaR9n3lA91fb6coNBJH!cfCAAsjl7O*ep z9*a6VCYJ%?kktbqvaIWX&^huQY=H5zyG0q^Y^gOcE1W7Q(?4$`4;Zfn8yz6nFBecv z*>WdaV6@@SXF^aDdz%(4Oytq@(oKncK5-G5byoW!9(y<9ji>AU6QoPxr45a;WtU`2 z6gV_lHe()9e0DOx*@W|xJ@zjxZ^`PA3J$4Tqh=RYi36P*^Zepe8K#S-S>rwp3&X39 zuKZ}+>)vk3-r#Ei%4f$sxB9LaS)HujDXe^7zUybEDXb?bcx~Y`;brDnieS8Bhu^@# zi)Z9XTNK{gM>K{StzFB8klihJ?`O`x`sU5gV-}8QjAZ)j*LUVPyIrqWC5`6yt(%p0 z#!9U_neDrDxGwN_=a*k;wk^K$kGyU~?NHyU+9nJB^N}>+YkRTL^G?swiAc@;FTQL~ z`1XawRDG*RRQ%WZ;oFL92X>j6^@g&SuiX}TQM^~_&n2ikt^9;x11wiP1VWPf3J9HB z`a>EBcVG@Ys?C(}A?V7Ja3Of04x)i)!B5t}{HOVsivK=vg9nVMWQa0#N6s>K?2tb` z)i`&%Jwke4EG<}opXS-<4wkF!K|N7prd`c-cWH24d&vqO9X-dT&2arw`l#r_JGAtu zZWYz|es7}8M3aJQ6wR2+XS+6(y0oqhaBl8O1e~L%byfNlIQQyfrgz!Zu=cgJ-DwD62Zb99BF+ccXmEwoxIx5J zE3tII8JmOq(M($4;qUt9gR}lV5%c%} zu0H3E1x8q5>}C`(ohA5AN$}LL4-@M65lHSf${=xqP;1Hw<%16o(kqGY7cu46L2-sK*z`-)^Mgj{S93bIJ-#)}7{ zz{0)(5mR`Mcn_F*_e*UJxyMPrGh_uUZ=|?>s-Jk!o!-izh{?Y|XfYO)&SGB{JckcC zjXol?+ecbkuF)?#sBv@9N5XoObLlMC-@c~YRNFxkX96ALjV35h+ zD2{+Zvr%sKpq9kbB<)Nun7`{umQR(Dsi}T|C`9JO>Vw(zJA~TI_KVuYjpZG z+B8T*o6JW@BtrITb&jc0L_i%~`zkKSYp2zVgy#u7G$%19lCotq1Dz`XUaAwwT(i>w5|IGYWyjL<^G2gcLpdzR^1yh8|#Qoh3q7N^|BtmgcB zn+3p>`n{YFi{dRqY{1k|A!|SPd8kN4s!)f^PcFq{d;J&2YXXB+l|ib?8aGv?n@14# ziEx`o6GiTzhieZ`j&L~To$VXfBp0Vmy}5Wp^hl6PU;14cSf?F4LOr=2!c)lmPR{1u zDu|oX7Zv@Lr+RI)lv?8i#nYqH7K;7@PqaF;TsM|BDF|A<&pCZVYww=A@fnfdZ+xlzjFDU^>CNsOu?nmF*6<(c_Rciezti0&#Gq>uXKk((<6E5o#Z*5wiMSJ#WJQ>MRNPjTyoj+O%YOZ#EY@Y zxE8V(YIpUNlAf;92(9O6CQ~5$Pev)squVHg(uq1!|U1A7>LvfxWxfaC^-+{d|q|wvzPb&IvbN3|`e$ z%T+-d9<_*OKk7`6oR^AY8r5N5$y(?44abxtArU4B*)KrIi(@cgRd)as_f5BiN+~D3 ze)#SWRk(?6uIMXX&PSPF)48_qzEw&>=iDo+C#Q(aQ2$x`Orv#GZ_eiJ# zJv27Z;|K?akyk!5&^N@pf#a28S+5#w2YV&d^gVVS_br&S2D*dL{ Date: Sun, 17 Apr 2016 11:43:51 +0100 Subject: [PATCH 4/9] CONTRIBUTING: use check, not connectedCheck We now have unit tests that run on the local jvm, so use `check` to run those too. --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 89a413dc4..7441a1282 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -65,7 +65,7 @@ In order to run the F-Droid test suite, you will need to have either a real devi connected via `adb`, or an emulator running. Then, execute the following from the command line: - ./gradlew connectedCheck + ./gradlew check Note that the CI already runs the tests on an emulator, so you don't necessarily have to do this yourself if you open a merge request as the tests From df39b0fe406a4440515bd39de5fdd0048df27233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sun, 17 Apr 2016 15:11:46 +0100 Subject: [PATCH 5/9] Drop elses after returns --- .../main/java/org/fdroid/fdroid/AndroidXMLDecompress.java | 5 ++--- .../org/fdroid/fdroid/views/AvailableAppListAdapter.java | 3 +-- .../org/fdroid/fdroid/views/CanUpdateAppListAdapter.java | 3 +-- .../org/fdroid/fdroid/views/InstalledAppListAdapter.java | 3 +-- app/src/main/java/org/fdroid/fdroid/views/RepoAdapter.java | 3 +-- 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/AndroidXMLDecompress.java b/app/src/main/java/org/fdroid/fdroid/AndroidXMLDecompress.java index 69ad04f40..b543764b1 100644 --- a/app/src/main/java/org/fdroid/fdroid/AndroidXMLDecompress.java +++ b/app/src/main/java/org/fdroid/fdroid/AndroidXMLDecompress.java @@ -113,10 +113,9 @@ public class AndroidXMLDecompress { attributes.put(attributeName, attributeValue); } return attributes; - } else { - // we only need the first start tag - break; } + // we only need the first start tag + break; } return new HashMap(0); } diff --git a/app/src/main/java/org/fdroid/fdroid/views/AvailableAppListAdapter.java b/app/src/main/java/org/fdroid/fdroid/views/AvailableAppListAdapter.java index e6010ede6..74ccc2a7e 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/AvailableAppListAdapter.java +++ b/app/src/main/java/org/fdroid/fdroid/views/AvailableAppListAdapter.java @@ -9,9 +9,8 @@ public class AvailableAppListAdapter extends AppListAdapter { public static AvailableAppListAdapter create(Context context, Cursor cursor, int flags) { if (Build.VERSION.SDK_INT >= 11) { return new AvailableAppListAdapter(context, cursor, flags); - } else { - return new AvailableAppListAdapter(context, cursor); } + return new AvailableAppListAdapter(context, cursor); } private AvailableAppListAdapter(Context context, Cursor c) { diff --git a/app/src/main/java/org/fdroid/fdroid/views/CanUpdateAppListAdapter.java b/app/src/main/java/org/fdroid/fdroid/views/CanUpdateAppListAdapter.java index 471763a85..9578370aa 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/CanUpdateAppListAdapter.java +++ b/app/src/main/java/org/fdroid/fdroid/views/CanUpdateAppListAdapter.java @@ -9,9 +9,8 @@ public class CanUpdateAppListAdapter extends AppListAdapter { public static CanUpdateAppListAdapter create(Context context, Cursor cursor, int flags) { if (Build.VERSION.SDK_INT >= 11) { return new CanUpdateAppListAdapter(context, cursor, flags); - } else { - return new CanUpdateAppListAdapter(context, cursor); } + return new CanUpdateAppListAdapter(context, cursor); } private CanUpdateAppListAdapter(Context context, Cursor c) { diff --git a/app/src/main/java/org/fdroid/fdroid/views/InstalledAppListAdapter.java b/app/src/main/java/org/fdroid/fdroid/views/InstalledAppListAdapter.java index bb88f07bf..4aaef1b8e 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/InstalledAppListAdapter.java +++ b/app/src/main/java/org/fdroid/fdroid/views/InstalledAppListAdapter.java @@ -9,9 +9,8 @@ public class InstalledAppListAdapter extends AppListAdapter { public static InstalledAppListAdapter create(Context context, Cursor cursor, int flags) { if (Build.VERSION.SDK_INT >= 11) { return new InstalledAppListAdapter(context, cursor, flags); - } else { - return new InstalledAppListAdapter(context, cursor); } + return new InstalledAppListAdapter(context, cursor); } private InstalledAppListAdapter(Context context, Cursor c) { diff --git a/app/src/main/java/org/fdroid/fdroid/views/RepoAdapter.java b/app/src/main/java/org/fdroid/fdroid/views/RepoAdapter.java index 90a2af306..08d071c70 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/RepoAdapter.java +++ b/app/src/main/java/org/fdroid/fdroid/views/RepoAdapter.java @@ -26,9 +26,8 @@ public class RepoAdapter extends CursorAdapter { public static RepoAdapter create(Context context, Cursor cursor, int flags) { if (Build.VERSION.SDK_INT >= 11) { return new RepoAdapter(context, cursor, flags); - } else { - return new RepoAdapter(context, cursor); } + return new RepoAdapter(context, cursor); } private RepoAdapter(Context context, Cursor c, int flags) { From 3c63bd4b1c2432782307ffddb1b37abfc9631c41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sun, 17 Apr 2016 15:14:37 +0100 Subject: [PATCH 6/9] Various spacing fixes --- app/src/main/java/org/fdroid/fdroid/RepoUpdater.java | 2 +- app/src/main/java/org/fdroid/fdroid/Utils.java | 2 +- .../java/org/fdroid/fdroid/net/WifiStateChangeService.java | 4 ++-- .../java/org/fdroid/fdroid/views/AvailableAppListAdapter.java | 2 +- .../java/org/fdroid/fdroid/views/InstalledAppListAdapter.java | 2 +- app/src/main/java/org/fdroid/fdroid/views/RepoAdapter.java | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/RepoUpdater.java b/app/src/main/java/org/fdroid/fdroid/RepoUpdater.java index ac226b0db..4dc986e05 100644 --- a/app/src/main/java/org/fdroid/fdroid/RepoUpdater.java +++ b/app/src/main/java/org/fdroid/fdroid/RepoUpdater.java @@ -359,7 +359,7 @@ public class RepoUpdater { if (repo.signingCertificate.equals(certFromJar) && repo.signingCertificate.equals(certFromIndexXml) && certFromIndexXml.equals(certFromJar)) { - return; // we have a match! + return; // we have a match! } throw new SigningException(repo, "Signing certificate does not match!"); } diff --git a/app/src/main/java/org/fdroid/fdroid/Utils.java b/app/src/main/java/org/fdroid/fdroid/Utils.java index 3b58681dc..2455d5ff4 100644 --- a/app/src/main/java/org/fdroid/fdroid/Utils.java +++ b/app/src/main/java/org/fdroid/fdroid/Utils.java @@ -275,7 +275,7 @@ public final class Utils { // return a fingerprint formatted for display public static String formatFingerprint(Context context, String fingerprint) { if (TextUtils.isEmpty(fingerprint) - || fingerprint.length() != 64 // SHA-256 is 64 hex chars + || fingerprint.length() != 64 // SHA-256 is 64 hex chars || fingerprint.matches(".*[^0-9a-fA-F].*")) { // its a hex string return context.getString(R.string.bad_fingerprint); } diff --git a/app/src/main/java/org/fdroid/fdroid/net/WifiStateChangeService.java b/app/src/main/java/org/fdroid/fdroid/net/WifiStateChangeService.java index 3dd1e134b..7b13d1683 100644 --- a/app/src/main/java/org/fdroid/fdroid/net/WifiStateChangeService.java +++ b/app/src/main/java/org/fdroid/fdroid/net/WifiStateChangeService.java @@ -55,7 +55,7 @@ public class WifiStateChangeService extends Service { NetworkInfo is only passed via WifiStateChangeReceiver */ Utils.debugLog(TAG, "ni == " + ni + " wifiState == " + printWifiState(wifiState)); if (wifiState == WifiManager.WIFI_STATE_ENABLED - || wifiState == WifiManager.WIFI_STATE_DISABLING // might be switching to hotspot + || wifiState == WifiManager.WIFI_STATE_DISABLING // might be switching to hotspot || wifiState == WifiManager.WIFI_STATE_DISABLED // might be hotspot || wifiState == WifiManager.WIFI_STATE_UNKNOWN) { // might be hotspot if (asyncTask != null) { @@ -100,7 +100,7 @@ public class WifiStateChangeService extends Service { if (FDroidApp.ipAddressString == null) { return null; } - } else { // a hotspot can be active during WIFI_STATE_UNKNOWN + } else { // a hotspot can be active during WIFI_STATE_UNKNOWN setIpInfoFromNetworkInterface(); } diff --git a/app/src/main/java/org/fdroid/fdroid/views/AvailableAppListAdapter.java b/app/src/main/java/org/fdroid/fdroid/views/AvailableAppListAdapter.java index 74ccc2a7e..e39f67ee1 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/AvailableAppListAdapter.java +++ b/app/src/main/java/org/fdroid/fdroid/views/AvailableAppListAdapter.java @@ -6,7 +6,7 @@ import android.os.Build; public class AvailableAppListAdapter extends AppListAdapter { - public static AvailableAppListAdapter create(Context context, Cursor cursor, int flags) { + public static AvailableAppListAdapter create(Context context, Cursor cursor, int flags) { if (Build.VERSION.SDK_INT >= 11) { return new AvailableAppListAdapter(context, cursor, flags); } diff --git a/app/src/main/java/org/fdroid/fdroid/views/InstalledAppListAdapter.java b/app/src/main/java/org/fdroid/fdroid/views/InstalledAppListAdapter.java index 4aaef1b8e..4c97ecc9e 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/InstalledAppListAdapter.java +++ b/app/src/main/java/org/fdroid/fdroid/views/InstalledAppListAdapter.java @@ -6,7 +6,7 @@ import android.os.Build; public class InstalledAppListAdapter extends AppListAdapter { - public static InstalledAppListAdapter create(Context context, Cursor cursor, int flags) { + public static InstalledAppListAdapter create(Context context, Cursor cursor, int flags) { if (Build.VERSION.SDK_INT >= 11) { return new InstalledAppListAdapter(context, cursor, flags); } diff --git a/app/src/main/java/org/fdroid/fdroid/views/RepoAdapter.java b/app/src/main/java/org/fdroid/fdroid/views/RepoAdapter.java index 08d071c70..fbb139c01 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/RepoAdapter.java +++ b/app/src/main/java/org/fdroid/fdroid/views/RepoAdapter.java @@ -23,7 +23,7 @@ public class RepoAdapter extends CursorAdapter { private EnabledListener enabledListener; - public static RepoAdapter create(Context context, Cursor cursor, int flags) { + public static RepoAdapter create(Context context, Cursor cursor, int flags) { if (Build.VERSION.SDK_INT >= 11) { return new RepoAdapter(context, cursor, flags); } From 7b70560c9ba84e5bc56c541053be6b74bc5b4257 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sun, 17 Apr 2016 15:28:15 +0100 Subject: [PATCH 7/9] Remove unused class UnexpectedResponseException --- .../net/bluetooth/UnexpectedResponseException.java | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 app/src/main/java/org/fdroid/fdroid/net/bluetooth/UnexpectedResponseException.java diff --git a/app/src/main/java/org/fdroid/fdroid/net/bluetooth/UnexpectedResponseException.java b/app/src/main/java/org/fdroid/fdroid/net/bluetooth/UnexpectedResponseException.java deleted file mode 100644 index 9aa03558d..000000000 --- a/app/src/main/java/org/fdroid/fdroid/net/bluetooth/UnexpectedResponseException.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.fdroid.fdroid.net.bluetooth; - -class UnexpectedResponseException extends Exception { - - UnexpectedResponseException(String message) { - super(message); - } - - UnexpectedResponseException(String message, Throwable cause) { - super("Unexpected response from Bluetooth server: '" + message + "'", cause); - } -} From 2074718391c2c17a974218bc6565cce2dc05407e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sun, 17 Apr 2016 15:55:19 +0100 Subject: [PATCH 8/9] Get java code closer to obeying PMD's java-basic --- .../java/org/fdroid/fdroid/Preferences.java | 1 + .../java/org/fdroid/fdroid/RepoUpdater.java | 21 +++++++++++-------- .../main/java/org/fdroid/fdroid/Utils.java | 9 ++++---- .../fdroid/fdroid/installer/Installer.java | 6 ++---- .../fdroid/localrepo/LocalRepoManager.java | 18 ++++++---------- .../org/fdroid/fdroid/net/LocalHTTPD.java | 18 +++++++--------- .../fdroid/net/bluetooth/BluetoothServer.java | 18 +++++++--------- .../install/InstallExtensionBootReceiver.java | 16 +++++++------- .../views/AppSecurityPermissions.java | 6 ++---- .../views/swap/SwapWorkflowActivity.java | 8 +++---- 10 files changed, 53 insertions(+), 68 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/Preferences.java b/app/src/main/java/org/fdroid/fdroid/Preferences.java index df67a16f6..aed547b90 100644 --- a/app/src/main/java/org/fdroid/fdroid/Preferences.java +++ b/app/src/main/java/org/fdroid/fdroid/Preferences.java @@ -79,6 +79,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh private static final boolean DEFAULT_EXPERT = false; private static final boolean DEFAULT_ENABLE_PROXY = false; public static final String DEFAULT_THEME = "light"; + @SuppressWarnings("PMD.AvoidUsingHardCodedIP") public static final String DEFAULT_PROXY_HOST = "127.0.0.1"; public static final int DEFAULT_PROXY_PORT = 8118; private static final boolean DEFAULT_SHOW_NFC_DURING_SWAP = true; diff --git a/app/src/main/java/org/fdroid/fdroid/RepoUpdater.java b/app/src/main/java/org/fdroid/fdroid/RepoUpdater.java index 4dc986e05..5fd62034b 100644 --- a/app/src/main/java/org/fdroid/fdroid/RepoUpdater.java +++ b/app/src/main/java/org/fdroid/fdroid/RepoUpdater.java @@ -92,6 +92,15 @@ public class RepoUpdater { return hasChanged; } + private static void cleanupDownloader(Downloader d) { + if (d == null || d.outputFile == null) { + return; + } + if (!d.outputFile.delete()) { + Log.w(TAG, "Couldn't delete file: " + d.outputFile.getAbsolutePath()); + } + } + private Downloader downloadIndex() throws UpdateException { Downloader downloader = null; try { @@ -106,11 +115,7 @@ public class RepoUpdater { } } catch (IOException e) { - if (downloader != null && downloader.outputFile != null) { - if (!downloader.outputFile.delete()) { - Log.w(TAG, "Couldn't delete file: " + downloader.outputFile.getAbsolutePath()); - } - } + cleanupDownloader(downloader); throw new UpdateException(repo, "Error getting index file", e); } catch (InterruptedException e) { @@ -197,10 +202,8 @@ public class RepoUpdater { } finally { FDroidApp.enableSpongyCastleOnLollipop(); Utils.closeQuietly(indexInputStream); - if (downloadedFile != null) { - if (!downloadedFile.delete()) { - Log.w(TAG, "Couldn't delete file: " + downloadedFile.getAbsolutePath()); - } + if (downloadedFile != null && !downloadedFile.delete()) { + Log.w(TAG, "Couldn't delete file: " + downloadedFile.getAbsolutePath()); } } } diff --git a/app/src/main/java/org/fdroid/fdroid/Utils.java b/app/src/main/java/org/fdroid/fdroid/Utils.java index 2455d5ff4..88a994bd1 100644 --- a/app/src/main/java/org/fdroid/fdroid/Utils.java +++ b/app/src/main/java/org/fdroid/fdroid/Utils.java @@ -673,11 +673,10 @@ public final class Utils { } for (File f : files) { - if ((startsWith != null && f.getName().startsWith(startsWith)) - || (endsWith != null && f.getName().endsWith(endsWith))) { - if (!f.delete()) { - Log.w(TAG, "Couldn't delete cache file " + f); - } + if (((startsWith != null && f.getName().startsWith(startsWith)) + || (endsWith != null && f.getName().endsWith(endsWith))) + && !f.delete()) { + Log.w(TAG, "Couldn't delete cache file " + f); } } } diff --git a/app/src/main/java/org/fdroid/fdroid/installer/Installer.java b/app/src/main/java/org/fdroid/fdroid/installer/Installer.java index bd85b71f0..3ead44b3c 100644 --- a/app/src/main/java/org/fdroid/fdroid/installer/Installer.java +++ b/app/src/main/java/org/fdroid/fdroid/installer/Installer.java @@ -178,10 +178,8 @@ public abstract class Installer { Map attributes = AndroidXMLDecompress.getManifestHeaderAttributes(apkFile.getAbsolutePath()); /* This isn't really needed, but might as well since we have the data already */ - if (attributes.containsKey("packageName")) { - if (!TextUtils.equals(packageName, (String) attributes.get("packageName"))) { - throw new InstallFailedException(apkFile + " has packageName that clashes with " + packageName); - } + if (attributes.containsKey("packageName") && !TextUtils.equals(packageName, (String) attributes.get("packageName"))) { + throw new InstallFailedException(apkFile + " has packageName that clashes with " + packageName); } if (!attributes.containsKey("versionCode")) { diff --git a/app/src/main/java/org/fdroid/fdroid/localrepo/LocalRepoManager.java b/app/src/main/java/org/fdroid/fdroid/localrepo/LocalRepoManager.java index 3ab5a2f67..dd358f00b 100644 --- a/app/src/main/java/org/fdroid/fdroid/localrepo/LocalRepoManager.java +++ b/app/src/main/java/org/fdroid/fdroid/localrepo/LocalRepoManager.java @@ -119,22 +119,16 @@ public final class LocalRepoManager { xmlIndexJar = new SanitizedFile(repoDir, "index.jar"); xmlIndexJarUnsigned = new SanitizedFile(repoDir, "index.unsigned.jar"); - if (!fdroidDir.exists()) { - if (!fdroidDir.mkdir()) { - Log.e(TAG, "Unable to create empty base: " + fdroidDir); - } + if (!fdroidDir.exists() && !fdroidDir.mkdir()) { + Log.e(TAG, "Unable to create empty base: " + fdroidDir); } - if (!repoDir.exists()) { - if (!repoDir.mkdir()) { - Log.e(TAG, "Unable to create empty repo: " + repoDir); - } + if (!repoDir.exists() && !repoDir.mkdir()) { + Log.e(TAG, "Unable to create empty repo: " + repoDir); } - if (!iconsDir.exists()) { - if (!iconsDir.mkdir()) { - Log.e(TAG, "Unable to create icons folder: " + iconsDir); - } + if (!iconsDir.exists() && !iconsDir.mkdir()) { + Log.e(TAG, "Unable to create icons folder: " + iconsDir); } } diff --git a/app/src/main/java/org/fdroid/fdroid/net/LocalHTTPD.java b/app/src/main/java/org/fdroid/fdroid/net/LocalHTTPD.java index 0a97ab8ee..23937b9ec 100644 --- a/app/src/main/java/org/fdroid/fdroid/net/LocalHTTPD.java +++ b/app/src/main/java/org/fdroid/fdroid/net/LocalHTTPD.java @@ -228,17 +228,15 @@ public class LocalHTTPD extends NanoHTTPD { long startFrom = 0; long endAt = -1; String range = header.get("range"); - if (range != null) { - if (range.startsWith("bytes=")) { - range = range.substring("bytes=".length()); - int minus = range.indexOf('-'); - try { - if (minus > 0) { - startFrom = Long.parseLong(range.substring(0, minus)); - endAt = Long.parseLong(range.substring(minus + 1)); - } - } catch (NumberFormatException ignored) { + if (range != null && range.startsWith("bytes=")) { + range = range.substring("bytes=".length()); + int minus = range.indexOf('-'); + try { + if (minus > 0) { + startFrom = Long.parseLong(range.substring(0, minus)); + endAt = Long.parseLong(range.substring(minus + 1)); } + } catch (NumberFormatException ignored) { } } diff --git a/app/src/main/java/org/fdroid/fdroid/net/bluetooth/BluetoothServer.java b/app/src/main/java/org/fdroid/fdroid/net/bluetooth/BluetoothServer.java index 848192731..811508992 100644 --- a/app/src/main/java/org/fdroid/fdroid/net/bluetooth/BluetoothServer.java +++ b/app/src/main/java/org/fdroid/fdroid/net/bluetooth/BluetoothServer.java @@ -266,17 +266,15 @@ public class BluetoothServer extends Thread { long startFrom = 0; long endAt = -1; String range = header.get("range"); - if (range != null) { - if (range.startsWith("bytes=")) { - range = range.substring("bytes=".length()); - int minus = range.indexOf('-'); - try { - if (minus > 0) { - startFrom = Long.parseLong(range.substring(0, minus)); - endAt = Long.parseLong(range.substring(minus + 1)); - } - } catch (NumberFormatException ignored) { + if (range != null && range.startsWith("bytes=")) { + range = range.substring("bytes=".length()); + int minus = range.indexOf('-'); + try { + if (minus > 0) { + startFrom = Long.parseLong(range.substring(0, minus)); + endAt = Long.parseLong(range.substring(minus + 1)); } + } catch (NumberFormatException ignored) { } } diff --git a/app/src/main/java/org/fdroid/fdroid/privileged/install/InstallExtensionBootReceiver.java b/app/src/main/java/org/fdroid/fdroid/privileged/install/InstallExtensionBootReceiver.java index f69d1d397..2074aac50 100644 --- a/app/src/main/java/org/fdroid/fdroid/privileged/install/InstallExtensionBootReceiver.java +++ b/app/src/main/java/org/fdroid/fdroid/privileged/install/InstallExtensionBootReceiver.java @@ -29,15 +29,13 @@ public class InstallExtensionBootReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { - if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) { - if (Preferences.get().isPostPrivilegedInstall()) { - Preferences.get().setPostPrivilegedInstall(false); + if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED) && Preferences.get().isPostPrivilegedInstall()) { + Preferences.get().setPostPrivilegedInstall(false); - Intent postInstall = new Intent(context.getApplicationContext(), InstallExtensionDialogActivity.class); - postInstall.setAction(InstallExtensionDialogActivity.ACTION_POST_INSTALL); - postInstall.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - context.startActivity(postInstall); - } + Intent postInstall = new Intent(context.getApplicationContext(), InstallExtensionDialogActivity.class); + postInstall.setAction(InstallExtensionDialogActivity.ACTION_POST_INSTALL); + postInstall.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(postInstall); } } -} \ No newline at end of file +} diff --git a/app/src/main/java/org/fdroid/fdroid/privileged/views/AppSecurityPermissions.java b/app/src/main/java/org/fdroid/fdroid/privileged/views/AppSecurityPermissions.java index f751080ed..e16a42efa 100644 --- a/app/src/main/java/org/fdroid/fdroid/privileged/views/AppSecurityPermissions.java +++ b/app/src/main/java/org/fdroid/fdroid/privileged/views/AppSecurityPermissions.java @@ -269,10 +269,8 @@ public class AppSecurityPermissions { String permName = strList[i]; // If we are only looking at an existing app, then we only // care about permissions that have actually been granted to it. - if (installedPkgInfo != null && info == installedPkgInfo) { - if ((flagsList[i] & PackageInfo.REQUESTED_PERMISSION_GRANTED) == 0) { - continue; - } + if (installedPkgInfo != null && info == installedPkgInfo && (flagsList[i] & PackageInfo.REQUESTED_PERMISSION_GRANTED) == 0) { + continue; } try { PermissionInfo tmpPermInfo = mPm.getPermissionInfo(permName, 0); diff --git a/app/src/main/java/org/fdroid/fdroid/views/swap/SwapWorkflowActivity.java b/app/src/main/java/org/fdroid/fdroid/views/swap/SwapWorkflowActivity.java index 5caf91554..0040019ae 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/swap/SwapWorkflowActivity.java +++ b/app/src/main/java/org/fdroid/fdroid/views/swap/SwapWorkflowActivity.java @@ -290,11 +290,9 @@ public class SwapWorkflowActivity extends AppCompatActivity { return; } - if (!forceReload) { - if (container.getVisibility() == View.GONE || currentView != null && currentView.getStep() == service.getStep()) { - // Already showing the correct step, so don't bother changing anything. - return; - } + if (!forceReload && (container.getVisibility() == View.GONE || currentView != null && currentView.getStep() == service.getStep())) { + // Already showing the correct step, so don't bother changing anything. + return; } switch (service.getStep()) { From a484c0381611ed08874d6fa4b2c3d1d1368d51fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Tue, 19 Apr 2016 21:36:37 +0100 Subject: [PATCH 9/9] PMD: Re-enable on test files This used to be the case, which is why only minimal changes were required to bring it back. This also makes it take the same files that checkstyle does, which is more consistent. --- app/build.gradle | 2 +- .../java/android/test/ProviderTestCase2MockContext.java | 5 +++++ .../androidTest/java/org/fdroid/fdroid/RepoUpdaterTest.java | 1 - 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index b680dcd98..e4c4fe60f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -218,7 +218,7 @@ task pmd(type: Pmd, dependsOn: assembleDebug) { 'java-migrating', //'java-unnecessary', // too nitpicky with parenthesis ] - source 'src/main/java' + source 'src/main/java', 'src/test/java', 'src/androidTest/java' include '**/*.java' } diff --git a/app/src/androidTest/java/android/test/ProviderTestCase2MockContext.java b/app/src/androidTest/java/android/test/ProviderTestCase2MockContext.java index 03ca4a982..659fba2f3 100644 --- a/app/src/androidTest/java/android/test/ProviderTestCase2MockContext.java +++ b/app/src/androidTest/java/android/test/ProviderTestCase2MockContext.java @@ -27,6 +27,9 @@ import android.os.Build; import android.test.mock.MockContentResolver; import android.test.mock.MockContext; +import org.junit.After; +import org.junit.Before; + import java.io.File; /** @@ -132,6 +135,7 @@ public abstract class ProviderTestCase2MockContext ex * @throws Exception */ @Override + @Before protected void setUp() throws Exception { super.setUp(); @@ -165,6 +169,7 @@ public abstract class ProviderTestCase2MockContext ex * {@link android.content.ContentProvider} represented by mProvider. */ @Override + @After protected void tearDown() throws Exception { shutdownProvider(); super.tearDown(); diff --git a/app/src/androidTest/java/org/fdroid/fdroid/RepoUpdaterTest.java b/app/src/androidTest/java/org/fdroid/fdroid/RepoUpdaterTest.java index 0d1468511..c706265e9 100644 --- a/app/src/androidTest/java/org/fdroid/fdroid/RepoUpdaterTest.java +++ b/app/src/androidTest/java/org/fdroid/fdroid/RepoUpdaterTest.java @@ -18,7 +18,6 @@ import static org.junit.Assert.fail; @RunWith(AndroidJUnit4.class) public class RepoUpdaterTest { - private static final String TAG = "RepoUpdaterTest"; private Context context; private RepoUpdater repoUpdater;