Skip to content

Commit 0c6d45a

Browse files
authored
Merge pull request #1 from niccellular/4.10.0
4.10.0
2 parents 0269875 + 1ba1904 commit 0c6d45a

File tree

14 files changed

+588
-456
lines changed

14 files changed

+588
-456
lines changed

.idea/workspace.xml

Lines changed: 167 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
buildscript {
1010

11-
ext.PLUGIN_VERSION = "1.0"
12-
ext.ATAK_VERSION = "4.8.1"
11+
ext.PLUGIN_VERSION = "3.0"
12+
ext.ATAK_VERSION = "4.10.0"
1313

1414
def takdevVersion = '2.+'
1515

@@ -59,7 +59,7 @@ buildscript {
5959
}
6060
}
6161
dependencies {
62-
classpath 'com.android.tools.build:gradle:4.2.2'
62+
classpath 'com.android.tools.build:gradle:7.4.2'
6363
if(isDevKitEnabled()) {
6464
classpath "com.atakmap.gradle:atak-gradle-takdev:${takdevVersion}"
6565
} else {
@@ -284,7 +284,8 @@ android {
284284
}
285285

286286
defaultConfig {
287-
minSdkVersion 21
287+
minSdkVersion 26
288+
targetSdkVersion 33
288289
ndk {
289290
abiFilters "armeabi-v7a", "arm64-v8a", "x86"
290291
}
@@ -294,7 +295,9 @@ android {
294295

295296
dependencies {
296297
implementation fileTree(dir: 'libs', include: '*.jar')
297-
implementation 'com.paulmandal.atak:libcotshrink:1.0.3'
298+
//implementation 'com.paulmandal.atak:libcotshrink:1.0.3'
298299

300+
// https://mvnrepository.com/artifact/com.siemens.ct.exi/exificient
301+
implementation 'com.siemens.ct.exi:exificient:1.0.7'
299302
}
300303

app/proguard-gradle.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@
4848

4949

5050

51-
-keep class * extends transapps.maps.plugin.tool.Tool {
52-
}
53-
-keep class * implements transapps.maps.plugin.lifecycle.Lifecycle {
51+
52+
-keep class * implements gov.tak.api.plugin.IPlugin {
5453
}
5554

55+
5656
# overcome an existing bug in the gradle subsystem (3.5.x)
5757
-keep class module-info
5858

app/src/main/AndroidManifest.xml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools"
23
package="com.atakmap.android.aprstak.plugin">
34
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
45

@@ -13,11 +14,12 @@
1314
<meta-data android:name="plugin-api" android:value="${atakApiVersion}"/>
1415
<meta-data android:name="app_desc" android:value="@string/app_desc"/>
1516

16-
<activity android:name="com.atakmap.app.component">
17-
<intent-filter android:label="@string/app_name">
18-
<action android:name="com.atakmap.app.component" />
19-
</intent-filter>
20-
</activity>
17+
<activity android:name="com.atakmap.app.component" tools:ignore="MissingClass" android:exported="true">
18+
<intent-filter android:label="@string/app_name">
19+
<action android:name="com.atakmap.app.component" />
20+
</intent-filter>
21+
</activity>
22+
2123

2224
</application>
2325

app/src/main/assets/plugin.xml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,8 @@
33
<plugin>
44

55
<extension
6-
type="transapps.maps.plugin.lifecycle.Lifecycle"
6+
type="gov.tak.api.plugin.IPlugin"
77
impl="com.atakmap.android.aprstak.plugin.PluginLifecycle"
88
singleton="true" />
99

10-
<extension
11-
type="transapps.maps.plugin.tool.ToolDescriptor"
12-
impl="com.atakmap.android.aprstak.plugin.PluginTool"
13-
singleton="true" />
14-
1510
</plugin>

app/src/main/java/com/atakmap/android/aprstak/APRSMessageHandler.java

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,70 @@
99

1010
import com.atakmap.comms.CommsMapComponent;
1111
import com.atakmap.coremap.cot.event.CotEvent;
12-
import com.paulmandal.atak.libcotshrink.pub.api.CotShrinker;
1312

1413
import com.atakmap.android.aprstak.plugin.PluginLifecycle;
14+
import com.siemens.ct.exi.core.EXIFactory;
15+
import com.siemens.ct.exi.core.helpers.DefaultEXIFactory;
16+
import com.siemens.ct.exi.main.api.sax.EXIResult;
1517

18+
import org.xml.sax.InputSource;
19+
import org.xml.sax.XMLReader;
20+
21+
import java.io.ByteArrayOutputStream;
22+
import java.io.StringReader;
1623
import java.nio.ByteBuffer;
1724
import java.security.MessageDigest;
1825
import java.security.SecureRandom;
1926

2027
import javax.crypto.Cipher;
2128
import javax.crypto.spec.IvParameterSpec;
2229
import javax.crypto.spec.SecretKeySpec;
30+
import javax.xml.parsers.SAXParser;
31+
import javax.xml.parsers.SAXParserFactory;
2332

2433
import utils.AprsUtility;
2534

2635
public class APRSMessageHandler implements CommsMapComponent.PreSendProcessor {
2736

2837
private static final String TAG = "APRSMessageHandler";
29-
private final CotShrinker cotShrinker;
3038

31-
public APRSMessageHandler(CotShrinker cotShrinker) {
39+
private Context context;
40+
41+
public APRSMessageHandler(Context context) {
3242
CommsMapComponent.getInstance().registerPreSendProcessor(this);
33-
this.cotShrinker = cotShrinker;
43+
this.context = context;
3444
}
3545

3646
@Override
3747
public void processCotEvent(CotEvent cotEvent, String[] toUIDs) {
3848
if (cotEvent.toString().contains("All Chat Rooms")) {
39-
byte[] cotBytes = cotShrinker.toByteArrayLossy(cotEvent);
40-
String encodedString;
49+
byte[] cotAsBytes;
50+
51+
try {
52+
EXIFactory exiFactory = DefaultEXIFactory.newInstance();
53+
ByteArrayOutputStream osEXI = new ByteArrayOutputStream();
54+
EXIResult exiResult = new EXIResult(exiFactory);
55+
exiResult.setOutputStream(osEXI);
56+
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
57+
SAXParser newSAXParser = saxParserFactory.newSAXParser();
58+
XMLReader xmlReader = newSAXParser.getXMLReader();
59+
xmlReader.setContentHandler(exiResult.getHandler());
60+
InputSource stream = new InputSource(new StringReader(cotEvent.toString()));
61+
xmlReader.parse(stream); // parse XML input
62+
cotAsBytes = osEXI.toByteArray();
63+
osEXI.close();
64+
} catch (Exception e) {
65+
e.printStackTrace();
66+
return;
67+
}
68+
69+
Log.d(TAG, "Size: " + cotAsBytes.length); String encodedString;
70+
4171
if (AprsUtility.usePSK) {
4272
com.atakmap.coremap.log.Log.i(TAG, "PSK enabled");
4373
ByteBuffer payload;
4474
byte[] PSKhash, cipherText;
45-
SharedPreferences sharedPref = PluginLifecycle.activity.getSharedPreferences("aprs-prefs", Context.MODE_PRIVATE);
75+
SharedPreferences sharedPref = context.getSharedPreferences("aprs-prefs", Context.MODE_PRIVATE);
4676
String psk = sharedPref.getString("PSKText", "atakatak");
4777
try {
4878
MessageDigest digest = MessageDigest.getInstance("MD5");
@@ -57,7 +87,7 @@ public void processCotEvent(CotEvent cotEvent, String[] toUIDs) {
5787
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
5888
SecretKeySpec key = new SecretKeySpec(PSKhash, "AES");
5989
cipher.init(Cipher.ENCRYPT_MODE, key, new IvParameterSpec(iv));
60-
cipherText = cipher.doFinal(cotBytes);
90+
cipherText = cipher.doFinal(cotAsBytes);
6191
// set the iv+cipherText as the payload
6292
payload = ByteBuffer.allocate(iv.length + cipherText.length);
6393
payload.put(iv);
@@ -68,13 +98,13 @@ public void processCotEvent(CotEvent cotEvent, String[] toUIDs) {
6898
}
6999
encodedString = Base64.encodeToString(payload.array(), Base64.NO_WRAP);
70100
} else {
71-
encodedString = Base64.encodeToString(cotBytes, Base64.NO_WRAP);
101+
encodedString = Base64.encodeToString(cotAsBytes, Base64.NO_WRAP);
72102
}
73103

74104
Log.d(TAG, "Base64 string len: " + encodedString.length());
75105
Intent i = new Intent("org.aprsdroid.app.SEND_PACKET").setPackage("org.aprsdroid.app");
76106
i.putExtra("data", ">M," + encodedString);
77-
PluginLifecycle.activity.getApplicationContext().startForegroundService(i);
107+
context.getApplicationContext().startForegroundService(i);
78108
}
79109
}
80110
}

0 commit comments

Comments
 (0)