use of android.os.ResultReceiver in project android_frameworks_base by crdroidandroid.
the class ActivityTransitionState method enterReady.
public void enterReady(Activity activity) {
if (mEnterActivityOptions == null || mIsEnterTriggered) {
return;
}
mIsEnterTriggered = true;
mHasExited = false;
ArrayList<String> sharedElementNames = mEnterActivityOptions.getSharedElementNames();
ResultReceiver resultReceiver = mEnterActivityOptions.getResultReceiver();
if (mEnterActivityOptions.isReturning()) {
restoreExitedViews();
activity.getWindow().getDecorView().setVisibility(View.VISIBLE);
}
mEnterTransitionCoordinator = new EnterTransitionCoordinator(activity, resultReceiver, sharedElementNames, mEnterActivityOptions.isReturning(), mEnterActivityOptions.isCrossTask());
if (mEnterActivityOptions.isCrossTask()) {
mExitingFrom = new ArrayList<>(mEnterActivityOptions.getSharedElementNames());
mExitingTo = new ArrayList<>(mEnterActivityOptions.getSharedElementNames());
}
if (!mIsEnterPostponed) {
startEnter();
}
}
use of android.os.ResultReceiver in project android_frameworks_base by crdroidandroid.
the class Pm method runShellCommand.
private int runShellCommand(String serviceName, String[] args) {
final HandlerThread handlerThread = new HandlerThread("results");
handlerThread.start();
try {
ServiceManager.getService(serviceName).shellCommand(FileDescriptor.in, FileDescriptor.out, FileDescriptor.err, args, new ResultReceiver(new Handler(handlerThread.getLooper())));
return 0;
} catch (RemoteException e) {
e.printStackTrace();
} finally {
handlerThread.quitSafely();
}
return -1;
}
use of android.os.ResultReceiver in project android_frameworks_base by crdroidandroid.
the class ExitTransitionCoordinator method notifyComplete.
protected void notifyComplete() {
if (isReadyToNotify()) {
if (!mSharedElementNotified) {
mSharedElementNotified = true;
delayCancel();
if (mListener == null) {
mResultReceiver.send(MSG_TAKE_SHARED_ELEMENTS, mSharedElementBundle);
notifyExitComplete();
} else {
final ResultReceiver resultReceiver = mResultReceiver;
final Bundle sharedElementBundle = mSharedElementBundle;
mListener.onSharedElementsArrived(mSharedElementNames, mSharedElements, new OnSharedElementsReadyListener() {
@Override
public void onSharedElementsReady() {
resultReceiver.send(MSG_TAKE_SHARED_ELEMENTS, sharedElementBundle);
notifyExitComplete();
}
});
}
} else {
notifyExitComplete();
}
}
}
use of android.os.ResultReceiver in project android_frameworks_base by crdroidandroid.
the class MediaBrowser method getItem.
/**
* Retrieves a specific {@link MediaItem} from the connected service. Not
* all services may support this, so falling back to subscribing to the
* parent's id should be used when unavailable.
*
* @param mediaId The id of the item to retrieve.
* @param cb The callback to receive the result on.
*/
public void getItem(@NonNull final String mediaId, @NonNull final ItemCallback cb) {
if (TextUtils.isEmpty(mediaId)) {
throw new IllegalArgumentException("mediaId is empty.");
}
if (cb == null) {
throw new IllegalArgumentException("cb is null.");
}
if (mState != CONNECT_STATE_CONNECTED) {
Log.i(TAG, "Not connected, unable to retrieve the MediaItem.");
mHandler.post(new Runnable() {
@Override
public void run() {
cb.onError(mediaId);
}
});
return;
}
ResultReceiver receiver = new ResultReceiver(mHandler) {
@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
if (resultCode != 0 || resultData == null || !resultData.containsKey(MediaBrowserService.KEY_MEDIA_ITEM)) {
cb.onError(mediaId);
return;
}
Parcelable item = resultData.getParcelable(MediaBrowserService.KEY_MEDIA_ITEM);
if (!(item instanceof MediaItem)) {
cb.onError(mediaId);
return;
}
cb.onItemLoaded((MediaItem) item);
}
};
try {
mServiceBinder.getMediaItem(mediaId, receiver, mServiceCallbacks);
} catch (RemoteException e) {
Log.i(TAG, "Remote error getting media item.");
mHandler.post(new Runnable() {
@Override
public void run() {
cb.onError(mediaId);
}
});
}
}
use of android.os.ResultReceiver in project android_frameworks_base by crdroidandroid.
the class DirectStatementService method onStartCommand.
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
super.onStartCommand(intent, flags, startId);
if (intent == null) {
Log.e(TAG, "onStartCommand called with null intent");
return START_STICKY;
}
if (intent.getAction().equals(CHECK_ALL_ACTION)) {
Bundle extras = intent.getExtras();
List<String> sources = extras.getStringArrayList(EXTRA_SOURCE_ASSET_DESCRIPTORS);
String target = extras.getString(EXTRA_TARGET_ASSET_DESCRIPTOR);
String relation = extras.getString(EXTRA_RELATION);
ResultReceiver resultReceiver = extras.getParcelable(EXTRA_RESULT_RECEIVER);
if (resultReceiver == null) {
Log.e(TAG, " Intent does not have extra " + EXTRA_RESULT_RECEIVER);
return START_STICKY;
}
if (sources == null) {
Log.e(TAG, " Intent does not have extra " + EXTRA_SOURCE_ASSET_DESCRIPTORS);
resultReceiver.send(RESULT_FAIL, Bundle.EMPTY);
return START_STICKY;
}
if (target == null) {
Log.e(TAG, " Intent does not have extra " + EXTRA_TARGET_ASSET_DESCRIPTOR);
resultReceiver.send(RESULT_FAIL, Bundle.EMPTY);
return START_STICKY;
}
if (relation == null) {
Log.e(TAG, " Intent does not have extra " + EXTRA_RELATION);
resultReceiver.send(RESULT_FAIL, Bundle.EMPTY);
return START_STICKY;
}
mHandler.post(new ExceptionLoggingFutureTask<Void>(new IsAssociatedCallable(sources, target, relation, resultReceiver), TAG));
} else {
Log.e(TAG, "onStartCommand called with unsupported action: " + intent.getAction());
}
return START_STICKY;
}
Aggregations