Search in sources :

Example 26 with ResultReceiver

use of android.os.ResultReceiver in project android_frameworks_base by crdroidandroid.

the class Tethering method getProxyReceiver.

/**
     * Creates a proxy {@link ResultReceiver} which enables tethering if the provsioning result is
     * successful before firing back up to the wrapped receiver.
     *
     * @param type The type of tethering being enabled.
     * @param receiver A ResultReceiver which will be called back with an int resultCode.
     * @return The proxy receiver.
     */
private ResultReceiver getProxyReceiver(final int type, final ResultReceiver receiver) {
    ResultReceiver rr = new ResultReceiver(null) {

        @Override
        protected void onReceiveResult(int resultCode, Bundle resultData) {
            // If provisioning is successful, enable tethering, otherwise just send the error.
            if (resultCode == ConnectivityManager.TETHER_ERROR_NO_ERROR) {
                enableTetheringInternal(type, true, receiver);
            } else {
                sendTetherResult(receiver, resultCode);
            }
        }
    };
    // The following is necessary to avoid unmarshalling issues when sending the receiver
    // across processes.
    Parcel parcel = Parcel.obtain();
    rr.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);
    ResultReceiver receiverForSending = ResultReceiver.CREATOR.createFromParcel(parcel);
    parcel.recycle();
    return receiverForSending;
}
Also used : Bundle(android.os.Bundle) Parcel(android.os.Parcel) ResultReceiver(android.os.ResultReceiver)

Example 27 with ResultReceiver

use of android.os.ResultReceiver in project android_frameworks_base by crdroidandroid.

the class Tethering method runSilentTetherProvisioningAndEnable.

private void runSilentTetherProvisioningAndEnable(int type, ResultReceiver receiver) {
    ResultReceiver proxyReceiver = getProxyReceiver(type, receiver);
    sendSilentTetherProvisionIntent(type, proxyReceiver);
}
Also used : ResultReceiver(android.os.ResultReceiver)

Example 28 with ResultReceiver

use of android.os.ResultReceiver in project android_frameworks_base by crdroidandroid.

the class Tethering method runUiTetherProvisioningAndEnable.

private void runUiTetherProvisioningAndEnable(int type, ResultReceiver receiver) {
    ResultReceiver proxyReceiver = getProxyReceiver(type, receiver);
    sendUiTetherProvisionIntent(type, proxyReceiver);
}
Also used : ResultReceiver(android.os.ResultReceiver)

Example 29 with ResultReceiver

use of android.os.ResultReceiver in project android_frameworks_base by crdroidandroid.

the class ShortcutManagerTest7 method callShellCommand.

private List<String> callShellCommand(String... args) throws IOException, RemoteException {
    // For reset to work, the current time needs to be incrementing.
    mInjectedCurrentTimeMillis++;
    final AtomicInteger resultCode = new AtomicInteger(Integer.MIN_VALUE);
    final ResultReceiver rr = new ResultReceiver(mHandler) {

        @Override
        public void send(int resultCode_, Bundle resultData) {
            resultCode.set(resultCode_);
        }
    };
    final File out = File.createTempFile("shellout-", ".tmp", getTestContext().getCacheDir());
    try {
        try (final ParcelFileDescriptor fd = ParcelFileDescriptor.open(out, ParcelFileDescriptor.MODE_READ_WRITE)) {
            mService.onShellCommand(/* fdin*/
            null, /* fdout*/
            fd.getFileDescriptor(), /* fderr*/
            fd.getFileDescriptor(), args, rr);
        }
        return readAll(out);
    } finally {
        out.delete();
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Bundle(android.os.Bundle) ParcelFileDescriptor(android.os.ParcelFileDescriptor) File(java.io.File) ResultReceiver(android.os.ResultReceiver)

Example 30 with ResultReceiver

use of android.os.ResultReceiver in project restful-android by jeremyhaberman.

the class TwitterServiceHelper method getTimeline.

public long getTimeline() {
    long requestId = generateRequestID();
    requests.put(timelineHashkey, requestId);
    ResultReceiver serviceCallback = new ResultReceiver(null) {

        @Override
        protected void onReceiveResult(int resultCode, Bundle resultData) {
            handleGetTimelineResponse(resultCode, resultData);
        }
    };
    Intent intent = new Intent(this.ctx, TwitterService.class);
    intent.putExtra(TwitterService.METHOD_EXTRA, TwitterService.METHOD_GET);
    intent.putExtra(TwitterService.RESOURCE_TYPE_EXTRA, TwitterService.RESOURCE_TYPE_TIMELINE);
    intent.putExtra(TwitterService.SERVICE_CALLBACK, serviceCallback);
    intent.putExtra(REQUEST_ID, requestId);
    this.ctx.startService(intent);
    return requestId;
}
Also used : Bundle(android.os.Bundle) Intent(android.content.Intent) 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