From 1233312bc14b7225506c467b7da9bccc53ad1331 Mon Sep 17 00:00:00 2001 From: Venus Dowoang <121656507+Innominate-Majesty@users.noreply.github.com> Date: Wed, 12 Jun 2024 14:48:43 -0700 Subject: [PATCH 1/5] modified logging HelloworldActivity.java --- BundleClient/app/src/main/AndroidManifest.xml | 3 +-- BundleClient/gradle.properties | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/BundleClient/app/src/main/AndroidManifest.xml b/BundleClient/app/src/main/AndroidManifest.xml index 33290693ee..9fa991e6bd 100644 --- a/BundleClient/app/src/main/AndroidManifest.xml +++ b/BundleClient/app/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - + diff --git a/BundleClient/gradle.properties b/BundleClient/gradle.properties index 52f5917cb0..193a5b26e7 100644 --- a/BundleClient/gradle.properties +++ b/BundleClient/gradle.properties @@ -16,4 +16,7 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 # https://developer.android.com/topic/libraries/support-library/androidx-rn android.useAndroidX=true # Automatically convert third-party libraries to use AndroidX -android.enableJetifier=true \ No newline at end of file +android.enableJetifier=true +android.defaults.buildfeatures.buildconfig=true +android.nonTransitiveRClass=false +android.nonFinalResIds=false \ No newline at end of file From ced42b4e2e3f27ecae37d2fe08c9720aad6c9bf2 Mon Sep 17 00:00:00 2001 From: Venus Dowoang <121656507+Innominate-Majesty@users.noreply.github.com> Date: Mon, 17 Jun 2024 11:12:50 -0700 Subject: [PATCH 2/5] changes AndroidManifest.xml and gradle.properties to match main --- BundleClient/app/src/main/AndroidManifest.xml | 3 ++- BundleClient/gradle.properties | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/BundleClient/app/src/main/AndroidManifest.xml b/BundleClient/app/src/main/AndroidManifest.xml index 9fa991e6bd..33290693ee 100644 --- a/BundleClient/app/src/main/AndroidManifest.xml +++ b/BundleClient/app/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ - + diff --git a/BundleClient/gradle.properties b/BundleClient/gradle.properties index 193a5b26e7..52f5917cb0 100644 --- a/BundleClient/gradle.properties +++ b/BundleClient/gradle.properties @@ -16,7 +16,4 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 # https://developer.android.com/topic/libraries/support-library/androidx-rn android.useAndroidX=true # Automatically convert third-party libraries to use AndroidX -android.enableJetifier=true -android.defaults.buildfeatures.buildconfig=true -android.nonTransitiveRClass=false -android.nonFinalResIds=false \ No newline at end of file +android.enableJetifier=true \ No newline at end of file From 557137500011297dc79b7a3e5cd1ac1159bc0230 Mon Sep 17 00:00:00 2001 From: Venus Dowoang <121656507+Innominate-Majesty@users.noreply.github.com> Date: Mon, 17 Jun 2024 15:20:56 -0700 Subject: [PATCH 3/5] update logging for bundlerouting package --- .../bundlerouting/ClientBundleGenerator.java | 14 ++++++-- .../client/bundlerouting/ClientRouting.java | 12 ++++++- .../client/bundlerouting/ClientWindow.java | 32 ++++++++++++------- 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientBundleGenerator.java b/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientBundleGenerator.java index c97ec1864a..c6d349a83b 100644 --- a/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientBundleGenerator.java +++ b/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientBundleGenerator.java @@ -6,6 +6,13 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; +import java.util.logging.Logger; +import static java.util.logging.Level.FINER; +import static java.util.logging.Level.FINE; +import static java.util.logging.Level.INFO; +import static java.util.logging.Level.WARNING; +import static java.util.logging.Level.SEVERE; + import com.ddd.client.bundlesecurity.BundleIDGenerator; import com.ddd.client.bundlesecurity.ClientSecurity; import com.ddd.client.bundlesecurity.SecurityExceptions.BundleIDCryptographyException; @@ -13,6 +20,9 @@ import com.ddd.client.bundlesecurity.SecurityUtils; public class ClientBundleGenerator { + + private static final Logger logger = Logger.getLogger(ClientBundleGenerator.class.getName()); + static ClientBundleGenerator singleGeneratorInstance = null; ClientSecurity clientSecurity = null; @@ -37,7 +47,7 @@ private void updateBundleIDFile() { try (FileOutputStream stream = new FileOutputStream(counterFilePath)) { stream.write(Long.toUnsignedString(currentCounter).getBytes(StandardCharsets.UTF_8)); } catch (IOException ex) { - System.out.println("[BR]: Failed to create counter backup file! " + ex); + logger.log(WARNING,"[BR]: Failed to create counter backup file! " + ex); } } @@ -45,7 +55,7 @@ public static ClientBundleGenerator initializeInstance(ClientSecurity clientSecu if (singleGeneratorInstance == null) { singleGeneratorInstance = new ClientBundleGenerator(clientSecurity, rootPath); } else { - System.out.println("[BR]: Client bundle generator instance is already created!"); + logger.log(WARNING,"[BR]: Client bundle generator instance is already created!"); } return singleGeneratorInstance; } diff --git a/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientRouting.java b/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientRouting.java index f8416e8577..9538f6a353 100644 --- a/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientRouting.java +++ b/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientRouting.java @@ -7,6 +7,13 @@ import java.util.HashMap; +import java.util.logging.Logger; +import static java.util.logging.Level.FINER; +import static java.util.logging.Level.FINE; +import static java.util.logging.Level.INFO; +import static java.util.logging.Level.WARNING; +import static java.util.logging.Level.SEVERE; + import com.ddd.client.bundlesecurity.SecurityUtils; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.type.TypeReference; @@ -18,6 +25,9 @@ import com.ddd.bundlerouting.RoutingExceptions.ClientMetaDataFileException; public class ClientRouting { + + private static final Logger logger = Logger.getLogger(ClientRouting.class.getName()); + private static ClientRouting singleClientRoutingInstance = null; HashMap metadata = null; String metaDataPath = null; @@ -57,7 +67,7 @@ public static ClientRouting initializeInstance(String metaDataPath) throws Clien if (singleClientRoutingInstance == null) { singleClientRoutingInstance = new ClientRouting(metaDataPath); } else { - System.out.println("[BR]: Client Routing Instance already Exists!"); + logger.log(INFO, "[BR]: Client Routing Instance already Exists!"); } return singleClientRoutingInstance; } diff --git a/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientWindow.java b/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientWindow.java index 2176bab547..bfd06421bb 100644 --- a/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientWindow.java +++ b/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientWindow.java @@ -10,6 +10,13 @@ import com.ddd.client.bundlesecurity.SecurityExceptions.BundleIDCryptographyException; import com.ddd.client.bundlesecurity.SecurityUtils; +import java.util.logging.Logger; +import static java.util.logging.Level.FINER; +import static java.util.logging.Level.FINE; +import static java.util.logging.Level.INFO; +import static java.util.logging.Level.WARNING; +import static java.util.logging.Level.SEVERE; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -17,6 +24,9 @@ import java.util.List; public class ClientWindow { + + private static final Logger logger = Logger.getLogger(ClientWindow.class.getName()); + static private ClientWindow singleClientWindowInstance = null; private String clientWindowDataPath = null; final private String windowFile = "clientWindow.csv"; @@ -56,7 +66,7 @@ private void updateDBWindow() { String metadata = Long.toUnsignedString(begin) + "," + Long.toUnsignedString(end) + "," + windowLength; stream.write(metadata.getBytes()); } catch (IOException e) { - System.out.println("Error: Failed to write Window to file! " + e); + logger.log(WARNING, "Error: Failed to write Window to file! " + e); } } @@ -87,12 +97,12 @@ private ClientWindow(int length, String clientID, String rootPath) throws Invali try { initializeWindow(); } catch (IOException e) { - Log.e(TAG, "Failed to initialize Window from Disk, creating new window\n" + e); + logger.log(WARNING, "Failed to initialize Window from Disk -- creating new window\n" + e); if (length > 0) { windowLength = length; } else { - //TODO: Change to log - Log.e(TAG, "Invalid window size, using default size: " + windowLength); + + logger.log(WARNING, "Invalid window size -- using default size: " + windowLength); } } @@ -107,7 +117,7 @@ public static ClientWindow initializeInstance(int windowLength, String clientID, if (singleClientWindowInstance == null) { singleClientWindowInstance = new ClientWindow(windowLength, clientID, rootPath); } else { - System.out.println("[WIN]: Client Window Instance is already initialized!"); + logger.log(INFO, "[WIN]: Client Window Instance is already initialized!"); } return singleClientWindowInstance; } @@ -128,15 +138,15 @@ public static ClientWindow getInstance() { public void processBundle(String bundleID, ClientSecurity clientSecurity) throws BufferOverflow, BundleIDCryptographyException { String decryptedBundleID = clientSecurity.decryptBundleID(bundleID); - System.out.println("Largest Bundle ID = " + decryptedBundleID); + logger.log(FINE, "Largest Bundle ID = " + decryptedBundleID); long ack = BundleIDGenerator.getCounterFromBundleID(decryptedBundleID, BundleIDGenerator.DOWNSTREAM); if (Long.compareUnsigned(ack, begin) == -1) { - System.out.println( + logger.log(FINE, "Received old [" + Long.toUnsignedString(ack) + " < " + Long.toUnsignedString(begin) + "]"); return; } else if (Long.compareUnsigned(ack, end) == 1) { - System.out.println( + logger.log(FINE, "Received Invalid ACK [" + Long.toUnsignedString(ack) + " < " + Long.toUnsignedString(end) + "]"); return; } @@ -149,14 +159,14 @@ public void processBundle(String bundleID, ClientSecurity clientSecurity) throws try { noDeleted = window.deleteUntilIndex(ackIndex); } catch (InvalidLength e) { - System.out.println("Received Invalid ACK [" + Long.toUnsignedString(ack) + "]"); + logger.log(WARNING, "Received Invalid ACK [" + Long.toUnsignedString(ack) + "]"); } begin = ack + 1; /* Add new bundleIDs to window */ fillWindow(noDeleted, end); - // TODO: Change to log - System.out.println("Updated Begin: " + Long.toUnsignedString(begin) + "; End: " + Long.toUnsignedString(end)); + + logger.log(FINE, "Updated Begin: " + Long.toUnsignedString(begin) + "; End: " + Long.toUnsignedString(end)); } /* Returns the entire window From 9c8fe59bc89c79778dfbe53f1d8606d009e2d877 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 17 Jun 2024 22:28:54 +0000 Subject: [PATCH 4/5] Auto-format code --- .../com/ddd/client/bundlerouting/ClientBundleGenerator.java | 5 +++-- .../java/com/ddd/client/bundlerouting/ClientRouting.java | 1 + .../java/com/ddd/client/bundlerouting/ClientWindow.java | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientBundleGenerator.java b/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientBundleGenerator.java index c6d349a83b..01908dae0a 100644 --- a/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientBundleGenerator.java +++ b/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientBundleGenerator.java @@ -7,6 +7,7 @@ import java.nio.charset.StandardCharsets; import java.util.logging.Logger; + import static java.util.logging.Level.FINER; import static java.util.logging.Level.FINE; import static java.util.logging.Level.INFO; @@ -47,7 +48,7 @@ private void updateBundleIDFile() { try (FileOutputStream stream = new FileOutputStream(counterFilePath)) { stream.write(Long.toUnsignedString(currentCounter).getBytes(StandardCharsets.UTF_8)); } catch (IOException ex) { - logger.log(WARNING,"[BR]: Failed to create counter backup file! " + ex); + logger.log(WARNING, "[BR]: Failed to create counter backup file! " + ex); } } @@ -55,7 +56,7 @@ public static ClientBundleGenerator initializeInstance(ClientSecurity clientSecu if (singleGeneratorInstance == null) { singleGeneratorInstance = new ClientBundleGenerator(clientSecurity, rootPath); } else { - logger.log(WARNING,"[BR]: Client bundle generator instance is already created!"); + logger.log(WARNING, "[BR]: Client bundle generator instance is already created!"); } return singleGeneratorInstance; } diff --git a/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientRouting.java b/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientRouting.java index 9538f6a353..714946f015 100644 --- a/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientRouting.java +++ b/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientRouting.java @@ -8,6 +8,7 @@ import java.util.HashMap; import java.util.logging.Logger; + import static java.util.logging.Level.FINER; import static java.util.logging.Level.FINE; import static java.util.logging.Level.INFO; diff --git a/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientWindow.java b/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientWindow.java index bfd06421bb..c7393697c4 100644 --- a/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientWindow.java +++ b/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientWindow.java @@ -11,6 +11,7 @@ import com.ddd.client.bundlesecurity.SecurityUtils; import java.util.logging.Logger; + import static java.util.logging.Level.FINER; import static java.util.logging.Level.FINE; import static java.util.logging.Level.INFO; @@ -143,11 +144,12 @@ public void processBundle(String bundleID, ClientSecurity clientSecurity) throws if (Long.compareUnsigned(ack, begin) == -1) { logger.log(FINE, - "Received old [" + Long.toUnsignedString(ack) + " < " + Long.toUnsignedString(begin) + "]"); + "Received old [" + Long.toUnsignedString(ack) + " < " + Long.toUnsignedString(begin) + "]"); return; } else if (Long.compareUnsigned(ack, end) == 1) { logger.log(FINE, - "Received Invalid ACK [" + Long.toUnsignedString(ack) + " < " + Long.toUnsignedString(end) + "]"); + "Received Invalid ACK [" + Long.toUnsignedString(ack) + " < " + Long.toUnsignedString(end) + + "]"); return; } From 685f40e6c518f59568af2de76b66622e40e8d460 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 17 Jun 2024 23:26:11 +0000 Subject: [PATCH 5/5] Auto-format code --- .../java/com/ddd/client/bundlerouting/ClientBundleGenerator.java | 1 - .../main/java/com/ddd/client/bundlerouting/ClientRouting.java | 1 - 2 files changed, 2 deletions(-) diff --git a/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientBundleGenerator.java b/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientBundleGenerator.java index f833908622..f5cefe8cf9 100644 --- a/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientBundleGenerator.java +++ b/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientBundleGenerator.java @@ -14,7 +14,6 @@ import static java.util.logging.Level.WARNING; import static java.util.logging.Level.SEVERE; - import com.ddd.bundlesecurity.BundleIDGenerator; import com.ddd.client.bundlesecurity.ClientSecurity; diff --git a/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientRouting.java b/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientRouting.java index 32f603c2c9..cbca20bdfd 100644 --- a/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientRouting.java +++ b/BundleClient/app/src/main/java/com/ddd/client/bundlerouting/ClientRouting.java @@ -7,7 +7,6 @@ import java.util.HashMap; - import java.util.logging.Logger; import static java.util.logging.Level.FINER;