-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #136 from MetaMask/communication-client-tests
feat: Communication client tests
- Loading branch information
Showing
17 changed files
with
892 additions
and
52 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,17 @@ | ||
# Project-wide Gradle settings. | ||
# IDE (e.g. Android Studio) users: | ||
# Gradle settings configured through the IDE *will override* | ||
# any settings specified in this file. | ||
# For more details on how to configure your build environment visit | ||
## For more details on how to configure your build environment visit | ||
# http://www.gradle.org/docs/current/userguide/build_environment.html | ||
# | ||
# Specifies the JVM arguments used for the daemon process. | ||
# The setting is particularly useful for tweaking memory settings. | ||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 | ||
# Default value: -Xmx1024m -XX:MaxPermSize=256m | ||
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 | ||
# | ||
# When configured, Gradle will run in incubating parallel mode. | ||
# This option should only be used with decoupled projects. More details, visit | ||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects | ||
# This option should only be used with decoupled projects. For more details, visit | ||
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects | ||
# org.gradle.parallel=true | ||
# AndroidX package structure to make it clearer which packages are bundled with the | ||
# Android operating system, and which are packaged with your app's APK | ||
# https://developer.android.com/topic/libraries/support-library/androidx-rn | ||
android.disableAutomaticComponentCreation=true | ||
android.nonTransitiveRClass=true | ||
android.useAndroidX=true | ||
# Kotlin code style for this project: "official" or "obsolete": | ||
kotlin.code.style=official | ||
# Enables namespacing of each library's R class so that its R class includes only the | ||
# resources declared in the library itself and none from the library's dependencies, | ||
# thereby reducing the size of the R class for that library | ||
android.nonTransitiveRClass=true | ||
android.disableAutomaticComponentCreation=true | ||
org.gradle.jvmargs=-Xmx1536M -Dkotlin.daemon.jvm.options\="-Xmx1024M" -Dfile.encoding\=UTF-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
metamask-android-sdk/src/main/java/io/metamask/androidsdk/ClientMessageServiceCallback.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.metamask.androidsdk | ||
|
||
import android.os.Bundle | ||
import io.metamask.nativesdk.IMessegeServiceCallback | ||
|
||
open class ClientMessageServiceCallback( | ||
var onMessage: ((Bundle) -> Unit)? = null | ||
) : IMessegeServiceCallback.Stub() { | ||
override fun onMessageReceived(bundle: Bundle) { | ||
onMessage?.invoke(bundle) | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
metamask-android-sdk/src/main/java/io/metamask/androidsdk/ClientServiceConnection.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package io.metamask.androidsdk | ||
|
||
import android.content.ComponentName | ||
import android.content.ServiceConnection | ||
import android.os.Bundle | ||
import android.os.IBinder | ||
import io.metamask.nativesdk.IMessegeService | ||
import io.metamask.nativesdk.IMessegeServiceCallback | ||
|
||
open class ClientServiceConnection( | ||
var onConnected: (() -> Unit)? = null, | ||
var onDisconnected: ((ComponentName?) -> Unit)? = null, | ||
var onBindingDied: ((ComponentName?) -> Unit)? = null, | ||
var onNullBinding: ((ComponentName?) -> Unit)? = null | ||
) : ServiceConnection { | ||
private var messageService: IMessegeService? = null | ||
|
||
override fun onServiceConnected(name: ComponentName?, service: IBinder?) { | ||
messageService = IMessegeService.Stub.asInterface(service) | ||
onConnected?.invoke() | ||
} | ||
|
||
override fun onServiceDisconnected(name: ComponentName?) { | ||
onDisconnected?.invoke(name) | ||
} | ||
|
||
override fun onBindingDied(name: ComponentName?) { | ||
onBindingDied?.invoke(name) | ||
} | ||
|
||
override fun onNullBinding(name: ComponentName?) { | ||
onNullBinding?.invoke(name) | ||
} | ||
|
||
open fun registerCallback(callback: IMessegeServiceCallback) { | ||
messageService?.registerCallback(callback) | ||
} | ||
|
||
open fun sendMessage(bundle: Bundle) { | ||
messageService?.sendMessage(bundle) | ||
} | ||
} |
Oops, something went wrong.