| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.app.backup; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.SystemApi; |
| 21 |
import android.os.Parcel; |
| 22 |
import android.os.Parcelable; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
@SystemApi |
| 34 |
public class RestoreDescription implements Parcelable { |
| 35 |
private final String mPackageName; |
| 36 |
private final int mDataType; |
| 37 |
|
| 38 |
private static final String NO_MORE_PACKAGES_SENTINEL = "NO_MORE_PACKAGES"; |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
public static final RestoreDescription NO_MORE_PACKAGES = |
| 45 |
new RestoreDescription(NO_MORE_PACKAGES_SENTINEL, 0); |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
public static final int TYPE_KEY_VALUE = 1; |
| 52 |
|
| 53 |
|
| 54 |
public static final int TYPE_FULL_STREAM = 2; |
| 55 |
|
| 56 |
@NonNull |
| 57 |
@Override |
| 58 |
public String toString() { |
| 59 |
return "RestoreDescription{" + mPackageName + " : " |
| 60 |
+ ((mDataType == TYPE_KEY_VALUE) ? "KEY_VALUE" : "STREAM") |
| 61 |
+ '}'; |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
public RestoreDescription(String packageName, int dataType) { |
| 68 |
mPackageName = packageName; |
| 69 |
mDataType = dataType; |
| 70 |
} |
| 71 |
|
| 72 |
public String getPackageName() { |
| 73 |
return mPackageName; |
| 74 |
} |
| 75 |
|
| 76 |
public int getDataType() { |
| 77 |
return mDataType; |
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
@Override |
| 84 |
public int describeContents() { |
| 85 |
return 0; |
| 86 |
} |
| 87 |
|
| 88 |
@Override |
| 89 |
public void writeToParcel(Parcel out, int flags) { |
| 90 |
out.writeString(mPackageName); |
| 91 |
out.writeInt(mDataType); |
| 92 |
} |
| 93 |
|
| 94 |
public static final @android.annotation.NonNull Parcelable.Creator<RestoreDescription> CREATOR |
| 95 |
= new Parcelable.Creator<RestoreDescription>() { |
| 96 |
public RestoreDescription createFromParcel(Parcel in) { |
| 97 |
final RestoreDescription unparceled = new RestoreDescription(in); |
| 98 |
return (NO_MORE_PACKAGES_SENTINEL.equals(unparceled.mPackageName)) |
| 99 |
? NO_MORE_PACKAGES |
| 100 |
: unparceled; |
| 101 |
} |
| 102 |
|
| 103 |
public RestoreDescription[] newArray(int size) { |
| 104 |
return new RestoreDescription[size]; |
| 105 |
} |
| 106 |
}; |
| 107 |
|
| 108 |
private RestoreDescription(Parcel in) { |
| 109 |
mPackageName = in.readString(); |
| 110 |
mDataType = in.readInt(); |
| 111 |
} |
| 112 |
} |