Search in sources :

Example 86 with Messenger

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

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 87 with Messenger

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

the class WifiManager method getChannel.

private synchronized AsyncChannel getChannel() {
    if (mAsyncChannel == null) {
        Messenger messenger = getWifiServiceMessenger();
        if (messenger == null) {
            throw new IllegalStateException("getWifiServiceMessenger() returned null!  This is invalid.");
        }
        mAsyncChannel = new AsyncChannel();
        mConnected = new CountDownLatch(1);
        Handler handler = new ServiceHandler(mLooper);
        mAsyncChannel.connect(mContext, handler, messenger);
        try {
            mConnected.await();
        } catch (InterruptedException e) {
            Log.e(TAG, "interrupted wait at init");
        }
    }
    return mAsyncChannel;
}
Also used : Handler(android.os.Handler) AsyncChannel(com.android.internal.util.AsyncChannel) Messenger(android.os.Messenger) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 88 with Messenger

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

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 89 with Messenger

use of android.os.Messenger in project mechanoid by robotoworks.

the class OperationService method onOperationStarting.

public void onOperationStarting(Intent request, Bundle data) {
    if (mEnableLogging) {
        Log.d(mLogTag, String.format("[Operation Starting] request:%s, data:%s", request, data));
    }
    Messenger messenger = request.getParcelableExtra(EXTRA_BRIDGE_MESSENGER);
    Message m = new Message();
    m.what = OperationServiceBridge.MSG_OPERATION_STARTING;
    m.arg1 = OperationServiceBridge.getOperationRequestId(request);
    m.setData(data);
    try {
        messenger.send(m);
    } catch (RemoteException e) {
        if (mEnableLogging) {
            Log.e(mLogTag, String.format("[Operation Exception] %s", Log.getStackTraceString(e)));
        }
    }
}
Also used : Message(android.os.Message) Messenger(android.os.Messenger) RemoteException(android.os.RemoteException)

Example 90 with Messenger

use of android.os.Messenger in project mechanoid by robotoworks.

the class OperationService method onOperationAborted.

public void onOperationAborted(Intent request, int reason, Bundle data) {
    if (mEnableLogging) {
        Log.d(mLogTag, String.format("[Operation Aborted] request:%s, reason%s, data:%s", request, reason, data));
    }
    Messenger messenger = request.getParcelableExtra(EXTRA_BRIDGE_MESSENGER);
    Message m = new Message();
    m.what = OperationServiceBridge.MSG_OPERATION_ABORTED;
    m.arg1 = OperationServiceBridge.getOperationRequestId(request);
    m.arg2 = reason;
    m.setData(data);
    try {
        messenger.send(m);
    } catch (RemoteException e) {
        if (mEnableLogging) {
            Log.e(mLogTag, String.format("[Operation Exception] %s", Log.getStackTraceString(e)));
        }
    }
    sendStopMessage(request);
}
Also used : Message(android.os.Message) Messenger(android.os.Messenger) RemoteException(android.os.RemoteException)

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