| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.os.health; |
| 18 |
|
| 19 |
import android.annotation.TestApi; |
| 20 |
import android.compat.annotation.UnsupportedAppUsage; |
| 21 |
import android.os.Build; |
| 22 |
import android.os.Parcel; |
| 23 |
import android.os.Parcelable; |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
@TestApi |
| 38 |
public class HealthStatsParceler implements Parcelable { |
| 39 |
private HealthStatsWriter mWriter; |
| 40 |
private HealthStats mHealthStats; |
| 41 |
|
| 42 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 43 |
public static final @android.annotation.NonNull Parcelable.Creator<HealthStatsParceler> CREATOR |
| 44 |
= new Parcelable.Creator<HealthStatsParceler>() { |
| 45 |
public HealthStatsParceler createFromParcel(Parcel in) { |
| 46 |
return new HealthStatsParceler(in); |
| 47 |
} |
| 48 |
|
| 49 |
public HealthStatsParceler[] newArray(int size) { |
| 50 |
return new HealthStatsParceler[size]; |
| 51 |
} |
| 52 |
}; |
| 53 |
|
| 54 |
public HealthStatsParceler(HealthStatsWriter writer) { |
| 55 |
mWriter = writer; |
| 56 |
} |
| 57 |
|
| 58 |
public HealthStatsParceler(Parcel in) { |
| 59 |
mHealthStats = new HealthStats(in); |
| 60 |
} |
| 61 |
|
| 62 |
public int describeContents() { |
| 63 |
return 0; |
| 64 |
} |
| 65 |
|
| 66 |
public void writeToParcel(Parcel out, int flags) { |
| 67 |
|
| 68 |
if (mWriter != null) { |
| 69 |
mWriter.flattenToParcel(out); |
| 70 |
} else { |
| 71 |
throw new RuntimeException("Can not re-parcel HealthStatsParceler that was" |
| 72 |
+ " constructed from a Parcel"); |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
public HealthStats getHealthStats() { |
| 77 |
if (mWriter != null) { |
| 78 |
final Parcel parcel = Parcel.obtain(); |
| 79 |
mWriter.flattenToParcel(parcel); |
| 80 |
parcel.setDataPosition(0); |
| 81 |
mHealthStats = new HealthStats(parcel); |
| 82 |
parcel.recycle(); |
| 83 |
} |
| 84 |
|
| 85 |
return mHealthStats; |
| 86 |
} |
| 87 |
} |
| 88 |
|