The following aidl code is available:
Package Android. hardware;
Import Android. content. context;
/**
* {@ Hide}
*/
Interface ieinkctlservice
{
Boolean updatemodelock (Boolean acquired, context );
Int retrieveworkmode ();
Boolean switchworkmode (INT mode );
}
Always prompts couldn't find import for class android. content. Context during compilation
It seems that the context class is not found, but we all know that android. content. context does exist.
I searched the internet and found many people who encountered this problem.
In fact, to understand this problem, we need to first understand what classes are required and can be imported into aidl.
Refer to the Section in Chapter 8th of the complete handout on Android/ophone development:
"The aidl service only supports a limited number of data types. Therefore, if you use the aidl service to transmit some complex data, you need to perform further processing. The aidl Service supports the following data types:
Java simple type (INT, Char, Boolean, etc ). Import is not required ).
String and charsequence. Import is not required ).
List and map. Note that the element types of list and map objects must be data types supported by aidl. Import is not required ).
The API automatically generated by aidl. Import is required ).
Class that implements the Android. OS. parcelable interface. Import is required ).
The next two data types need to be imported using import, which will be detailed later in this chapter.
The method for passing data types that do not require import is the same. The procedure for passing a value of the data type to be imported (for example, a class implementing the Android. OS. parcelable Interface) is slightly complicated. In addition to creating a class that implements the Android. OS. parcelable interface, you also need to create an aidl file for this class and define it using the parcelable keyword ."
It should be clear that the context class is not a class that implements the parcelable interface, nor does it have a corresponding aidl file, so it cannot be imported in aidl.
In addition, there is a "method" on the Internet, that is, adding local_aidl_includes :=$ (frameworks_base_java_src_dirs) in frameworks/base/Android. mk with local_aidl_includes := the location of the class to be imported. In fact, this "method" is also restricted by the import rules mentioned above. A class that does not implement the parcelable interface is powerless.