当前位置: 首页>>代码示例>>Java>>正文


Java IBinder.linkToDeath方法代码示例

本文整理汇总了Java中android.os.IBinder.linkToDeath方法的典型用法代码示例。如果您正苦于以下问题:Java IBinder.linkToDeath方法的具体用法?Java IBinder.linkToDeath怎么用?Java IBinder.linkToDeath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.os.IBinder的用法示例。


在下文中一共展示了IBinder.linkToDeath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addPendingIntent

import android.os.IBinder; //导入方法依赖的package包/类
final void addPendingIntent(final IBinder binder, String creator) {
    synchronized (mLruHistory) {
        try {
            binder.linkToDeath(new IBinder.DeathRecipient() {
                @Override
                public void binderDied() {
                    binder.unlinkToDeath(this, 0);
                    mLruHistory.remove(binder);
                }
            }, 0);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
        PendingIntentData pendingIntentData = mLruHistory.get(binder);
        if (pendingIntentData == null) {
            mLruHistory.put(binder, new PendingIntentData(creator, binder));
        } else {
            pendingIntentData.creator = creator;
        }
    }
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:22,代码来源:PendingIntents.java

示例2: getPref

import android.os.IBinder; //导入方法依赖的package包/类
/**
 * @param context
 * @return
 * @throws RemoteException
 */
public static final IPref getPref(Context context) throws RemoteException {
    if (sPref == null) {
        if (IPC.isPersistentProcess()) {
            // 需要枷锁否?
            initPref();
        } else {
            IBinder b = PluginProviderStub.proxyFetchHostPref(context);
            b.linkToDeath(new DeathRecipient() {

                @Override
                public void binderDied() {
                    sPref = null;
                }
            }, 0);
            sPref = IPref.Stub.asInterface(b);
        }
    }
    return sPref;
}
 
开发者ID:wangyupeng1-iri,项目名称:springreplugin,代码行数:25,代码来源:PluginProviderStub.java

示例3: addService

import android.os.IBinder; //导入方法依赖的package包/类
@Override
public void addService(String serviceName, IBinder service)
		throws RemoteException {

	LogControler.info("ServiceManagerServer", "[svcmgr server] addService name = " + serviceName + " , service = " + service+ " , callingpid = " + Binder.getCallingPid());

	service.linkToDeath(new BinderServiceDeathRecipient(serviceName),0);
	clientServiceContainer.put(serviceName, service);

	//查看是否有listen这个服务的
	IServiceCallbackProxy serviceCallback = asyncClientServiceContainer.get(serviceName);

	if(serviceCallback!=null){
		try {
			LogControler.info("ServiceManagerServer", "[svcmgr server] addService onReady");
			serviceCallback.callback(service);
		} catch(Exception e){
			e.printStackTrace();
		}
	} else {
		LogControler.info("ServiceManagerServer", "[svcmgr server] addService serviceCallback not found");
	}
}
 
开发者ID:devyok,项目名称:IPCServiceManager,代码行数:24,代码来源:ServiceManagerServer.java

示例4: getServiceManager

import android.os.IBinder; //导入方法依赖的package包/类
IServiceManager getServiceManager(){
	if(serviceManager == null || !Utils.isAlive(serviceManager.asBinder())) {

		LogControler.info("ServiceManager", "[svcmgr proxy] recreate svcmgr object");

		IBinder svcmgr = BinderQuerier.query(sContext,IPC.SERVICE_MANAGER_URI,"server");

		try {
			svcmgr.linkToDeath(this,0);
		} catch(Exception e){
			e.printStackTrace();
		}

		serviceManager = IServiceManager.Stub.asInterface(svcmgr);
	}

	return serviceManager;
}
 
开发者ID:devyok,项目名称:IPCServiceManager,代码行数:19,代码来源:ServiceManager.java

示例5: onServiceConnected

import android.os.IBinder; //导入方法依赖的package包/类
public void onServiceConnected(ComponentName className, IBinder serviceBinder) {
    try {
        synchronized (AbstractServiceHandler.this) {
            AbstractServiceHandler.this.service = initService(serviceBinder);
            if (AbstractServiceHandler.this.service != null) {
                connected = true;
                AbstractServiceHandler.this.notifyAll();
            }
        }
        serviceBinder.linkToDeath(new IBinder.DeathRecipient() {
            @Override
            public void binderDied() {
                connectToService();
            }
        }, 0);
        AbstractServiceHandler.this.onServiceConnected();
    } catch (Exception ex) {
        Log.w(TAG, ex);
    }
}
 
开发者ID:josesamuel,项目名称:serviceconnector,代码行数:21,代码来源:AbstractServiceHandler.java

示例6: call

import android.os.IBinder; //导入方法依赖的package包/类
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
    MethodParameterUtils.replaceFirstAppPkg(args);
    args[IDX_RequiredPermission] = null;
    IntentFilter filter = (IntentFilter) args[IDX_IntentFilter];
    SpecialComponentList.protectIntentFilter(filter);
    if (args.length > IDX_IIntentReceiver && IIntentReceiver.class.isInstance(args[IDX_IIntentReceiver])) {
        final IInterface old = (IInterface) args[IDX_IIntentReceiver];
        if (!IIntentReceiverProxy.class.isInstance(old)) {
            final IBinder token = old.asBinder();
            if (token != null) {
                token.linkToDeath(new IBinder.DeathRecipient() {
                    @Override
                    public void binderDied() {
                        token.unlinkToDeath(this, 0);
                        mProxyIIntentReceivers.remove(token);
                    }
                }, 0);
                IIntentReceiver proxyIIntentReceiver = mProxyIIntentReceivers.get(token);
                if (proxyIIntentReceiver == null) {
                    proxyIIntentReceiver = new IIntentReceiverProxy(old);
                    mProxyIIntentReceivers.put(token, proxyIIntentReceiver);
                }
                WeakReference mDispatcher = LoadedApk.ReceiverDispatcher.InnerReceiver.mDispatcher.get(old);
                if (mDispatcher != null) {
                    LoadedApk.ReceiverDispatcher.mIIntentReceiver.set(mDispatcher.get(), proxyIIntentReceiver);
                    args[IDX_IIntentReceiver] = proxyIIntentReceiver;
                }
            }
        }
    }
    return method.invoke(who, args);
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:34,代码来源:MethodProxies.java

示例7: linkBinderDied

import android.os.IBinder; //导入方法依赖的package包/类
private static void linkBinderDied(final IBinder binder) {
	IBinder.DeathRecipient deathRecipient = new IBinder.DeathRecipient() {
		@Override
		public void binderDied() {
			binder.unlinkToDeath(this, 0);
		}
	};
	try {
		binder.linkToDeath(deathRecipient, 0);
	} catch (RemoteException e) {
		e.printStackTrace();
	}
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:14,代码来源:ServiceManagerNative.java

示例8: createLocalServiceManager

import android.os.IBinder; //导入方法依赖的package包/类
static ServiceManagerImpl createLocalServiceManager(Context context,IBinder remoteServiceManager){
	ServiceManagerImpl serviceManager = new ServiceManagerImpl(context,remoteServiceManager);
	
	try {
		remoteServiceManager.linkToDeath(serviceManager, 0);
	} catch (RemoteException e) {
		e.printStackTrace(); //ignore
	}
	
	serviceManager.managedSelf(context.getPackageName());
	
	return serviceManager;
}
 
开发者ID:devyok,项目名称:DroidIPC,代码行数:14,代码来源:ServiceManagerImpl.java

示例9: ProcessRecord

import android.os.IBinder; //导入方法依赖的package包/类
private ProcessRecord(int pid, IBinder deathMonitor) {
    this.pid = pid;
    this.deathMonitor = deathMonitor;
    try {
        deathMonitor.linkToDeath(this, 0);
    } catch (RemoteException e) {
        if (DEBUG) {
            Log.d(TAG, "Error when linkToDeath: ");
        }
    }
    refCount = 1;
}
 
开发者ID:wangyupeng1-iri,项目名称:springreplugin,代码行数:13,代码来源:PluginServiceRecord.java

示例10: installBinder

import android.os.IBinder; //导入方法依赖的package包/类
@Override
public void installBinder(String name, IBinder binder) throws RemoteException {
    if (LOG) {
        LogDebug.d(PLUGIN_TAG, "install binder: n=" + name + " b=" + binder);
    }
    synchronized (PluginProcessMain.sBinders) {
        if (binder != null) {
            PluginProcessMain.sBinders.put(name, binder);
            binder.linkToDeath(new BinderDied(name, binder), 0);
        } else {
            PluginProcessMain.sBinders.remove(name);
        }
    }
}
 
开发者ID:wangyupeng1-iri,项目名称:springreplugin,代码行数:15,代码来源:PmHostSvc.java

示例11: create

import android.os.IBinder; //导入方法依赖的package包/类
static IServiceManager create(Context context) {

			sContext = context;

			IBinder svcmgr = BinderQuerier.query(context,IPC.SERVICE_MANAGER_URI,"server");

			RemoteServiceManagerProxy proxy = new RemoteServiceManagerProxy(svcmgr);
			try {
				svcmgr.linkToDeath(proxy,0);
			} catch(Exception e){
				e.printStackTrace();
			}
			return proxy;
		}
 
开发者ID:devyok,项目名称:IPCServiceManager,代码行数:15,代码来源:ServiceManager.java

示例12: proxy

import android.os.IBinder; //导入方法依赖的package包/类
public static IBinder proxy(String serviceName,IBinder target) {
	BinderProxy binderProxy = new BinderProxy(serviceName,target);
	try {
		target.linkToDeath(binderProxy, 0);
	} catch (RemoteException e) {
		e.printStackTrace();
	}
	return binderProxy;
}
 
开发者ID:devyok,项目名称:IPCServiceManager,代码行数:10,代码来源:BinderProxy.java

示例13: linkBinderDied

import android.os.IBinder; //导入方法依赖的package包/类
private static void linkBinderDied(final IBinder binder) {
    IBinder.DeathRecipient deathRecipient = new IBinder.DeathRecipient() {
        @Override
        public void binderDied() {
            binder.unlinkToDeath(this, 0);
        }
    };
    try {
        binder.linkToDeath(deathRecipient, 0);
    } catch (RemoteException e) {
        e.printStackTrace();
    }
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:14,代码来源:ServiceManagerNative.java

示例14: call

import android.os.IBinder; //导入方法依赖的package包/类
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
    HookUtils.replaceFirstAppPkg(args);
    args[IDX_RequiredPermission] = null;
    IntentFilter filter = (IntentFilter) args[IDX_IntentFilter];
    IntentFilter backupFilter = new IntentFilter(filter);
    protectIntentFilter(filter);
    if (args.length > IDX_IIntentReceiver && IIntentReceiver.class.isInstance(args[IDX_IIntentReceiver])) {
        final IInterface old = (IInterface) args[IDX_IIntentReceiver];
        if (!IIntentReceiverProxy.class.isInstance(old)) {
            final IBinder token = old.asBinder();
            if (token != null) {
                token.linkToDeath(new IBinder.DeathRecipient() {
                    @Override
                    public void binderDied() {
                        token.unlinkToDeath(this, 0);
                        mProxyIIntentReceivers.remove(token);
                    }
                }, 0);
                IIntentReceiver proxyIIntentReceiver = mProxyIIntentReceivers.get(token);
                if (proxyIIntentReceiver == null) {
                    proxyIIntentReceiver = new IIntentReceiverProxy(old);
                    mProxyIIntentReceivers.put(token, proxyIIntentReceiver);
                }
                WeakReference mDispatcher = LoadedApk.ReceiverDispatcher.InnerReceiver.mDispatcher.get(old);
                if (mDispatcher != null) {
                    LoadedApk.ReceiverDispatcher.mIIntentReceiver.set(mDispatcher.get(), proxyIIntentReceiver);
                    args[IDX_IIntentReceiver] = proxyIIntentReceiver;
                }
            }
        }
    }
    Object res = method.invoke(who, args);
    Intent intent = VActivityManager.get().dispatchStickyBroadcast(backupFilter);
    if (intent != null) {
        return intent;
    }
    return res;
}
 
开发者ID:codehz,项目名称:container,代码行数:40,代码来源:RegisterReceiver.java

示例15: doConnected

import android.os.IBinder; //导入方法依赖的package包/类
public void doConnected(ComponentName name, IBinder service) {
        ServiceDispatcher.ConnectionInfo old;
        ServiceDispatcher.ConnectionInfo info;

        synchronized (this) {
            if (mForgotten) {
                // We unbound before receiving the connection; ignore
                // any connection received.
                return;
            }
            old = mActiveConnections.get(name);
            if (old != null && old.binder == service) {
                // Huh, already have this one.  Oh well!
                return;
            }

            if (service != null) {
                // A new service is being connected... set it all up.
//                mDied = false;
                info = new ConnectionInfo();
                info.binder = service;
                info.deathMonitor = new DeathMonitor(name, service);
                try {
                    service.linkToDeath(info.deathMonitor, 0);
                    mActiveConnections.put(name, info);
                } catch (RemoteException e) {
                    // This service was dead before we got it...  just
                    // don't do anything with it.
                    mActiveConnections.remove(name);
                    return;
                }

            } else {
                // The named service is being disconnected... clean up.
                mActiveConnections.remove(name);
            }

            if (old != null) {
                old.binder.unlinkToDeath(old.deathMonitor, 0);
            }
        }

        // If there was an old service, it is not disconnected.
        if (old != null) {
            mConnection.onServiceDisconnected(name);
        }
        // If there is a new service, it is now connected.
        if (service != null) {
            mConnection.onServiceConnected(name, service);
        }
    }
 
开发者ID:wangyupeng1-iri,项目名称:springreplugin,代码行数:52,代码来源:ServiceDispatcher.java


注:本文中的android.os.IBinder.linkToDeath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。