| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.security.keymaster; |
| 18 |
|
| 19 |
import android.os.Parcel; |
| 20 |
import android.os.Parcelable; |
| 21 |
import android.os.ParcelFormatException; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
abstract class KeymasterArgument implements Parcelable { |
| 31 |
public final int tag; |
| 32 |
|
| 33 |
public static final @android.annotation.NonNull Parcelable.Creator<KeymasterArgument> CREATOR = new |
| 34 |
Parcelable.Creator<KeymasterArgument>() { |
| 35 |
@Override |
| 36 |
public KeymasterArgument createFromParcel(Parcel in) { |
| 37 |
final int pos = in.dataPosition(); |
| 38 |
final int tag = in.readInt(); |
| 39 |
switch (KeymasterDefs.getTagType(tag)) { |
| 40 |
case KeymasterDefs.KM_ENUM: |
| 41 |
case KeymasterDefs.KM_ENUM_REP: |
| 42 |
case KeymasterDefs.KM_UINT: |
| 43 |
case KeymasterDefs.KM_UINT_REP: |
| 44 |
return new KeymasterIntArgument(tag, in); |
| 45 |
case KeymasterDefs.KM_ULONG: |
| 46 |
case KeymasterDefs.KM_ULONG_REP: |
| 47 |
return new KeymasterLongArgument(tag, in); |
| 48 |
case KeymasterDefs.KM_DATE: |
| 49 |
return new KeymasterDateArgument(tag, in); |
| 50 |
case KeymasterDefs.KM_BYTES: |
| 51 |
case KeymasterDefs.KM_BIGNUM: |
| 52 |
return new KeymasterBlobArgument(tag, in); |
| 53 |
case KeymasterDefs.KM_BOOL: |
| 54 |
return new KeymasterBooleanArgument(tag, in); |
| 55 |
default: |
| 56 |
throw new ParcelFormatException("Bad tag: " + tag + " at " + pos); |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
@Override |
| 61 |
public KeymasterArgument[] newArray(int size) { |
| 62 |
return new KeymasterArgument[size]; |
| 63 |
} |
| 64 |
}; |
| 65 |
|
| 66 |
protected KeymasterArgument(int tag) { |
| 67 |
this.tag = tag; |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
public abstract void writeValue(Parcel out); |
| 74 |
|
| 75 |
@Override |
| 76 |
public int describeContents() { |
| 77 |
return 0; |
| 78 |
} |
| 79 |
|
| 80 |
@Override |
| 81 |
public void writeToParcel(Parcel out, int flags) { |
| 82 |
out.writeInt(tag); |
| 83 |
writeValue(out); |
| 84 |
} |
| 85 |
} |