Java Code Examples for android.net.Uri#writeToParcel()

The following examples show how to use android.net.Uri#writeToParcel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContentProviderNative.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public AssetFileDescriptor openTypedAssetFile(String callingPkg, Uri url, String mimeType,
        Bundle opts, ICancellationSignal signal) throws RemoteException, FileNotFoundException {
    Parcel data = Parcel.obtain();
    Parcel reply = Parcel.obtain();
    try {
        data.writeInterfaceToken(IContentProvider.descriptor);

        data.writeString(callingPkg);
        url.writeToParcel(data, 0);
        data.writeString(mimeType);
        data.writeBundle(opts);
        data.writeStrongBinder(signal != null ? signal.asBinder() : null);

        mRemote.transact(IContentProvider.OPEN_TYPED_ASSET_FILE_TRANSACTION, data, reply, 0);

        DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(reply);
        int has = reply.readInt();
        AssetFileDescriptor fd = has != 0
                ? AssetFileDescriptor.CREATOR.createFromParcel(reply) : null;
        return fd;
    } finally {
        data.recycle();
        reply.recycle();
    }
}
 
Example 2
Source File: RemoteDeviceManager.java    From letv with Apache License 2.0 6 votes vote down vote up
public int playMedia(String deviceId, Uri uri, int start) throws RemoteException {
    Parcel _data = Parcel.obtain();
    Parcel _reply = Parcel.obtain();
    int _result = 1;
    try {
        _data.writeInterfaceToken(Stub.DESCRIPTOR);
        _data.writeString(deviceId);
        if (uri != null) {
            _data.writeInt(1);
            uri.writeToParcel(_data, 0);
        } else {
            _data.writeInt(0);
        }
        _data.writeInt(start);
        this.mRemote.transact(13, _data, _reply, 0);
        ExceptionUtils.readExceptionFromParcel(_reply);
        _result = _reply.readInt();
        return _result;
    } finally {
        _reply.recycle();
        _data.recycle();
    }
}
 
Example 3
Source File: RemoteDeviceManager.java    From letv with Apache License 2.0 6 votes vote down vote up
public void sendFileToDevice(String deviceId, String mimeType, Uri uri) throws RemoteException {
    Parcel _data = Parcel.obtain();
    Parcel _reply = Parcel.obtain();
    try {
        _data.writeInterfaceToken(Stub.DESCRIPTOR);
        _data.writeString(deviceId);
        _data.writeString(mimeType);
        if (uri != null) {
            _data.writeInt(1);
            uri.writeToParcel(_data, 0);
        } else {
            _data.writeInt(0);
        }
        this.mRemote.transact(9, _data, _reply, 0);
        ExceptionUtils.readExceptionFromParcel(_reply);
    } finally {
        _reply.recycle();
        _data.recycle();
    }
}
 
Example 4
Source File: ICustomTabsService.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public boolean requestPostMessageChannel(ICustomTabsCallback callback, Uri postMessageOrigin) throws RemoteException {
    Parcel _data = Parcel.obtain();
    Parcel _reply = Parcel.obtain();

    boolean _result;
    try {
        _data.writeInterfaceToken("android.support.customtabs.ICustomTabsService");
        _data.writeStrongBinder(callback != null?callback.asBinder():null);
        if(postMessageOrigin != null) {
            _data.writeInt(1);
            postMessageOrigin.writeToParcel(_data, 0);
        } else {
            _data.writeInt(0);
        }

        this.mRemote.transact(7, _data, _reply, 0);
        _reply.readException();
        _result = 0 != _reply.readInt();
    } finally {
        _reply.recycle();
        _data.recycle();
    }

    return _result;
}
 
Example 5
Source File: ICustomTabsService.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public boolean requestPostMessageChannel(ICustomTabsCallback callback, Uri postMessageOrigin) throws RemoteException {
    Parcel _data = Parcel.obtain();
    Parcel _reply = Parcel.obtain();

    boolean _result;
    try {
        _data.writeInterfaceToken("android.support.customtabs.ICustomTabsService");
        _data.writeStrongBinder(callback != null?callback.asBinder():null);
        if(postMessageOrigin != null) {
            _data.writeInt(1);
            postMessageOrigin.writeToParcel(_data, 0);
        } else {
            _data.writeInt(0);
        }

        this.mRemote.transact(7, _data, _reply, 0);
        _reply.readException();
        _result = 0 != _reply.readInt();
    } finally {
        _reply.recycle();
        _data.recycle();
    }

    return _result;
}
 
Example 6
Source File: ContentProviderNative.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public boolean refresh(String callingPkg, Uri url, Bundle args, ICancellationSignal signal)
        throws RemoteException {
    Parcel data = Parcel.obtain();
    Parcel reply = Parcel.obtain();
    try {
        data.writeInterfaceToken(IContentProvider.descriptor);

        data.writeString(callingPkg);
        url.writeToParcel(data, 0);
        data.writeBundle(args);
        data.writeStrongBinder(signal != null ? signal.asBinder() : null);

        mRemote.transact(IContentProvider.REFRESH_TRANSACTION, data, reply, 0);

        DatabaseUtils.readExceptionFromParcel(reply);
        int success = reply.readInt();
        return (success == 0);
    } finally {
        data.recycle();
        reply.recycle();
    }
}
 
Example 7
Source File: ContentProviderNative.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public Uri uncanonicalize(String callingPkg, Uri url) throws RemoteException {
    Parcel data = Parcel.obtain();
    Parcel reply = Parcel.obtain();
    try {
        data.writeInterfaceToken(IContentProvider.descriptor);

        data.writeString(callingPkg);
        url.writeToParcel(data, 0);

        mRemote.transact(IContentProvider.UNCANONICALIZE_TRANSACTION, data, reply, 0);

        DatabaseUtils.readExceptionFromParcel(reply);
        Uri out = Uri.CREATOR.createFromParcel(reply);
        return out;
    } finally {
        data.recycle();
        reply.recycle();
    }
}
 
Example 8
Source File: ContentProviderNative.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public Uri canonicalize(String callingPkg, Uri url) throws RemoteException
{
    Parcel data = Parcel.obtain();
    Parcel reply = Parcel.obtain();
    try {
        data.writeInterfaceToken(IContentProvider.descriptor);

        data.writeString(callingPkg);
        url.writeToParcel(data, 0);

        mRemote.transact(IContentProvider.CANONICALIZE_TRANSACTION, data, reply, 0);

        DatabaseUtils.readExceptionFromParcel(reply);
        Uri out = Uri.CREATOR.createFromParcel(reply);
        return out;
    } finally {
        data.recycle();
        reply.recycle();
    }
}
 
Example 9
Source File: IMediaSession.java    From letv with Apache License 2.0 6 votes vote down vote up
public void playFromUri(Uri uri, Bundle extras) throws RemoteException {
    Parcel _data = Parcel.obtain();
    Parcel _reply = Parcel.obtain();
    try {
        _data.writeInterfaceToken(Stub.DESCRIPTOR);
        if (uri != null) {
            _data.writeInt(1);
            uri.writeToParcel(_data, 0);
        } else {
            _data.writeInt(0);
        }
        if (extras != null) {
            _data.writeInt(1);
            extras.writeToParcel(_data, 0);
        } else {
            _data.writeInt(0);
        }
        this.mRemote.transact(16, _data, _reply, 0);
        _reply.readException();
    } finally {
        _reply.recycle();
        _data.recycle();
    }
}
 
Example 10
Source File: ContentProviderNative.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public AssetFileDescriptor openAssetFile(
        String callingPkg, Uri url, String mode, ICancellationSignal signal)
        throws RemoteException, FileNotFoundException {
    Parcel data = Parcel.obtain();
    Parcel reply = Parcel.obtain();
    try {
        data.writeInterfaceToken(IContentProvider.descriptor);

        data.writeString(callingPkg);
        url.writeToParcel(data, 0);
        data.writeString(mode);
        data.writeStrongBinder(signal != null ? signal.asBinder() : null);

        mRemote.transact(IContentProvider.OPEN_ASSET_FILE_TRANSACTION, data, reply, 0);

        DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(reply);
        int has = reply.readInt();
        AssetFileDescriptor fd = has != 0
                ? AssetFileDescriptor.CREATOR.createFromParcel(reply) : null;
        return fd;
    } finally {
        data.recycle();
        reply.recycle();
    }
}
 
Example 11
Source File: ContentProviderNative.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public int update(String callingPkg, Uri url, ContentValues values, String selection,
        String[] selectionArgs) throws RemoteException {
    Parcel data = Parcel.obtain();
    Parcel reply = Parcel.obtain();
    try {
        data.writeInterfaceToken(IContentProvider.descriptor);

        data.writeString(callingPkg);
        url.writeToParcel(data, 0);
        values.writeToParcel(data, 0);
        data.writeString(selection);
        data.writeStringArray(selectionArgs);

        mRemote.transact(IContentProvider.UPDATE_TRANSACTION, data, reply, 0);

        DatabaseUtils.readExceptionFromParcel(reply);
        int count = reply.readInt();
        return count;
    } finally {
        data.recycle();
        reply.recycle();
    }
}
 
Example 12
Source File: ContentProviderNative.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public int delete(String callingPkg, Uri url, String selection, String[] selectionArgs)
        throws RemoteException {
    Parcel data = Parcel.obtain();
    Parcel reply = Parcel.obtain();
    try {
        data.writeInterfaceToken(IContentProvider.descriptor);

        data.writeString(callingPkg);
        url.writeToParcel(data, 0);
        data.writeString(selection);
        data.writeStringArray(selectionArgs);

        mRemote.transact(IContentProvider.DELETE_TRANSACTION, data, reply, 0);

        DatabaseUtils.readExceptionFromParcel(reply);
        int count = reply.readInt();
        return count;
    } finally {
        data.recycle();
        reply.recycle();
    }
}
 
Example 13
Source File: ContentProviderNative.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public int bulkInsert(String callingPkg, Uri url, ContentValues[] values) throws RemoteException {
    Parcel data = Parcel.obtain();
    Parcel reply = Parcel.obtain();
    try {
        data.writeInterfaceToken(IContentProvider.descriptor);

        data.writeString(callingPkg);
        url.writeToParcel(data, 0);
        data.writeTypedArray(values, 0);

        mRemote.transact(IContentProvider.BULK_INSERT_TRANSACTION, data, reply, 0);

        DatabaseUtils.readExceptionFromParcel(reply);
        int count = reply.readInt();
        return count;
    } finally {
        data.recycle();
        reply.recycle();
    }
}
 
Example 14
Source File: ContentProviderNative.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public Uri insert(String callingPkg, Uri url, ContentValues values) throws RemoteException
{
    Parcel data = Parcel.obtain();
    Parcel reply = Parcel.obtain();
    try {
        data.writeInterfaceToken(IContentProvider.descriptor);

        data.writeString(callingPkg);
        url.writeToParcel(data, 0);
        values.writeToParcel(data, 0);

        mRemote.transact(IContentProvider.INSERT_TRANSACTION, data, reply, 0);

        DatabaseUtils.readExceptionFromParcel(reply);
        Uri out = Uri.CREATOR.createFromParcel(reply);
        return out;
    } finally {
        data.recycle();
        reply.recycle();
    }
}
 
Example 15
Source File: ContentProviderNative.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public String getType(Uri url) throws RemoteException
{
    Parcel data = Parcel.obtain();
    Parcel reply = Parcel.obtain();
    try {
        data.writeInterfaceToken(IContentProvider.descriptor);

        url.writeToParcel(data, 0);

        mRemote.transact(IContentProvider.GET_TYPE_TRANSACTION, data, reply, 0);

        DatabaseUtils.readExceptionFromParcel(reply);
        String out = reply.readString();
        return out;
    } finally {
        data.recycle();
        reply.recycle();
    }
}
 
Example 16
Source File: InputContentInfo.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Used to package this object into a {@link Parcel}.
 *
 * @param dest The {@link Parcel} to be written.
 * @param flags The flags used for parceling.
 */
@Override
public void writeToParcel(Parcel dest, int flags) {
    Uri.writeToParcel(dest, mContentUri);
    dest.writeInt(mContentUriOwnerUserId);
    mDescription.writeToParcel(dest, flags);
    Uri.writeToParcel(dest, mLinkUri);
    if (mUriToken != null) {
        dest.writeInt(1);
        dest.writeStrongBinder(mUriToken.asBinder());
    } else {
        dest.writeInt(0);
    }
}
 
Example 17
Source File: ICustomTabsService.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public boolean mayLaunchUrl(ICustomTabsCallback callback, Uri url, Bundle extras, List<Bundle> otherLikelyBundles) throws RemoteException {
    Parcel _data = Parcel.obtain();
    Parcel _reply = Parcel.obtain();

    boolean _result;
    try {
        _data.writeInterfaceToken("android.support.customtabs.ICustomTabsService");
        _data.writeStrongBinder(callback != null?callback.asBinder():null);
        if(url != null) {
            _data.writeInt(1);
            url.writeToParcel(_data, 0);
        } else {
            _data.writeInt(0);
        }

        if(extras != null) {
            _data.writeInt(1);
            extras.writeToParcel(_data, 0);
        } else {
            _data.writeInt(0);
        }

        _data.writeTypedList(otherLikelyBundles);
        this.mRemote.transact(4, _data, _reply, 0);
        _reply.readException();
        _result = 0 != _reply.readInt();
    } finally {
        _reply.recycle();
        _data.recycle();
    }

    return _result;
}
 
Example 18
Source File: ICustomTabsService.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public boolean mayLaunchUrl(ICustomTabsCallback callback, Uri url, Bundle extras, List<Bundle> otherLikelyBundles) throws RemoteException {
    Parcel _data = Parcel.obtain();
    Parcel _reply = Parcel.obtain();

    boolean _result;
    try {
        _data.writeInterfaceToken("android.support.customtabs.ICustomTabsService");
        _data.writeStrongBinder(callback != null?callback.asBinder():null);
        if(url != null) {
            _data.writeInt(1);
            url.writeToParcel(_data, 0);
        } else {
            _data.writeInt(0);
        }

        if(extras != null) {
            _data.writeInt(1);
            extras.writeToParcel(_data, 0);
        } else {
            _data.writeInt(0);
        }

        _data.writeTypedList(otherLikelyBundles);
        this.mRemote.transact(4, _data, _reply, 0);
        _reply.readException();
        _result = 0 != _reply.readInt();
    } finally {
        _reply.recycle();
        _data.recycle();
    }

    return _result;
}
 
Example 19
Source File: ICustomTabsService.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public boolean mayLaunchUrl(ICustomTabsCallback callback, Uri url, Bundle extras, List<Bundle> otherLikelyBundles) throws RemoteException {
    Parcel _data = Parcel.obtain();
    Parcel _reply = Parcel.obtain();

    boolean _result;
    try {
        _data.writeInterfaceToken("android.support.customtabs.ICustomTabsService");
        _data.writeStrongBinder(callback != null?callback.asBinder():null);
        if(url != null) {
            _data.writeInt(1);
            url.writeToParcel(_data, 0);
        } else {
            _data.writeInt(0);
        }

        if(extras != null) {
            _data.writeInt(1);
            extras.writeToParcel(_data, 0);
        } else {
            _data.writeInt(0);
        }

        _data.writeTypedList(otherLikelyBundles);
        this.mRemote.transact(4, _data, _reply, 0);
        _reply.readException();
        _result = 0 != _reply.readInt();
    } finally {
        _reply.recycle();
        _data.recycle();
    }

    return _result;
}
 
Example 20
Source File: ContentProviderOperation.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
public void writeToParcel(Parcel dest, int flags) {
    dest.writeInt(mType);
    Uri.writeToParcel(dest, mUri);
    if (mValues != null) {
        dest.writeInt(1);
        mValues.writeToParcel(dest, 0);
    } else {
        dest.writeInt(0);
    }
    if (mSelection != null) {
        dest.writeInt(1);
        dest.writeString(mSelection);
    } else {
        dest.writeInt(0);
    }
    if (mSelectionArgs != null) {
        dest.writeInt(1);
        dest.writeStringArray(mSelectionArgs);
    } else {
        dest.writeInt(0);
    }
    if (mExpectedCount != null) {
        dest.writeInt(1);
        dest.writeInt(mExpectedCount);
    } else {
        dest.writeInt(0);
    }
    if (mValuesBackReferences != null) {
        dest.writeInt(1);
        mValuesBackReferences.writeToParcel(dest, 0);
    } else {
        dest.writeInt(0);
    }
    if (mSelectionArgsBackReferences != null) {
        dest.writeInt(1);
        dest.writeInt(mSelectionArgsBackReferences.size());
        for (Map.Entry<Integer, Integer> entry : mSelectionArgsBackReferences.entrySet()) {
            dest.writeInt(entry.getKey());
            dest.writeInt(entry.getValue());
        }
    } else {
        dest.writeInt(0);
    }
    dest.writeInt(mYieldAllowed ? 1 : 0);
}