mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-05 10:58:23 +00:00
test aidl
This commit is contained in:
@@ -155,6 +155,7 @@ android {
|
|||||||
buildFeatures {
|
buildFeatures {
|
||||||
compose true
|
compose true
|
||||||
buildConfig true
|
buildConfig true
|
||||||
|
aidl true
|
||||||
}
|
}
|
||||||
|
|
||||||
packagingOptions {
|
packagingOptions {
|
||||||
|
|||||||
@@ -30,10 +30,22 @@
|
|||||||
android:usesCleartextTraffic="true"
|
android:usesCleartextTraffic="true"
|
||||||
android:windowSoftInputMode="adjustResize"
|
android:windowSoftInputMode="adjustResize"
|
||||||
tools:targetApi="33">
|
tools:targetApi="33">
|
||||||
|
<service
|
||||||
|
android:name=".nostr_nip55_signer"
|
||||||
|
android:enabled="true"
|
||||||
|
android:exported="true"
|
||||||
|
>
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="nostr_nip55_signer" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
</service>
|
||||||
|
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".service.KillSwitchReceiver"
|
android:name=".service.KillSwitchReceiver"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="false"></receiver>
|
android:exported="false" />
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".service.ReconnectReceiver"
|
android:name=".service.ReconnectReceiver"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// INostrSigner.aidl
|
||||||
|
package com.greenart7c3.nostrsigner;
|
||||||
|
|
||||||
|
// Declare any non-default types here with import statements
|
||||||
|
|
||||||
|
interface INostrSigner {
|
||||||
|
String getPublicKey();
|
||||||
|
String signEvent(String unsigned_event);
|
||||||
|
String nip44Encrypt(String current_user_public_key, String public_key, String plaintext);
|
||||||
|
String nip44Decrypt(String current_user_public_key, String public_key, String ciphertext);
|
||||||
|
}
|
||||||
@@ -184,6 +184,7 @@ class Amber : Application(), LifecycleObserver {
|
|||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
|
|
||||||
isStartingApp.value = true
|
isStartingApp.value = true
|
||||||
|
|
||||||
Log.d(TAG, "onCreate Amber")
|
Log.d(TAG, "onCreate Amber")
|
||||||
@@ -233,29 +234,31 @@ class Amber : Application(), LifecycleObserver {
|
|||||||
client.disconnect()
|
client.disconnect()
|
||||||
}
|
}
|
||||||
launch(Dispatchers.Main) {
|
launch(Dispatchers.Main) {
|
||||||
ProcessLifecycleOwner.get().lifecycle.addObserver(object : DefaultLifecycleObserver {
|
ProcessLifecycleOwner.get().lifecycle.addObserver(
|
||||||
override fun onStart(owner: LifecycleOwner) {
|
object : DefaultLifecycleObserver {
|
||||||
Log.d("ProcessLifecycleOwner", "App in foreground")
|
override fun onStart(owner: LifecycleOwner) {
|
||||||
isAppInForeground = true
|
Log.d("ProcessLifecycleOwner", "App in foreground")
|
||||||
|
isAppInForeground = true
|
||||||
|
|
||||||
// activates the profile filter only when the app is in the foreground
|
// activates the profile filter only when the app is in the foreground
|
||||||
if (!settings.killSwitch.value) {
|
if (!settings.killSwitch.value) {
|
||||||
applicationIOScope.launch {
|
applicationIOScope.launch {
|
||||||
profileSubscription.updateFilter()
|
profileSubscription.updateFilter()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
override fun onStop(owner: LifecycleOwner) {
|
override fun onStop(owner: LifecycleOwner) {
|
||||||
Log.d("ProcessLifecycleOwner", "App in background")
|
Log.d("ProcessLifecycleOwner", "App in background")
|
||||||
isAppInForeground = false
|
isAppInForeground = false
|
||||||
|
|
||||||
// closes the filter when in the background
|
// closes the filter when in the background
|
||||||
applicationIOScope.launch {
|
applicationIOScope.launch {
|
||||||
profileSubscription.closeSub()
|
profileSubscription.closeSub()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
})
|
)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e(TAG, "Failed to run migrations", e)
|
Log.e(TAG, "Failed to run migrations", e)
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package com.greenart7c3.nostrsigner
|
||||||
|
|
||||||
|
import android.app.Service
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.IBinder
|
||||||
|
import android.util.Log
|
||||||
|
|
||||||
|
@Suppress("ClassName")
|
||||||
|
class nostr_nip55_signer : Service() {
|
||||||
|
override fun onCreate() {
|
||||||
|
Log.d("NostrSignerService", "Service class = ${this::class.qualifiedName}")
|
||||||
|
super.onCreate()
|
||||||
|
}
|
||||||
|
|
||||||
|
private val binder = object : INostrSigner.Stub() {
|
||||||
|
override fun getPublicKey(): String? {
|
||||||
|
Log.d(Amber.TAG, "getPublicKey")
|
||||||
|
val callingPackage = applicationContext.packageManager.getPackagesForUid(getCallingUid())?.firstOrNull()
|
||||||
|
|
||||||
|
Log.d(Amber.TAG, callingPackage ?: "")
|
||||||
|
|
||||||
|
return "123"
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun signEvent(unsigned_event: String?): String? {
|
||||||
|
Log.d(Amber.TAG, "signEvent")
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun nip44Encrypt(current_user_public_key: String?, public_key: String?, plaintext: String?): String? {
|
||||||
|
Log.d(Amber.TAG, "nip44Encrypt")
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun nip44Decrypt(current_user_public_key: String?, public_key: String?, ciphertext: String?): String? {
|
||||||
|
Log.d(Amber.TAG, "nip44Decrypt")
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBind(intent: Intent): IBinder {
|
||||||
|
return binder
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user