Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronjwood committed Sep 11, 2022
2 parents 27f5771 + da1ab59 commit cc3e3b7
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 37 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[<img src="https://f-droid.org/badge/get-it-on.png" alt="Get it on F-Droid" height="60">](https://f-droid.org/app/com.aaronjwood.portauthority)
<a href="https://play.google.com/store/apps/details?id=com.aaronjwood.portauthority.free"><img src="https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png" height="60"></a>

[![Codacy Badge](https://api.codacy.com/project/badge/grade/74a6e90f803d46a1a39b34daabeb8af1)](https://www.codacy.com/app/aaronjwood/PortAuthority)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/8687/badge.svg)](https://scan.coverity.com/projects/aaronjwood-portauthority)
[![Known Vulnerabilities](https://snyk.io/test/github/aaronjwood/PortAuthority/badge.svg)](https://snyk.io/test/github/aaronjwood/PortAuthority)

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ android {
defaultConfig {
minSdkVersion 19
targetSdkVersion 33
versionCode 65
versionName "2.4.3"
versionCode 66
versionName "2.4.4"
applicationId "com.aaronjwood.portauthority"
setProperty("archivesBaseName", "PortAuthority-$versionName")
externalNativeBuild {
Expand Down
2 changes: 2 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
-dontwarn javax.annotation.**
# A resource is loaded with a relative path so the package of this class must be preserved.
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
-keepattributes LineNumberTable,SourceFile
-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,6 @@ protected Void doInBackground(Integer... params) {
int cidr = params[1];
int timeout = params[2];
MainAsyncResponse activity = delegate.get();
Context ctx = (Context) activity;

try {
ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
ParcelFileDescriptor readSidePfd = pipe[0];
ParcelFileDescriptor writeSidePfd = pipe[1];
ParcelFileDescriptor.AutoCloseInputStream inputStream = new ParcelFileDescriptor.AutoCloseInputStream(readSidePfd);
int fd_write = writeSidePfd.detachFd();
int returnCode = nativeIPNeigh(fd_write);
inputStream.close();
if (returnCode != 0) {
activity.processFinish(new IOException(ctx.getResources().getString(R.string.errAccessArp)));
activity.processFinish(true);

return null;
}
} catch (IOException e) {
activity.processFinish(new IOException(ctx.getResources().getString(R.string.errParseArp)));
activity.processFinish(true);
}

ExecutorService executor = Executors.newCachedThreadPool();

double hostBits = 32.0d - cidr; // How many bits do we have for the hosts.
Expand Down
24 changes: 13 additions & 11 deletions app/src/main/java/com/aaronjwood/portauthority/db/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,20 @@ private Database(Context context) {

/**
* Starts a transaction that allows for multiple readers and one writer.
*
*/
public void beginTransaction() {
db.beginTransactionNonExclusive();
}

/**
* Finishes the transaction.
*
*/
public void endTransaction() {
db.endTransaction();
}

/**
* Marks the transaction as successful and commits the transaction.
*
*/
public void setTransactionSuccessful() {
db.setTransactionSuccessful();
Expand Down Expand Up @@ -135,7 +132,6 @@ public long insertPort(String port, String description) {

/**
* Wipes out all of the OUIs that are currently in the database.
*
*/
public void clearOuis() {
db.execSQL("DELETE FROM " + OUI_TABLE);
Expand All @@ -144,7 +140,6 @@ public void clearOuis() {

/**
* Wipes out all of the ports that are currently in the database.
*
*/
public void clearPorts() {
db.execSQL("DELETE FROM " + PORT_TABLE);
Expand All @@ -159,13 +154,18 @@ public void clearPorts() {
*/
public String selectVendor(String mac) {
Cursor cursor = db.rawQuery("SELECT " + VENDOR_FIELD + " FROM " + OUI_TABLE + " WHERE " + MAC_FIELD + " = ?", new String[]{mac});
String vendor;
if (!cursor.moveToFirst()) {
cursor.close();
return null;
}

vendor = cursor.getString(cursor.getColumnIndex("vendor"));
int vendorIdx = cursor.getColumnIndex(VENDOR_FIELD);
if (vendorIdx < 0) {
cursor.close();
return null;
}

String vendor = cursor.getString(vendorIdx);
cursor.close();
return vendor;
}
Expand All @@ -178,14 +178,16 @@ public String selectVendor(String mac) {
*/
public String selectPortDescription(String port) {
Cursor cursor = db.rawQuery("SELECT " + DESCRIPTION_FIELD + " FROM " + PORT_TABLE + " WHERE " + PORT_FIELD + " = ?", new String[]{port});
String name = "";
String descrip = "";
if (cursor.moveToFirst()) {
name = cursor.getString(cursor.getColumnIndex(DESCRIPTION_FIELD));
int descripIdx = cursor.getColumnIndex(DESCRIPTION_FIELD);
if (descripIdx >= 0) {
descrip = cursor.getString(descripIdx);
}
}

cursor.close();

return name;
return descrip;
}

}
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,5 @@
<string name="errFindArp">ARP-Tabelle konnte nicht gefunden werden</string>
<string name="errReadArp">ARP-Tabelle konnte nicht gelesen werden</string>
<string name="errExternIp">Externe IP kann nicht abfragt werden</string>
<string name="nonPrivilegedMacAccess">Nicht verfügbar für nicht-privilegierte Apps (ab Android 11)</string>
</resources>
3 changes: 2 additions & 1 deletion app/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,5 @@
<string name="errFindArp">找不到 ARP 表</string>
<string name="errReadArp">无法读取 ARP 表</string>
<string name="errExternIp">无法获得你的外部 IP</string>
</resources>
<string name="nonPrivilegedMacAccess">从 Android 11 起对非特权应用不可用</string>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<CheckBoxPreference
android:defaultValue="true"
android:key="externalIp"
android:summary="Determines whether or not the application should get your external IP using a third party service"
android:summary="Determines whether or not the application should get your external IP using a web service"
android:title="Fetch device's external IP"
android:widgetLayout="@layout/checkbox" />
</PreferenceCategory>
Expand Down

0 comments on commit cc3e3b7

Please sign in to comment.