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

Commit 8dedad31 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Wire up storage stats API to installd.

Now that installd has the implementation details we need, we can wire
up the public APIs to use them.

Shuffle APIs around a bit so that StorageStats can be reused for both
UID and UserHandle results, and rename StorageSummary to
ExternalStorageStats.  Provide getTotalBytes() and getFreeBytes() as
first-class methods so we can answer those questions quickly without
paying the cost of measuring external storage details.

Current costs on a typical device with a test account after flushing
dentry caches:

queryStatsForUid() manual: 6922ms
queryStatsForUid() quota: 525ms

queryStatsForUser() manual: 1686ms
queryStatsForUser() quota: 113ms

queryExternalStatsForUser() manual: 42ms
queryExternalStatsForUser() quota: 2ms

For verification purposes, a new "fw.verify_storage" system property
can be set to compute both manual and quota statistics, and log any
discrepancies.

Test: builds, boots
Bug: 27948817, 32206268
Change-Id: I4ea3df3372a7379aa8cf4c20c44120c8f0702c15
parent bd439dce
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -690,8 +690,8 @@ aidl_files := \
	frameworks/base/core/java/android/service/notification/StatusBarNotification.aidl \
	frameworks/base/core/java/android/service/chooser/ChooserTarget.aidl \
	frameworks/base/core/java/android/speech/tts/Voice.aidl \
	frameworks/base/core/java/android/app/usage/ExternalStorageStats.aidl \
	frameworks/base/core/java/android/app/usage/StorageStats.aidl \
	frameworks/base/core/java/android/app/usage/StorageSummary.aidl \
	frameworks/base/core/java/android/app/usage/UsageEvents.aidl \
	frameworks/base/core/java/android/app/Notification.aidl \
	frameworks/base/core/java/android/app/NotificationManager.aidl \
+14 −17
Original line number Diff line number Diff line
@@ -6627,6 +6627,16 @@ package android.app.usage {
    field public static final android.os.Parcelable.Creator<android.app.usage.ConfigurationStats> CREATOR;
  }
  public final class ExternalStorageStats implements android.os.Parcelable {
    method public int describeContents();
    method public long getAudioBytes();
    method public long getImageBytes();
    method public long getTotalBytes();
    method public long getVideoBytes();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.usage.ExternalStorageStats> CREATOR;
  }
  public final class NetworkStats implements java.lang.AutoCloseable {
    method public void close();
    method public boolean getNextBucket(android.app.usage.NetworkStats.Bucket);
@@ -6681,31 +6691,18 @@ package android.app.usage {
  public final class StorageStats implements android.os.Parcelable {
    method public int describeContents();
    method public long getCacheBytes();
    method public long getCacheQuotaBytes();
    method public long getCodeBytes();
    method public long getDataBytes();
    method public int getUid();
    method public java.lang.String getVolumeUuid();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.usage.StorageStats> CREATOR;
  }
  public class StorageStatsManager {
    method public long getFreeBytes(java.lang.String);
    method public long getTotalBytes(java.lang.String);
    method public android.app.usage.ExternalStorageStats queryExternalStatsForUser(java.lang.String, android.os.UserHandle);
    method public android.app.usage.StorageStats queryStatsForUid(java.lang.String, int);
    method public android.app.usage.StorageSummary querySummary(java.lang.String);
  }
  public final class StorageSummary implements android.os.Parcelable {
    method public int describeContents();
    method public long getFreeBytes();
    method public long getSharedAudioBytes();
    method public long getSharedImagesBytes();
    method public long getSharedTotalBytes();
    method public long getSharedVideoBytes();
    method public long getTotalBytes();
    method public java.lang.String getVolumeUuid();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.usage.StorageSummary> CREATOR;
    method public android.app.usage.StorageStats queryStatsForUser(java.lang.String, android.os.UserHandle);
  }
  public final class UsageEvents implements android.os.Parcelable {
+14 −17
Original line number Diff line number Diff line
@@ -6940,6 +6940,16 @@ package android.app.usage {
    field public static final android.os.Parcelable.Creator<android.app.usage.ConfigurationStats> CREATOR;
  }
  public final class ExternalStorageStats implements android.os.Parcelable {
    method public int describeContents();
    method public long getAudioBytes();
    method public long getImageBytes();
    method public long getTotalBytes();
    method public long getVideoBytes();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.usage.ExternalStorageStats> CREATOR;
  }
  public final class NetworkStats implements java.lang.AutoCloseable {
    method public void close();
    method public boolean getNextBucket(android.app.usage.NetworkStats.Bucket);
@@ -6994,31 +7004,18 @@ package android.app.usage {
  public final class StorageStats implements android.os.Parcelable {
    method public int describeContents();
    method public long getCacheBytes();
    method public long getCacheQuotaBytes();
    method public long getCodeBytes();
    method public long getDataBytes();
    method public int getUid();
    method public java.lang.String getVolumeUuid();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.usage.StorageStats> CREATOR;
  }
  public class StorageStatsManager {
    method public long getFreeBytes(java.lang.String);
    method public long getTotalBytes(java.lang.String);
    method public android.app.usage.ExternalStorageStats queryExternalStatsForUser(java.lang.String, android.os.UserHandle);
    method public android.app.usage.StorageStats queryStatsForUid(java.lang.String, int);
    method public android.app.usage.StorageSummary querySummary(java.lang.String);
  }
  public final class StorageSummary implements android.os.Parcelable {
    method public int describeContents();
    method public long getFreeBytes();
    method public long getSharedAudioBytes();
    method public long getSharedImagesBytes();
    method public long getSharedTotalBytes();
    method public long getSharedVideoBytes();
    method public long getTotalBytes();
    method public java.lang.String getVolumeUuid();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.usage.StorageSummary> CREATOR;
    method public android.app.usage.StorageStats queryStatsForUser(java.lang.String, android.os.UserHandle);
  }
  public final class UsageEvents implements android.os.Parcelable {
+14 −17
Original line number Diff line number Diff line
@@ -6649,6 +6649,16 @@ package android.app.usage {
    field public static final android.os.Parcelable.Creator<android.app.usage.ConfigurationStats> CREATOR;
  }
  public final class ExternalStorageStats implements android.os.Parcelable {
    method public int describeContents();
    method public long getAudioBytes();
    method public long getImageBytes();
    method public long getTotalBytes();
    method public long getVideoBytes();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.usage.ExternalStorageStats> CREATOR;
  }
  public final class NetworkStats implements java.lang.AutoCloseable {
    method public void close();
    method public boolean getNextBucket(android.app.usage.NetworkStats.Bucket);
@@ -6703,31 +6713,18 @@ package android.app.usage {
  public final class StorageStats implements android.os.Parcelable {
    method public int describeContents();
    method public long getCacheBytes();
    method public long getCacheQuotaBytes();
    method public long getCodeBytes();
    method public long getDataBytes();
    method public int getUid();
    method public java.lang.String getVolumeUuid();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.usage.StorageStats> CREATOR;
  }
  public class StorageStatsManager {
    method public long getFreeBytes(java.lang.String);
    method public long getTotalBytes(java.lang.String);
    method public android.app.usage.ExternalStorageStats queryExternalStatsForUser(java.lang.String, android.os.UserHandle);
    method public android.app.usage.StorageStats queryStatsForUid(java.lang.String, int);
    method public android.app.usage.StorageSummary querySummary(java.lang.String);
  }
  public final class StorageSummary implements android.os.Parcelable {
    method public int describeContents();
    method public long getFreeBytes();
    method public long getSharedAudioBytes();
    method public long getSharedImagesBytes();
    method public long getSharedTotalBytes();
    method public long getSharedVideoBytes();
    method public long getTotalBytes();
    method public java.lang.String getVolumeUuid();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.usage.StorageSummary> CREATOR;
    method public android.app.usage.StorageStats queryStatsForUser(java.lang.String, android.os.UserHandle);
  }
  public final class UsageEvents implements android.os.Parcelable {
+1 −1
Original line number Diff line number Diff line
@@ -16,4 +16,4 @@

package android.app.usage;

parcelable StorageSummary;
parcelable ExternalStorageStats;
Loading