1 package com.android.hotspot2.app; 2 3 import android.os.Parcel; 4 import android.os.Parcelable; 5 6 import com.android.hotspot2.flow.OSUInfo; 7 import com.android.hotspot2.osu.OSUManager; 8 9 public class OSUData implements Parcelable { 10 private final String mName; 11 private final String mServiceDescription; 12 private final byte[] mIconData; 13 private final int mId; 14 15 public OSUData(OSUInfo osuInfo) { 16 mName = osuInfo.getName(OSUManager.LOCALE); 17 mServiceDescription = osuInfo.getServiceDescription(OSUManager.LOCALE); 18 mIconData = osuInfo.getIconFileElement().getIconData(); 19 mId = osuInfo.getOsuID(); 20 } 21 22 public String getName() { 23 return mName; 24 } 25 26 public String getServiceDescription() { 27 return mServiceDescription; 28 } 29 30 public byte[] getIconData() { 31 return mIconData; 32 } 33 34 public int getId() { 35 return mId; 36 } 37 38 private OSUData(Parcel in) { 39 mName = in.readString(); 40 mServiceDescription = in.readString(); 41 int iconSize = in.readInt(); 42 mIconData = new byte[iconSize]; 43 in.readByteArray(mIconData); 44 mId = in.readInt(); 45 } 46 47 public static final Parcelable.Creator<OSUData> CREATOR = new Parcelable.Creator<OSUData>() { 48 public OSUData createFromParcel(Parcel in) { 49 return new OSUData(in); 50 } 51 52 public OSUData[] newArray(int size) { 53 return new OSUData[size]; 54 } 55 }; 56 57 @Override 58 public int describeContents() { 59 return 0; 60 } 61 62 @Override 63 public void writeToParcel(Parcel dest, int flags) { 64 dest.writeString(mName); 65 dest.writeString(mServiceDescription); 66 dest.writeByteArray(mIconData); 67 dest.writeInt(mId); 68 } 69 } 70