Skip to content

Commit 5a511c3

Browse files
setTicketToken exposed to jni and java layer for Android apps to set tokens like AAD (#1131)
* Expose the setTicketToken to jni and java layer for Android apps to set Tokens like AAD with the event * Fix the fucntion call for jni * Fixed comments
1 parent 0f06e94 commit 5a511c3

File tree

5 files changed

+46
-0
lines changed

5 files changed

+46
-0
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public interface ILogManager extends AutoCloseable {
2323

2424
public Status resumeTransmission();
2525

26+
public Status setTicketToken(TicketType type, final String tokenValue);
27+
2628
public Status setTransmitProfile(TransmitProfile profile);
2729

2830
public Status setTransmitProfile(String profile);

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

+15
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,21 @@ public static Status resumeTransmission() {
495495
return Status.getEnum(nativeResumeTransmission());
496496
}
497497

498+
private static native int nativeSetIntTicketToken(int type, final String tokenValue);
499+
500+
/**
501+
* Sets the token ID with the value.
502+
*
503+
* @param type Type of token(like AAD etc)
504+
* @param tokenValue Value of the token
505+
* @return Status enum corresponding to the native API execution status_t.
506+
*/
507+
public static Status setTicketToken(TicketType type, final String tokenValue) {
508+
if (type == null) throw new IllegalArgumentException("type is null");
509+
510+
return Status.getEnum(nativeSetIntTicketToken(type.getValue(), tokenValue));
511+
}
512+
498513
private static native int nativeSetIntTransmitProfile(int profile);
499514

500515
/**

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

+7
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ public Status resumeTransmission() {
8686
return Status.getEnum(nativeResumeTransmission(nativeLogManager));
8787
}
8888

89+
protected native int nativeSetIntTicketToken(long nativeLogManager, int type, final String tokenValue);
90+
91+
@Override
92+
public Status setTicketToken(TicketType type, final String tokenValue) {
93+
return Status.getEnum(nativeSetIntTicketToken(nativeLogManager, type.getValue(), tokenValue));
94+
}
95+
8996
protected native int nativeSetTransmitProfileTP(long nativeLogManager, int profile);
9097

9198
@Override

lib/include/public/LogManagerBase.hpp

+10
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,16 @@ namespace MAT_NS_BEGIN
585585
static IAuthTokensController* GetAuthTokensController()
586586
LM_SAFE_CALL_PTR(GetAuthTokensController);
587587

588+
/// <summary>
589+
///Sets the ticket token with a value
590+
/// </summary>
591+
static status_t SetTicketToken(TicketType type, const std::string& tokenValue)
592+
{
593+
if (isHost())
594+
LM_SAFE_CALL(GetAuthTokensController()->SetTicketToken, type, tokenValue.c_str());
595+
return STATUS_EPERM; // Permission denied
596+
}
597+
588598
/// <summary>
589599
/// Obtain event filter collection.
590600
/// Notes:

lib/jni/LogManager_jni.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,18 @@ extern "C"
9494
return static_cast<jint>(WrapperLogManager::ResumeTransmission());
9595
}
9696

97+
JNIEXPORT jint JNICALL
98+
Java_com_microsoft_applications_events_LogManager_nativeSetIntTicketToken(
99+
JNIEnv* env,
100+
jclass /* this */,
101+
jint jType,
102+
jstring jstrTokenValue)
103+
{
104+
auto ticketValue = JStringToStdString(env, jstrTokenValue);
105+
return static_cast<jint>(WrapperLogManager::SetTicketToken(
106+
static_cast<TicketType>(jType), ticketValue));
107+
}
108+
97109
JNIEXPORT jint JNICALL
98110
Java_com_microsoft_applications_events_LogManager_nativeSetIntTransmitProfile(
99111
JNIEnv* /* env */,

0 commit comments

Comments
 (0)