Reformat code and bump version

This commit is contained in:
Tad 2018-10-21 16:07:32 -04:00
parent 521ae4891d
commit 716b58bd16
4 changed files with 12 additions and 13 deletions

Binary file not shown.

View file

@ -6,8 +6,8 @@ android {
applicationId "us.spotco.malwarescanner" applicationId "us.spotco.malwarescanner"
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 26 targetSdkVersion 26
versionCode 38 versionCode 39
versionName "2.8" versionName "2.9"
resConfigs "en" resConfigs "en"
} }
buildTypes { buildTypes {

View file

@ -124,7 +124,7 @@ class Database {
if (databaseLocation.exists()) { if (databaseLocation.exists()) {
try { try {
BufferedReader reader; BufferedReader reader;
if(databaseLocation.getName().endsWith(".gz")) { if (databaseLocation.getName().endsWith(".gz")) {
reader = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(databaseLocation)))); reader = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(databaseLocation))));
} else { } else {
reader = new BufferedReader(new FileReader(databaseLocation)); reader = new BufferedReader(new FileReader(databaseLocation));
@ -133,7 +133,7 @@ class Database {
if (database.getName().contains(".hdb")) {//.hdb format: md5, size, name if (database.getName().contains(".hdb")) {//.hdb format: md5, size, name
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
String[] lineS = line.split(":"); String[] lineS = line.split(":");
if(Utils.TRIM_VARIANT_NUMBER) { if (Utils.TRIM_VARIANT_NUMBER) {
lineS[2] = lineS[2].split("-")[0]; lineS[2] = lineS[2].split("-")[0];
} }
signaturesMD5.put(lineS[0].substring(0, Utils.MAX_HASH_LENGTH), lineS[2]); signaturesMD5.put(lineS[0].substring(0, Utils.MAX_HASH_LENGTH), lineS[2]);
@ -141,7 +141,7 @@ class Database {
} else if (database.getName().contains(".hsb")) {//.hsb format: sha256, size, name } else if (database.getName().contains(".hsb")) {//.hsb format: sha256, size, name
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
String[] lineS = line.split(":"); String[] lineS = line.split(":");
if(Utils.TRIM_VARIANT_NUMBER) { if (Utils.TRIM_VARIANT_NUMBER) {
lineS[2] = lineS[2].split("-")[0]; lineS[2] = lineS[2].split("-")[0];
} }
if (lineS[0].length() == 32) { if (lineS[0].length() == 32) {
@ -152,7 +152,7 @@ class Database {
} }
} }
reader.close(); reader.close();
} catch(Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }

View file

@ -23,7 +23,6 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.os.Build; import android.os.Build;
import android.preference.PreferenceManager;
import java.io.File; import java.io.File;
import java.net.Socket; import java.net.Socket;
@ -37,7 +36,7 @@ class Utils {
public final static int MAX_SCAN_SIZE_REALTIME = MAX_SCAN_SIZE / 2; //40MB public final static int MAX_SCAN_SIZE_REALTIME = MAX_SCAN_SIZE / 2; //40MB
public final static int MAX_HASH_LENGTH = 12; public final static int MAX_HASH_LENGTH = 12;
public final static boolean TRIM_VARIANT_NUMBER = true; public final static boolean TRIM_VARIANT_NUMBER = false;
public static int FILES_SCANNED = 0; public static int FILES_SCANNED = 0;
private static ThreadPoolExecutor threadPoolExecutor = null; private static ThreadPoolExecutor threadPoolExecutor = null;
@ -111,7 +110,7 @@ class Utils {
PackageManager pm = context.getPackageManager(); PackageManager pm = context.getPackageManager();
try { try {
pm.getPackageInfo(packageID, PackageManager.GET_META_DATA); pm.getPackageInfo(packageID, PackageManager.GET_META_DATA);
} catch(PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) {
return false; return false;
} }
return true; return true;
@ -135,13 +134,13 @@ class Utils {
try { try {
s = new Socket(host, port); s = new Socket(host, port);
return true; return true;
} catch(Exception e) { } catch (Exception e) {
return false; return false;
} finally { } finally {
if (s != null) { if (s != null) {
try { try {
s.close(); s.close();
} catch(Exception e1) { } catch (Exception e1) {
} }
} }
} }
@ -150,11 +149,11 @@ class Utils {
public static boolean waitUntilOrbotIsAvailable() { public static boolean waitUntilOrbotIsAvailable() {
int tries = 0; int tries = 0;
boolean listening; boolean listening;
while(!(listening = isPortListening("127.0.0.1", 9050)) && tries <= 60) { while (!(listening = isPortListening("127.0.0.1", 9050)) && tries <= 60) {
tries++; tries++;
try { try {
Thread.sleep(1000); Thread.sleep(1000);
} catch(Exception e) { } catch (Exception e) {
} }
} }