}
public final class LocusId implements android.os.Parcelable {
- ctor public LocusId(@NonNull android.net.Uri);
+ ctor public LocusId(@NonNull String);
method public int describeContents();
- method @NonNull public android.net.Uri getUri();
+ method @NonNull public String getId();
method public void writeToParcel(android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.content.LocusId> CREATOR;
}
public final class ContentCaptureContext implements android.os.Parcelable {
method public int describeContents();
- method @NonNull public static android.view.contentcapture.ContentCaptureContext forLocusId(@NonNull android.net.Uri);
+ method @NonNull public static android.view.contentcapture.ContentCaptureContext forLocusId(@NonNull String);
method @Nullable public android.os.Bundle getExtras();
method @NonNull public android.content.LocusId getLocusId();
method public void writeToParcel(android.os.Parcel, int);
method public boolean isForEverything();
method public void writeToParcel(android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.view.contentcapture.UserDataRemovalRequest> CREATOR;
+ field public static final int FLAG_IS_PREFIX = 1; // 0x1
}
public static final class UserDataRemovalRequest.Builder {
ctor public UserDataRemovalRequest.Builder();
- method @NonNull public android.view.contentcapture.UserDataRemovalRequest.Builder addLocusId(@NonNull android.content.LocusId, boolean);
+ method @NonNull public android.view.contentcapture.UserDataRemovalRequest.Builder addLocusId(@NonNull android.content.LocusId, int);
method @NonNull public android.view.contentcapture.UserDataRemovalRequest build();
method @NonNull public android.view.contentcapture.UserDataRemovalRequest.Builder forEverything();
}
public final class UserDataRemovalRequest.LocusIdRequest {
+ method @NonNull public int getFlags();
method @NonNull public android.content.LocusId getLocusId();
- method @NonNull public boolean isRecursive();
}
}
package android.content;
import android.annotation.NonNull;
-import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
// TODO(b/123577059): make sure this is well documented and understandable
public final class LocusId implements Parcelable {
- private final Uri mUri;
+ private final String mId;
/**
* Default constructor.
*/
- public LocusId(@NonNull Uri uri) {
- mUri = Preconditions.checkNotNull(uri);
+ public LocusId(@NonNull String id) {
+ mId = Preconditions.checkNotNull(id);
}
/**
- * Gets the {@code uri} associated with the locus.
+ * Gets the {@code id} associated with the locus.
*/
@NonNull
- public Uri getUri() {
- return mUri;
+ public String getId() {
+ return mId;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((mUri == null) ? 0 : mUri.hashCode());
+ result = prime * result + ((mId == null) ? 0 : mId.hashCode());
return result;
}
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
final LocusId other = (LocusId) obj;
- if (mUri == null) {
- if (other.mUri != null) return false;
+ if (mId == null) {
+ if (other.mId != null) return false;
} else {
- if (!mUri.equals(other.mUri)) return false;
+ if (!mId.equals(other.mId)) return false;
}
return true;
}
@Override
public String toString() {
- return "LocusId[uri=" + getSanitizedUri() + "]";
+ return "LocusId[" + getSanitizedId() + "]";
}
/** @hide */
public void dump(@NonNull PrintWriter pw) {
- pw.print("uri:"); pw.println(getSanitizedUri());
+ pw.print("id:"); pw.println(getSanitizedId());
}
- private String getSanitizedUri() {
- final int size = mUri.toString().length();
+ @NonNull
+ private String getSanitizedId() {
+ final int size = mId.length();
return size + "_chars";
}
}
@Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeParcelable(mUri, flags);
+ public void writeToParcel(Parcel parcel, int flags) {
+ parcel.writeString(mId);
}
public static final @android.annotation.NonNull Parcelable.Creator<LocusId> CREATOR =
@NonNull
@Override
- public LocusId createFromParcel(Parcel source) {
- final Uri uri = source.readParcelable(null);
- return new LocusId(uri);
+ public LocusId createFromParcel(Parcel parcel) {
+ return new LocusId(parcel.readString());
}
@NonNull
import android.content.ComponentName;
import android.content.Context;
import android.content.LocusId;
-import android.net.Uri;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
}
/**
- * Helper that creates a {@link ContentCaptureContext} associated with the given {@code uri}.
+ * Helper that creates a {@link ContentCaptureContext} associated with the given {@code id}.
*/
@NonNull
- public static ContentCaptureContext forLocusId(@NonNull Uri uri) {
- return new Builder(new LocusId(uri)).build();
+ public static ContentCaptureContext forLocusId(@NonNull String id) {
+ return new Builder(new LocusId(id)).build();
}
/**
*/
package android.view.contentcapture;
+import android.annotation.IntDef;
import android.annotation.NonNull;
import android.app.ActivityThread;
import android.content.LocusId;
import com.android.internal.util.Preconditions;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.List;
*/
public final class UserDataRemovalRequest implements Parcelable {
+ /**
+ * When set, service should use the {@link LocusId#getId()} as prefix for the data to be
+ * removed.
+ */
+ public static final int FLAG_IS_PREFIX = 0x1;
+
+ /** @hide */
+ @IntDef(prefix = { "FLAG" }, flag = true, value = {
+ FLAG_IS_PREFIX
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ @interface Flags {}
+
private final String mPackageName;
private final boolean mForEverything;
mLocusIdRequests = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
mLocusIdRequests.add(new LocusIdRequest(builder.mLocusIds.get(i),
- builder.mRecursive.get(i) == 1));
+ builder.mFlags.get(i)));
}
}
}
mLocusIdRequests = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
mLocusIdRequests.add(new LocusIdRequest((LocusId) parcel.readValue(null),
- parcel.readBoolean()));
+ parcel.readInt()));
}
}
}
private boolean mForEverything;
private ArrayList<LocusId> mLocusIds;
- private IntArray mRecursive;
+ private IntArray mFlags;
private boolean mDestroyed;
* Request service to remove data associated with a given {@link LocusId}.
*
* @param locusId the {@link LocusId} being requested to be removed.
- * @param recursive whether it should remove the data associated with just the
- * {@code LocusId} or its tree of descendants.
+ * @param flags either {@link UserDataRemovalRequest#FLAG_IS_PREFIX} or {@code 0}
*
* @return this builder
*/
@NonNull
- public Builder addLocusId(@NonNull LocusId locusId, boolean recursive) {
+ public Builder addLocusId(@NonNull LocusId locusId, @Flags int flags) {
throwIfDestroyed();
Preconditions.checkState(!mForEverything, "Already is for everything");
Preconditions.checkNotNull(locusId);
+ // felipeal: check flags
if (mLocusIds == null) {
mLocusIds = new ArrayList<>();
- mRecursive = new IntArray();
+ mFlags = new IntArray();
}
mLocusIds.add(locusId);
- mRecursive.add(recursive ? 1 : 0);
+ mFlags.add(flags);
return this;
}
public UserDataRemovalRequest build() {
throwIfDestroyed();
- Preconditions.checkState(mForEverything || mLocusIds != null);
+ Preconditions.checkState(mForEverything || mLocusIds != null,
+ "must call either #forEverything() or add one #addLocusId()");
mDestroyed = true;
return new UserDataRemovalRequest(this);
for (int i = 0; i < size; i++) {
final LocusIdRequest request = mLocusIdRequests.get(i);
parcel.writeValue(request.getLocusId());
- parcel.writeBoolean(request.isRecursive());
+ parcel.writeInt(request.getFlags());
}
}
}
*/
public final class LocusIdRequest {
private final @NonNull LocusId mLocusId;
- private final boolean mRecursive;
+ private final @Flags int mFlags;
- private LocusIdRequest(@NonNull LocusId locusId, boolean recursive) {
+ private LocusIdRequest(@NonNull LocusId locusId, @Flags int flags) {
this.mLocusId = locusId;
- this.mRecursive = recursive;
+ this.mFlags = flags;
}
/**
}
/**
- * Checks whether the request is to remove just the data associated with the {@link LocusId}
- * per se, or also its descendants.
+ * Gets the flags associates with request.
+ *
+ * @return either {@link UserDataRemovalRequest#FLAG_IS_PREFIX} or {@code 0}.
*/
@NonNull
- public boolean isRecursive() {
- return mRecursive;
+ public @Flags int getFlags() {
+ return mFlags;
}
}
}
import static org.testng.Assert.assertThrows;
import android.content.LocusId;
-import android.net.Uri;
import android.os.Parcel;
import android.os.SystemClock;
import android.view.autofill.AutofillId;
private static final long MY_EPOCH = SystemClock.uptimeMillis();
- private static final LocusId ID = new LocusId(Uri.parse("WHATEVER"));
+ private static final LocusId ID = new LocusId("WHATEVER");
// Not using @Mock because it's final - no need to be fancy here....
private final ContentCaptureContext mClientContext =