Creating an android service with no name but package

26 views Asked by At

I've a third party library doing the next:

static void connectService(Context context) {
        Intent intent = new Intent();
        intent.setPackage("com.one.package");
        intent.setAction("com.one.package.action");            
        context.bindService(intent, 1, mExecutor, mConnection);
        waitForServiceReady(context);
    }

So, this library is supposed to run in a custom rom that already have that service implemented, but, would be possible to run it in any emulator creating the service by myself?

So far I have tried it with this

<service
    android:name="com.one.package.Service"
    android:exported="true"
    tools:ignore="ExportedService">
    <intent-filter>
        <action android:name="com.one.package.action" />
    </intent-filter>
</service>

That class implements an interface of the expected Service class

class Service : Service() {

inner class ServiceBinder : Binder() {
    fun getService(): Service =
        service //This is an object created that implements expected service
}

override fun onBind(intent: Intent): IBinder =
    ServiceBinder().getService().asBinder()

override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
    when (intent?.action) {
        "com.one.package.action" -> {
            //No-op
        }
    }
    return super.onStartCommand(intent, flags, startId)
}

}

But bindService is always returning false. So my guess is, is not possible to do what I'm trying?

0

There are 0 answers