Search in sources :

Example 81 with Messenger

use of android.os.Messenger in project android_frameworks_base by DirtyUnicorns.

the class NsdManager method init.

/**
     * Initialize AsyncChannel
     */
private void init() {
    final Messenger messenger = getMessenger();
    if (messenger == null)
        throw new RuntimeException("Failed to initialize");
    HandlerThread t = new HandlerThread("NsdManager");
    t.start();
    mHandler = new ServiceHandler(t.getLooper());
    mAsyncChannel.connect(mContext, mHandler, messenger);
    try {
        mConnected.await();
    } catch (InterruptedException e) {
        Log.e(TAG, "interrupted wait at init");
    }
}
Also used : HandlerThread(android.os.HandlerThread) Messenger(android.os.Messenger)

Example 82 with Messenger

use of android.os.Messenger in project android_frameworks_base by DirtyUnicorns.

the class NetworkFactory method register.

public void register() {
    if (DBG)
        log("Registering NetworkFactory");
    if (mMessenger == null) {
        mMessenger = new Messenger(this);
        ConnectivityManager.from(mContext).registerNetworkFactory(mMessenger, LOG_TAG);
    }
}
Also used : Messenger(android.os.Messenger)

Example 83 with Messenger

use of android.os.Messenger in project android_frameworks_base by DirtyUnicorns.

the class AsyncChannel method connectSrcHandlerToPackageSync.

/**
     * Connect handler to named package/class synchronously.
     *
     * @param srcContext is the context of the source
     * @param srcHandler is the hander to receive CONNECTED & DISCONNECTED
     *            messages
     * @param dstPackageName is the destination package name
     * @param dstClassName is the fully qualified class name (i.e. contains
     *            package name)
     *
     * @return STATUS_SUCCESSFUL on success any other value is an error.
     */
public int connectSrcHandlerToPackageSync(Context srcContext, Handler srcHandler, String dstPackageName, String dstClassName) {
    if (DBG)
        log("connect srcHandler to dst Package & class E");
    mConnection = new AsyncChannelConnection();
    /* Initialize the source information */
    mSrcContext = srcContext;
    mSrcHandler = srcHandler;
    mSrcMessenger = new Messenger(srcHandler);
    /*
         * Initialize destination information to null they will
         * be initialized when the AsyncChannelConnection#onServiceConnected
         * is called
         */
    mDstMessenger = null;
    /* Send intent to create the connection */
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.setClassName(dstPackageName, dstClassName);
    boolean result = srcContext.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
    if (DBG)
        log("connect srcHandler to dst Package & class X result=" + result);
    return result ? STATUS_SUCCESSFUL : STATUS_BINDING_UNSUCCESSFUL;
}
Also used : Intent(android.content.Intent) Messenger(android.os.Messenger)

Example 84 with Messenger

use of android.os.Messenger in project android_frameworks_base by DirtyUnicorns.

the class AsyncChannel method connected.

/**
     * Connect handler to messenger. This method is typically called
     * when a server receives a CMD_CHANNEL_FULL_CONNECTION request
     * and initializes the internal instance variables to allow communication
     * with the dstMessenger.
     *
     * @param srcContext
     * @param srcHandler
     * @param dstMessenger
     */
public void connected(Context srcContext, Handler srcHandler, Messenger dstMessenger) {
    if (DBG)
        log("connected srcHandler to the dstMessenger  E");
    // Initialize source fields
    mSrcContext = srcContext;
    mSrcHandler = srcHandler;
    mSrcMessenger = new Messenger(mSrcHandler);
    // Initialize destination fields
    mDstMessenger = dstMessenger;
    linkToDeathMonitor();
    if (DBG)
        log("connected srcHandler to the dstMessenger X");
}
Also used : Messenger(android.os.Messenger)

Example 85 with Messenger

use of android.os.Messenger in project android_frameworks_base by AOSPA.

the class NetworkFactory method register.

public void register() {
    if (DBG)
        log("Registering NetworkFactory");
    if (mMessenger == null) {
        mMessenger = new Messenger(this);
        ConnectivityManager.from(mContext).registerNetworkFactory(mMessenger, LOG_TAG);
    }
}
Also used : Messenger(android.os.Messenger)

Aggregations

Messenger (android.os.Messenger)108 RemoteException (android.os.RemoteException)44 Message (android.os.Message)42 Intent (android.content.Intent)38 Handler (android.os.Handler)27 ComponentName (android.content.ComponentName)23 IBinder (android.os.IBinder)23 ServiceConnection (android.content.ServiceConnection)19 DataUsageRequest (android.net.DataUsageRequest)9 Looper (android.os.Looper)9 ConditionVariable (android.os.ConditionVariable)8 AsyncChannel (com.android.internal.util.AsyncChannel)8 PendingIntent (android.app.PendingIntent)7 Bundle (android.os.Bundle)7 HandlerThread (android.os.HandlerThread)7 Binder (android.os.Binder)6 File (java.io.File)6 CountDownLatch (java.util.concurrent.CountDownLatch)6 NetworkTemplate (android.net.NetworkTemplate)5 RecognizerIntent (android.speech.RecognizerIntent)5