Example usage for android.os IBinder pingBinder

List of usage examples for android.os IBinder pingBinder

Introduction

In this page you can find the example usage for android.os IBinder pingBinder.

Prototype

public boolean pingBinder();

Source Link

Document

Check to see if the object still exists.

Usage

From source file:edu.umich.flowfence.service.Sandbox.java

private void unbind() {
    if (localLOGD) {
        Log.d(TAG, "unbind: " + this);
    }//from w  ww  .j av  a 2  s .co  m
    onBeforeDisconnect.fire(this, null);
    ISandboxService sandbox;
    synchronized (mSync) {
        sandbox = mSandboxService;
        mApplication.unbindService(mConnection);
    }

    if (sandbox != null) {
        handleDisconnected();
    } else {
        return;
    }

    synchronized (mSync) {
        // Ask it to terminate itself.
        try {
            IBinder binder = sandbox.asBinder();
            sandbox.kill();

            if (!binder.isBinderAlive()) {
                return;
            }

            int timeout = DEATH_PING_MAX;
            while (--timeout >= 0) {
                if (!binder.pingBinder() || !binder.isBinderAlive()) {
                    return;
                }
                SystemClock.sleep(DEATH_PING_INTERVAL);
            }
            throw new SecurityException("Sandbox process has not died");
        } catch (RemoteException e) {
            // Object's already dead, or we're getting a spurious TransactionTooLarge.
        }
    }
}