Commit c4592694 authored by Ecco Park's avatar Ecco Park Committed by android-build-team Robot

Osu: fixed Mismatch between createFromParcel and writeToParcel

Bug: 77600924
Change-Id: I46d765892e8e6839ed5140a3b0d6bb1815ccf9bc
Signed-off-by: default avatarEcco Park <eccopark@google.com>
(cherry picked from commit 9a59cf84)
parent d60d1869
...@@ -42,6 +42,7 @@ public class OSUInfo implements Parcelable { ...@@ -42,6 +42,7 @@ public class OSUInfo implements Parcelable {
private HSIconFileElement mIconFileElement; private HSIconFileElement mIconFileElement;
private String mIconFileName; private String mIconFileName;
private IconInfo mIconInfo; private IconInfo mIconInfo;
private int mIconIndex;
public OSUInfo(ScanResult scanResult, OSUProvider osuProvider, int osuID) { public OSUInfo(ScanResult scanResult, OSUProvider osuProvider, int osuID) {
mOsuID = osuID; mOsuID = osuID;
...@@ -50,6 +51,7 @@ public class OSUInfo implements Parcelable { ...@@ -50,6 +51,7 @@ public class OSUInfo implements Parcelable {
mAnqpDomID = scanResult.anqpDomainId; mAnqpDomID = scanResult.anqpDomainId;
mAdvertisingSSID = scanResult.SSID; mAdvertisingSSID = scanResult.SSID;
mOSUProvider = osuProvider; mOSUProvider = osuProvider;
mIconIndex = -1;
} }
public long getOSUBssid() { public long getOSUBssid() {
...@@ -157,12 +159,15 @@ public class OSUInfo implements Parcelable { ...@@ -157,12 +159,15 @@ public class OSUInfo implements Parcelable {
public void setIconFileElement(HSIconFileElement iconFileElement, String fileName) { public void setIconFileElement(HSIconFileElement iconFileElement, String fileName) {
synchronized (mOSUProvider) { synchronized (mOSUProvider) {
mIconFileElement = iconFileElement; mIconFileElement = iconFileElement;
int index = 0;
for (IconInfo iconInfo : mOSUProvider.getIcons()) { for (IconInfo iconInfo : mOSUProvider.getIcons()) {
if (iconInfo.getFileName().equals(fileName)) { if (iconInfo.getFileName().equals(fileName)) {
mIconInfo = iconInfo; mIconInfo = iconInfo;
mIconFileName = fileName; mIconFileName = fileName;
mIconIndex = index;
break; break;
} }
index++;
} }
mIconStatus = IconStatus.Available; mIconStatus = IconStatus.Available;
} }
...@@ -285,9 +290,9 @@ public class OSUInfo implements Parcelable { ...@@ -285,9 +290,9 @@ public class OSUInfo implements Parcelable {
return; return;
} }
mIconFileElement = new HSIconFileElement(in); mIconFileElement = new HSIconFileElement(in);
int iconIndex = in.readInt(); mIconIndex = in.readInt();
mIconInfo = iconIndex >= 0 && iconIndex < mOSUProvider.getIcons().size() mIconInfo = mIconIndex >= 0 && mIconIndex < mOSUProvider.getIcons().size()
? mOSUProvider.getIcons().get(iconIndex) : null; ? mOSUProvider.getIcons().get(mIconIndex) : null;
} }
public static final Parcelable.Creator<OSUInfo> CREATOR = new Parcelable.Creator<OSUInfo>() { public static final Parcelable.Creator<OSUInfo> CREATOR = new Parcelable.Creator<OSUInfo>() {
...@@ -317,5 +322,6 @@ public class OSUInfo implements Parcelable { ...@@ -317,5 +322,6 @@ public class OSUInfo implements Parcelable {
dest.writeInt(mIconStatus.ordinal()); dest.writeInt(mIconStatus.ordinal());
mOSUProvider.writeParcel(dest); mOSUProvider.writeParcel(dest);
mIconFileElement.writeParcel(dest); mIconFileElement.writeParcel(dest);
dest.writeInt(mIconIndex);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment