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

Commit c7640aa6 authored by Saumya Pathak's avatar Saumya Pathak Committed by Android (Google) Code Review
Browse files

Merge "Adding StorageStats API to get external cache size"

parents ee5aac1d d2486196
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -8163,6 +8163,7 @@ package android.app.usage {
    method public long getAppBytes();
    method public long getCacheBytes();
    method public long getDataBytes();
    method public long getExternalCacheBytes();
    method public void writeToParcel(android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.app.usage.StorageStats> CREATOR;
  }
+14 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ public final class StorageStats implements Parcelable {
    /** {@hide} */ public long codeBytes;
    /** {@hide} */ public long dataBytes;
    /** {@hide} */ public long cacheBytes;
    /** {@hide} */ public long externalCacheBytes;

    /**
     * Return the size of app. This includes {@code APK} files, optimized
@@ -77,6 +78,17 @@ public final class StorageStats implements Parcelable {
        return cacheBytes;
    }

    /**
     * Return the size of all cached data in the primary external/shared storage.
     * This includes files stored under
     * {@link Context#getExternalCacheDir()}.
     * <p>
     * Cached data is isolated for each user on a multiuser device.
     */
    public @BytesLong long getExternalCacheBytes() {
        return externalCacheBytes;
    }

    /** {@hide} */
    public StorageStats() {
    }
@@ -86,6 +98,7 @@ public final class StorageStats implements Parcelable {
        this.codeBytes = in.readLong();
        this.dataBytes = in.readLong();
        this.cacheBytes = in.readLong();
        this.externalCacheBytes = in.readLong();
    }

    @Override
@@ -98,6 +111,7 @@ public final class StorageStats implements Parcelable {
        dest.writeLong(codeBytes);
        dest.writeLong(dataBytes);
        dest.writeLong(cacheBytes);
        dest.writeLong(externalCacheBytes);
    }

    public static final @android.annotation.NonNull Creator<StorageStats> CREATOR = new Creator<StorageStats>() {
+1 −0
Original line number Diff line number Diff line
@@ -514,6 +514,7 @@ public class StorageStatsService extends IStorageStatsManager.Stub {
        res.codeBytes = stats.codeSize + stats.externalCodeSize;
        res.dataBytes = stats.dataSize + stats.externalDataSize;
        res.cacheBytes = stats.cacheSize + stats.externalCacheSize;
        res.externalCacheBytes = stats.externalCacheSize;
        return res;
    }