summaryrefslogtreecommitdiff
path: root/apex/blobstore/framework
diff options
context:
space:
mode:
Diffstat (limited to 'apex/blobstore/framework')
-rw-r--r--apex/blobstore/framework/java/android/app/blob/AccessorInfo.java119
-rw-r--r--apex/blobstore/framework/java/android/app/blob/BlobInfo.aidl19
-rw-r--r--apex/blobstore/framework/java/android/app/blob/BlobInfo.java109
-rw-r--r--apex/blobstore/framework/java/android/app/blob/BlobStoreManager.java30
-rw-r--r--apex/blobstore/framework/java/android/app/blob/IBlobStoreManager.aidl4
5 files changed, 278 insertions, 3 deletions
diff --git a/apex/blobstore/framework/java/android/app/blob/AccessorInfo.java b/apex/blobstore/framework/java/android/app/blob/AccessorInfo.java
new file mode 100644
index 000000000000..3725ad4a6c09
--- /dev/null
+++ b/apex/blobstore/framework/java/android/app/blob/AccessorInfo.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.app.blob;
+
+import android.annotation.NonNull;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.List;
+
+/**
+ * Class to provide information about an accessor of a shared blob.
+ *
+ * @hide
+ */
+public final class AccessorInfo implements Parcelable {
+ private final String mPackageName;
+ private final long mExpiryTimeMs;
+ private final int mDescriptionResId;
+ private final CharSequence mDescription;
+
+ public AccessorInfo(String packageName, long expiryTimeMs,
+ int descriptionResId, CharSequence description) {
+ mPackageName = packageName;
+ mExpiryTimeMs = expiryTimeMs;
+ mDescriptionResId = descriptionResId;
+ mDescription = description;
+ }
+
+ private AccessorInfo(Parcel in) {
+ mPackageName = in.readString();
+ mExpiryTimeMs = in.readLong();
+ mDescriptionResId = in.readInt();
+ mDescription = in.readCharSequence();
+ }
+
+ public String getPackageName() {
+ return mPackageName;
+ }
+
+ public long getExpiryTimeMs() {
+ return mExpiryTimeMs;
+ }
+
+ public int getDescriptionResId() {
+ return mDescriptionResId;
+ }
+
+ public CharSequence getDescription() {
+ return mDescription;
+ }
+
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ dest.writeString(mPackageName);
+ dest.writeLong(mExpiryTimeMs);
+ dest.writeInt(mDescriptionResId);
+ dest.writeCharSequence(mDescription);
+ }
+
+ @Override
+ public String toString() {
+ return "AccessorInfo {"
+ + "package: " + mPackageName + ","
+ + "expiryMs: " + mExpiryTimeMs + ","
+ + "descriptionResId: " + mDescriptionResId + ","
+ + "description: " + mDescription + ","
+ + "}";
+ }
+
+ private String toShortString() {
+ return mPackageName;
+ }
+
+ public static String toShortString(List<AccessorInfo> accessors) {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("[");
+ for (int i = 0, size = accessors.size(); i < size; ++i) {
+ sb.append(accessors.get(i).toShortString());
+ sb.append(",");
+ }
+ sb.append("]");
+ return sb.toString();
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @NonNull
+ public static final Creator<AccessorInfo> CREATOR = new Creator<AccessorInfo>() {
+ @Override
+ @NonNull
+ public AccessorInfo createFromParcel(Parcel source) {
+ return new AccessorInfo(source);
+ }
+
+ @Override
+ @NonNull
+ public AccessorInfo[] newArray(int size) {
+ return new AccessorInfo[size];
+ }
+ };
+}
diff --git a/apex/blobstore/framework/java/android/app/blob/BlobInfo.aidl b/apex/blobstore/framework/java/android/app/blob/BlobInfo.aidl
new file mode 100644
index 000000000000..25497738f685
--- /dev/null
+++ b/apex/blobstore/framework/java/android/app/blob/BlobInfo.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.app.blob;
+
+/** {@hide} */
+parcelable BlobInfo; \ No newline at end of file
diff --git a/apex/blobstore/framework/java/android/app/blob/BlobInfo.java b/apex/blobstore/framework/java/android/app/blob/BlobInfo.java
new file mode 100644
index 000000000000..9746dd023002
--- /dev/null
+++ b/apex/blobstore/framework/java/android/app/blob/BlobInfo.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.app.blob;
+
+import android.annotation.NonNull;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Class to provide information about a shared blob.
+ *
+ * @hide
+ */
+public final class BlobInfo implements Parcelable {
+ private final long mId;
+ private final long mExpiryTimeMs;
+ private final CharSequence mLabel;
+ private final List<AccessorInfo> mAccessors;
+
+ public BlobInfo(long id, long expiryTimeMs, CharSequence label,
+ List<AccessorInfo> accessors) {
+ mId = id;
+ mExpiryTimeMs = expiryTimeMs;
+ mLabel = label;
+ mAccessors = accessors;
+ }
+
+ private BlobInfo(Parcel in) {
+ mId = in.readLong();
+ mExpiryTimeMs = in.readLong();
+ mLabel = in.readCharSequence();
+ mAccessors = in.readArrayList(null /* classloader */);
+ }
+
+ public long getId() {
+ return mId;
+ }
+
+ public long getExpiryTimeMs() {
+ return mExpiryTimeMs;
+ }
+
+ public CharSequence getLabel() {
+ return mLabel;
+ }
+
+ public List<AccessorInfo> getAccessors() {
+ return Collections.unmodifiableList(mAccessors);
+ }
+
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ dest.writeLong(mId);
+ dest.writeLong(mExpiryTimeMs);
+ dest.writeCharSequence(mLabel);
+ dest.writeList(mAccessors);
+ }
+
+ @Override
+ public String toString() {
+ return toShortString();
+ }
+
+ private String toShortString() {
+ return "BlobInfo {"
+ + "id: " + mId + ","
+ + "expiryMs: " + mExpiryTimeMs + ","
+ + "label: " + mLabel + ","
+ + "accessors: " + AccessorInfo.toShortString(mAccessors) + ","
+ + "}";
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @NonNull
+ public static final Creator<BlobInfo> CREATOR = new Creator<BlobInfo>() {
+ @Override
+ @NonNull
+ public BlobInfo createFromParcel(Parcel source) {
+ return new BlobInfo(source);
+ }
+
+ @Override
+ @NonNull
+ public BlobInfo[] newArray(int size) {
+ return new BlobInfo[size];
+ }
+ };
+}
diff --git a/apex/blobstore/framework/java/android/app/blob/BlobStoreManager.java b/apex/blobstore/framework/java/android/app/blob/BlobStoreManager.java
index d1e28e99b6d6..7af3f662c195 100644
--- a/apex/blobstore/framework/java/android/app/blob/BlobStoreManager.java
+++ b/apex/blobstore/framework/java/android/app/blob/BlobStoreManager.java
@@ -27,11 +27,13 @@ import android.os.ParcelFileDescriptor;
import android.os.ParcelableException;
import android.os.RemoteCallback;
import android.os.RemoteException;
+import android.os.UserHandle;
import com.android.internal.util.function.pooled.PooledLambda;
import java.io.Closeable;
import java.io.IOException;
+import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
@@ -145,9 +147,6 @@ public class BlobStoreManager {
/** @hide */
public static final int INVALID_RES_ID = -1;
- /** @hide */
- public static final String DESC_RES_TYPE_STRING = "string";
-
private final Context mContext;
private final IBlobStoreManager mService;
@@ -495,6 +494,31 @@ public class BlobStoreManager {
}
}
+ /** @hide */
+ @NonNull
+ public List<BlobInfo> queryBlobsForUser(@NonNull UserHandle user) throws IOException {
+ try {
+ return mService.queryBlobsForUser(user.getIdentifier());
+ } catch (ParcelableException e) {
+ e.maybeRethrow(IOException.class);
+ throw new RuntimeException(e);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /** @hide */
+ public void deleteBlob(@NonNull BlobInfo blobInfo) throws IOException {
+ try {
+ mService.deleteBlob(blobInfo.getId());
+ } catch (ParcelableException e) {
+ e.maybeRethrow(IOException.class);
+ throw new RuntimeException(e);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
/**
* Represents an ongoing session of a blob's contribution to the blob store managed by the
* system.
diff --git a/apex/blobstore/framework/java/android/app/blob/IBlobStoreManager.aidl b/apex/blobstore/framework/java/android/app/blob/IBlobStoreManager.aidl
index a85a25c9c4ad..beeb03f06ed7 100644
--- a/apex/blobstore/framework/java/android/app/blob/IBlobStoreManager.aidl
+++ b/apex/blobstore/framework/java/android/app/blob/IBlobStoreManager.aidl
@@ -16,6 +16,7 @@
package android.app.blob;
import android.app.blob.BlobHandle;
+import android.app.blob.BlobInfo;
import android.app.blob.IBlobStoreSession;
import android.os.RemoteCallback;
@@ -31,4 +32,7 @@ interface IBlobStoreManager {
void releaseLease(in BlobHandle handle, in String packageName);
void waitForIdle(in RemoteCallback callback);
+
+ List<BlobInfo> queryBlobsForUser(int userId);
+ void deleteBlob(long blobId);
} \ No newline at end of file