Add a field for transport properties to RestoreSet object

Android Framework needs to know for each RestoreSet provided by
BackupTransport the properties of the transport (e.g. device-to-device
transport, encryption) that was used to obtain the data in the restore
set in question.

Bug: 182986784
CTS-Coverage-Bug: 183441953
Test: atest FullBackupRulesHostSideTest
Change-Id: I07bc2d4eb3837390ea3b0aee769d143ab153335d
This commit is contained in:
Ruslan Tkhakokhov
2021-03-18 13:02:39 +00:00
parent e05824f661
commit 3762670bb7
2 changed files with 47 additions and 7 deletions

View File

@@ -1191,12 +1191,14 @@ package android.app.backup {
public class RestoreSet implements android.os.Parcelable {
ctor public RestoreSet();
ctor public RestoreSet(String, String, long);
ctor public RestoreSet(@Nullable String, @Nullable String, long);
ctor public RestoreSet(@Nullable String, @Nullable String, long, int);
method public int describeContents();
method public void writeToParcel(android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.app.backup.RestoreSet> CREATOR;
field public String device;
field public String name;
field public final int backupTransportFlags;
field @Nullable public String device;
field @Nullable public String name;
field public long token;
}

View File

@@ -16,6 +16,7 @@
package android.app.backup;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
@@ -32,12 +33,14 @@ public class RestoreSet implements Parcelable {
* Name of this restore set. May be user generated, may simply be the name
* of the handset model, e.g. "T-Mobile G1".
*/
@Nullable
public String name;
/**
* Identifier of the device whose data this is. This will be as unique as
* is practically possible; for example, it might be an IMEI.
*/
@Nullable
public String device;
/**
@@ -47,15 +50,48 @@ public class RestoreSet implements Parcelable {
*/
public long token;
/**
* Properties of the {@link BackupTransport} transport that was used to obtain the data in
* this restore set.
*/
public final int backupTransportFlags;
/**
* Constructs a RestoreSet object that identifies a set of data that can be restored.
*/
public RestoreSet() {
// Leave everything zero / null
backupTransportFlags = 0;
}
public RestoreSet(String _name, String _dev, long _token) {
name = _name;
device = _dev;
token = _token;
/**
* Constructs a RestoreSet object that identifies a set of data that can be restored.
*
* @param name The name of the restore set.
* @param device The name of the device where the restore data is coming from.
* @param token The unique identifier for the current restore set.
*/
public RestoreSet(@Nullable String name, @Nullable String device, long token) {
this(name, device, token, /* backupTransportFlags */ 0);
}
/**
* Constructs a RestoreSet object that identifies a set of data that can be restored.
*
* @param name The name of the restore set.
* @param device The name of the device where the restore data is coming from.
* @param token The unique identifier for the current restore set.
* @param backupTransportFlags Flags returned by {@link BackupTransport#getTransportFlags()}
* implementation of the backup transport used by the source device
* to create this restore set. See {@link BackupAgent} for possible
* flag values.
*/
public RestoreSet(@Nullable String name, @Nullable String device, long token,
int backupTransportFlags) {
this.name = name;
this.device = device;
this.token = token;
this.backupTransportFlags = backupTransportFlags;
}
// Parcelable implementation
@@ -67,6 +103,7 @@ public class RestoreSet implements Parcelable {
out.writeString(name);
out.writeString(device);
out.writeLong(token);
out.writeInt(backupTransportFlags);
}
public static final @android.annotation.NonNull Parcelable.Creator<RestoreSet> CREATOR
@@ -84,5 +121,6 @@ public class RestoreSet implements Parcelable {
name = in.readString();
device = in.readString();
token = in.readLong();
backupTransportFlags = in.readInt();
}
}