Skip to content

A Kotlin Android BroadcastReceiver implementation that facilitates log collection and sharing between Android applications and the Neat Log Aggregator service.

License

Notifications You must be signed in to change notification settings

neat-no/neatlogsample

Repository files navigation

NeatLogSampleBroadcastReceiver

A Kotlin Android BroadcastReceiver implementation that facilitates log collection and sharing between Android applications and the Neat Log Aggregator service.

Overview

The NeatLogSampleBroadcastReceiver enables applications to participate in centralized log collection by responding to broadcast intents from the Neat Log Aggregator service and sharing log files securely using Android's FileProvider API.

Setup Requirements

1. AndroidManifest.xml Configuration

Add the following FileProvider configuration to your AndroidManifest.xml:

<provider
    android:name=".NeatLogSampleFileProvider"
    android:authorities="${applicationId}.fileprovider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/file_paths" />
</provider>

<queries>
    <package android:name="no.neat.logaggregator" />
</queries>

2. File Paths Configuration

Create a file at res/xml/file_paths.xml with the following content:

<paths>
    <files-path name="neatlog" path="neatlog/" />
</paths>

3. Broadcast Registration

Register the receiver in the manifest for the following actions:

  • no.neat.logaggregator.ACTION_LOG_COLLECTION_REGISTER
  • no.neat.logaggregator.ACTION_RECEIVE_LOGS
  • no.neat.logaggregator.ACTION_LOG_COLLECTION_COMPLETED

If you register via context then keep in mind that you will not receive any broadcast for these actions unless your apps process is running. (Even if your app is in the bg it will receive)

Intent Actions Reference

Incoming Actions

  • ACTION_LOG_COLLECTION_REGISTER: Initiates registration
  • ACTION_RECEIVE_LOGS: Requests log files
  • ACTION_LOG_COLLECTION_COMPLETED: Signals completion

Outgoing Actions

  • ACTION_RECEIVE_LOG_ACTION_REGISTER_REQUEST: Registration request
  • ACTION_SEND_LOGS: Sends log file URIs

Intent Extras

  • EXTRA_LOG_COLLECTION_PACKAGE_NAME: Sender's package name
  • EXTRA_LOG_COLLECTION_IDEMPOTENCY_KEY: Unique collection ID
  • EXTRA_LOG_COLLECTION_FILE_URIS: Array of file URIs

Testing

To test the log collection functionality:

  1. Install the sample app on a Neat device
  2. Trigger log collection using one of these methods:
    • From Pulse:
      • Navigate to the device page
      • Click "Submit logs" button
    • From Remote Access:
      • Navigate to the device page
      • Click "Generate logs" button
  3. The log collection process will start automatically and files will be shared with the Log Aggregator service

About

A Kotlin Android BroadcastReceiver implementation that facilitates log collection and sharing between Android applications and the Neat Log Aggregator service.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages