test aidl

This commit is contained in:
greenart7c3
2025-09-01 13:33:49 -03:00
parent 997f679d08
commit eed5ea3869
5 changed files with 89 additions and 18 deletions
+1
View File
@@ -155,6 +155,7 @@ android {
buildFeatures {
compose true
buildConfig true
aidl true
}
packagingOptions {
+13 -1
View File
@@ -30,10 +30,22 @@
android:usesCleartextTraffic="true"
android:windowSoftInputMode="adjustResize"
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
android:name=".service.KillSwitchReceiver"
android:enabled="true"
android:exported="false"></receiver>
android:exported="false" />
<receiver
android:name=".service.ReconnectReceiver"
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() {
super.onCreate()
isStartingApp.value = true
Log.d(TAG, "onCreate Amber")
@@ -233,29 +234,31 @@ class Amber : Application(), LifecycleObserver {
client.disconnect()
}
launch(Dispatchers.Main) {
ProcessLifecycleOwner.get().lifecycle.addObserver(object : DefaultLifecycleObserver {
override fun onStart(owner: LifecycleOwner) {
Log.d("ProcessLifecycleOwner", "App in foreground")
isAppInForeground = true
ProcessLifecycleOwner.get().lifecycle.addObserver(
object : DefaultLifecycleObserver {
override fun onStart(owner: LifecycleOwner) {
Log.d("ProcessLifecycleOwner", "App in foreground")
isAppInForeground = true
// activates the profile filter only when the app is in the foreground
if (!settings.killSwitch.value) {
applicationIOScope.launch {
profileSubscription.updateFilter()
// activates the profile filter only when the app is in the foreground
if (!settings.killSwitch.value) {
applicationIOScope.launch {
profileSubscription.updateFilter()
}
}
}
}
override fun onStop(owner: LifecycleOwner) {
Log.d("ProcessLifecycleOwner", "App in background")
isAppInForeground = false
override fun onStop(owner: LifecycleOwner) {
Log.d("ProcessLifecycleOwner", "App in background")
isAppInForeground = false
// closes the filter when in the background
applicationIOScope.launch {
profileSubscription.closeSub()
// closes the filter when in the background
applicationIOScope.launch {
profileSubscription.closeSub()
}
}
}
})
},
)
}
} catch (e: Exception) {
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
}
}