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");
}
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;
}
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");
}
}
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)));
}
}
}
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);
}
Aggregations