static public IServiceManager asInterface(IBinder obj) {
// obj为BinderProxy对象
if (obj == null) {
return null;
}
// BinderProxy对象的该方法默认返回null
IServiceManager in = (IServiceManager)obj.queryLocalInterface(descriptor);
if (in != null) {
return in;
}
return new ServiceManagerProxy(obj);
}
由上述代码可知ServiceManagerNative.asInterface(new BinderProxy()) 等价于new ServiceManagerProxy(new BinderProxy())。