Java Code Examples for android.os.Messenger#getBinder()

The following examples show how to use android.os.Messenger#getBinder() . 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: MediaRouteProviderProtocol.java    From cwac-mediarouter with Apache License 2.0 5 votes vote down vote up
/**
 * Returns true if the messenger object is valid.
 * <p>
 * The messenger constructor and unparceling code does not check whether the
 * provided IBinder is a valid IMessenger object.  As a result, it's possible
 * for a peer to send an invalid IBinder that will result in crashes downstream.
 * This method checks that the messenger is in a valid state.
 * </p>
 */
public static boolean isValidRemoteMessenger(Messenger messenger) {
    try {
        return messenger != null && messenger.getBinder() != null;
    } catch (NullPointerException ex) {
        // If the messenger was constructed with a binder interface other than
        // IMessenger then the call to getBinder() will crash with an NPE.
        return false;
    }
}
 
Example 2
Source File: PushRegisterService.java    From android_packages_apps_GmsCore with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public IBinder onBind(Intent intent) {
    Log.d(TAG, "onBind: " + intent.toString());
    if (ACTION_C2DM_REGISTER.equals(intent.getAction())) {
        Messenger messenger = new Messenger(new PushRegisterHandler(this, database));
        return messenger.getBinder();
    }
    return super.onBind(intent);
}
 
Example 3
Source File: SocksVpnService.java    From Xndroid with GNU General Public License v3.0 4 votes vote down vote up
@Override
public IBinder onBind(Intent intent) {
    Messenger messenger = new Messenger(new SockHandler());
    return messenger.getBinder();
}
 
Example 4
Source File: ChromePrerenderService.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
public IBinder onBind(Intent intent) {
    mMessenger = new Messenger(new IncomingHandler(getApplicationContext()));
    return mMessenger.getBinder();
}
 
Example 5
Source File: ChromePrerenderService.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
public IBinder onBind(Intent intent) {
    mMessenger = new Messenger(new IncomingHandler(getApplicationContext()));
    return mMessenger.getBinder();
}
 
Example 6
Source File: ChromePrerenderService.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public IBinder onBind(Intent intent) {
    mMessenger = new Messenger(new IncomingHandler(getApplicationContext()));
    return mMessenger.getBinder();
}
 
Example 7
Source File: MediaRouteProviderService.java    From cwac-mediarouter with Apache License 2.0 4 votes vote down vote up
public boolean hasMessenger(Messenger other) {
    return mMessenger.getBinder() == other.getBinder();
}