frameworks/base/core/java/android/os下面加aidl文件和frameworks/base/core/java/android/app下面加aidl文件有什么区别,不清楚

interface ICarSignalManager {     void setBacklightState(boolean state);}

在frameworks/base/services/java的com.android.server下面

public class CarSignalManagerService extends ICarSignalManager.Stub {         ......}

在SystemServer的ServerThread的run方法中

ServiceManager.addService(Context.CAR_SIGNAL_SERVICE, new CarSignalManagerService(context));

上面的方法涉及到ServiceManager,我们这里根据那个addService来跟踪下:

    public static void addService(String name, IBinder service) {        try {            getIServiceManager().addService(name, service);        } catch (RemoteException e) {            Log.e(TAG, "error in addService", e);        }    }

IServiceManager的实现类:ServiceManagerNative和ServiceManagerProxy这两个又有什么区别呢?

服务调用的地方

public CarSignalManager(Context context) {IBinder b = ServiceManager.getService(Context.CAR_SIGNAL_SERVICE);if (b == null) {throw new RuntimeException("Car Signal service not available!");}mService = ICarSignalManager.Stub.asInterface(b);}

CarSignalManager carSignalManager = (CarSignalManager) mContext.getSystemService(Context.CAR_SIGNAL_SERVICE);carSignalManager.setBacklightState(false);


ApplicationContext中

 @Override    public Object getSystemService(String name) {...if (CAR_SIGNAL_SERVICE.equals(name)) {            return getCarSignalManager();}...}


更多相关文章

  1. android图片压缩的3种方法实例
  2. Android Selector和Shape的使用方法
  3. android内核编译方法
  4. View类xml属性、方法
  5. 【Android 开发】:UI控件之显示图片控件 ImageView 的使用方法
  6. Android与JavaScript方法相互调用!
  7. Android 系统音量最大值的定义位置以及默认值的修改方法

随机推荐

  1. Android(安卓)Property System | Android
  2. android studio 使用adb命令传递文件到an
  3. Android™ 2.1 android.R.drawable Icon
  4. Android(安卓)Studio点击按钮更换背景图
  5. Android(安卓)Treble 简介
  6. android scroller类的使用
  7. android相关
  8. ch020 Android(安卓)SQLite3(第二部分)
  9. android中ImageView、ImageButton、Butto
  10. Android(安卓)进度条