Skip to content

Commit 03656f4

Browse files
Merge pull request #4 from adwise-fiu/android-java
Refactor the package name
2 parents 394d9af + c165e3c commit 03656f4

21 files changed

Lines changed: 181 additions & 274 deletions

.gitattributes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Set the default line endings for all text files to LF
2+
* text=auto
3+
4+
# Always checkout with LF
5+
*.sh text eol=lf
6+
gradlew text eol=lf
7+
8+
# Always checkout with CRLF
9+
*.bat text eol=crlf

.github/workflows/deploy_jar.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
increment: ${{ env.increment }}
3030

3131
upload_release:
32+
if: github.repository == 'adwise-fiu/Secure_Indoor_Localization'
3233
needs: [ create_release ]
3334
runs-on: ubuntu-latest
3435
steps:
@@ -71,10 +72,9 @@ jobs:
7172
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
7273
VERSION: ${{ env.RELEASE_VERSION }}
7374

74-
# You want to use the 'ciphercraft-<version>.jar' for your uses
7575
- name: Release the JAR file
7676
uses: softprops/action-gh-release@v2
7777
with:
7878
tag_name: ${{ needs.create_release.outputs.v-version }}
79-
files: REUServer/build/libs/fingerprint_localization*.jar
79+
files: REUServer/build/libs/*.jar
8080
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/parallel_tests.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ jobs:
5353
chmod +x gradlew
5454
./gradlew test
5555
56+
- name: Upload coverage reports to Codecov
57+
uses: codecov/codecov-action@v5
58+
with:
59+
token: ${{ secrets.CODECOV_TOKEN }}
60+
5661
test-android:
5762
runs-on: ubuntu-latest
5863
steps:

REU2017/app/src/main/AndroidManifest.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,30 @@
3737
<!-- The top two lines are needed to scale all images -->
3838

3939
<activity
40-
android:name="ui.MainActivity"
40+
android:name="edu.fiu.adwise.fingerprint_localization.ui.MainActivity"
4141
android:exported="true">
4242
<intent-filter>
4343
<action android:name="android.intent.action.MAIN" />
4444
<category android:name="android.intent.category.LAUNCHER" />
4545
</intent-filter>
4646
</activity>
4747

48-
<activity android:name="ui.TrainActivity"
48+
<activity android:name="edu.fiu.adwise.fingerprint_localization.ui.TrainActivity"
4949
android:exported="true">
5050
<intent-filter>
5151
<action android:name="ui.TrainActivity" />
5252
</intent-filter>
5353
</activity>
5454

55-
<activity android:name="ui.LocalizeActivity"
55+
<activity android:name="edu.fiu.adwise.fingerprint_localization.ui.LocalizeActivity"
5656
android:exported="true">
5757
<intent-filter>
5858
<action android:name="ui.LocalizeActivity" />
5959
</intent-filter>
6060
</activity>
6161

6262
<activity
63-
android:name="ui.AddMapActivity"
63+
android:name="edu.fiu.adwise.fingerprint_localization.ui.AddMapActivity"
6464
android:exported="true">
6565
<intent-filter>
6666
<action android:name="ui.AddMapActivity" />

REU2017/app/src/main/java/Localization/ClientThread.java renamed to REU2017/app/src/main/java/edu/fiu/adwise/fingerprint_localization/localization/ClientThread.java

Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package Localization;
1+
package edu.fiu.adwise.fingerprint_localization.localization;
22

33
import android.util.Log;
44

@@ -14,12 +14,12 @@
1414
import edu.fiu.adwise.fingerprint_localization.structs.LocalizationResult;
1515
import edu.fiu.adwise.fingerprint_localization.structs.SendTrainingData;
1616
import edu.fiu.adwise.homomorphic_encryption.misc.HomomorphicException;
17-
import ui.MainActivity;
18-
import ui.TrainActivity;
17+
import edu.fiu.adwise.fingerprint_localization.ui.MainActivity;
18+
import edu.fiu.adwise.fingerprint_localization.ui.TrainActivity;
1919

2020

21-
import static ui.MainActivity.SQLDatabase;
22-
import static ui.MainActivity.portNumber;
21+
import static edu.fiu.adwise.fingerprint_localization.ui.MainActivity.SQLDatabase;
22+
import static edu.fiu.adwise.fingerprint_localization.ui.MainActivity.portNumber;
2323
import edu.fiu.adwise.fingerprint_localization.distance_computation.LOCALIZATION_SCHEME;
2424

2525
import edu.fiu.adwise.homomorphic_encryption.dgk.DGKOperations;
@@ -30,31 +30,21 @@
3030
import edu.fiu.adwise.homomorphic_encryption.paillier.PaillierPublicKey;
3131
import edu.fiu.adwise.homomorphic_encryption.socialistmillionaire.bob;
3232

33-
public class ClientThread implements Runnable
34-
{
33+
public class ClientThread implements Runnable {
3534
private final static String TAG = "CLIENT_THREAD";
36-
37-
private ObjectOutputStream toServer = null;
38-
private ObjectInputStream fromServer = null;
39-
4035
//Pass Data back to class by reference...
4136
private background findMe;
4237
private TrainActivity trainMe;
4338
private background getColumns;
44-
45-
//Data Objects
46-
private SendTrainingData sendTraining; //Training Data
47-
private SendLocalizationData transmission; //For Encrypted Paillier/DGK Transmission
48-
39+
private SendTrainingData sendTraining;
40+
private SendLocalizationData transmission;
4941
// Have all Keys in case comparison is needed!!
5042
private final DGKPublicKey pubKey = KeyMaster.DGKpk;
5143
private final DGKPrivateKey privKey = KeyMaster.DGKsk;
5244
private final PaillierPublicKey pk = KeyMaster.pk;
5345
private final PaillierPrivateKey sk = KeyMaster.sk;
5446

5547
private final LOCALIZATION_SCHEME LOCALIZATIONSCHEME;
56-
private Socket clientSocket;
57-
5848
// Get all currently trained points
5949
public ClientThread(TrainActivity trainActivity) {
6050
this.LOCALIZATIONSCHEME = LOCALIZATION_SCHEME.from_int(-3);
@@ -66,8 +56,7 @@ public ClientThread(TrainActivity trainActivity) {
6656
Purpose: Force mySQL Database to process data from
6757
training data.
6858
*/
69-
public ClientThread()
70-
{
59+
public ClientThread() {
7160
this.LOCALIZATIONSCHEME = LOCALIZATION_SCHEME.from_int(-2);
7261
}
7362

@@ -93,12 +82,11 @@ public ClientThread (SendTrainingData in) {
9382

9483
public void run () {
9584
Object in;
96-
try
97-
{
98-
clientSocket = new Socket(SQLDatabase, portNumber);
99-
// Prepare I/O Stream
100-
this.toServer = new ObjectOutputStream(clientSocket.getOutputStream());
101-
this.fromServer = new ObjectInputStream(clientSocket.getInputStream());
85+
try (
86+
Socket clientSocket = new Socket(SQLDatabase, portNumber);
87+
ObjectOutputStream toServer = new ObjectOutputStream(clientSocket.getOutputStream());
88+
ObjectInputStream fromServer = new ObjectInputStream(clientSocket.getInputStream())
89+
) {
10290
Log.d(TAG, "I/O Streams set!");
10391

10492
switch(LOCALIZATIONSCHEME) {
@@ -110,16 +98,6 @@ public void run () {
11098
toServer.writeObject(KeyMaster.map_name);
11199
toServer.flush();
112100

113-
// Following this patch the server needs to know the Phone as well
114-
if(MainActivity.multi_phone) {
115-
String [] phone_data = MainActivity.getPhoneData();
116-
for (String s: phone_data) {
117-
Log.d(TAG, s);
118-
}
119-
toServer.writeObject(phone_data);
120-
toServer.flush();
121-
}
122-
123101
in = fromServer.readObject();
124102
if(in instanceof Double []) {
125103
trainMe.existingX = (Double []) in;
@@ -155,7 +133,6 @@ public void run () {
155133
break;
156134
case GET_COLUMN:
157135
toServer.writeObject("Get Lookup Columns");
158-
159136
// Send the Map with all (x, y)
160137
toServer.writeObject(KeyMaster.map_name);
161138
toServer.flush();
@@ -179,7 +156,6 @@ public void run () {
179156
MainActivity.bad_train.show();
180157
}
181158
break;
182-
183159
case PLAIN_MIN:
184160
case PLAIN_DMA:
185161
case PLAIN_MCA:
@@ -189,7 +165,7 @@ public void run () {
189165
case DGK_MIN:
190166
case DGK_MCA:
191167
case DGK_DMA:
192-
localize();
168+
localize(clientSocket, toServer, fromServer);
193169
break;
194170
default:
195171
Log.d(TAG, "Error at Thread run: No Valid Object was sent here");
@@ -209,7 +185,11 @@ public void run () {
209185
}
210186
}
211187

212-
private void localize() throws IOException, ClassNotFoundException, HomomorphicException {
188+
private void localize(
189+
Socket clientSocket,
190+
ObjectOutputStream toServer,
191+
ObjectInputStream fromServer
192+
) throws IOException, ClassNotFoundException, HomomorphicException {
213193
bob andrew;
214194
BigInteger [] location;
215195
BigInteger divisor;

REU2017/app/src/main/java/Localization/KeyMaster.java renamed to REU2017/app/src/main/java/edu/fiu/adwise/fingerprint_localization/localization/KeyMaster.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package Localization;
1+
package edu.fiu.adwise.fingerprint_localization.localization;
22

33
import android.graphics.Bitmap;
44

@@ -50,8 +50,7 @@ public static void init() throws HomomorphicException {
5050
finished = true;
5151
}
5252

53-
public void run()
54-
{
53+
public void run() {
5554
try {
5655
init();
5756
} catch (HomomorphicException e) {

REU2017/app/src/main/java/Localization/background.java renamed to REU2017/app/src/main/java/edu/fiu/adwise/fingerprint_localization/localization/background.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package Localization;
1+
package edu.fiu.adwise.fingerprint_localization.localization;
22

33
import android.graphics.Bitmap;
44
import android.graphics.Canvas;
@@ -25,7 +25,7 @@
2525
import edu.fiu.adwise.fingerprint_localization.structs.SendLocalizationData;
2626
import edu.fiu.adwise.fingerprint_localization.structs.LocalizationResult;
2727
import edu.fiu.adwise.homomorphic_encryption.misc.HomomorphicException;
28-
import ui.MainActivity;
28+
import edu.fiu.adwise.fingerprint_localization.ui.MainActivity;
2929

3030
import edu.fiu.adwise.homomorphic_encryption.dgk.DGKOperations;
3131
import edu.fiu.adwise.homomorphic_encryption.dgk.DGKPrivateKey;
@@ -36,7 +36,7 @@
3636

3737
import static android.graphics.Color.RED;
3838
import static edu.fiu.adwise.fingerprint_localization.distance_computation.LOCALIZATION_SCHEME.*;
39-
import static ui.LocalizeActivity.off_map;
39+
import static edu.fiu.adwise.fingerprint_localization.ui.LocalizeActivity.off_map;
4040

4141
public final class background {
4242
private final static String TAG = "LOCALIZE";
@@ -45,7 +45,6 @@ public final class background {
4545
List<LocalizationResult> fromServer = new ArrayList<>();
4646
Double [] coordinates = new Double[2];
4747
private final LOCALIZATION_SCHEME LOCALIZATION_SCHEME;
48-
4948
//Keys and read Keys
5049
private static final PaillierPublicKey pk = KeyMaster.pk;
5150
private static final DGKPublicKey DGKpk = KeyMaster.DGKpk;
@@ -197,8 +196,7 @@ private Float[] doInBackground() {
197196
location[1] = fromServer.get(0).getY().floatValue();
198197
}
199198
else {
200-
Phase3();
201-
return location;
199+
return Phase3();
202200
}
203201
publishProgress(10);
204202
}
@@ -211,8 +209,8 @@ private Float[] doInBackground() {
211209
try {
212210
if(LOCALIZATION_SCHEME == DGK_DMA) {
213211
for (int i = 0; i < MainActivity.VECTOR_SIZE; i++) {
214-
S2[i] = DGKOperations.encrypt(-2 * RSS_send[i], DGKpk);
215-
S3_comp[i] = DGKOperations.encrypt(RSS_send[i] * RSS_send[i], DGKpk);
212+
S2[i] = DGKOperations.encrypt(-2L * RSS_send[i], DGKpk);
213+
S3_comp[i] = DGKOperations.encrypt((long) RSS_send[i] * RSS_send[i], DGKpk);
216214
}
217215
t = new Thread( new ClientThread(
218216
new SendLocalizationData(MAC_send, S2, null, S3_comp,
@@ -222,8 +220,8 @@ private Float[] doInBackground() {
222220
}
223221
else {
224222
for (int i = 0; i < MainActivity.VECTOR_SIZE; i++) {
225-
S2[i] = DGKOperations.encrypt(-2 * RSS_send[i], DGKpk);
226-
S3_plaintext += RSS_send[i] * RSS_send[i];
223+
S2[i] = DGKOperations.encrypt(-2L * RSS_send[i], DGKpk);
224+
S3_plaintext += (long) RSS_send[i] * RSS_send[i];
227225
}
228226

229227
try {
@@ -292,8 +290,8 @@ private Float[] doInBackground() {
292290
try {
293291
if(LOCALIZATION_SCHEME == PAILLIER_DMA) {
294292
for (int i = 0; i < MainActivity.VECTOR_SIZE; i++) {
295-
S2[i] = PaillierCipher.encrypt(-2 * RSS_send[i], pk);
296-
S3_comp[i] = PaillierCipher.encrypt(RSS_send[i] * RSS_send[i], pk);
293+
S2[i] = PaillierCipher.encrypt(-2L * RSS_send[i], pk);
294+
S3_comp[i] = PaillierCipher.encrypt((long) RSS_send[i] * RSS_send[i], pk);
297295
}
298296
(t = new Thread(new ClientThread(
299297
new SendLocalizationData(MAC_send, S2, null, S3_comp,
@@ -304,8 +302,8 @@ private Float[] doInBackground() {
304302
}
305303
else {
306304
for (int i = 0; i < MainActivity.VECTOR_SIZE; i++) {
307-
S2[i] = PaillierCipher.encrypt(-2 * RSS_send[i], pk);
308-
S3_plaintext += RSS_send[i] * RSS_send[i];
305+
S2[i] = PaillierCipher.encrypt(-2L * RSS_send[i], pk);
306+
S3_plaintext += (long) RSS_send[i] * RSS_send[i];
309307
}
310308
S3 = PaillierCipher.encrypt(S3_plaintext, pk);
311309

REU2017/app/src/main/java/sensors/WifiReceiver.java renamed to REU2017/app/src/main/java/edu/fiu/adwise/fingerprint_localization/sensors/WifiReceiver.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package sensors;
1+
package edu.fiu.adwise.fingerprint_localization.sensors;
22

33

44
import android.Manifest;
@@ -16,7 +16,7 @@
1616

1717
import java.util.List;
1818

19-
import ui.MainActivity;
19+
import edu.fiu.adwise.fingerprint_localization.ui.MainActivity;
2020

2121
import static android.widget.Toast.*;
2222

@@ -66,8 +66,7 @@ public void unregisterReceiver(Context context) {
6666

6767
// Try this...
6868
// https://stackoverflow.com/questions/13238600/use-registerreceiver-for-non-activity-and-non-service-class
69-
public void onReceive(Context context, Intent intent)
70-
{
69+
public void onReceive(Context context, Intent intent) {
7170
String action = intent.getAction();
7271
if (WifiManager.SCAN_RESULTS_AVAILABLE_ACTION.equals(action)) {
7372
get_data();

0 commit comments

Comments
 (0)