當前位置: 首頁>>代碼示例>>Java>>正文


Java Parcel.unmarshall方法代碼示例

本文整理匯總了Java中android.os.Parcel.unmarshall方法的典型用法代碼示例。如果您正苦於以下問題:Java Parcel.unmarshall方法的具體用法?Java Parcel.unmarshall怎麽用?Java Parcel.unmarshall使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.os.Parcel的用法示例。


在下文中一共展示了Parcel.unmarshall方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readPackageCache

import android.os.Parcel; //導入方法依賴的package包/類
public static VPackage readPackageCache(String packageName) {
    Parcel p = Parcel.obtain();
    try {
        File cacheFile = VEnvironment.getPackageCacheFile(packageName);
        FileInputStream is = new FileInputStream(cacheFile);
        byte[] bytes = FileUtils.toByteArray(is);
        is.close();
        p.unmarshall(bytes, 0, bytes.length);
        p.setDataPosition(0);
        if (p.readInt() != 4) {
            throw new IllegalStateException("Invalid version.");
        }
        VPackage pkg = new VPackage(p);
        addOwner(pkg);
        return pkg;
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        p.recycle();
    }
    return null;
}
 
開發者ID:7763sea,項目名稱:VirtualHook,代碼行數:23,代碼來源:PackageParserEx.java

示例2: parcelClone

import android.os.Parcel; //導入方法依賴的package包/類
public MasterSecret parcelClone() {
  Parcel thisParcel = Parcel.obtain();
  Parcel thatParcel = Parcel.obtain();
  byte[] bytes      = null;

  thisParcel.writeValue(this);
  bytes = thisParcel.marshall();

  thatParcel.unmarshall(bytes, 0, bytes.length);
  thatParcel.setDataPosition(0);

  MasterSecret that = (MasterSecret)thatParcel.readValue(MasterSecret.class.getClassLoader());

  thisParcel.recycle();
  thatParcel.recycle();

  return that;
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:19,代碼來源:MasterSecret.java

示例3: readSignature

import android.os.Parcel; //導入方法依賴的package包/類
public static void readSignature(VPackage pkg) {
    File signatureFile = VEnvironment.getSignatureFile(pkg.packageName);
    if (!signatureFile.exists()) {
        return;
    }
    Parcel p = Parcel.obtain();
    try {
        FileInputStream fis = new FileInputStream(signatureFile);
        byte[] bytes = FileUtils.toByteArray(fis);
        fis.close();
        p.unmarshall(bytes, 0, bytes.length);
        p.setDataPosition(0);
        pkg.mSignatures = p.createTypedArray(Signature.CREATOR);
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        p.recycle();
    }
}
 
開發者ID:7763sea,項目名稱:VirtualHook,代碼行數:20,代碼來源:PackageParserEx.java

示例4: unmarshallParcelable

import android.os.Parcel; //導入方法依賴的package包/類
/**
 * Unmarshalls a parcelable's byte array into the object
 *
 * @param bytes the byte array
 * @param clazz the class
 * @param <T>   the type
 * @return the object
 */
@SuppressWarnings("unchecked")
public static <T extends Parcelable> T unmarshallParcelable(byte[] bytes, Class<T> clazz) {
    if (bytes == null) {
        return null;
    }
    Parcel parcel = Parcel.obtain();
    parcel.unmarshall(bytes, 0, bytes.length);
    parcel.setDataPosition(0);

    try {
        Parcelable.Creator<? extends Parcelable> creator = (Parcelable.Creator<? extends Parcelable>) clazz.getField("CREATOR").get(null);
        return (T) creator.createFromParcel(parcel);
    } catch (Exception e) {
        throw new BadParcelableException(e);
    } finally {
        parcel.recycle();
    }
}
 
開發者ID:hortonworks,項目名稱:nifi-android-s2s,代碼行數:27,代碼來源:SerializationUtils.java

示例5: bytes2Parcelable

import android.os.Parcel; //導入方法依賴的package包/類
private static <T> T bytes2Parcelable(byte[] bytes, Parcelable.Creator<T> creator) {
    if (bytes == null) return null;
    Parcel parcel = Parcel.obtain();
    parcel.unmarshall(bytes, 0, bytes.length);
    parcel.setDataPosition(0);
    T result = creator.createFromParcel(parcel);
    parcel.recycle();
    return result;
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:10,代碼來源:CacheUtils.java

示例6: readJobs

import android.os.Parcel; //導入方法依賴的package包/類
private void readJobs() {
    File jobFile = VEnvironment.getJobConfigFile();
    if (!jobFile.exists()) {
        return;
    }
    Parcel p = Parcel.obtain();
    try {
        FileInputStream fis = new FileInputStream(jobFile);
        byte[] bytes = new byte[(int) jobFile.length()];
        int len = fis.read(bytes);
        fis.close();
        if (len != bytes.length) {
            throw new IOException("Unable to read job config.");
        }
        p.unmarshall(bytes, 0, bytes.length);
        p.setDataPosition(0);
        int version = p.readInt();
        if (version != JOB_FILE_VERSION) {
            throw new IOException("Bad version of job file: " + version);
        }
        if (!mJobStore.isEmpty()) {
            mJobStore.clear();
        }
        int count = p.readInt();
        for (int i = 0; i < count; i++) {
            JobId jobId = new JobId(p);
            JobConfig config = new JobConfig(p);
            mJobStore.put(jobId, config);
            mGlobalJobId = Math.max(mGlobalJobId, config.virtualJobId);
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        p.recycle();
    }

}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:38,代碼來源:VJobSchedulerService.java

示例7: unmarshall

import android.os.Parcel; //導入方法依賴的package包/類
static <T> T unmarshall(byte[] array) {
    Parcel parcel = Parcel.obtain();
    parcel.unmarshall(array, 0, array.length);
    parcel.setDataPosition(0);
    Object value = parcel.readValue(CLASS_LOADER);
    parcel.recycle();
    return (T)value;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:9,代碼來源:ParcelFn.java

示例8: bytes2Parcelable

import android.os.Parcel; //導入方法依賴的package包/類
private static <T> T bytes2Parcelable(final byte[] bytes, final Parcelable.Creator<T> creator) {
    if (bytes == null) return null;
    Parcel parcel = Parcel.obtain();
    parcel.unmarshall(bytes, 0, bytes.length);
    parcel.setDataPosition(0);
    T result = creator.createFromParcel(parcel);
    parcel.recycle();
    return result;
}
 
開發者ID:Wilshion,項目名稱:HeadlineNews,代碼行數:10,代碼來源:CacheUtils.java

示例9: getPendingIntents

import android.os.Parcel; //導入方法依賴的package包/類
/**
 * Retreives all pending intents that have been saved
 *
 * @return the pending intents
 */
public List<PendingIntentWrapper> getPendingIntents() {
    List<PendingIntentWrapper> pendingIntents = new ArrayList<>();
    SQLiteDatabase readableDatabase = sqLiteOpenHelper.getReadableDatabase();
    try {
        Cursor cursor = readableDatabase.query(false, PENDING_INTENT_TABLE_NAME, new String[]{ID_COLUMN, PENDING_INTENT_REQUEST_CODE, CONTENT_COLUMN}, null, null, null, null, null, null);
        try {
            int idIndex = cursor.getColumnIndexOrThrow(ID_COLUMN);
            int requestCodeIndex = cursor.getColumnIndexOrThrow(PENDING_INTENT_REQUEST_CODE);
            int contentIndex = cursor.getColumnIndexOrThrow(CONTENT_COLUMN);
            while (cursor.moveToNext()) {
                Parcel parcel = Parcel.obtain();
                byte[] bytes = cursor.getBlob(contentIndex);
                parcel.unmarshall(bytes, 0, bytes.length);
                parcel.setDataPosition(0);
                int requestCode = cursor.getInt(requestCodeIndex);
                Intent intent = Intent.CREATOR.createFromParcel(parcel);
                pendingIntents.add(new PendingIntentWrapper(cursor.getLong(idIndex), PendingIntent.getBroadcast(context, requestCode, intent, PendingIntent.FLAG_NO_CREATE)));
            }
        } finally {
            cursor.close();
        }
    } finally {
        readableDatabase.close();
    }
    return pendingIntents;
}
 
開發者ID:hortonworks,項目名稱:nifi-android-s2s,代碼行數:32,代碼來源:DemoAppDB.java

示例10: unwrap

import android.os.Parcel; //導入方法依賴的package包/類
private static BreventProtocol unwrap(byte[] bytes) {
    Parcel parcel = Parcel.obtain();
    parcel.unmarshall(bytes, 0, bytes.length);
    parcel.setDataPosition(0);
    parcel.readInt(); // skip version
    int action = parcel.readInt();
    parcel.setDataPosition(0);

    try {
        switch (action) {
            case STATUS_REQUEST:
                return new BreventRequest(parcel);
            case STATUS_RESPONSE:
                return new BreventResponse(parcel);
            case UPDATE_BREVENT:
                return new BreventPackages(parcel);
            case CONFIGURATION:
                return new BreventConfiguration(parcel);
            case UPDATE_PRIORITY:
                return new BreventPriority(parcel);
            case STATUS_NO_EVENT:
                return new BreventNoEvent(parcel);
            case OPS_KO:
                return BreventOpsKO.INSTANCE;
            case OPS_RESET:
                return new BreventOpsReset(parcel);
            case OPS_UPDATE:
                return new BreventOpsUpdate(parcel);
            case OPS_OK:
                return BreventOpsOK.INSTANCE;
            default:
                return null;
        }
    } finally {
        parcel.recycle();
    }
}
 
開發者ID:brevent,項目名稱:Brevent,代碼行數:38,代碼來源:BreventProtocol.java

示例11: clone

import android.os.Parcel; //導入方法依賴的package包/類
public RecordFood clone() {
    Parcel parcel = Parcel.obtain();
    writeToParcel(parcel, 0);
    byte[] bytes = parcel.marshall();
    Parcel parcel2 = Parcel.obtain();
    parcel2.unmarshall(bytes, 0, bytes.length);
    parcel2.setDataPosition(0);
    return (RecordFood) CREATOR.createFromParcel(parcel2);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:10,代碼來源:RecordFood.java

示例12: bytes2Parcelable

import android.os.Parcel; //導入方法依賴的package包/類
private static <T> T bytes2Parcelable(final byte[] bytes, final Parcelable.Creator<T> creator) {
    if (bytes == null) {
        return null;
    }
    Parcel parcel = Parcel.obtain();
    parcel.unmarshall(bytes, 0, bytes.length);
    parcel.setDataPosition(0);
    T result = creator.createFromParcel(parcel);
    parcel.recycle();
    return result;
}
 
開發者ID:imliujun,項目名稱:LJFramework,代碼行數:12,代碼來源:CacheUtils.java

示例13: read

import android.os.Parcel; //導入方法依賴的package包/類
public void read() {
    File file = mPersistenceFile;
    Parcel p = Parcel.obtain();
    try {
        FileInputStream fis = new FileInputStream(file);
        byte[] bytes = new byte[(int) file.length()];
        int len = fis.read(bytes);
        fis.close();
        if (len != bytes.length) {
            throw new IOException("Unable to read Persistence file.");
        }
        p.unmarshall(bytes, 0, bytes.length);
        p.setDataPosition(0);
        if (!verifyMagic(p)) {
            onPersistenceFileDamage();
            throw new IOException("Invalid persistence file.");
        }
        int fileVersion = p.readInt();
        int currentVersion = getCurrentVersion();
        if (fileVersion != getCurrentVersion()) {
            if (!onVersionConflict(fileVersion, currentVersion)) {
                throw new IOException("Unable to process the bad version persistence file.");
            }
        }
        readPersistenceData(p);
    } catch (Exception e) {
        if (!(e instanceof FileNotFoundException)) {
            e.printStackTrace();
        }
    } finally {
        p.recycle();
    }
}
 
開發者ID:7763sea,項目名稱:VirtualHook,代碼行數:34,代碼來源:PersistenceLayer.java

示例14: unmarshall

import android.os.Parcel; //導入方法依賴的package包/類
private static Parcel unmarshall(byte[] bytes) {
    Parcel parcel = Parcel.obtain();
    parcel.unmarshall(bytes, 0, bytes.length);
    parcel.setDataPosition(0);
    return parcel;
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:7,代碼來源:ParcelableUtil.java

示例15: deserialize

import android.os.Parcel; //導入方法依賴的package包/類
public static Parcel deserialize(byte[] bytes) {
  Parcel parcel = Parcel.obtain();
  parcel.unmarshall(bytes, 0, bytes.length);
  parcel.setDataPosition(0);
  return parcel;
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:7,代碼來源:ParcelUtil.java


注:本文中的android.os.Parcel.unmarshall方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。