android_Service与Binder的关系
2014-04-03 14:53
274 查看
Service与Binder的关系:
客户端的服务无法注册为系统服务;客户端服务只能为该客户端服务;
系统定制,将自定义服务注册到SystemServer,需在开机过程中添加;位置frameworks/base/services/java/com/android/server/下SystemServer.java;
run方法中,ServiceManager.addService(Context.My_Service,new MyToolService(context));
Binder驱动代码运行在内核态,客户端通过系统调用完成的。
仅基于Binder类编写服务,但只是一部分。系统服务指可以使用getSystemService()方法获取的服务。
客户端的服务则必须基于Service类来编写。某一应用客户端服务不能为其他客户端应用提供服务(个人意见)。
android.app包,public abstract class Service extends ContextWrapper implements ComponentCallbacks2{ *** }
public class Application extends ContextWrapper implements ComponentCallbacks2{ *** }
public final class ActivityThread{ *** }
android.os包,public class Binder implements IBinder{ *** }
android.view包,public final class ViewRootImpl implements ViewParent,View.AttachInfo.Callbacks,HardwareRenderer.HardwareDrawCallbacks { *** }
public interface ViewParent{ *** }
com.android.server.am包,public final class ActivityManagerService extends ActivityManagerNative implements Watchdog.Monitor, BatteryStatsImpl.BatteryCallback{ *** }
com.android.server包,public class Watchdog extends Thread{ *** }
com.android.internal.os包,public final class BatteryStatsImpl extends BatteryStats{ *** }
android.os包,public interface IInterface{ public IBinder asBinder(); } #Base class for Binder interfaces. When defining a new interface,you must derive it from IInterface.
public interface IBinder{ *** } #Base interface for a remotable object, the core part of a lightweight remote procedure call mechanism designed for high performance when performing in-process and cross-process calls.
android.content包,public interface ServiceConnection{ *** } #mContext.bindService(**),需要传入ServiceConnection接口。
Service分类:LocalService;RemoteService;
Messenger:Reference to a Handler, which others can use to send messages to it. This allows for the implementation of message-based communication across processes, by creating a Messenger pointing to a Handler in one process, and handing that Messenger to
another process.
android:isolatedProcess="true" //If set to true, this service will run under a special process that is isolated from the rest of the system and has no permissions of its own. The only communication with it is through the Service API (binding and starting).
android:exported="false" //是否允许activity/Service能够跨进程调用;default为true;
android:permission="***" //其他应用必须也设置usepermission xxx.xxx.xx才能调用该activity/Service;
android:process=":remote" //代表新建进程;
android:enabled=""; //Whether or not the service can be instantiated by the system;
android:process=""; //The name of the process where the service is to run. Normally, all components of an application run in the default process created for the application.
客户端的服务无法注册为系统服务;客户端服务只能为该客户端服务;
系统定制,将自定义服务注册到SystemServer,需在开机过程中添加;位置frameworks/base/services/java/com/android/server/下SystemServer.java;
run方法中,ServiceManager.addService(Context.My_Service,new MyToolService(context));
Binder驱动代码运行在内核态,客户端通过系统调用完成的。
仅基于Binder类编写服务,但只是一部分。系统服务指可以使用getSystemService()方法获取的服务。
客户端的服务则必须基于Service类来编写。某一应用客户端服务不能为其他客户端应用提供服务(个人意见)。
android.app包,public abstract class Service extends ContextWrapper implements ComponentCallbacks2{ *** }
public class Application extends ContextWrapper implements ComponentCallbacks2{ *** }
public final class ActivityThread{ *** }
android.os包,public class Binder implements IBinder{ *** }
android.view包,public final class ViewRootImpl implements ViewParent,View.AttachInfo.Callbacks,HardwareRenderer.HardwareDrawCallbacks { *** }
public interface ViewParent{ *** }
com.android.server.am包,public final class ActivityManagerService extends ActivityManagerNative implements Watchdog.Monitor, BatteryStatsImpl.BatteryCallback{ *** }
com.android.server包,public class Watchdog extends Thread{ *** }
com.android.internal.os包,public final class BatteryStatsImpl extends BatteryStats{ *** }
android.os包,public interface IInterface{ public IBinder asBinder(); } #Base class for Binder interfaces. When defining a new interface,you must derive it from IInterface.
public interface IBinder{ *** } #Base interface for a remotable object, the core part of a lightweight remote procedure call mechanism designed for high performance when performing in-process and cross-process calls.
android.content包,public interface ServiceConnection{ *** } #mContext.bindService(**),需要传入ServiceConnection接口。
Service分类:LocalService;RemoteService;
Messenger:Reference to a Handler, which others can use to send messages to it. This allows for the implementation of message-based communication across processes, by creating a Messenger pointing to a Handler in one process, and handing that Messenger to
another process.
android:isolatedProcess="true" //If set to true, this service will run under a special process that is isolated from the rest of the system and has no permissions of its own. The only communication with it is through the Service API (binding and starting).
android:exported="false" //是否允许activity/Service能够跨进程调用;default为true;
android:permission="***" //其他应用必须也设置usepermission xxx.xxx.xx才能调用该activity/Service;
android:process=":remote" //代表新建进程;
android:enabled=""; //Whether or not the service can be instantiated by the system;
android:process=""; //The name of the process where the service is to run. Normally, all components of an application run in the default process created for the application.
相关文章推荐
- Android service binder aidl 关系
- Android 核心分析 之六 IPC框架分析 Binder,Service,Service manager
- Android Binder Mechanism (4) -- 如何使用已注册的系统Service
- Android中的Service:Binder,Messenger,AIDL(2)
- 有关Android中Service实现UI更新(Binder的运用)
- Android - Binder机制 - 普通service注册
- Android Binder机制的Native应用&&Android系统RPC与Binder && Android Service学习之AIDL, Parcelable和远程服务
- Android源码(10) --- Binder(4) ServiceManager 启动
- 【Android进阶】Android Binder之ServiceManager注册服务解析1
- Android 核心分析 之六 IPC框架分析 Binder,Service,Service manager(转)
- Android Binder Mechanism (4) -- 如何使用已注册的系统Service
- 浅谈Service Manager成为Android进程间通信(IPC)机制Binder守护进程之路
- Android Binder分析一:ServiceMananger的启动
- service manager和binder service的关系
- Android 核心分析 之六 -----IPC框架分析 Binder,Service,Service manager
- Android Binder机制 - defaultServiceManager()源码分析
- Android 核心分析 之六 -----IPC框架分析 Binder,Service,Service manager 收藏
- Android 绑定Service的实现方法一:扩展Binder类来构建接口
- Android 核心分析 之六 -----IPC框架分析 Binder,Service,Service manager
- 图解Android - Binder 和 Service