Debian Codegraph @

core/java/android/app/backup/RestoreDescription.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
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 * Description of the available restore data for a given package. Returned by a
26 * BackupTransport in response to a request about the next available restorable
27 * package.
28 *
29 * @see BackupTransport#nextRestorePackage()
30 *
31 * @hide
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 * Return this constant RestoreDescription from BackupTransport.nextRestorePackage()
42 * to indicate that no more package data is available in the current restore operation.
43 */
44 public static final RestoreDescription NO_MORE_PACKAGES =
45 new RestoreDescription(NO_MORE_PACKAGES_SENTINEL, 0);
46
47 // ---------------------------------------
48 // Data type identifiers
49
50 /** This package's restore data is an original-style key/value dataset */
51 public static final int TYPE_KEY_VALUE = 1;
52
53 /** This package's restore data is a tarball-type full data stream */
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 // API
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 // Parcelable implementation - not used by transport
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 }