Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 188abab5 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Add @TestApis getLeasedBlobs() and getLeaseInfo()." into rvc-dev am: c95e8472

Change-Id: Ic22a495f9e8584d2e85c18e8c9cd44401bd738cd
parents 1bd14787 c95e8472
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -121,8 +121,9 @@ public class BlobStorePerfTests {
    }

    private DummyBlobData prepareDataBlob(int fileSizeInMb) throws Exception {
        final DummyBlobData blobData = new DummyBlobData(mContext,
                fileSizeInMb * 1024 * 1024 /* bytes */);
        final DummyBlobData blobData = new DummyBlobData.Builder(mContext)
                .setFileSize(fileSizeInMb * 1024 * 1024 /* bytes */)
                .build();
        blobData.prepare();
        return blobData;
    }
+8 −8
Original line number Diff line number Diff line
@@ -32,21 +32,21 @@ public final class BlobInfo implements Parcelable {
    private final long mId;
    private final long mExpiryTimeMs;
    private final CharSequence mLabel;
    private final List<AccessorInfo> mAccessors;
    private final List<LeaseInfo> mLeaseInfos;

    public BlobInfo(long id, long expiryTimeMs, CharSequence label,
            List<AccessorInfo> accessors) {
            List<LeaseInfo> leaseInfos) {
        mId = id;
        mExpiryTimeMs = expiryTimeMs;
        mLabel = label;
        mAccessors = accessors;
        mLeaseInfos = leaseInfos;
    }

    private BlobInfo(Parcel in) {
        mId = in.readLong();
        mExpiryTimeMs = in.readLong();
        mLabel = in.readCharSequence();
        mAccessors = in.readArrayList(null /* classloader */);
        mLeaseInfos = in.readArrayList(null /* classloader */);
    }

    public long getId() {
@@ -61,8 +61,8 @@ public final class BlobInfo implements Parcelable {
        return mLabel;
    }

    public List<AccessorInfo> getAccessors() {
        return Collections.unmodifiableList(mAccessors);
    public List<LeaseInfo> getLeases() {
        return Collections.unmodifiableList(mLeaseInfos);
    }

    @Override
@@ -70,7 +70,7 @@ public final class BlobInfo implements Parcelable {
        dest.writeLong(mId);
        dest.writeLong(mExpiryTimeMs);
        dest.writeCharSequence(mLabel);
        dest.writeList(mAccessors);
        dest.writeList(mLeaseInfos);
    }

    @Override
@@ -83,7 +83,7 @@ public final class BlobInfo implements Parcelable {
                + "id: " + mId + ","
                + "expiryMs: " + mExpiryTimeMs + ","
                + "label: " + mLabel + ","
                + "accessors: " + AccessorInfo.toShortString(mAccessors) + ","
                + "leases: " + LeaseInfo.toShortString(mLeaseInfos) + ","
                + "}";
    }

+45 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.annotation.CurrentTimeMillisLong;
import android.annotation.IdRes;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.content.Context;
@@ -521,6 +522,50 @@ public class BlobStoreManager {
        }
    }

    /**
     * Return the {@link BlobHandle BlobHandles} corresponding to the data blobs that
     * the calling app has acquired a lease on using {@link #acquireLease(BlobHandle, int)} or
     * one of it's other variants.
     *
     * @hide
     */
    @TestApi
    @NonNull
    public List<BlobHandle> getLeasedBlobs() throws IOException {
        try {
            return mService.getLeasedBlobs(mContext.getOpPackageName());
        } catch (ParcelableException e) {
            e.maybeRethrow(IOException.class);
            throw new RuntimeException(e);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Return {@link LeaseInfo} representing a lease acquired using
     * {@link #acquireLease(BlobHandle, int)} or one of it's other variants,
     * or {@code null} if there is no lease acquired.
     *
     * @throws SecurityException when the blob represented by the {@code blobHandle} does not
     *                           exist or the caller does not have access to it.
     * @throws IllegalArgumentException when {@code blobHandle} is invalid.
     *
     * @hide
     */
    @TestApi
    @Nullable
    public LeaseInfo getLeaseInfo(@NonNull BlobHandle blobHandle) throws IOException {
        try {
            return mService.getLeaseInfo(blobHandle, mContext.getOpPackageName());
        } 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.
+4 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.app.blob;
import android.app.blob.BlobHandle;
import android.app.blob.BlobInfo;
import android.app.blob.IBlobStoreSession;
import android.app.blob.LeaseInfo;
import android.os.RemoteCallback;

/** {@hide} */
@@ -35,4 +36,7 @@ interface IBlobStoreManager {

    List<BlobInfo> queryBlobsForUser(int userId);
    void deleteBlob(long blobId);

    List<BlobHandle> getLeasedBlobs(in String packageName);
    LeaseInfo getLeaseInfo(in BlobHandle blobHandle, in String packageName);
}
 No newline at end of file
+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 LeaseInfo;
 No newline at end of file
Loading