本文整理匯總了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;
}
示例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;
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例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();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
示例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);
}
示例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;
}
示例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();
}
}
示例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;
}
示例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;
}