Java Code Examples for android.os.Parcel#recycle()
The following examples show how to use
android.os.Parcel#recycle() .
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: BookManagerImpl.java From VirtualAPK with Apache License 2.0 | 7 votes |
@Override public List<Book> getBookList() throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); List<Book> result; try { data.writeInterfaceToken(DESCRIPTOR); mRemote.transact(TRANSACTION_getBookList, data, reply, 0); reply.readException(); result = reply.createTypedArrayList(Book.CREATOR); } finally { reply.recycle(); data.recycle(); } return result; }
Example 2
Source File: ContentProviderNative.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@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 3
Source File: ICustomTabsCallback.java From Telegram with GNU General Public License v2.0 | 6 votes |
public void onPostMessage(String message, Bundle extras) throws RemoteException { Parcel _data = Parcel.obtain(); Parcel _reply = Parcel.obtain(); try { _data.writeInterfaceToken("android.support.customtabs.ICustomTabsCallback"); _data.writeString(message); if(extras != null) { _data.writeInt(1); extras.writeToParcel(_data, 0); } else { _data.writeInt(0); } this.mRemote.transact(5, _data, _reply, 0); _reply.readException(); } finally { _reply.recycle(); _data.recycle(); } }
Example 4
Source File: ICustomTabsService.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public int postMessage(ICustomTabsCallback callback, String message, Bundle extras) throws RemoteException { Parcel _data = Parcel.obtain(); Parcel _reply = Parcel.obtain(); int _result; try { _data.writeInterfaceToken("android.support.customtabs.ICustomTabsService"); _data.writeStrongBinder(callback != null?callback.asBinder():null); _data.writeString(message); if(extras != null) { _data.writeInt(1); extras.writeToParcel(_data, 0); } else { _data.writeInt(0); } this.mRemote.transact(8, _data, _reply, 0); _reply.readException(); _result = _reply.readInt(); } finally { _reply.recycle(); _data.recycle(); } return _result; }
Example 5
Source File: BookManagerImpl.java From VirtualAPK with Apache License 2.0 | 6 votes |
@Override public void addBook(Book book) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); try { data.writeInterfaceToken(DESCRIPTOR); if ((book != null)) { data.writeInt(1); book.writeToParcel(data, 0); } else { data.writeInt(0); } mRemote.transact(TRANSACTION_addBook, data, reply, 0); reply.readException(); } finally { reply.recycle(); data.recycle(); } }
Example 6
Source File: ServiceErrorTest.java From arca-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void testServiceErrorParcelableCreator() { final int code = 1; final String type = "type"; final String message = "message"; final ServiceError error = new ServiceError(code, type, message); final Parcel parcel = Parcel.obtain(); error.writeToParcel(parcel, 0); parcel.setDataPosition(0); final ServiceError parceled = ServiceError.CREATOR.createFromParcel(parcel); assertEquals(code, parceled.getCode()); assertEquals(type, parceled.getType()); assertEquals(message, parceled.getMessage()); parcel.recycle(); }
Example 7
Source File: AndroidSharedKeyRecord.java From commcare-android with Apache License 2.0 | 6 votes |
public Bundle getIncomingCallout(Intent incoming) { byte[] incomingCallout = incoming.getByteArrayExtra(EXTRA_KEY_CALLOUT); byte[] incomingKey = incoming.getByteArrayExtra(EXTRA_KEY_CALLOUT_SYMETRIC_KEY); Parcel p = Parcel.obtain(); byte[] decoded; try { byte[] aesKey = CryptUtil.decrypt(incomingKey, CryptUtil.getPrivateKeyCipher(this.privateKey)); decoded = CryptUtil.decrypt(incomingCallout, CryptUtil.getAesKeyCipher(aesKey)); } catch (GeneralSecurityException gse) { Logger.exception("Error getting incoming callout", gse); return null; } p.unmarshall(decoded, 0, decoded.length); p.setDataPosition(0); Bundle result = p.readBundle(); p.recycle(); return result; }
Example 8
Source File: RichInputConnectionAndTextRangeTests.java From Indic-Keyboard with Apache License 2.0 | 6 votes |
public MockConnection(final CharSequence text, final int cursorPosition) { super(null, false); // Interaction of spans with Parcels is completely non-trivial, but in the actual case // the CharSequences do go through Parcels because they go through IPC. There // are some significant differences between the behavior of Spanned objects that // have and that have not gone through parceling, so it's much easier to simulate // the environment with Parcels than try to emulate things by hand. final Parcel p = Parcel.obtain(); TextUtils.writeToParcel(text.subSequence(0, cursorPosition), p, 0 /* flags */); TextUtils.writeToParcel(text.subSequence(cursorPosition, text.length()), p, 0 /* flags */); final byte[] marshalled = p.marshall(); p.unmarshall(marshalled, 0, marshalled.length); p.setDataPosition(0); mTextBefore = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(p); mTextAfter = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(p); mExtractedText = null; p.recycle(); }
Example 9
Source File: ICustomTabsCallback.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public void onMessageChannelReady(Bundle extras) throws RemoteException { Parcel _data = Parcel.obtain(); Parcel _reply = Parcel.obtain(); try { _data.writeInterfaceToken("android.support.customtabs.ICustomTabsCallback"); if(extras != null) { _data.writeInt(1); extras.writeToParcel(_data, 0); } else { _data.writeInt(0); } this.mRemote.transact(4, _data, _reply, 0); _reply.readException(); } finally { _reply.recycle(); _data.recycle(); } }
Example 10
Source File: EncryptListenerProxy.java From letv with Apache License 2.0 | 5 votes |
public void onEncryptStartedError(int errorCode) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); try { data.writeInt(errorCode); this.mRemote.transact(2, data, reply, 0); reply.readException(); } finally { data.recycle(); reply.recycle(); } }
Example 11
Source File: ICdeBinder.java From letv with Apache License 2.0 | 5 votes |
public void setChannelSeekPosition(String url, double pos) throws RemoteException { Parcel _data = Parcel.obtain(); Parcel _reply = Parcel.obtain(); try { _data.writeInterfaceToken(Stub.DESCRIPTOR); _data.writeString(url); _data.writeDouble(pos); this.mRemote.transact(10, _data, _reply, 0); _reply.readException(); } finally { _reply.recycle(); _data.recycle(); } }
Example 12
Source File: SipCallSession.java From CSipSimple with GNU General Public License v3.0 | 5 votes |
/** * Constructor by copy * @param callInfo */ public SipCallSession(SipCallSession callInfo) { Parcel p = Parcel.obtain(); callInfo.writeToParcel(p, 0); p.setDataPosition(0); initFromParcel(p); p.recycle(); }
Example 13
Source File: INotificationSideChannel.java From letv with Apache License 2.0 | 5 votes |
public void cancel(String packageName, int id, String tag) throws RemoteException { Parcel _data = Parcel.obtain(); try { _data.writeInterfaceToken(Stub.DESCRIPTOR); _data.writeString(packageName); _data.writeInt(id); _data.writeString(tag); this.mRemote.transact(2, _data, null, 1); } finally { _data.recycle(); } }
Example 14
Source File: IMediaSession.java From letv with Apache License 2.0 | 5 votes |
public void skipToQueueItem(long id) throws RemoteException { Parcel _data = Parcel.obtain(); Parcel _reply = Parcel.obtain(); try { _data.writeInterfaceToken(Stub.DESCRIPTOR); _data.writeLong(id); this.mRemote.transact(17, _data, _reply, 0); _reply.readException(); } finally { _reply.recycle(); _data.recycle(); } }
Example 15
Source File: IMediaSession.java From letv with Apache License 2.0 | 5 votes |
public void seekTo(long pos) throws RemoteException { Parcel _data = Parcel.obtain(); Parcel _reply = Parcel.obtain(); try { _data.writeInterfaceToken(Stub.DESCRIPTOR); _data.writeLong(pos); this.mRemote.transact(24, _data, _reply, 0); _reply.readException(); } finally { _reply.recycle(); _data.recycle(); } }
Example 16
Source File: ParcelUtil.java From deltachat-android with GNU General Public License v3.0 | 5 votes |
public static byte[] serialize(Parcelable parceable) { Parcel parcel = Parcel.obtain(); parceable.writeToParcel(parcel, 0); byte[] bytes = parcel.marshall(); parcel.recycle(); return bytes; }
Example 17
Source File: ProcessStatsService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
void performWriteState(long initialTime) { if (DEBUG) Slog.d(TAG, "Performing write to " + mFile.getBaseFile()); Parcel data; AtomicFile file; synchronized (mPendingWriteLock) { data = mPendingWrite; file = mPendingWriteFile; mPendingWriteCommitted = false; if (data == null) { return; } mPendingWrite = null; mPendingWriteFile = null; mWriteLock.lock(); } final long startTime = SystemClock.uptimeMillis(); FileOutputStream stream = null; try { stream = file.startWrite(); stream.write(data.marshall()); stream.flush(); file.finishWrite(stream); com.android.internal.logging.EventLogTags.writeCommitSysConfigFile( "procstats", SystemClock.uptimeMillis() - startTime + initialTime); if (DEBUG) Slog.d(TAG, "Write completed successfully!"); } catch (IOException e) { Slog.w(TAG, "Error writing process statistics", e); file.failWrite(stream); } finally { data.recycle(); trimHistoricStatesWriteLocked(); mWriteLock.unlock(); } }
Example 18
Source File: IMediaSession.java From letv with Apache License 2.0 | 5 votes |
public void pause() throws RemoteException { Parcel _data = Parcel.obtain(); Parcel _reply = Parcel.obtain(); try { _data.writeInterfaceToken(Stub.DESCRIPTOR); this.mRemote.transact(18, _data, _reply, 0); _reply.readException(); } finally { _reply.recycle(); _data.recycle(); } }
Example 19
Source File: SpeakEasyProtocol.java From android-test with Apache License 2.0 | 5 votes |
/** Strips the custom subclass out of the ResultReceiver so you can ship between packages. */ private static ResultReceiver marshableReceiver(ResultReceiver r) { if (r.getClass().equals(ResultReceiver.class)) { return r; } Parcel p = Parcel.obtain(); try { r.writeToParcel(p, 0); p.setDataPosition(0); return ResultReceiver.CREATOR.createFromParcel(p); } finally { p.recycle(); } }
Example 20
Source File: LocalRouterServiceTests.java From sdl_java_suite with BSD 3-Clause "New" or "Revised" License | 4 votes |
public void corruptParcel(int testWith){ Parcel p = Parcel.obtain(); p.writeInt(4); p.writeLong(System.currentTimeMillis()); p.writeParcelable(new ComponentName(mContext, "test"), 0); p.writeParcelable(new Intent(), 0); p.setDataPosition(0); SdlRouterService.LocalRouterService local = getLocalRouterService(testWith, p); assertNotNull(local); assertNull(local.launchIntent); assertNull(local.name); p.recycle(); //--------------------------------------------------------------------------- p = Parcel.obtain(); p.writeInt(4); p.writeLong(System.currentTimeMillis()); p.writeParcelable(null,0); p.writeParcelable(null,0); p.setDataPosition(0); local = getLocalRouterService(testWith, p); assertNotNull(local); assertNull(local.launchIntent); assertNull(local.name); p.recycle(); //--------------------------------------------------------------------------- p = Parcel.obtain(); p.writeInt(4); p.writeLong(System.currentTimeMillis()); p.setDataPosition(0); local = getLocalRouterService(testWith, p); assertNotNull(local); assertNull(local.launchIntent); assertNull(local.name); p.recycle(); //--------------------------------------------------------------------------- local = null; p = null; p = Parcel.obtain(); p.writeInt(4); p.writeLong(System.currentTimeMillis()); int space = p.dataSize(); p.writeParcelable(new Intent(), 0); p.writeParcelable(new ComponentName(mContext, "test"), 0); p.setDataPosition(0); byte[] raw = p.marshall(); for(;space<raw.length;space++){ raw[space] = 0x00; } p.recycle(); p = Parcel.obtain(); p.unmarshall(raw, 0, raw.length); p.setDataPosition(0); local = getLocalRouterService(testWith, p); assertNotNull(local); assertNull(local.launchIntent); assertNull(local.name); p.recycle(); }