Merge pull request #523 from microsoft/maharrim/piikind
Android EventProperty: piiKind and dataCategory
This commit is contained in:
Коммит
a19365ecab
|
@ -11,6 +11,9 @@ import android.content.Context;
|
|||
import android.util.Log;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import com.microsoft.applications.events.DataCategory;
|
||||
import com.microsoft.applications.events.EventProperties;
|
||||
import com.microsoft.applications.events.EventProperty;
|
||||
import com.microsoft.applications.events.HttpClient;
|
||||
import com.microsoft.applications.events.ILogConfiguration;
|
||||
import com.microsoft.applications.events.ILogManager;
|
||||
|
@ -20,6 +23,7 @@ import com.microsoft.applications.events.LogManager;
|
|||
import com.microsoft.applications.events.LogManager.LogConfigurationImpl;
|
||||
import com.microsoft.applications.events.LogManagerProvider;
|
||||
import com.microsoft.applications.events.OfflineRoom;
|
||||
import com.microsoft.applications.events.PiiKind;
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.TypeSafeDiagnosingMatcher;
|
||||
import org.junit.Test;
|
||||
|
@ -222,4 +226,18 @@ public class SDKUnitNativeTest extends MaeUnitLogger {
|
|||
assertThat((LogConfigurationImpl) mangled, isValueSuperset(config));
|
||||
}
|
||||
|
||||
public native int nativeGetPiiType(EventProperty property);
|
||||
public native int nativeGetDataCategory(EventProperty property);
|
||||
|
||||
@Test
|
||||
public void piiKindIdentity() {
|
||||
System.loadLibrary("maesdk");
|
||||
System.loadLibrary("native-lib");
|
||||
|
||||
EventProperty prop = new EventProperty("foo", PiiKind.Identity, DataCategory.PartB);
|
||||
int roundTrip = nativeGetPiiType(prop);
|
||||
assertThat(roundTrip, is(PiiKind.Identity.getValue()));
|
||||
roundTrip = nativeGetDataCategory(prop);
|
||||
assertThat(roundTrip, is(DataCategory.PartB.getValue()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include <android/log.h>
|
||||
#include <jni.h>
|
||||
#include <string>
|
||||
#include "jni/JniConvertors.hpp"
|
||||
|
||||
#include "LogManager.hpp"
|
||||
#include "api/LogManagerImpl.hpp"
|
||||
|
@ -139,3 +140,24 @@ Java_com_microsoft_applications_events_maesdktest_TestStub_runNativeTests(
|
|||
{
|
||||
return RunTests::run_all_tests(env, logger);
|
||||
}
|
||||
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_microsoft_applications_events_maesdktest_SDKUnitNativeTest_nativeGetPiiType(
|
||||
JNIEnv *env,
|
||||
jobject thiz,
|
||||
jobject jProperty) {
|
||||
auto property = GetEventProperty(env, jProperty);
|
||||
return static_cast<int>(property.piiKind);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_microsoft_applications_events_maesdktest_SDKUnitNativeTest_nativeGetDataCategory(
|
||||
JNIEnv *env,
|
||||
jobject thiz,
|
||||
jobject jProperty) {
|
||||
auto property = GetEventProperty(env, jProperty);
|
||||
return static_cast<int>(property.dataCategory);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ public enum DataCategory {
|
|||
m_value = value;
|
||||
}
|
||||
|
||||
int getValue() {
|
||||
public int getValue() {
|
||||
return m_value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,16 @@ public class EventProperty {
|
|||
return m_piiKind;
|
||||
}
|
||||
|
||||
@Keep
|
||||
int getPiiKindValue() {
|
||||
return m_piiKind.getValue();
|
||||
}
|
||||
|
||||
@Keep
|
||||
int getDataCategoryValue() {
|
||||
return m_category.getValue();
|
||||
}
|
||||
|
||||
DataCategory getDataCategory() {
|
||||
return m_category;
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ public enum PiiKind {
|
|||
m_value = value;
|
||||
}
|
||||
|
||||
int getValue() {
|
||||
public int getValue() {
|
||||
return m_value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,11 @@ EventProperty GetEventProperty(JNIEnv* env, const jobject& jEventProperty) {
|
|||
jobject jEventPropertyValue = env->CallObjectMethod(jEventProperty, getEventPropertyValueMethodID);
|
||||
|
||||
jclass jEventPropertyValueClass = env->GetObjectClass(jEventPropertyValue);
|
||||
auto getPiiKindValue = env->GetMethodID(jEventPropertyClass, "getPiiKindValue", "()I");
|
||||
auto jPiiKind = env->CallIntMethod(jEventProperty, getPiiKindValue);
|
||||
auto getDataCategoryValue = env->GetMethodID(jEventPropertyClass, "getDataCategoryValue", "()I");
|
||||
auto jDataCategory = env->CallIntMethod(jEventProperty, getDataCategoryValue);
|
||||
|
||||
jmethodID getTypeMethodID = env->GetMethodID(jEventPropertyValueClass, "getType", "()I");
|
||||
jint type = env->CallIntMethod(jEventPropertyValue, getTypeMethodID);
|
||||
|
||||
|
@ -138,7 +143,11 @@ EventProperty GetEventProperty(JNIEnv* env, const jobject& jEventProperty) {
|
|||
env->DeleteLocalRef(jEventPropertyValue);
|
||||
env->DeleteLocalRef(jEventPropertyClass);
|
||||
|
||||
return (eventProperty);
|
||||
// The value assignment above (in the switch() statement) clears piiKind
|
||||
// and dataCategory, so we have assign these here, after that assignment.
|
||||
eventProperty.piiKind = static_cast<PiiKind>(jPiiKind);
|
||||
eventProperty.dataCategory = static_cast<DataCategory>(jDataCategory);
|
||||
return eventProperty;
|
||||
}
|
||||
|
||||
EventProperties GetEventProperties(JNIEnv* env, const jstring& jstrEventName, const jstring& jstrEventType, const jint& jEventLatency,
|
||||
|
|
|
@ -835,4 +835,4 @@ Java_com_microsoft_applications_events_LogManager_00024LogConfigurationImpl_roun
|
|||
|
||||
ConfigConstructor builder(env);
|
||||
return builder.mapTranslate(*logConfiguration);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче