Skip to content

Commit 640aec6

Browse files
author
npaine
committed
Change constructor for JNI and Java sanitizers
1 parent 13532ec commit 640aec6

File tree

2 files changed

+1
-55
lines changed

2 files changed

+1
-55
lines changed

lib/android_build/maesdk/src/main/java/com/microsoft/applications/events/Sanitizer.java

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class Sanitizer {
1414
* @param enforceSanitization Flag to control whether sanitization is enforced.
1515
* @return true if initialization was successful, false otherwise.
1616
*/
17-
private static native boolean nativeInitialize(long loggerNativePtr, String notificationEventName, boolean enforceSanitization);
17+
private static native boolean nativeInitialize(long loggerNativePtr, String notificationEventName, boolean enforceSanitization, int sanitizerConfigurationOverrides);
1818

1919
/**
2020
* Initializes the sanitizer with the provided configuration.
@@ -23,36 +23,6 @@ public class Sanitizer {
2323
* @return true if initialization succeeds, false otherwise.
2424
* @throws IllegalArgumentException if config or any required field is null or invalid.
2525
*/
26-
public static boolean initialize(SanitizerConfiguration config) {
27-
28-
// Validate that the configuration object is not null
29-
if(config == null) {
30-
throw new IllegalArgumentException("initConfig cannot be null");
31-
}
32-
33-
// Ensure the logger instance is provided
34-
if(config.getLogger() == null) {
35-
throw new IllegalArgumentException(("loggerInstance cannot be null in config."));
36-
}
37-
38-
// Ensure the notification event name is not null or empty
39-
if (config.getNotificationEventName() == null || config.getNotificationEventName().isEmpty()) {
40-
throw new IllegalArgumentException(("notificationEventName cannot be null in config."));
41-
}
42-
43-
return nativeInitialize(
44-
config.getLogger().getNativeILoggerPtr(),
45-
config.getNotificationEventName(),
46-
config.isEnforceSanitization());
47-
}
48-
49-
/**
50-
* Initializes the sanitizer with the provided configuration.
51-
*
52-
* @param config The configuration settings used to initialize a sanitizer.
53-
* @return true if initialization succeeds, false otherwise.
54-
* @throws IllegalArgumentException if config or any required field is null or invalid.
55-
*/
5626
public static boolean initialize(SanitizerConfiguration config, int sanitizerConfigurationOverrides) {
5727

5828
// Validate that the configuration object is not null

lib/jni/Sanitizer_jni.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,6 @@ Java_com_microsoft_applications_events_Sanitizer_isInitialized(const JNIEnv *env
2323
return spSanitizer != nullptr;
2424
}
2525

26-
extern "C"
27-
JNIEXPORT jboolean JNICALL
28-
Java_com_microsoft_applications_events_Sanitizer_nativeInitialize(
29-
JNIEnv *env, jclass /* this */,
30-
jlong iLoggerNativePtr,
31-
jstring notificationEventName,
32-
jboolean warningsToSanitization) {
33-
34-
if (spSanitizer != nullptr) {
35-
return false;
36-
}
37-
38-
SanitizerConfiguration sanitizerConfig(reinterpret_cast<ILogger*>(iLoggerNativePtr), static_cast<int>(0));
39-
40-
if (notificationEventName != nullptr) {
41-
sanitizerConfig.NotificationEventName = JStringToStdString(env, notificationEventName);
42-
}
43-
44-
sanitizerConfig.SetAllWarningsToSanitizations = static_cast<bool>(warningsToSanitization);
45-
46-
spSanitizer = std::make_shared<Sanitizer>(sanitizerConfig);
47-
return true;
48-
}
49-
5026
extern "C"
5127
JNIEXPORT jboolean JNICALL
5228
Java_com_microsoft_applications_events_Sanitizer_nativeInitialize(

0 commit comments

Comments
 (0)