use of android.os.Messenger in project android_frameworks_base by DirtyUnicorns.
the class AsyncService method onCreate.
/**
* onCreate
*/
@Override
public void onCreate() {
super.onCreate();
mAsyncServiceInfo = createHandler();
mHandler = mAsyncServiceInfo.mHandler;
mMessenger = new Messenger(mHandler);
}
use of android.os.Messenger in project android_frameworks_base by ParanoidAndroid.
the class AsyncService method onCreate.
/**
* onCreate
*/
@Override
public void onCreate() {
super.onCreate();
mAsyncServiceInfo = createHandler();
mHandler = mAsyncServiceInfo.mHandler;
mMessenger = new Messenger(mHandler);
}
use of android.os.Messenger in project android_frameworks_base by ParanoidAndroid.
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;
if (DBG)
log("connected srcHandler to the dstMessenger X");
}
use of android.os.Messenger in project android_frameworks_base by AOSPA.
the class SettingInjectorService method sendStatus.
/**
* Send the enabled values back to the caller via the messenger encoded in the
* intent.
*/
private void sendStatus(Intent intent, boolean enabled) {
Message message = Message.obtain();
Bundle bundle = new Bundle();
bundle.putBoolean(ENABLED_KEY, enabled);
message.setData(bundle);
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, mName + ": received " + intent + ", enabled=" + enabled + ", sending message: " + message);
}
Messenger messenger = intent.getParcelableExtra(MESSENGER_KEY);
try {
messenger.send(message);
} catch (RemoteException e) {
Log.e(TAG, mName + ": sending dynamic status failed", e);
}
}
use of android.os.Messenger in project android_frameworks_base by AOSPA.
the class NetworkStatsManager method registerUsageCallback.
/**
* Registers to receive notifications about data usage on specified networks.
*
* <p>The callbacks will continue to be called as long as the process is live or
* {@link #unregisterUsageCallback} is called.
*
* @param networkType Type of network to monitor. Either
{@link ConnectivityManager#TYPE_MOBILE} or {@link ConnectivityManager#TYPE_WIFI}.
* @param subscriberId If applicable, the subscriber id of the network interface.
* @param thresholdBytes Threshold in bytes to be notified on.
* @param callback The {@link UsageCallback} that the system will call when data usage
* has exceeded the specified threshold.
* @param handler to dispatch callback events through, otherwise if {@code null} it uses
* the calling thread.
*/
public void registerUsageCallback(int networkType, String subscriberId, long thresholdBytes, UsageCallback callback, @Nullable Handler handler) {
checkNotNull(callback, "UsageCallback cannot be null");
final Looper looper;
if (handler == null) {
looper = Looper.myLooper();
} else {
looper = handler.getLooper();
}
if (DBG) {
Log.d(TAG, "registerUsageCallback called with: {" + " networkType=" + networkType + " subscriberId=" + subscriberId + " thresholdBytes=" + thresholdBytes + " }");
}
NetworkTemplate template = createTemplate(networkType, subscriberId);
DataUsageRequest request = new DataUsageRequest(DataUsageRequest.REQUEST_ID_UNSET, template, thresholdBytes);
try {
CallbackHandler callbackHandler = new CallbackHandler(looper, networkType, subscriberId, callback);
callback.request = mService.registerUsageCallback(mContext.getOpPackageName(), request, new Messenger(callbackHandler), new Binder());
if (DBG)
Log.d(TAG, "registerUsageCallback returned " + callback.request);
if (callback.request == null) {
Log.e(TAG, "Request from callback is null; should not happen");
}
} catch (RemoteException e) {
if (DBG)
Log.d(TAG, "Remote exception when registering callback");
throw e.rethrowFromSystemServer();
}
}
Aggregations