Loading apex/blobstore/framework/java/android/app/blob/AccessorInfo.java 0 → 100644 +119 −0 Original line number Diff line number Diff line /* * 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]; } }; } apex/blobstore/framework/java/android/app/blob/BlobInfo.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * 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 apex/blobstore/framework/java/android/app/blob/BlobInfo.java 0 → 100644 +109 −0 Original line number Diff line number Diff line /* * 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]; } }; } apex/blobstore/framework/java/android/app/blob/BlobStoreManager.java +27 −3 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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. Loading apex/blobstore/framework/java/android/app/blob/IBlobStoreManager.aidl +4 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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 Loading
apex/blobstore/framework/java/android/app/blob/AccessorInfo.java 0 → 100644 +119 −0 Original line number Diff line number Diff line /* * 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]; } }; }
apex/blobstore/framework/java/android/app/blob/BlobInfo.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * 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
apex/blobstore/framework/java/android/app/blob/BlobInfo.java 0 → 100644 +109 −0 Original line number Diff line number Diff line /* * 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]; } }; }
apex/blobstore/framework/java/android/app/blob/BlobStoreManager.java +27 −3 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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. Loading
apex/blobstore/framework/java/android/app/blob/IBlobStoreManager.aidl +4 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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