正文
+ output.processManifest.manifestOutputDirectory.absolutePath
output.processManifest.outputs.files.each { File file ->
if
((file.name.equalsIgnoreCase(
"AndroidManifest.xml"
) && !file.isDirectory()) || file.isDirectory()) {
if
(file.isDirectory()) {
injectManifestFile(
new
File(file,
"AndroidManifest.xml"
))
}
else
{
injectManifestFile(file)
}
}
}
}
}
}
}
}
其内会写入三种文件
def static final STUB_SERVICE = 'org.qiyi.video.svg.stub.CommuStubService$CommuStubService'
xml.application {
int index = 0
//每个进程都声明使用这个CommuStubService文件
customProcessNames.each {
//加上序号,$CommuStuService会替换成数字
String serviceName = "${STUB_SERVICE}" + index.toString()
service("${NAME}": serviceName,
"${ENABLED}": "${TRUE}",
"${EXPORTED}": "${FALSE}",
"${PROCESS}": it
)
if (matchedServices == null) {
matchedServices = new HashMap<>()
}
matchedServices.put(it, serviceName)
++index
}
这里DipatcherService和DipatchProvider是binder的中转管理控件,默认配置到主进程。
//配置进程地址
this.dispatcher = project.extensions.getByType(DispatcherExtension)
//之后,写入DispatcherService和DispatcherProvider
def dispatcherProcess = dispatcher.process
println "dispatcher.process:" + dispatcher.process
if (dispatcherProcess != null && dispatcherProcess.length() > 0) {
service("${NAME}": DISPATCHER_SERVICE,
"${ENABLED}": "${TRUE}",
"${EXPORTED}": "${FALSE}",
"${PROCESS}": dispatcherProcess
)
provider(
"${AUTHORITIES}": getAuthority(),
"${EXPORTED}": "${FALSE}",
"${NAME}": DISPTACHER_PROVIDER,
"${ENABLED}": "${TRUE}",
"${PROCESS}": dispatcherProcess
)
} else {
service("${NAME}": DISPATCHER_SERVICE,
"${ENABLED}": "${TRUE}",
"${EXPORTED}": "${FALSE}"
)
provider(
"${AUTHORITIES}": getAuthority(),
"${EXPORTED}": "${FALSE}",
"${NAME}": DISPTACHER_PROVIDER,
"${ENABLED}": "${TRUE}"
)
}
正如通信所涉及的必要的几个步骤
1.注册
2.发其通信
3.binder间的相互绑定
4.binder间传输数据
首先注册,通过公共的Andromeda入口注册提供远程沟通的服务
Andromeda.getInstance().registerRemoteService(IBuyApple.class, BuyAppleImpl.getInstance());
public static <T extends IBinder> void registerRemoteService(Class serviceClass, T stubBinder)