aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/cyanogenmod/profiles
diff options
context:
space:
mode:
authorAdnan Begovic <adnan@cyngn.com>2015-07-20 13:47:50 -0700
committerAdnan Begovic <adnan@cyngn.com>2015-07-20 21:57:43 -0700
commit33a24ad5890b3244bbb91fd4286ecd9ee682b273 (patch)
tree962f075d4a59cdc4186e174300c85a1b6ddce750 /src/java/cyanogenmod/profiles
parent5ff5e10bf01ace13f38750e694340ab41db03b59 (diff)
downloadvendor_cmsdk-33a24ad5890b3244bbb91fd4286ecd9ee682b273.zip
vendor_cmsdk-33a24ad5890b3244bbb91fd4286ecd9ee682b273.tar.gz
vendor_cmsdk-33a24ad5890b3244bbb91fd4286ecd9ee682b273.tar.bz2
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
Diffstat (limited to 'src/java/cyanogenmod/profiles')
-rw-r--r--src/java/cyanogenmod/profiles/AirplaneModeSettings.java37
-rw-r--r--src/java/cyanogenmod/profiles/BrightnessSettings.java37
-rw-r--r--src/java/cyanogenmod/profiles/ConnectionSettings.java39
-rw-r--r--src/java/cyanogenmod/profiles/RingModeSettings.java37
-rw-r--r--src/java/cyanogenmod/profiles/StreamSettings.java39
5 files changed, 172 insertions, 17 deletions
diff --git a/src/java/cyanogenmod/profiles/AirplaneModeSettings.java b/src/java/cyanogenmod/profiles/AirplaneModeSettings.java
index 563e297..f79bf84 100644
--- a/src/java/cyanogenmod/profiles/AirplaneModeSettings.java
+++ b/src/java/cyanogenmod/profiles/AirplaneModeSettings.java
@@ -22,6 +22,7 @@ import android.provider.Settings;
import android.os.Parcel;
import android.os.Parcelable;
+import cyanogenmod.os.Build;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -187,15 +188,45 @@ public final class AirplaneModeSettings implements Parcelable {
/** @hide */
@Override
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(mValue);
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 */
public void readFromParcel(Parcel in) {
- mOverride = in.readInt() != 0;
- mValue = in.readInt();
- mDirty = in.readInt() != 0;
+ // Read parcelable version, make sure to define explicit changes
+ // within {@link Build.PARCELABLE_VERSION);
+ 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);
}
}
diff --git a/src/java/cyanogenmod/profiles/BrightnessSettings.java b/src/java/cyanogenmod/profiles/BrightnessSettings.java
index c0b9438..eb74491 100644
--- a/src/java/cyanogenmod/profiles/BrightnessSettings.java
+++ b/src/java/cyanogenmod/profiles/BrightnessSettings.java
@@ -21,6 +21,7 @@ import android.provider.Settings;
import android.os.Parcel;
import android.os.Parcelable;
+import cyanogenmod.os.Build;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -185,15 +186,45 @@ public final class BrightnessSettings implements Parcelable {
/** @hide */
@Override
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(mValue);
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 */
public void readFromParcel(Parcel in) {
- mOverride = in.readInt() != 0;
- mValue = in.readInt();
- mDirty = in.readInt() != 0;
+ // Read parcelable version, make sure to define explicit changes
+ // within {@link Build.PARCELABLE_VERSION);
+ 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);
}
}
diff --git a/src/java/cyanogenmod/profiles/ConnectionSettings.java b/src/java/cyanogenmod/profiles/ConnectionSettings.java
index 61ad6b9..f8f745d 100644
--- a/src/java/cyanogenmod/profiles/ConnectionSettings.java
+++ b/src/java/cyanogenmod/profiles/ConnectionSettings.java
@@ -31,6 +31,7 @@ import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import com.android.internal.telephony.RILConstants;
+import cyanogenmod.os.Build;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -390,17 +391,47 @@ public final class ConnectionSettings implements Parcelable {
/** @hide */
@Override
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(mOverride ? 1 : 0);
dest.writeInt(mValue);
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 */
public void readFromParcel(Parcel in) {
- mConnectionId = in.readInt();
- mOverride = in.readInt() != 0;
- mValue = in.readInt();
- mDirty = in.readInt() != 0;
+ // Read parcelable version, make sure to define explicit changes
+ // within {@link Build.PARCELABLE_VERSION);
+ 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) {
+ mConnectionId = in.readInt();
+ mOverride = in.readInt() != 0;
+ mValue = in.readInt();
+ mDirty = in.readInt() != 0;
+ }
+
+ in.setDataPosition(startPosition + parcelableSize);
}
}
diff --git a/src/java/cyanogenmod/profiles/RingModeSettings.java b/src/java/cyanogenmod/profiles/RingModeSettings.java
index d7f6c03..befff5d 100644
--- a/src/java/cyanogenmod/profiles/RingModeSettings.java
+++ b/src/java/cyanogenmod/profiles/RingModeSettings.java
@@ -21,6 +21,7 @@ import android.media.AudioManager;
import android.os.Parcel;
import android.os.Parcelable;
+import cyanogenmod.os.Build;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -177,15 +178,45 @@ public final class RingModeSettings implements Parcelable {
/** @hide */
@Override
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.writeString(mValue);
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 */
public void readFromParcel(Parcel in) {
- mOverride = in.readInt() != 0;
- mValue = in.readString();
- mDirty = in.readInt() != 0;
+ // Read parcelable version, make sure to define explicit changes
+ // within {@link Build.PARCELABLE_VERSION);
+ 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);
}
}
diff --git a/src/java/cyanogenmod/profiles/StreamSettings.java b/src/java/cyanogenmod/profiles/StreamSettings.java
index 9898334..2d8b845 100644
--- a/src/java/cyanogenmod/profiles/StreamSettings.java
+++ b/src/java/cyanogenmod/profiles/StreamSettings.java
@@ -16,6 +16,7 @@
package cyanogenmod.profiles;
+import cyanogenmod.os.Build;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -176,17 +177,47 @@ public final class StreamSettings implements Parcelable{
/** @hide */
@Override
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(mOverride ? 1 : 0);
dest.writeInt(mValue);
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 */
public void readFromParcel(Parcel in) {
- mStreamId = in.readInt();
- mOverride = in.readInt() != 0;
- mValue = in.readInt();
- mDirty = in.readInt() != 0;
+ // Read parcelable version, make sure to define explicit changes
+ // within {@link Build.PARCELABLE_VERSION);
+ 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) {
+ mStreamId = in.readInt();
+ mOverride = in.readInt() != 0;
+ mValue = in.readInt();
+ mDirty = in.readInt() != 0;
+ }
+
+ in.setDataPosition(startPosition + parcelableSize);
}
}