照旧按照教程来,自己画了一下韦老师那个图:
1、创建 IIoctrlJ25Service.aidl 放在/frameworks/base/core/java/android/os/
package android.os;
/** {@hide} */
interface IIoctrlJ25Service
{
int IoctrlJ25(int which,int status);
}
修改/frameworks/base下的Android.mk,修改完就可以 mmm /frameworks/base ,完成以后你获得一份系统生成的文件out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/os/IIoctrlJ25Service.java 其中最后一部分
static final int TRANSACTION_IoctrlJ25 = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
}
public int IoctrlJ25(int which, int status) throws android.os.RemoteException;
}
与接口文件接口相同。
2、 创建完成IoctrlJ25Service.java,放在frameworks/base/services/core/java/com/android/server/IoctrlJ25Service.java
package com.android.server;
import android.os.IIoctrlJ25Service;
import android.util.Log;
public class IoctrlJ25Service extends IIoctrlJ25Service.Stub {
private static final String TAG = "IoctrlJ25Service";
/* call native c function to access hardware */
public int IoctrlJ25(int which, int status) throws android.os.RemoteException
{
Log.i(TAG,"IO "+which+" status"+status);
return native_ioctrlj25_ctl(which, status);
}
public IoctrlJ25Service() {
int ret = native_ioctrlj25_open();
Log.i(TAG,"native_ioctrlj25_open ret="+ret);
}
public static native int native_ioctrlj25_open();
public static native void native_ioctrlj25_close();
public static native int native_ioctrlj25_ctl(int which, int status);
}
注意IoctrlJ25该接口方法要与上边保持一致