Search in sources :

Example 21 with ResultReceiver

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();
    }
}
Also used : ResultReceiver(android.os.ResultReceiver)

Example 22 with ResultReceiver

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;
}
Also used : HandlerThread(android.os.HandlerThread) Handler(android.os.Handler) RemoteException(android.os.RemoteException) ResultReceiver(android.os.ResultReceiver)

Example 23 with ResultReceiver

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();
        }
    }
}
Also used : Bundle(android.os.Bundle) OnSharedElementsReadyListener(android.app.SharedElementCallback.OnSharedElementsReadyListener) ResultReceiver(android.os.ResultReceiver)

Example 24 with ResultReceiver

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);
            }
        });
    }
}
Also used : Bundle(android.os.Bundle) Parcelable(android.os.Parcelable) RemoteException(android.os.RemoteException) ResultReceiver(android.os.ResultReceiver)

Example 25 with ResultReceiver

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;
}
Also used : Bundle(android.os.Bundle) ResultReceiver(android.os.ResultReceiver)

Aggregations

ResultReceiver (android.os.ResultReceiver)70 Bundle (android.os.Bundle)38 RemoteException (android.os.RemoteException)11 Handler (android.os.Handler)9 HandlerThread (android.os.HandlerThread)6 OnSharedElementsReadyListener (android.app.SharedElementCallback.OnSharedElementsReadyListener)5 Intent (android.content.Intent)5 Parcel (android.os.Parcel)5 Parcelable (android.os.Parcelable)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 JSONArray (org.json.JSONArray)5 JSONException (org.json.JSONException)5 ParcelFileDescriptor (android.os.ParcelFileDescriptor)4 File (java.io.File)4 SharedPreferences (android.content.SharedPreferences)3 IOException (java.io.IOException)3 Point (android.graphics.Point)2 InputMethodManager (android.view.inputmethod.InputMethodManager)2 IResultReceiver (com.android.internal.os.IResultReceiver)2 JSONObject (org.json.JSONObject)2