cmsdk: Declare a parcelable header.
- This change forces that a parcelable header is written as the first data positions in a parcel and defines a means to distinguish between old sdk class versions vs new ones to do proper unraveling of parcels. Ticket: BAMBOO-152 Change-Id: I9cc762fe8a51cc527e85be7fe5de57e4613be019
This commit is contained in:
parent
5ff5e10bf0
commit
33a24ad589
|
@ -23,6 +23,7 @@ import android.net.Uri;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import cyanogenmod.os.Build;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@ -85,26 +86,42 @@ public class CustomTile implements Parcelable {
|
||||||
* Unflatten the CustomTile from a parcel.
|
* Unflatten the CustomTile from a parcel.
|
||||||
*/
|
*/
|
||||||
public CustomTile(Parcel parcel) {
|
public CustomTile(Parcel parcel) {
|
||||||
resourcesPackageName = parcel.readString();
|
// Read parcelable version, make sure to define explicit changes
|
||||||
if (parcel.readInt() != 0) {
|
// within {@link Build.PARCELABLE_VERSION);
|
||||||
this.onClick = PendingIntent.CREATOR.createFromParcel(parcel);
|
int parcelableVersion = parcel.readInt();
|
||||||
|
int parcelableSize = parcel.readInt();
|
||||||
|
int startPosition = parcel.dataPosition();
|
||||||
|
|
||||||
|
// Pattern here is that all new members should be added to the end of
|
||||||
|
// the writeToParcel method. Then we step through each version, until the latest
|
||||||
|
// API release to help unravel this parcel
|
||||||
|
if (parcelableVersion >= Build.CM_VERSION_CODES.APRICOT) {
|
||||||
|
if (parcel.readInt() != 0) {
|
||||||
|
this.onClick = PendingIntent.CREATOR.createFromParcel(parcel);
|
||||||
|
}
|
||||||
|
if (parcel.readInt() != 0) {
|
||||||
|
this.onSettingsClick = Intent.CREATOR.createFromParcel(parcel);
|
||||||
|
}
|
||||||
|
if (parcel.readInt() != 0) {
|
||||||
|
this.onClickUri = Uri.CREATOR.createFromParcel(parcel);
|
||||||
|
}
|
||||||
|
if (parcel.readInt() != 0) {
|
||||||
|
this.label = parcel.readString();
|
||||||
|
}
|
||||||
|
if (parcel.readInt() != 0) {
|
||||||
|
this.contentDescription = parcel.readString();
|
||||||
|
}
|
||||||
|
if (parcel.readInt() != 0) {
|
||||||
|
this.expandedStyle = ExpandedStyle.CREATOR.createFromParcel(parcel);
|
||||||
|
}
|
||||||
|
this.icon = parcel.readInt();
|
||||||
}
|
}
|
||||||
if (parcel.readInt() != 0) {
|
|
||||||
this.onSettingsClick = Intent.CREATOR.createFromParcel(parcel);
|
if (parcelableVersion >= Build.CM_VERSION_CODES.BOYSENBERRY) {
|
||||||
|
this.resourcesPackageName = parcel.readString();
|
||||||
}
|
}
|
||||||
if (parcel.readInt() != 0) {
|
|
||||||
this.onClickUri = Uri.CREATOR.createFromParcel(parcel);
|
parcel.setDataPosition(startPosition + parcelableSize);
|
||||||
}
|
|
||||||
if (parcel.readInt() != 0) {
|
|
||||||
this.label = parcel.readString();
|
|
||||||
}
|
|
||||||
if (parcel.readInt() != 0) {
|
|
||||||
this.contentDescription = parcel.readString();
|
|
||||||
}
|
|
||||||
if (parcel.readInt() != 0) {
|
|
||||||
this.expandedStyle = ExpandedStyle.CREATOR.createFromParcel(parcel);
|
|
||||||
}
|
|
||||||
this.icon = parcel.readInt();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -177,7 +194,17 @@ public class CustomTile implements Parcelable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel out, int flags) {
|
public void writeToParcel(Parcel out, int flags) {
|
||||||
out.writeString(resourcesPackageName);
|
// Write parcelable version, make sure to define explicit changes
|
||||||
|
// within {@link Build.PARCELABLE_VERSION);
|
||||||
|
out.writeInt(Build.PARCELABLE_VERSION);
|
||||||
|
|
||||||
|
// Inject a placeholder that will store the parcel size from this point on
|
||||||
|
// (not including the size itself).
|
||||||
|
int sizePosition = out.dataPosition();
|
||||||
|
out.writeInt(0);
|
||||||
|
int startPosition = out.dataPosition();
|
||||||
|
|
||||||
|
// ==== APRICOT =====
|
||||||
if (onClick != null) {
|
if (onClick != null) {
|
||||||
out.writeInt(1);
|
out.writeInt(1);
|
||||||
onClick.writeToParcel(out, 0);
|
onClick.writeToParcel(out, 0);
|
||||||
|
@ -215,6 +242,15 @@ public class CustomTile implements Parcelable {
|
||||||
out.writeInt(0);
|
out.writeInt(0);
|
||||||
}
|
}
|
||||||
out.writeInt(icon);
|
out.writeInt(icon);
|
||||||
|
|
||||||
|
// ==== BOYSENBERRY =====
|
||||||
|
out.writeString(resourcesPackageName);
|
||||||
|
|
||||||
|
// Go back and write size
|
||||||
|
int parcelableSize = out.dataPosition() - startPosition;
|
||||||
|
out.setDataPosition(sizePosition);
|
||||||
|
out.writeInt(parcelableSize);
|
||||||
|
out.setDataPosition(startPosition + parcelableSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -245,10 +281,23 @@ public class CustomTile implements Parcelable {
|
||||||
private int styleId;
|
private int styleId;
|
||||||
|
|
||||||
private ExpandedStyle(Parcel parcel) {
|
private ExpandedStyle(Parcel parcel) {
|
||||||
if (parcel.readInt() != 0) {
|
// Read parcelable version, make sure to define explicit changes
|
||||||
expandedItems = parcel.createTypedArray(ExpandedItem.CREATOR);
|
// within {@link Build.PARCELABLE_VERSION);
|
||||||
|
int parcelableVersion = parcel.readInt();
|
||||||
|
int parcelableSize = parcel.readInt();
|
||||||
|
int startPosition = parcel.dataPosition();
|
||||||
|
|
||||||
|
// Pattern here is that all new members should be added to the end of
|
||||||
|
// the writeToParcel method. Then we step through each version, until the latest
|
||||||
|
// API release to help unravel this parcel
|
||||||
|
if (parcelableVersion >= Build.CM_VERSION_CODES.APRICOT) {
|
||||||
|
if (parcel.readInt() != 0) {
|
||||||
|
expandedItems = parcel.createTypedArray(ExpandedItem.CREATOR);
|
||||||
|
}
|
||||||
|
styleId = parcel.readInt();
|
||||||
}
|
}
|
||||||
styleId = parcel.readInt();
|
|
||||||
|
parcel.setDataPosition(startPosition + parcelableSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -298,6 +347,17 @@ public class CustomTile implements Parcelable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel parcel, int i) {
|
public void writeToParcel(Parcel parcel, int i) {
|
||||||
|
// Write parcelable version, make sure to define explicit changes
|
||||||
|
// within {@link Build.PARCELABLE_VERSION);
|
||||||
|
parcel.writeInt(Build.PARCELABLE_VERSION);
|
||||||
|
|
||||||
|
// Inject a placeholder that will store the parcel size from this point on
|
||||||
|
// (not including the size itself).
|
||||||
|
int sizePosition = parcel.dataPosition();
|
||||||
|
parcel.writeInt(0);
|
||||||
|
int startPosition = parcel.dataPosition();
|
||||||
|
|
||||||
|
// ==== APRICOT ====
|
||||||
if (expandedItems != null) {
|
if (expandedItems != null) {
|
||||||
parcel.writeInt(1);
|
parcel.writeInt(1);
|
||||||
parcel.writeTypedArray(expandedItems, 0);
|
parcel.writeTypedArray(expandedItems, 0);
|
||||||
|
@ -305,6 +365,12 @@ public class CustomTile implements Parcelable {
|
||||||
parcel.writeInt(0);
|
parcel.writeInt(0);
|
||||||
}
|
}
|
||||||
parcel.writeInt(styleId);
|
parcel.writeInt(styleId);
|
||||||
|
|
||||||
|
// Go back and write size
|
||||||
|
int parcelableSize = parcel.dataPosition() - startPosition;
|
||||||
|
parcel.setDataPosition(sizePosition);
|
||||||
|
parcel.writeInt(parcelableSize);
|
||||||
|
parcel.setDataPosition(startPosition + parcelableSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -444,16 +510,29 @@ public class CustomTile implements Parcelable {
|
||||||
* Unflatten the ExpandedItem from a parcel.
|
* Unflatten the ExpandedItem from a parcel.
|
||||||
*/
|
*/
|
||||||
protected ExpandedItem(Parcel parcel) {
|
protected ExpandedItem(Parcel parcel) {
|
||||||
if (parcel.readInt() != 0) {
|
// Read parcelable version, make sure to define explicit changes
|
||||||
onClickPendingIntent = PendingIntent.CREATOR.createFromParcel(parcel);
|
// within {@link Build.PARCELABLE_VERSION);
|
||||||
|
int parcelableVersion = parcel.readInt();
|
||||||
|
int parcelableSize = parcel.readInt();
|
||||||
|
int startPosition = parcel.dataPosition();
|
||||||
|
|
||||||
|
// Pattern here is that all new members should be added to the end of
|
||||||
|
// the writeToParcel method. Then we step through each version, until the latest
|
||||||
|
// API release to help unravel this parcel
|
||||||
|
if (parcelableVersion >= Build.CM_VERSION_CODES.APRICOT) {
|
||||||
|
if (parcel.readInt() != 0) {
|
||||||
|
onClickPendingIntent = PendingIntent.CREATOR.createFromParcel(parcel);
|
||||||
|
}
|
||||||
|
if (parcel.readInt() != 0) {
|
||||||
|
itemTitle = parcel.readString();
|
||||||
|
}
|
||||||
|
if (parcel.readInt() != 0) {
|
||||||
|
itemSummary = parcel.readString();
|
||||||
|
}
|
||||||
|
itemDrawableResourceId = parcel.readInt();
|
||||||
}
|
}
|
||||||
if (parcel.readInt() != 0) {
|
|
||||||
itemTitle = parcel.readString();
|
parcel.setDataPosition(startPosition + parcelableSize);
|
||||||
}
|
|
||||||
if (parcel.readInt() != 0) {
|
|
||||||
itemSummary = parcel.readString();
|
|
||||||
}
|
|
||||||
itemDrawableResourceId = parcel.readInt();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -463,6 +542,16 @@ public class CustomTile implements Parcelable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel out, int flags) {
|
public void writeToParcel(Parcel out, int flags) {
|
||||||
|
// Write parcelable version, make sure to define explicit changes
|
||||||
|
// within {@link Build.PARCELABLE_VERSION);
|
||||||
|
out.writeInt(Build.PARCELABLE_VERSION);
|
||||||
|
|
||||||
|
// Inject a placeholder that will store the parcel size from this point on
|
||||||
|
// (not including the size itself).
|
||||||
|
int sizePosition = out.dataPosition();
|
||||||
|
out.writeInt(0);
|
||||||
|
int startPosition = out.dataPosition();
|
||||||
|
|
||||||
if (onClickPendingIntent != null) {
|
if (onClickPendingIntent != null) {
|
||||||
out.writeInt(1);
|
out.writeInt(1);
|
||||||
onClickPendingIntent.writeToParcel(out, 0);
|
onClickPendingIntent.writeToParcel(out, 0);
|
||||||
|
@ -482,6 +571,12 @@ public class CustomTile implements Parcelable {
|
||||||
out.writeInt(0);
|
out.writeInt(0);
|
||||||
}
|
}
|
||||||
out.writeInt(itemDrawableResourceId);
|
out.writeInt(itemDrawableResourceId);
|
||||||
|
|
||||||
|
// Go back and write size
|
||||||
|
int parcelableSize = out.dataPosition() - startPosition;
|
||||||
|
out.setDataPosition(sizePosition);
|
||||||
|
out.writeInt(parcelableSize);
|
||||||
|
out.setDataPosition(startPosition + parcelableSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -26,6 +26,7 @@ import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import cyanogenmod.os.Build;
|
||||||
import cyanogenmod.profiles.AirplaneModeSettings;
|
import cyanogenmod.profiles.AirplaneModeSettings;
|
||||||
import cyanogenmod.profiles.BrightnessSettings;
|
import cyanogenmod.profiles.BrightnessSettings;
|
||||||
import cyanogenmod.profiles.ConnectionSettings;
|
import cyanogenmod.profiles.ConnectionSettings;
|
||||||
|
@ -189,18 +190,47 @@ public final class Profile implements Parcelable, Comparable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ProfileTrigger(Parcel in) {
|
private ProfileTrigger(Parcel in) {
|
||||||
mType = in.readInt();
|
// Read parcelable version, make sure to define explicit changes
|
||||||
mId = in.readString();
|
// within {@link Build.PARCELABLE_VERSION);
|
||||||
mState = in.readInt();
|
int parcelableVersion = in.readInt();
|
||||||
mName = in.readString();
|
int parcelableSize = in.readInt();
|
||||||
|
int startPosition = in.dataPosition();
|
||||||
|
|
||||||
|
// Pattern here is that all new members should be added to the end of
|
||||||
|
// the writeToParcel method. Then we step through each version, until the latest
|
||||||
|
// API release to help unravel this parcel
|
||||||
|
if (parcelableVersion >= Build.CM_VERSION_CODES.BOYSENBERRY) {
|
||||||
|
mType = in.readInt();
|
||||||
|
mId = in.readString();
|
||||||
|
mState = in.readInt();
|
||||||
|
mName = in.readString();
|
||||||
|
}
|
||||||
|
|
||||||
|
in.setDataPosition(startPosition + parcelableSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
// Write parcelable version, make sure to define explicit changes
|
||||||
|
// within {@link Build.PARCELABLE_VERSION);
|
||||||
|
dest.writeInt(Build.PARCELABLE_VERSION);
|
||||||
|
|
||||||
|
// Inject a placeholder that will store the parcel size from this point on
|
||||||
|
// (not including the size itself).
|
||||||
|
int sizePosition = dest.dataPosition();
|
||||||
|
dest.writeInt(0);
|
||||||
|
int startPosition = dest.dataPosition();
|
||||||
|
|
||||||
dest.writeInt(mType);
|
dest.writeInt(mType);
|
||||||
dest.writeString(mId);
|
dest.writeString(mId);
|
||||||
dest.writeInt(mState);
|
dest.writeInt(mState);
|
||||||
dest.writeString(mName);
|
dest.writeString(mName);
|
||||||
|
|
||||||
|
// Go back and write size
|
||||||
|
int parcelableSize = dest.dataPosition() - startPosition;
|
||||||
|
dest.setDataPosition(sizePosition);
|
||||||
|
dest.writeInt(parcelableSize);
|
||||||
|
dest.setDataPosition(startPosition + parcelableSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -476,6 +506,17 @@ public final class Profile implements Parcelable, Comparable {
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
// Write parcelable version, make sure to define explicit changes
|
||||||
|
// within {@link Build.PARCELABLE_VERSION);
|
||||||
|
dest.writeInt(Build.PARCELABLE_VERSION);
|
||||||
|
|
||||||
|
// Inject a placeholder that will store the parcel size from this point on
|
||||||
|
// (not including the size itself).
|
||||||
|
int sizePosition = dest.dataPosition();
|
||||||
|
dest.writeInt(0);
|
||||||
|
int startPosition = dest.dataPosition();
|
||||||
|
|
||||||
|
// === BOYSENBERRY ===
|
||||||
if (!TextUtils.isEmpty(mName)) {
|
if (!TextUtils.isEmpty(mName)) {
|
||||||
dest.writeInt(1);
|
dest.writeInt(1);
|
||||||
dest.writeString(mName);
|
dest.writeString(mName);
|
||||||
|
@ -550,62 +591,81 @@ public final class Profile implements Parcelable, Comparable {
|
||||||
dest.writeMap(mTriggers);
|
dest.writeMap(mTriggers);
|
||||||
dest.writeInt(mExpandedDesktopMode);
|
dest.writeInt(mExpandedDesktopMode);
|
||||||
dest.writeInt(mDozeMode);
|
dest.writeInt(mDozeMode);
|
||||||
|
|
||||||
|
// Go back and write size
|
||||||
|
int parcelableSize = dest.dataPosition() - startPosition;
|
||||||
|
dest.setDataPosition(sizePosition);
|
||||||
|
dest.writeInt(parcelableSize);
|
||||||
|
dest.setDataPosition(startPosition + parcelableSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void readFromParcel(Parcel in) {
|
public void readFromParcel(Parcel in) {
|
||||||
if (in.readInt() != 0) {
|
// Read parcelable version, make sure to define explicit changes
|
||||||
mName = in.readString();
|
// within {@link Build.PARCELABLE_VERSION);
|
||||||
}
|
int parcelableVersion = in.readInt();
|
||||||
if (in.readInt() != 0) {
|
int parcelableSize = in.readInt();
|
||||||
mNameResId = in.readInt();
|
int startPosition = in.dataPosition();
|
||||||
}
|
|
||||||
if (in.readInt() != 0) {
|
// Pattern here is that all new members should be added to the end of
|
||||||
mUuid = ParcelUuid.CREATOR.createFromParcel(in).getUuid();
|
// the writeToParcel method. Then we step through each version, until the latest
|
||||||
}
|
// API release to help unravel this parcel
|
||||||
if (in.readInt() != 0) {
|
if (parcelableVersion >= Build.CM_VERSION_CODES.BOYSENBERRY) {
|
||||||
for (Parcelable parcel : in.readParcelableArray(null)) {
|
if (in.readInt() != 0) {
|
||||||
ParcelUuid u = (ParcelUuid) parcel;
|
mName = in.readString();
|
||||||
mSecondaryUuids.add(u.getUuid());
|
|
||||||
}
|
}
|
||||||
}
|
if (in.readInt() != 0) {
|
||||||
mStatusBarIndicator = (in.readInt() == 1);
|
mNameResId = in.readInt();
|
||||||
mProfileType = in.readInt();
|
}
|
||||||
mDirty = (in.readInt() == 1);
|
if (in.readInt() != 0) {
|
||||||
if (in.readInt() != 0) {
|
mUuid = ParcelUuid.CREATOR.createFromParcel(in).getUuid();
|
||||||
for (Parcelable group : in.readParcelableArray(null)) {
|
}
|
||||||
ProfileGroup grp = (ProfileGroup) group;
|
if (in.readInt() != 0) {
|
||||||
profileGroups.put(grp.getUuid(), grp);
|
for (Parcelable parcel : in.readParcelableArray(null)) {
|
||||||
if (grp.isDefaultGroup()) {
|
ParcelUuid u = (ParcelUuid) parcel;
|
||||||
mDefaultGroup = grp;
|
mSecondaryUuids.add(u.getUuid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
mStatusBarIndicator = (in.readInt() == 1);
|
||||||
if (in.readInt() != 0) {
|
mProfileType = in.readInt();
|
||||||
for (Parcelable parcel : in.readParcelableArray(null)) {
|
mDirty = (in.readInt() == 1);
|
||||||
StreamSettings stream = (StreamSettings) parcel;
|
if (in.readInt() != 0) {
|
||||||
streams.put(stream.getStreamId(), stream);
|
for (Parcelable group : in.readParcelableArray(null)) {
|
||||||
|
ProfileGroup grp = (ProfileGroup) group;
|
||||||
|
profileGroups.put(grp.getUuid(), grp);
|
||||||
|
if (grp.isDefaultGroup()) {
|
||||||
|
mDefaultGroup = grp;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if (in.readInt() != 0) {
|
||||||
if (in.readInt() != 0) {
|
for (Parcelable parcel : in.readParcelableArray(null)) {
|
||||||
for (Parcelable parcel : in.readParcelableArray(null)) {
|
StreamSettings stream = (StreamSettings) parcel;
|
||||||
ConnectionSettings connection = (ConnectionSettings) parcel;
|
streams.put(stream.getStreamId(), stream);
|
||||||
connections.put(connection.getConnectionId(), connection);
|
}
|
||||||
}
|
}
|
||||||
|
if (in.readInt() != 0) {
|
||||||
|
for (Parcelable parcel : in.readParcelableArray(null)) {
|
||||||
|
ConnectionSettings connection = (ConnectionSettings) parcel;
|
||||||
|
connections.put(connection.getConnectionId(), connection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (in.readInt() != 0) {
|
||||||
|
mRingMode = RingModeSettings.CREATOR.createFromParcel(in);
|
||||||
|
}
|
||||||
|
if (in.readInt() != 0) {
|
||||||
|
mAirplaneMode = AirplaneModeSettings.CREATOR.createFromParcel(in);
|
||||||
|
}
|
||||||
|
if (in.readInt() != 0) {
|
||||||
|
mBrightness = BrightnessSettings.CREATOR.createFromParcel(in);
|
||||||
|
}
|
||||||
|
mScreenLockMode = in.readInt();
|
||||||
|
in.readMap(mTriggers, null);
|
||||||
|
mExpandedDesktopMode = in.readInt();
|
||||||
|
mDozeMode = in.readInt();
|
||||||
}
|
}
|
||||||
if (in.readInt() != 0) {
|
|
||||||
mRingMode = RingModeSettings.CREATOR.createFromParcel(in);
|
in.setDataPosition(startPosition + parcelableSize);
|
||||||
}
|
|
||||||
if (in.readInt() != 0) {
|
|
||||||
mAirplaneMode = AirplaneModeSettings.CREATOR.createFromParcel(in);
|
|
||||||
}
|
|
||||||
if (in.readInt() != 0) {
|
|
||||||
mBrightness = BrightnessSettings.CREATOR.createFromParcel(in);
|
|
||||||
}
|
|
||||||
mScreenLockMode = in.readInt();
|
|
||||||
in.readMap(mTriggers, null);
|
|
||||||
mExpandedDesktopMode = in.readInt();
|
|
||||||
mDozeMode = in.readInt();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,6 +18,7 @@ package cyanogenmod.app;
|
||||||
|
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.NotificationGroup;
|
import android.app.NotificationGroup;
|
||||||
|
import cyanogenmod.os.Build;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
|
@ -263,32 +264,61 @@ public final class ProfileGroup implements Parcelable {
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
// Write parcelable version, make sure to define explicit changes
|
||||||
|
// within {@link Build.PARCELABLE_VERSION);
|
||||||
|
dest.writeInt(Build.PARCELABLE_VERSION);
|
||||||
|
|
||||||
|
// Inject a placeholder that will store the parcel size from this point on
|
||||||
|
// (not including the size itself).
|
||||||
|
int sizePosition = dest.dataPosition();
|
||||||
|
dest.writeInt(0);
|
||||||
|
int startPosition = dest.dataPosition();
|
||||||
|
|
||||||
|
// === BOYSENBERRY ===
|
||||||
dest.writeString(mName);
|
dest.writeString(mName);
|
||||||
new ParcelUuid(mUuid).writeToParcel(dest, 0);
|
new ParcelUuid(mUuid).writeToParcel(dest, 0);
|
||||||
dest.writeInt(mDefaultGroup ? 1 : 0);
|
dest.writeInt(mDefaultGroup ? 1 : 0);
|
||||||
dest.writeInt(mDirty ? 1 : 0);
|
dest.writeInt(mDirty ? 1 : 0);
|
||||||
dest.writeParcelable(mSoundOverride, flags);
|
dest.writeParcelable(mSoundOverride, flags);
|
||||||
dest.writeParcelable(mRingerOverride, flags);
|
dest.writeParcelable(mRingerOverride, flags);
|
||||||
|
|
||||||
dest.writeString(mSoundMode.name());
|
dest.writeString(mSoundMode.name());
|
||||||
dest.writeString(mRingerMode.name());
|
dest.writeString(mRingerMode.name());
|
||||||
dest.writeString(mVibrateMode.name());
|
dest.writeString(mVibrateMode.name());
|
||||||
dest.writeString(mLightsMode.name());
|
dest.writeString(mLightsMode.name());
|
||||||
|
|
||||||
|
// Go back and write size
|
||||||
|
int parcelableSize = dest.dataPosition() - startPosition;
|
||||||
|
dest.setDataPosition(sizePosition);
|
||||||
|
dest.writeInt(parcelableSize);
|
||||||
|
dest.setDataPosition(startPosition + parcelableSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void readFromParcel(Parcel in) {
|
public void readFromParcel(Parcel in) {
|
||||||
mName = in.readString();
|
// Read parcelable version, make sure to define explicit changes
|
||||||
mUuid = ParcelUuid.CREATOR.createFromParcel(in).getUuid();
|
// within {@link Build.PARCELABLE_VERSION);
|
||||||
mDefaultGroup = in.readInt() != 0;
|
int parcelableVersion = in.readInt();
|
||||||
mDirty = in.readInt() != 0;
|
int parcelableSize = in.readInt();
|
||||||
mSoundOverride = in.readParcelable(null);
|
int startPosition = in.dataPosition();
|
||||||
mRingerOverride = in.readParcelable(null);
|
|
||||||
|
|
||||||
mSoundMode = Mode.valueOf(Mode.class, in.readString());
|
// Pattern here is that all new members should be added to the end of
|
||||||
mRingerMode = Mode.valueOf(Mode.class, in.readString());
|
// the writeToParcel method. Then we step through each version, until the latest
|
||||||
mVibrateMode = Mode.valueOf(Mode.class, in.readString());
|
// API release to help unravel this parcel
|
||||||
mLightsMode = Mode.valueOf(Mode.class, in.readString());
|
if (parcelableVersion >= Build.CM_VERSION_CODES.BOYSENBERRY) {
|
||||||
|
mName = in.readString();
|
||||||
|
mUuid = ParcelUuid.CREATOR.createFromParcel(in).getUuid();
|
||||||
|
mDefaultGroup = in.readInt() != 0;
|
||||||
|
mDirty = in.readInt() != 0;
|
||||||
|
mSoundOverride = in.readParcelable(null);
|
||||||
|
mRingerOverride = in.readParcelable(null);
|
||||||
|
|
||||||
|
mSoundMode = Mode.valueOf(Mode.class, in.readString());
|
||||||
|
mRingerMode = Mode.valueOf(Mode.class, in.readString());
|
||||||
|
mVibrateMode = Mode.valueOf(Mode.class, in.readString());
|
||||||
|
mLightsMode = Mode.valueOf(Mode.class, in.readString());
|
||||||
|
}
|
||||||
|
|
||||||
|
in.setDataPosition(startPosition + parcelableSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Mode {
|
public enum Mode {
|
||||||
|
|
|
@ -19,6 +19,7 @@ package cyanogenmod.app;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
|
import cyanogenmod.os.Build;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class encapsulating a Custom Tile. Sent by the StatusBarManagerService to clients including
|
* Class encapsulating a Custom Tile. Sent by the StatusBarManagerService to clients including
|
||||||
|
@ -66,21 +67,62 @@ public class StatusBarPanelCustomTile implements Parcelable {
|
||||||
|
|
||||||
|
|
||||||
public StatusBarPanelCustomTile(Parcel in) {
|
public StatusBarPanelCustomTile(Parcel in) {
|
||||||
this.pkg = in.readString();
|
// Read parcelable version, make sure to define explicit changes
|
||||||
this.resPkg = in.readString();
|
// within {@link Build.PARCELABLE_VERSION);
|
||||||
this.opPkg = in.readString();
|
int parcelableVersion = in.readInt();
|
||||||
this.id = in.readInt();
|
int parcelableSize = in.readInt();
|
||||||
if (in.readInt() != 0) {
|
int startPosition = in.dataPosition();
|
||||||
this.tag = in.readString();
|
|
||||||
} else {
|
// tmp variables for final
|
||||||
this.tag = null;
|
String tmpResPkg = null;
|
||||||
|
String tmpPkg = null;
|
||||||
|
String tmpOpPkg = null;
|
||||||
|
int tmpId = -1;
|
||||||
|
String tmpTag = null;
|
||||||
|
int tmpUid = -1;
|
||||||
|
int tmpPid = -1;
|
||||||
|
CustomTile tmpCustomTile = null;
|
||||||
|
UserHandle tmpUser = null;
|
||||||
|
long tmpPostTime = -1;
|
||||||
|
|
||||||
|
// Pattern here is that all new members should be added to the end of
|
||||||
|
// the writeToParcel method. Then we step through each version, until the latest
|
||||||
|
// API release to help unravel this parcel
|
||||||
|
if (parcelableVersion >= Build.CM_VERSION_CODES.APRICOT) {
|
||||||
|
// default
|
||||||
|
tmpPkg = in.readString();
|
||||||
|
tmpOpPkg = in.readString();
|
||||||
|
tmpId = in.readInt();
|
||||||
|
if (in.readInt() != 0) {
|
||||||
|
tmpTag = in.readString();
|
||||||
|
} else {
|
||||||
|
tmpTag = null;
|
||||||
|
}
|
||||||
|
tmpUid = in.readInt();
|
||||||
|
tmpPid = in.readInt();
|
||||||
|
tmpCustomTile = new CustomTile(in);
|
||||||
|
tmpUser = UserHandle.readFromParcel(in);
|
||||||
|
tmpPostTime = in.readLong();
|
||||||
}
|
}
|
||||||
this.uid = in.readInt();
|
|
||||||
this.initialPid = in.readInt();
|
if (parcelableVersion >= Build.CM_VERSION_CODES.BOYSENBERRY) {
|
||||||
this.customTile = new CustomTile(in);
|
tmpResPkg = in.readString();
|
||||||
this.user = UserHandle.readFromParcel(in);
|
}
|
||||||
this.postTime = in.readLong();
|
|
||||||
|
// Assign finals
|
||||||
|
this.resPkg = tmpResPkg;
|
||||||
|
this.pkg = tmpPkg;
|
||||||
|
this.opPkg = tmpOpPkg;
|
||||||
|
this.id = tmpId;
|
||||||
|
this.tag = tmpTag;
|
||||||
|
this.uid = tmpUid;
|
||||||
|
this.initialPid = tmpPid;
|
||||||
|
this.customTile = tmpCustomTile;
|
||||||
|
this.user = tmpUser;
|
||||||
|
this.postTime = tmpPostTime;
|
||||||
this.key = key();
|
this.key = key();
|
||||||
|
|
||||||
|
in.setDataPosition(startPosition + parcelableSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String key() {
|
private String key() {
|
||||||
|
@ -115,8 +157,18 @@ public class StatusBarPanelCustomTile implements Parcelable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel out, int flags) {
|
public void writeToParcel(Parcel out, int flags) {
|
||||||
|
// Write parcelable version, make sure to define explicit changes
|
||||||
|
// within {@link Build.PARCELABLE_VERSION);
|
||||||
|
out.writeInt(Build.PARCELABLE_VERSION);
|
||||||
|
|
||||||
|
// Inject a placeholder that will store the parcel size from this point on
|
||||||
|
// (not including the size itself).
|
||||||
|
int sizePosition = out.dataPosition();
|
||||||
|
out.writeInt(0);
|
||||||
|
int startPosition = out.dataPosition();
|
||||||
|
|
||||||
|
// ==== APRICOT ===
|
||||||
out.writeString(this.pkg);
|
out.writeString(this.pkg);
|
||||||
out.writeString(this.resPkg);
|
|
||||||
out.writeString(this.opPkg);
|
out.writeString(this.opPkg);
|
||||||
out.writeInt(this.id);
|
out.writeInt(this.id);
|
||||||
if (this.tag != null) {
|
if (this.tag != null) {
|
||||||
|
@ -130,6 +182,15 @@ public class StatusBarPanelCustomTile implements Parcelable {
|
||||||
this.customTile.writeToParcel(out, flags);
|
this.customTile.writeToParcel(out, flags);
|
||||||
user.writeToParcel(out, flags);
|
user.writeToParcel(out, flags);
|
||||||
out.writeLong(this.postTime);
|
out.writeLong(this.postTime);
|
||||||
|
|
||||||
|
// ==== BOYSENBERRY =====
|
||||||
|
out.writeString(this.resPkg);
|
||||||
|
|
||||||
|
// Go back and write size
|
||||||
|
int parcelableSize = out.dataPosition() - startPosition;
|
||||||
|
out.setDataPosition(sizePosition);
|
||||||
|
out.writeInt(parcelableSize);
|
||||||
|
out.setDataPosition(startPosition + parcelableSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -27,6 +27,16 @@ public class Build {
|
||||||
/** Value used for when a build property is unknown. */
|
/** Value used for when a build property is unknown. */
|
||||||
public static final String UNKNOWN = "unknown";
|
public static final String UNKNOWN = "unknown";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Since there might be a case where new versions of the cm framework use applications running
|
||||||
|
* old versions of the protocol (and thus old versions of this class), we need a versioning
|
||||||
|
* system for the parcels sent between the core framework and its sdk users.
|
||||||
|
*
|
||||||
|
* This parcelable version should be the latest version API version listed in
|
||||||
|
* {@link CM_VERSION_CODES}
|
||||||
|
*/
|
||||||
|
public static final int PARCELABLE_VERSION = CM_VERSION_CODES.BOYSENBERRY;
|
||||||
|
|
||||||
private static final SparseArray<String> sdkMap;
|
private static final SparseArray<String> sdkMap;
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,6 +22,7 @@ import android.provider.Settings;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
import cyanogenmod.os.Build;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
|
@ -187,15 +188,45 @@ public final class AirplaneModeSettings implements Parcelable {
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
// Write parcelable version, make sure to define explicit changes
|
||||||
|
// within {@link Build.PARCELABLE_VERSION);
|
||||||
|
dest.writeInt(Build.PARCELABLE_VERSION);
|
||||||
|
|
||||||
|
// Inject a placeholder that will store the parcel size from this point on
|
||||||
|
// (not including the size itself).
|
||||||
|
int sizePosition = dest.dataPosition();
|
||||||
|
dest.writeInt(0);
|
||||||
|
int startPosition = dest.dataPosition();
|
||||||
|
|
||||||
|
// === BOYSENBERRY ===
|
||||||
dest.writeInt(mOverride ? 1 : 0);
|
dest.writeInt(mOverride ? 1 : 0);
|
||||||
dest.writeInt(mValue);
|
dest.writeInt(mValue);
|
||||||
dest.writeInt(mDirty ? 1 : 0);
|
dest.writeInt(mDirty ? 1 : 0);
|
||||||
|
|
||||||
|
// Go back and write size
|
||||||
|
int parcelableSize = dest.dataPosition() - startPosition;
|
||||||
|
dest.setDataPosition(sizePosition);
|
||||||
|
dest.writeInt(parcelableSize);
|
||||||
|
dest.setDataPosition(startPosition + parcelableSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void readFromParcel(Parcel in) {
|
public void readFromParcel(Parcel in) {
|
||||||
mOverride = in.readInt() != 0;
|
// Read parcelable version, make sure to define explicit changes
|
||||||
mValue = in.readInt();
|
// within {@link Build.PARCELABLE_VERSION);
|
||||||
mDirty = in.readInt() != 0;
|
int parcelableVersion = in.readInt();
|
||||||
|
int parcelableSize = in.readInt();
|
||||||
|
int startPosition = in.dataPosition();
|
||||||
|
|
||||||
|
// Pattern here is that all new members should be added to the end of
|
||||||
|
// the writeToParcel method. Then we step through each version, until the latest
|
||||||
|
// API release to help unravel this parcel
|
||||||
|
if (parcelableVersion >= Build.CM_VERSION_CODES.BOYSENBERRY) {
|
||||||
|
mOverride = in.readInt() != 0;
|
||||||
|
mValue = in.readInt();
|
||||||
|
mDirty = in.readInt() != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
in.setDataPosition(startPosition + parcelableSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import android.provider.Settings;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
import cyanogenmod.os.Build;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
|
@ -185,15 +186,45 @@ public final class BrightnessSettings implements Parcelable {
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
// Write parcelable version, make sure to define explicit changes
|
||||||
|
// within {@link Build.PARCELABLE_VERSION);
|
||||||
|
dest.writeInt(Build.PARCELABLE_VERSION);
|
||||||
|
|
||||||
|
// Inject a placeholder that will store the parcel size from this point on
|
||||||
|
// (not including the size itself).
|
||||||
|
int sizePosition = dest.dataPosition();
|
||||||
|
dest.writeInt(0);
|
||||||
|
int startPosition = dest.dataPosition();
|
||||||
|
|
||||||
|
// === BOYSENBERRY ===
|
||||||
dest.writeInt(mOverride ? 1 : 0);
|
dest.writeInt(mOverride ? 1 : 0);
|
||||||
dest.writeInt(mValue);
|
dest.writeInt(mValue);
|
||||||
dest.writeInt(mDirty ? 1 : 0);
|
dest.writeInt(mDirty ? 1 : 0);
|
||||||
|
|
||||||
|
// Go back and write size
|
||||||
|
int parcelableSize = dest.dataPosition() - startPosition;
|
||||||
|
dest.setDataPosition(sizePosition);
|
||||||
|
dest.writeInt(parcelableSize);
|
||||||
|
dest.setDataPosition(startPosition + parcelableSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void readFromParcel(Parcel in) {
|
public void readFromParcel(Parcel in) {
|
||||||
mOverride = in.readInt() != 0;
|
// Read parcelable version, make sure to define explicit changes
|
||||||
mValue = in.readInt();
|
// within {@link Build.PARCELABLE_VERSION);
|
||||||
mDirty = in.readInt() != 0;
|
int parcelableVersion = in.readInt();
|
||||||
|
int parcelableSize = in.readInt();
|
||||||
|
int startPosition = in.dataPosition();
|
||||||
|
|
||||||
|
// Pattern here is that all new members should be added to the end of
|
||||||
|
// the writeToParcel method. Then we step through each version, until the latest
|
||||||
|
// API release to help unravel this parcel
|
||||||
|
if (parcelableVersion >= Build.CM_VERSION_CODES.BOYSENBERRY) {
|
||||||
|
mOverride = in.readInt() != 0;
|
||||||
|
mValue = in.readInt();
|
||||||
|
mDirty = in.readInt() != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
in.setDataPosition(startPosition + parcelableSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import android.telephony.SubscriptionManager;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import com.android.internal.telephony.RILConstants;
|
import com.android.internal.telephony.RILConstants;
|
||||||
|
|
||||||
|
import cyanogenmod.os.Build;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
|
@ -390,17 +391,47 @@ public final class ConnectionSettings implements Parcelable {
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
// Write parcelable version, make sure to define explicit changes
|
||||||
|
// within {@link Build.PARCELABLE_VERSION);
|
||||||
|
dest.writeInt(Build.PARCELABLE_VERSION);
|
||||||
|
|
||||||
|
// Inject a placeholder that will store the parcel size from this point on
|
||||||
|
// (not including the size itself).
|
||||||
|
int sizePosition = dest.dataPosition();
|
||||||
|
dest.writeInt(0);
|
||||||
|
int startPosition = dest.dataPosition();
|
||||||
|
|
||||||
|
// === BOYSENBERRY ===
|
||||||
dest.writeInt(mConnectionId);
|
dest.writeInt(mConnectionId);
|
||||||
dest.writeInt(mOverride ? 1 : 0);
|
dest.writeInt(mOverride ? 1 : 0);
|
||||||
dest.writeInt(mValue);
|
dest.writeInt(mValue);
|
||||||
dest.writeInt(mDirty ? 1 : 0);
|
dest.writeInt(mDirty ? 1 : 0);
|
||||||
|
|
||||||
|
// Go back and write size
|
||||||
|
int parcelableSize = dest.dataPosition() - startPosition;
|
||||||
|
dest.setDataPosition(sizePosition);
|
||||||
|
dest.writeInt(parcelableSize);
|
||||||
|
dest.setDataPosition(startPosition + parcelableSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void readFromParcel(Parcel in) {
|
public void readFromParcel(Parcel in) {
|
||||||
mConnectionId = in.readInt();
|
// Read parcelable version, make sure to define explicit changes
|
||||||
mOverride = in.readInt() != 0;
|
// within {@link Build.PARCELABLE_VERSION);
|
||||||
mValue = in.readInt();
|
int parcelableVersion = in.readInt();
|
||||||
mDirty = in.readInt() != 0;
|
int parcelableSize = in.readInt();
|
||||||
|
int startPosition = in.dataPosition();
|
||||||
|
|
||||||
|
// Pattern here is that all new members should be added to the end of
|
||||||
|
// the writeToParcel method. Then we step through each version, until the latest
|
||||||
|
// API release to help unravel this parcel
|
||||||
|
if (parcelableVersion >= Build.CM_VERSION_CODES.BOYSENBERRY) {
|
||||||
|
mConnectionId = in.readInt();
|
||||||
|
mOverride = in.readInt() != 0;
|
||||||
|
mValue = in.readInt();
|
||||||
|
mDirty = in.readInt() != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
in.setDataPosition(startPosition + parcelableSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import android.media.AudioManager;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
import cyanogenmod.os.Build;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
|
@ -177,15 +178,45 @@ public final class RingModeSettings implements Parcelable {
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
// Write parcelable version, make sure to define explicit changes
|
||||||
|
// within {@link Build.PARCELABLE_VERSION);
|
||||||
|
dest.writeInt(Build.PARCELABLE_VERSION);
|
||||||
|
|
||||||
|
// Inject a placeholder that will store the parcel size from this point on
|
||||||
|
// (not including the size itself).
|
||||||
|
int sizePosition = dest.dataPosition();
|
||||||
|
dest.writeInt(0);
|
||||||
|
int startPosition = dest.dataPosition();
|
||||||
|
|
||||||
|
// === BOYSENBERRY ===
|
||||||
dest.writeInt(mOverride ? 1 : 0);
|
dest.writeInt(mOverride ? 1 : 0);
|
||||||
dest.writeString(mValue);
|
dest.writeString(mValue);
|
||||||
dest.writeInt(mDirty ? 1 : 0);
|
dest.writeInt(mDirty ? 1 : 0);
|
||||||
|
|
||||||
|
// Go back and write size
|
||||||
|
int parcelableSize = dest.dataPosition() - startPosition;
|
||||||
|
dest.setDataPosition(sizePosition);
|
||||||
|
dest.writeInt(parcelableSize);
|
||||||
|
dest.setDataPosition(startPosition + parcelableSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void readFromParcel(Parcel in) {
|
public void readFromParcel(Parcel in) {
|
||||||
mOverride = in.readInt() != 0;
|
// Read parcelable version, make sure to define explicit changes
|
||||||
mValue = in.readString();
|
// within {@link Build.PARCELABLE_VERSION);
|
||||||
mDirty = in.readInt() != 0;
|
int parcelableVersion = in.readInt();
|
||||||
|
int parcelableSize = in.readInt();
|
||||||
|
int startPosition = in.dataPosition();
|
||||||
|
|
||||||
|
// Pattern here is that all new members should be added to the end of
|
||||||
|
// the writeToParcel method. Then we step through each version, until the latest
|
||||||
|
// API release to help unravel this parcel
|
||||||
|
if (parcelableVersion >= Build.CM_VERSION_CODES.BOYSENBERRY) {
|
||||||
|
mOverride = in.readInt() != 0;
|
||||||
|
mValue = in.readString();
|
||||||
|
mDirty = in.readInt() != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
in.setDataPosition(startPosition + parcelableSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package cyanogenmod.profiles;
|
package cyanogenmod.profiles;
|
||||||
|
|
||||||
|
import cyanogenmod.os.Build;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
|
@ -176,17 +177,47 @@ public final class StreamSettings implements Parcelable{
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
// Write parcelable version, make sure to define explicit changes
|
||||||
|
// within {@link Build.PARCELABLE_VERSION);
|
||||||
|
dest.writeInt(Build.PARCELABLE_VERSION);
|
||||||
|
|
||||||
|
// Inject a placeholder that will store the parcel size from this point on
|
||||||
|
// (not including the size itself).
|
||||||
|
int sizePosition = dest.dataPosition();
|
||||||
|
dest.writeInt(0);
|
||||||
|
int startPosition = dest.dataPosition();
|
||||||
|
|
||||||
|
// === BOYSENBERRY ===
|
||||||
dest.writeInt(mStreamId);
|
dest.writeInt(mStreamId);
|
||||||
dest.writeInt(mOverride ? 1 : 0);
|
dest.writeInt(mOverride ? 1 : 0);
|
||||||
dest.writeInt(mValue);
|
dest.writeInt(mValue);
|
||||||
dest.writeInt(mDirty ? 1 : 0);
|
dest.writeInt(mDirty ? 1 : 0);
|
||||||
|
|
||||||
|
// Go back and write size
|
||||||
|
int parcelableSize = dest.dataPosition() - startPosition;
|
||||||
|
dest.setDataPosition(sizePosition);
|
||||||
|
dest.writeInt(parcelableSize);
|
||||||
|
dest.setDataPosition(startPosition + parcelableSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void readFromParcel(Parcel in) {
|
public void readFromParcel(Parcel in) {
|
||||||
mStreamId = in.readInt();
|
// Read parcelable version, make sure to define explicit changes
|
||||||
mOverride = in.readInt() != 0;
|
// within {@link Build.PARCELABLE_VERSION);
|
||||||
mValue = in.readInt();
|
int parcelableVersion = in.readInt();
|
||||||
mDirty = in.readInt() != 0;
|
int parcelableSize = in.readInt();
|
||||||
|
int startPosition = in.dataPosition();
|
||||||
|
|
||||||
|
// Pattern here is that all new members should be added to the end of
|
||||||
|
// the writeToParcel method. Then we step through each version, until the latest
|
||||||
|
// API release to help unravel this parcel
|
||||||
|
if (parcelableVersion >= Build.CM_VERSION_CODES.BOYSENBERRY) {
|
||||||
|
mStreamId = in.readInt();
|
||||||
|
mOverride = in.readInt() != 0;
|
||||||
|
mValue = in.readInt();
|
||||||
|
mDirty = in.readInt() != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
in.setDataPosition(startPosition + parcelableSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue