當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。