Skip to content

[Android] Expose IDataViewer as public Java API - #1534

Open
KartikDhawaniya wants to merge 1 commit into
microsoft:mainfrom
KartikDhawaniya:user/kdhawaniya/android-idataviewer-api
Open

[Android] Expose IDataViewer as public Java API#1534
KartikDhawaniya wants to merge 1 commit into
microsoft:mainfrom
KartikDhawaniya:user/kdhawaniya/android-idataviewer-api

Conversation

@KartikDhawaniya

Copy link
Copy Markdown

Summary

Expose the native 1DS IDataViewer extension point through the Android Java/JNI API so Android consumers can register a product-owned viewer without changing the bundled DefaultDataViewer implementation.

This enables consumers such as Teams Android to keep broad Network Security Configuration cleartext traffic disabled while owning any product-specific diagnostic transport outside the SDK.

Changes

  • Add the public Android IDataViewer callback contract.
  • Add registerDataViewer and unregisterDataViewer to ILogManager and LogManagerProvider.LogManagerImpl.
  • Add a JNI-backed C++ IDataViewer proxy that:
    • retains the Java implementation with a global reference;
    • attaches native SDK worker threads to the JVM when required;
    • forwards encoded packet payloads as byte[];
    • caches a stable viewer name;
    • isolates and clears Java callback exceptions; and
    • releases JNI references deterministically.
  • Retain registered proxies per native LogManager and clean them up on unregister/close.
  • Reject invalid, empty, duplicate, or unknown viewer registrations with explicit failure results.
  • Add consumer R8/ProGuard rules for reverse-JNI callbacks.
  • Add Android instrumentation coverage for registration, duplicate rejection, callback dispatch, callback exception isolation, and unregistration.

Scope

This is an additive Android API bridge over the existing native extension point. It does not change:

  • production telemetry upload or routing;
  • endpoint selection or authentication;
  • the existing DefaultDataViewer APIs; or
  • product-specific transport, endpoint validation, queueing, retry, or feature-gating policy.

Validation

  • :maesdk:assembleDebug
  • :app:compileDebugAndroidTestJavaWithJavac
  • Native Android builds for arm64-v8a, armeabi-v7a, x86, and x86_64

The instrumentation test was compiled but not executed because no Android device was connected.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@KartikDhawaniya
KartikDhawaniya requested a review from a team as a code owner September 11, 2026 21:48
@KartikDhawaniya

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Microsoft"

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The public interface change breaks source compatibility, and callback lifecycle documentation and unregistration coverage need correction.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds a public Android/JNI bridge for registering product-owned IDataViewer implementations.

Changes:

  • Adds the Java callback API and LogManager registration methods.
  • Implements JNI proxy lifecycle, callback forwarding, and cleanup.
  • Adds shrinker rules and instrumentation coverage.
File summaries
File Description
lib/jni/LogManager_jni.cpp Manages viewer registration and cleanup.
lib/jni/JavaDataViewerProxy.hpp Declares the JNI viewer proxy.
lib/jni/JavaDataViewerProxy.cpp Implements Java callback forwarding.
lib/CMakeLists.txt Builds the new proxy source.
lib/android_build/maesdk/src/main/java/com/microsoft/applications/events/LogManagerProvider.java Implements Java registration APIs.
lib/android_build/maesdk/src/main/java/com/microsoft/applications/events/ILogManager.java Exposes registration publicly.
lib/android_build/maesdk/src/main/java/com/microsoft/applications/events/IDataViewer.java Defines the callback contract.
lib/android_build/maesdk/consumer-rules.pro Preserves reverse-JNI callback methods.
lib/android_build/app/src/androidTest/java/com/microsoft/applications/events/maesdktest/LogManagerDDVUnitTest.java Tests registration and dispatch behavior.
Review details
  • Files reviewed: 9/9 changed files
  • Comments generated: 3
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

* @return {@code true} when the viewer was registered, {@code false} for invalid input or a
* duplicate viewer name
*/
public boolean registerDataViewer(IDataViewer dataViewer);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KartikDhawaniya This is the most important comment from CoPilot to address

Comment on lines +333 to +334
assertThat(manager.unregisterDataViewer("receiving-viewer"), is(true));
assertThat(manager.unregisterDataViewer("receiving-viewer"), is(false));
Comment on lines +13 to +14
* Callbacks can occur on an SDK worker thread and should return promptly. Implementations must not
* register or unregister viewers from within a callback.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants