Skip to content

Commit

Permalink
Merge pull request iqiyi#18 from iqiyi/fixInitBug
Browse files Browse the repository at this point in the history
improved init action for dispatcherProxy before in any cases it used
  • Loading branch information
HiWong authored Jun 12, 2018
2 parents 6ed1300 + c570dda commit 95354a3
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ public class Constants {

public static final String REMOTE_GUARD_SERVICE_MODULE = "RemoteGuardServiceModule";

public static final String APPLE_MODULE = "apple";

public static final String CHERRY_MODULE = "cherry";

//public static final String APPLE_PROCESS_SEVICE_ACTION ="qiyi://apple/process/stub";

//public static final String PLUGIN1_PROCESS_SERVICE_ACTION="qiyi://plugin1/process/stub";

public static final String APPLE_PROCESS_SEVICE_ACTION = "qiyi.apple.process.stub";

public static final String PLUGIN1_PROCESS_SERVICE_ACTION = "qiyi.plugin1.process.stub";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public BinderBean getTargetBinderLocked(String serviceCanonicalName) throws Remo
@Override
public void registerRemoteServiceLocked(final String serviceCanonicalName, String processName,
IBinder binder) throws RemoteException {
Log.d(TAG, "ServiceDispatcher-->registerStubServiceLocked,serviceCanonicalName:" + serviceCanonicalName + ",pid:" + android.os.Process.myPid() + ",thread:" + Thread.currentThread().getName());
Log.d(TAG, "ServiceDispatcher-->registerRemoteServiceLocked,serviceCanonicalName:" + serviceCanonicalName + ",pid:" + android.os.Process.myPid() + ",thread:" + Thread.currentThread().getName());
if (binder != null) {
binder.linkToDeath(new IBinder.DeathRecipient() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public class RemoteTransfer extends IRemoteTransfer.Stub implements IRemoteServi
public static void init(Context context) {
getInstance().setContext(context);

//如果是主进程就可以直接调用ServiceDispatcher
getInstance().sendRegisterInfo();
}

Expand Down Expand Up @@ -93,7 +92,7 @@ public void setContext(Context context) {
this.context = context;
}

//让ServiceDispatcher注册到当前进程
//让ServiceDispatcher反向注册到当前进程
private synchronized void sendRegisterInfo() {
if (dispatcherProxy == null) {
//后面考虑还是采用"has-a"的方式会更好
Expand All @@ -106,13 +105,7 @@ private synchronized void sendRegisterInfo() {
}
}

@Override
public synchronized BinderBean getRemoteServiceBean(String serviceCanonicalName) {
Logger.d("RemoteTransfer-->getRemoteServiceBean,pid=" + android.os.Process.myPid() + ",thread:" + Thread.currentThread().getName());
BinderBean cacheBinderBean = serviceTransfer.getIBinderFromCache(context, serviceCanonicalName);
if (cacheBinderBean != null) {
return cacheBinderBean;
}
private void initDispatchProxyLocked() {
if (null == dispatcherProxy) {
IBinder dispatcherBinder = getIBinderFromProvider();
if (null != dispatcherBinder) {
Expand All @@ -126,9 +119,20 @@ public synchronized BinderBean getRemoteServiceBean(String serviceCanonicalName)
try {
wait(MAX_WAIT_TIME);
} catch (InterruptedException ex) {
Logger.e("Attention! Wait out of time!");
ex.printStackTrace();
}
}
}

@Override
public synchronized BinderBean getRemoteServiceBean(String serviceCanonicalName) {
Logger.d("RemoteTransfer-->getRemoteServiceBean,pid=" + android.os.Process.myPid() + ",thread:" + Thread.currentThread().getName());
BinderBean cacheBinderBean = serviceTransfer.getIBinderFromCache(context, serviceCanonicalName);
if (cacheBinderBean != null) {
return cacheBinderBean;
}
initDispatchProxyLocked();
if (serviceTransfer == null || dispatcherProxy == null) {
return null;
}
Expand All @@ -151,7 +155,6 @@ private IBinder getIBinderFromProvider() {
Logger.d("RemoteTransfer-->getIBinderFromProvider()");
Cursor cursor = null;
try {

cursor = context.getContentResolver().query(getDispatcherProviderUri(), DispatcherProvider.PROJECTION_MAIN,
null, null, null);
if (cursor == null) {
Expand All @@ -165,6 +168,7 @@ private IBinder getIBinderFromProvider() {

@Override
public synchronized void registerStubService(String serviceCanonicalName, IBinder stubBinder) {
initDispatchProxyLocked();
serviceTransfer.registerStubServiceLocked(serviceCanonicalName, stubBinder, context, dispatcherProxy, this);
}

Expand All @@ -176,6 +180,7 @@ public synchronized void registerStubService(String serviceCanonicalName, IBinde
*/
@Override
public synchronized void unregisterStubService(String serviceCanonicalName) {
initDispatchProxyLocked();
serviceTransfer.unregisterStubServiceLocked(serviceCanonicalName, context, dispatcherProxy);
}

Expand All @@ -193,6 +198,7 @@ public synchronized void unsubscribeEvent(EventListener listener) {

@Override
public synchronized void publish(Event event) {
initDispatchProxyLocked();
eventTransfer.publishLocked(event, dispatcherProxy, this, context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void notifyLocked(Event event) {
Logger.d("EventTransfer-->notifyLocked,pid:" + android.os.Process.myPid() + ",event.name:" + event.getName());
List<WeakReference<EventListener>> listeners = eventListeners.get(event.getName());
if (listeners == null) {
Logger.d("There is no listeners for " + event.getName()+ " in pid "+android.os.Process.myPid());
Logger.d("There is no listeners for " + event.getName() + " in pid " + android.os.Process.myPid());
return;
}
for (int i = listeners.size() - 1; i >= 0; --i) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
/*
* Copyright (c) 2018-present, iQIYI, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
* Copyright (c) 2018-present, iQIYI, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package org.qiyi.video.svg.transfer.service;

import android.content.Context;
Expand Down Expand Up @@ -98,7 +98,6 @@ public void unregisterStubServiceLocked(String serviceCanonicalName, Context con
Intent intent = new Intent(context, DispatcherService.class);
intent.setAction(Constants.DISPATCH_UNREGISTER_SERVICE_ACTION);
intent.putExtra(Constants.KEY_SERVICE_NAME, serviceCanonicalName);
//setProcessInfo(intent, context);
ServiceUtils.startServiceSafely(context, intent);
} else {
try {
Expand Down
2 changes: 1 addition & 1 deletion CHINESE_README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Andromeda
![Andromeda_license](https://img.shields.io/badge/license-BSD--3--Clause-brightgreen.svg)
![Andromeda_core_tag](https://img.shields.io/badge/Andromeda%20Core-1.1.6-brightgreen.svg)
![Andromeda_core_tag](https://img.shields.io/badge/Andromeda%20Core-1.1.7-brightgreen.svg)
![Andromeda_plugin_tag](https://img.shields.io/badge/Andromeda%20plugin-1.1.1-brightgreen.svg)

Andromeda提供了接口式的组件间通信管理,包括同进程的本地接口调用和跨进程接口调用。
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Andromeda
![Andromeda_license](https://img.shields.io/badge/license-BSD--3--Clause-brightgreen.svg)
![Andromeda_core_tag](https://img.shields.io/badge/Andromeda%20Core-1.1.6-brightgreen.svg)
![Andromeda_core_tag](https://img.shields.io/badge/Andromeda%20Core-1.1.7-brightgreen.svg)
![Andromeda_plugin_tag](https://img.shields.io/badge/Andromeda%20plugin-1.1.1-brightgreen.svg)

Andromeda provides communication among modules for both local and remote service.
Expand Down
3 changes: 0 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ dependencies {

implementation 'com.android.support:design:26.0.2'

//implementation "org.qiyi.video.svg:core:$maven_config.core_build_version"
//implementation project(":Andromeda-Plugin")

implementation 'com.android.support:appcompat-v7:26.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
Expand Down
2 changes: 0 additions & 2 deletions applemodule/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.0.2'

api project(":moduleexportlib")
//api project(':Andromeda-Lib')
//implementation "org.qiyi.video.svg:core:$maven_config.core_build_version"

implementation 'com.android.support:appcompat-v7:26.0.2'
testImplementation 'junit:junit:4.12'
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ buildscript {
'userName':USER_NAME,
'groupId':GROUP_ID,
'passWord':PASS_WORD,
'version_code':116,
'version_name':'1.1.6',
'core_build_version':'1.1.6',
'version_code':117,
'version_name':'1.1.7',
'core_build_version':'1.1.7',
'plugin_build_version':'1.1.1'
]

Expand Down
2 changes: 0 additions & 2 deletions cherrymodule/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

api project(":moduleexportlib")
//api project(':Andromeda-Lib')
//implementation "org.qiyi.video.svg:core:$maven_config.core_build_version"

implementation 'com.android.support:appcompat-v7:26.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
Expand Down
3 changes: 1 addition & 2 deletions moduleexportlib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ uploadArchives{
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

//compile project(':Andromeda-Lib')
//api project(':Andromeda-Lib')
api "org.qiyi.video.svg:core:$maven_config.core_build_version"


compileOnly 'com.android.support:appcompat-v7:26.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
Expand Down

0 comments on commit 95354a3

Please sign in to comment.