Java Code Examples for android.os.IBinder#DeathRecipient

The following examples show how to use android.os.IBinder#DeathRecipient . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomTabsService.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@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;
    }
}
 
Example 2
Source File: CustomTabsService.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@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;
    }
}
 
Example 3
Source File: CustomTabsService.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@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;
    }
}
 
Example 4
Source File: CustomTabsService.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@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;
    }
}
 
Example 5
Source File: CustomTabsService.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@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;
    }
}
 
Example 6
Source File: CustomTabsService.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@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;
    }
}
 
Example 7
Source File: MediaProjectionManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public MediaProjectionManagerService(Context context) {
    super(context);
    mContext = context;
    mDeathEaters = new ArrayMap<IBinder, IBinder.DeathRecipient>();
    mCallbackDelegate = new CallbackDelegate();
    mAppOps = (AppOpsManager) mContext.getSystemService(Context.APP_OPS_SERVICE);
    mMediaRouter = (MediaRouter) mContext.getSystemService(Context.MEDIA_ROUTER_SERVICE);
    mMediaRouterCallback = new MediaRouterCallback();
    Watchdog.getInstance().addMonitor(this);
}
 
Example 8
Source File: MediaProjectionManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private void addCallback(final IMediaProjectionWatcherCallback callback) {
    IBinder.DeathRecipient deathRecipient = new IBinder.DeathRecipient() {
        @Override
        public void binderDied() {
            removeCallback(callback);
        }
    };
    synchronized (mLock) {
        mCallbackDelegate.add(callback);
        linkDeathRecipientLocked(callback, deathRecipient);
    }
}
 
Example 9
Source File: MediaProjectionManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private void linkDeathRecipientLocked(IMediaProjectionWatcherCallback callback,
        IBinder.DeathRecipient deathRecipient) {
    try {
        final IBinder token = callback.asBinder();
        token.linkToDeath(deathRecipient, 0);
        mDeathEaters.put(token, deathRecipient);
    } catch (RemoteException e) {
        Slog.e(TAG, "Unable to link to death for media projection monitoring callback", e);
    }
}
 
Example 10
Source File: MediaProjectionManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private void unlinkDeathRecipientLocked(IMediaProjectionWatcherCallback callback) {
    final IBinder token = callback.asBinder();
    IBinder.DeathRecipient deathRecipient = mDeathEaters.remove(token);
    if (deathRecipient != null) {
        token.unlinkToDeath(deathRecipient, 0);
    }
}
 
Example 11
Source File: MediaProjectionManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override // Binder call
public void start(final IMediaProjectionCallback callback) {
    if (callback == null) {
        throw new IllegalArgumentException("callback must not be null");
    }
    synchronized (mLock) {
        if (isValidMediaProjection(asBinder())) {
            throw new IllegalStateException(
                    "Cannot start already started MediaProjection");
        }
        mCallback = callback;
        registerCallback(mCallback);
        try {
            mToken = callback.asBinder();
            mDeathEater = new IBinder.DeathRecipient() {
                @Override
                public void binderDied() {
                    mCallbackDelegate.remove(callback);
                    stop();
                }
            };
            mToken.linkToDeath(mDeathEater, 0);
        } catch (RemoteException e) {
            Slog.w(TAG,
                    "MediaProjectionCallbacks must be valid, aborting MediaProjection", e);
            return;
        }
        startProjectionLocked(this);
    }
}
 
Example 12
Source File: ServiceManagerNative.java    From container with GNU General Public License v3.0 5 votes vote down vote up
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();
	}
}
 
Example 13
Source File: ServiceItem.java    From DroidService with GNU Lesser General Public License v3.0 5 votes vote down vote up
ServiceItem(String name, IBinder binder, Intent intent, IBinder.DeathRecipient recipient, String callingPackage, int callingPid, int callingUid) {
    this.name = name;
    this.callingPid = callingPid;
    this.callingUid = callingUid;
    this.binder = binder;
    this.intent = intent;
    this.recipient = recipient;
}
 
Example 14
Source File: SpeakEasyTest.java    From android-test with Apache License 2.0 5 votes vote down vote up
@Override
public void linkToDeath(IBinder.DeathRecipient death, int flags) {
  if (dead) {
    throw new RuntimeException("I daed");
  }
  this.death = death;
}
 
Example 15
Source File: ICameraDeviceUserWrapper.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
public void unlinkToDeath(IBinder.DeathRecipient recipient, int flags) {
    if (mRemoteDevice.asBinder() != null) {
        mRemoteDevice.asBinder().unlinkToDeath(recipient, flags);
    }
}
 
Example 16
Source File: SpeakEasy.java    From android-test with Apache License 2.0 4 votes vote down vote up
Holder(IBinder binder, IBinder.DeathRecipient death) {
  this.binder = binder;
  this.death = death;
}