android.os.Parcel#dataSize ( )源码实例Demo

下面列出了android.os.Parcel#dataSize ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android_9.0.0_r45   文件: AssistStructure.java
boolean writeToParcelInner(AssistStructure as, Parcel out) {
    if (mNumWindows == 0) {
        return false;
    }
    if (DEBUG_PARCEL) Log.d(TAG, "Creating PooledStringWriter @ " + out.dataPosition());
    PooledStringWriter pwriter = new PooledStringWriter(out);
    while (writeNextEntryToParcel(as, out, pwriter)) {
        // If the parcel is above the IPC limit, then we are getting too
        // large for a single IPC so stop here and let the caller come back when it
        // is ready for more.
        if (out.dataSize() > IBinder.MAX_IPC_SIZE) {
            if (DEBUG_PARCEL) Log.d(TAG, "Assist data size is " + out.dataSize()
                    + " @ pos " + out.dataPosition() + "; returning partial result");
            out.writeInt(0);
            out.writeStrongBinder(this);
            if (DEBUG_PARCEL) Log.d(TAG, "Finishing PooledStringWriter @ "
                    + out.dataPosition() + ", size " + pwriter.getStringCount());
            pwriter.finish();
            return true;
        }
    }
    if (DEBUG_PARCEL) Log.d(TAG, "Finishing PooledStringWriter @ "
            + out.dataPosition() + ", size " + pwriter.getStringCount());
    pwriter.finish();
    mViewStack.clear();
    return false;
}
 
源代码2 项目: mvvm-template   文件: Bundler.java
@NonNull public Bundle end() {
    Parcel parcel = Parcel.obtain();
    bundle.writeToParcel(parcel, 0);
    int size = parcel.dataSize();
    Logger.e(size);
    if (size > 500000) {
        bundle.clear();
    }
    return get();
}
 
源代码3 项目: OpenHub   文件: BundleHelper.java
public Bundle build(){
    Parcel parcel = Parcel.obtain();
    bundle.writeToParcel(parcel, 0);
    if (parcel.dataSize() > 512 * 1024) {
        bundle.clear();
        throw new IllegalArgumentException("bundle data is too large, please reduce date size to avoid Exception");
    }
    return bundle;
}
 
源代码4 项目: xDrip   文件: BitmapLoader.java
private static int getBundleSizeInBytes(Bundle bundle) {
    final Parcel parcel = Parcel.obtain();
    parcel.writeBundle(bundle);
    final int size = parcel.dataSize();
    parcel.recycle();
    return size;
}
 
源代码5 项目: xDrip-plus   文件: BitmapLoader.java
private static int getBundleSizeInBytes(Bundle bundle) {
    final Parcel parcel = Parcel.obtain();
    parcel.writeBundle(bundle);
    final int size = parcel.dataSize();
    parcel.recycle();
    return size;
}
 
/** @see #MAX_EXTRAS_SIZE_BYTES */
private static int measureBundleSize(Bundle extras) {
  Parcel p = Parcel.obtain();
  extras.writeToParcel(p, 0);
  int sizeInBytes = p.dataSize();
  p.recycle();

  return sizeInBytes;
}
 
源代码7 项目: FairEmail   文件: Helper.java
static int getSize(Bundle bundle) {
    Parcel p = Parcel.obtain();
    bundle.writeToParcel(p, 0);
    return p.dataSize();
}
 
源代码8 项目: mvvm-template   文件: Bundler.java
public static boolean isValidBundleSize(@NonNull Bundle bundle) {
    Parcel parcel = Parcel.obtain();
    bundle.writeToParcel(parcel, 0);
    return parcel.dataSize() < 500000;
}
 
源代码9 项目: sdl_java_suite   文件: LocalRouterServiceTests.java
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();
	
}
 
源代码10 项目: delion   文件: IntentUtils.java
/**
 * Returns how large the Intent will be in Parcel form, which is helpful for gauging whether
 * Android will deliver the Intent instead of throwing a TransactionTooLargeException.
 *
 * @param intent Intent to get the size of.
 * @return Number of bytes required to parcel the Intent.
 */
public static int getParceledIntentSize(Intent intent) {
    Parcel parcel = Parcel.obtain();
    intent.writeToParcel(parcel, 0);
    return parcel.dataSize();
}
 
源代码11 项目: AndroidChromium   文件: IntentUtils.java
/**
 * Returns how large the Intent will be in Parcel form, which is helpful for gauging whether
 * Android will deliver the Intent instead of throwing a TransactionTooLargeException.
 *
 * @param intent Intent to get the size of.
 * @return Number of bytes required to parcel the Intent.
 */
public static int getParceledIntentSize(Intent intent) {
    Parcel parcel = Parcel.obtain();
    intent.writeToParcel(parcel, 0);
    return parcel.dataSize();
}
 
源代码12 项目: 365browser   文件: IntentUtils.java
/**
 * Returns how large the Intent will be in Parcel form, which is helpful for gauging whether
 * Android will deliver the Intent instead of throwing a TransactionTooLargeException.
 *
 * @param intent Intent to get the size of.
 * @return Number of bytes required to parcel the Intent.
 */
public static int getParceledIntentSize(Intent intent) {
    Parcel parcel = Parcel.obtain();
    intent.writeToParcel(parcel, 0);
    return parcel.dataSize();
}
 
 方法所在类
 同类方法