1.在frameworks下添加,其目录如下:
1.1 添加IDemoManager.aidl文件
//mls_demo
// IDemoManager.aidl
package android.app;
// Declare any non-default types here with import statements
interface IDemoManager {
int plus(int a, int b);
}
1.2 添加 DemoManager.java文件
//mls_demo
package android.app;
import android.annotation.SystemService;
import android.content.Context;
import android.compat.annotation.UnsupportedAppUsage;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Log;
import android.util.Singleton;
@SystemService(Context.DEMO_SERVICE)
public class DemoManager {
private static String TAG = "DemoManager";
/**
* @hide
*/
@UnsupportedAppUsage
public static IDemoManager getService() {
return IDemoManagerSingleton.get();
}
@UnsupportedAppUsage
private static final Singleton<IDemoManager> IDemoManagerSingleton =
new Singleton<IDemoManager>() {
@Override
protected IDemoManager create() {
final IBinder b = ServiceManager.getService(Context.DEMO_SERVICE);
fina