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 api (83) —— InputMethodSession [输入法]
  2. android图片压缩的3种方法实例
  3. android客户端程序访问服务器端webservice,几篇不错的文章!
  4. Android之Handler用法总结
  5. Android(安卓)Selector和Shape的使用方法
  6. android内核编译方法
  7. Android(安卓)Handler机制
  8. Android(安卓)Studio failed to open by giving error “Files L
  9. android:configChanges属性总结

随机推荐

  1. sqlserver数据库出现置疑的解决思路
  2. MSSQL 2005/2008 日志压缩清理方法小结
  3. SQL Server游标的使用/关闭/释放/优化小
  4. Sql学习第四天——SQL 关于with cube,wit
  5. sql server 还原数据库时提示数据库正在
  6. sqlserver中delete、update中使用表别名
  7. Sql学习第三天——SQL 关于CTE(公用表达
  8. Sql学习第三天——SQL 关于with ties介绍
  9. Sql学习第二天——SQL DML与CTE概述
  10. Sql学习第一天——SQL 将变量定义为Table