Search code examples
androidaidl

AIDL cannot find custom declared interface


I want to pass a Listener through a System Service in Android. I created my Listener Interface using AIDL.

Content of IStatusBarLostFocusCallback.aidl:

package com.android.internal.statusbar;

interface IStatusBarLostFocusCallback {
  void onLostFocus();
}

then I extended Androids IStatusBarService.aidl with following Function:

void setStatusBarLostFocusCallback(in IStatusBarLostFocusCallback listener);

and also imported my Interface (in the same directory)

import com.android.internal.statusbar.IStatusBarLostFocusCallback;

In Androids StatusBarManagerService, I extended this Interface since I read to do this in this Thread: Android remote service callbacks like this:

public interface StatusBarLostFocusCallback extends IStatusBarLostFocusCallback {
    public void onLostFocus();
}

Now I want to set the Listener with the setStatusBarLostFocusCallback which is defined in IStatusBarService.aidl and implemented in StatusBarManagerService.java.

However, when I try to compile the Framework, I get the following Error

out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/com/android/internal/statusbar/IStatusBarService.java:287: cannot find symbol
symbol  : class IStatusBarLostFocusCallback
location: package com.android.internal.statusbar
com.android.internal.statusbar.IStatusBarLostFocusCallback _arg0;

What have I missed. Do I have to write a .java for the IStatusBarLostFocusCallback? If so, what should be in there?


Solution

  • I managed it now. I forgot to add my AIDL to the Build in /frameworks/base/Android.mk (I did forget to mention I am building the Source). I now no longer extend the Interface but implement it like this:

    mBarService.setStatusBarLostFocusCallback(new IStatusBarLostFocusCallback.Stub(){
        public void onLostFocus(){
            mHasStatusbarFocus = false;
        }
    });