类android.os.IBinder.DeathRecipient源码实例Demo

下面列出了怎么用android.os.IBinder.DeathRecipient的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: TelePlus-Android   文件: CustomTabsService.java
@Override
public boolean newSession(ICustomTabsCallback callback) {
    final CustomTabsSessionToken sessionToken = new CustomTabsSessionToken(callback);
    try {
        DeathRecipient deathRecipient = new IBinder.DeathRecipient() {
            @Override
            public void binderDied() {
                cleanUpSession(sessionToken);
            }
        };
        synchronized (mDeathRecipientMap) {
            callback.asBinder().linkToDeath(deathRecipient, 0);
            mDeathRecipientMap.put(callback.asBinder(), deathRecipient);
        }
        return CustomTabsService.this.newSession(sessionToken);
    } catch (RemoteException e) {
        return false;
    }
}
 
源代码2 项目: TelePlus-Android   文件: CustomTabsService.java
@Override
public boolean newSession(ICustomTabsCallback callback) {
    final CustomTabsSessionToken sessionToken = new CustomTabsSessionToken(callback);
    try {
        DeathRecipient deathRecipient = new IBinder.DeathRecipient() {
            @Override
            public void binderDied() {
                cleanUpSession(sessionToken);
            }
        };
        synchronized (mDeathRecipientMap) {
            callback.asBinder().linkToDeath(deathRecipient, 0);
            mDeathRecipientMap.put(callback.asBinder(), deathRecipient);
        }
        return CustomTabsService.this.newSession(sessionToken);
    } catch (RemoteException e) {
        return false;
    }
}
 
源代码3 项目: springreplugin   文件: PluginProviderStub.java
/**
 * @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;
}
 
源代码4 项目: AndroidChromium   文件: CustomTabsService.java
@Override
public boolean newSession(ICustomTabsCallback callback) {
    final CustomTabsSessionToken sessionToken = new CustomTabsSessionToken(callback);
    try {
        DeathRecipient deathRecipient = new IBinder.DeathRecipient() {
            @Override
            public void binderDied() {
                cleanUpSession(sessionToken);
            }
        };
        synchronized (mDeathRecipientMap) {
            callback.asBinder().linkToDeath(deathRecipient, 0);
            mDeathRecipientMap.put(callback.asBinder(), deathRecipient);
        }
        return CustomTabsService.this.newSession(sessionToken);
    } catch (RemoteException e) {
        return false;
    }
}
 
源代码5 项目: 365browser   文件: CustomTabsService.java
@Override
public boolean newSession(ICustomTabsCallback callback) {
    final CustomTabsSessionToken sessionToken = new CustomTabsSessionToken(callback);
    try {
        DeathRecipient deathRecipient = new IBinder.DeathRecipient() {
            @Override
            public void binderDied() {
                cleanUpSession(sessionToken);
            }
        };
        synchronized (mDeathRecipientMap) {
            callback.asBinder().linkToDeath(deathRecipient, 0);
            mDeathRecipientMap.put(callback.asBinder(), deathRecipient);
        }
        return CustomTabsService.this.newSession(sessionToken);
    } catch (RemoteException e) {
        return false;
    }
}
 
源代码6 项目: Telegram-FOSS   文件: CustomTabsService.java
@Override
public boolean newSession(ICustomTabsCallback callback) {
    final CustomTabsSessionToken sessionToken = new CustomTabsSessionToken(callback);
    try {
        DeathRecipient deathRecipient = new IBinder.DeathRecipient() {
            @Override
            public void binderDied() {
                cleanUpSession(sessionToken);
            }
        };
        synchronized (mDeathRecipientMap) {
            callback.asBinder().linkToDeath(deathRecipient, 0);
            mDeathRecipientMap.put(callback.asBinder(), deathRecipient);
        }
        return CustomTabsService.this.newSession(sessionToken);
    } catch (RemoteException e) {
        return false;
    }
}
 
源代码7 项目: Telegram   文件: CustomTabsService.java
@Override
public boolean newSession(ICustomTabsCallback callback) {
    final CustomTabsSessionToken sessionToken = new CustomTabsSessionToken(callback);
    try {
        DeathRecipient deathRecipient = new IBinder.DeathRecipient() {
            @Override
            public void binderDied() {
                cleanUpSession(sessionToken);
            }
        };
        synchronized (mDeathRecipientMap) {
            callback.asBinder().linkToDeath(deathRecipient, 0);
            mDeathRecipientMap.put(callback.asBinder(), deathRecipient);
        }
        return CustomTabsService.this.newSession(sessionToken);
    } catch (RemoteException e) {
        return false;
    }
}
 
源代码8 项目: android_9.0.0_r45   文件: Installer.java
private void connect() {
    IBinder binder = ServiceManager.getService("installd");
    if (binder != null) {
        try {
            binder.linkToDeath(new DeathRecipient() {
                @Override
                public void binderDied() {
                    Slog.w(TAG, "installd died; reconnecting");
                    connect();
                }
            }, 0);
        } catch (RemoteException e) {
            binder = null;
        }
    }

    if (binder != null) {
        mInstalld = IInstalld.Stub.asInterface(binder);
        try {
            invalidateMounts();
        } catch (InstallerException ignored) {
        }
    } else {
        Slog.w(TAG, "installd not found; trying again");
        BackgroundThread.getHandler().postDelayed(() -> {
            connect();
        }, DateUtils.SECOND_IN_MILLIS);
    }
}
 
源代码9 项目: TelePlus-Android   文件: CustomTabsService.java
/**
 * Called when the client side {@link IBinder} for this {@link CustomTabsSessionToken} is dead.
 * Can also be used to clean up {@link DeathRecipient} instances allocated for the given token.
 *
 * @param sessionToken The session token for which the {@link DeathRecipient} call has been
 *                     received.
 * @return Whether the clean up was successful. Multiple calls with two tokens holdings the
 * same binder will return false.
 */
protected boolean cleanUpSession(CustomTabsSessionToken sessionToken) {
    try {
        synchronized (mDeathRecipientMap) {
            IBinder binder = sessionToken.getCallbackBinder();
            DeathRecipient deathRecipient =
                    mDeathRecipientMap.get(binder);
            binder.unlinkToDeath(deathRecipient, 0);
            mDeathRecipientMap.remove(binder);
        }
    } catch (NoSuchElementException e) {
        return false;
    }
    return true;
}
 
源代码10 项目: TelePlus-Android   文件: CustomTabsService.java
/**
 * Called when the client side {@link IBinder} for this {@link CustomTabsSessionToken} is dead.
 * Can also be used to clean up {@link DeathRecipient} instances allocated for the given token.
 *
 * @param sessionToken The session token for which the {@link DeathRecipient} call has been
 *                     received.
 * @return Whether the clean up was successful. Multiple calls with two tokens holdings the
 * same binder will return false.
 */
protected boolean cleanUpSession(CustomTabsSessionToken sessionToken) {
    try {
        synchronized (mDeathRecipientMap) {
            IBinder binder = sessionToken.getCallbackBinder();
            DeathRecipient deathRecipient =
                    mDeathRecipientMap.get(binder);
            binder.unlinkToDeath(deathRecipient, 0);
            mDeathRecipientMap.remove(binder);
        }
    } catch (NoSuchElementException e) {
        return false;
    }
    return true;
}
 
源代码11 项目: AndroidChromium   文件: CustomTabsService.java
/**
 * Called when the client side {@link IBinder} for this {@link CustomTabsSessionToken} is dead.
 * Can also be used to clean up {@link DeathRecipient} instances allocated for the given token.
 * @param sessionToken The session token for which the {@link DeathRecipient} call has been
 *                     received.
 * @return Whether the clean up was successful. Multiple calls with two tokens holdings the
 *         same binder will return false.
 */
protected boolean cleanUpSession(CustomTabsSessionToken sessionToken) {
    try {
        synchronized (mDeathRecipientMap) {
           IBinder binder = sessionToken.getCallbackBinder();
           DeathRecipient deathRecipient =
                   mDeathRecipientMap.get(binder);
           binder.unlinkToDeath(deathRecipient, 0);
           mDeathRecipientMap.remove(binder);
       }
    } catch (NoSuchElementException e) {
        return false;
    }
    return true;
}
 
源代码12 项目: custom-tabs-client   文件: CustomTabsService.java
private boolean newSessionInternal(ICustomTabsCallback callback, PendingIntent sessionId) {
    final CustomTabsSessionToken sessionToken =
            new CustomTabsSessionToken(callback, sessionId);
    try {
        DeathRecipient deathRecipient = () -> cleanUpSession(sessionToken);
        synchronized (mDeathRecipientMap) {
            callback.asBinder().linkToDeath(deathRecipient, 0);
            mDeathRecipientMap.put(callback.asBinder(), deathRecipient);
        }
        return CustomTabsService.this.newSession(sessionToken);
    } catch (RemoteException e) {
        return false;
    }
}
 
源代码13 项目: custom-tabs-client   文件: CustomTabsService.java
/**
 * Called when the client side {@link IBinder} for this {@link CustomTabsSessionToken} is dead.
 * Can also be used to clean up {@link DeathRecipient} instances allocated for the given token.
 *
 * @param sessionToken The session token for which the {@link DeathRecipient} call has been
 *                     received.
 * @return Whether the clean up was successful. Multiple calls with two tokens holdings the
 * same binder will return false.
 */
protected boolean cleanUpSession(CustomTabsSessionToken sessionToken) {
    try {
        synchronized (mDeathRecipientMap) {
            IBinder binder = sessionToken.getCallbackBinder();
            DeathRecipient deathRecipient =
                    mDeathRecipientMap.get(binder);
            binder.unlinkToDeath(deathRecipient, 0);
            mDeathRecipientMap.remove(binder);
        }
    } catch (NoSuchElementException e) {
        return false;
    }
    return true;
}
 
源代码14 项目: 365browser   文件: CustomTabsService.java
/**
 * Called when the client side {@link IBinder} for this {@link CustomTabsSessionToken} is dead.
 * Can also be used to clean up {@link DeathRecipient} instances allocated for the given token.
 *
 * @param sessionToken The session token for which the {@link DeathRecipient} call has been
 *                     received.
 * @return Whether the clean up was successful. Multiple calls with two tokens holdings the
 * same binder will return false.
 */
protected boolean cleanUpSession(CustomTabsSessionToken sessionToken) {
    try {
        synchronized (mDeathRecipientMap) {
            IBinder binder = sessionToken.getCallbackBinder();
            DeathRecipient deathRecipient =
                    mDeathRecipientMap.get(binder);
            binder.unlinkToDeath(deathRecipient, 0);
            mDeathRecipientMap.remove(binder);
        }
    } catch (NoSuchElementException e) {
        return false;
    }
    return true;
}
 
源代码15 项目: Telegram-FOSS   文件: CustomTabsService.java
/**
 * Called when the client side {@link IBinder} for this {@link CustomTabsSessionToken} is dead.
 * Can also be used to clean up {@link DeathRecipient} instances allocated for the given token.
 *
 * @param sessionToken The session token for which the {@link DeathRecipient} call has been
 *                     received.
 * @return Whether the clean up was successful. Multiple calls with two tokens holdings the
 * same binder will return false.
 */
protected boolean cleanUpSession(CustomTabsSessionToken sessionToken) {
    try {
        synchronized (mDeathRecipientMap) {
            IBinder binder = sessionToken.getCallbackBinder();
            DeathRecipient deathRecipient =
                    mDeathRecipientMap.get(binder);
            binder.unlinkToDeath(deathRecipient, 0);
            mDeathRecipientMap.remove(binder);
        }
    } catch (NoSuchElementException e) {
        return false;
    }
    return true;
}
 
源代码16 项目: Telegram   文件: CustomTabsService.java
/**
 * Called when the client side {@link IBinder} for this {@link CustomTabsSessionToken} is dead.
 * Can also be used to clean up {@link DeathRecipient} instances allocated for the given token.
 *
 * @param sessionToken The session token for which the {@link DeathRecipient} call has been
 *                     received.
 * @return Whether the clean up was successful. Multiple calls with two tokens holdings the
 * same binder will return false.
 */
protected boolean cleanUpSession(CustomTabsSessionToken sessionToken) {
    try {
        synchronized (mDeathRecipientMap) {
            IBinder binder = sessionToken.getCallbackBinder();
            DeathRecipient deathRecipient =
                    mDeathRecipientMap.get(binder);
            binder.unlinkToDeath(deathRecipient, 0);
            mDeathRecipientMap.remove(binder);
        }
    } catch (NoSuchElementException e) {
        return false;
    }
    return true;
}
 
源代码17 项目: letv   文件: MyFakeIBinder.java
public void linkToDeath(DeathRecipient deathRecipient, int i) throws RemoteException {
}
 
源代码18 项目: letv   文件: MyFakeIBinder.java
public boolean unlinkToDeath(DeathRecipient deathRecipient, int i) {
    return false;
}
 
 类所在包
 同包方法