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

Commit e8cece9f authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Initial API shape for storage statistics.

This API is designed to provide both UID-level stats and overall
summary data for a given storage device, as identified by UUID.

The use of UID-level granularity might appear a bit clunky, but it
matches other usage statistics (such as network and battery), and it
allows us to implement it using an extremely fast quota kernel
feature.

A future CL will wire up the implementation to installd.

Test: builds, boots
Bug: 32206268
Change-Id: I7b51877682d0370c2402c19346f57809f0e7ac53
parent c9facc0a
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -108,6 +108,7 @@ LOCAL_SRC_FILES += \
	core/java/android/app/backup/IFullBackupRestoreObserver.aidl \
	core/java/android/app/backup/IRestoreObserver.aidl \
	core/java/android/app/backup/IRestoreSession.aidl \
	core/java/android/app/usage/IStorageStatsManager.aidl \
	core/java/android/app/usage/IUsageStatsManager.aidl \
	core/java/android/bluetooth/IBluetooth.aidl \
	core/java/android/bluetooth/IBluetoothA2dp.aidl \
@@ -689,6 +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/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 \
+31 −0
Original line number Diff line number Diff line
@@ -6679,6 +6679,36 @@ package android.app.usage {
    method public abstract void onThresholdReached(int, java.lang.String);
  }
  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 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;
  }
  public final class UsageEvents implements android.os.Parcelable {
    method public int describeContents();
    method public boolean getNextEvent(android.app.usage.UsageEvents.Event);
@@ -8415,6 +8445,7 @@ package android.content {
    field public static final java.lang.String SENSOR_SERVICE = "sensor";
    field public static final java.lang.String SHORTCUT_SERVICE = "shortcut";
    field public static final java.lang.String STORAGE_SERVICE = "storage";
    field public static final java.lang.String STORAGE_STATS_SERVICE = "storagestats";
    field public static final java.lang.String SYSTEM_HEALTH_SERVICE = "systemhealth";
    field public static final java.lang.String TELECOM_SERVICE = "telecom";
    field public static final java.lang.String TELEPHONY_SERVICE = "phone";
+31 −0
Original line number Diff line number Diff line
@@ -6992,6 +6992,36 @@ package android.app.usage {
    method public abstract void onThresholdReached(int, java.lang.String);
  }
  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 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;
  }
  public final class UsageEvents implements android.os.Parcelable {
    method public int describeContents();
    method public boolean getNextEvent(android.app.usage.UsageEvents.Event);
@@ -8770,6 +8800,7 @@ package android.content {
    field public static final java.lang.String SENSOR_SERVICE = "sensor";
    field public static final java.lang.String SHORTCUT_SERVICE = "shortcut";
    field public static final java.lang.String STORAGE_SERVICE = "storage";
    field public static final java.lang.String STORAGE_STATS_SERVICE = "storagestats";
    field public static final java.lang.String SYSTEM_HEALTH_SERVICE = "systemhealth";
    field public static final java.lang.String TELECOM_SERVICE = "telecom";
    field public static final java.lang.String TELEPHONY_SERVICE = "phone";
+31 −0
Original line number Diff line number Diff line
@@ -6701,6 +6701,36 @@ package android.app.usage {
    method public abstract void onThresholdReached(int, java.lang.String);
  }
  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 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;
  }
  public final class UsageEvents implements android.os.Parcelable {
    method public int describeContents();
    method public boolean getNextEvent(android.app.usage.UsageEvents.Event);
@@ -8439,6 +8469,7 @@ package android.content {
    field public static final java.lang.String SENSOR_SERVICE = "sensor";
    field public static final java.lang.String SHORTCUT_SERVICE = "shortcut";
    field public static final java.lang.String STORAGE_SERVICE = "storage";
    field public static final java.lang.String STORAGE_STATS_SERVICE = "storagestats";
    field public static final java.lang.String SYSTEM_HEALTH_SERVICE = "systemhealth";
    field public static final java.lang.String TELECOM_SERVICE = "telecom";
    field public static final java.lang.String TELEPHONY_SERVICE = "phone";
+11 −0
Original line number Diff line number Diff line
@@ -23,8 +23,10 @@ import android.app.admin.IDevicePolicyManager;
import android.app.job.IJobScheduler;
import android.app.job.JobScheduler;
import android.app.trust.TrustManager;
import android.app.usage.IStorageStatsManager;
import android.app.usage.IUsageStatsManager;
import android.app.usage.NetworkStatsManager;
import android.app.usage.StorageStatsManager;
import android.app.usage.UsageStatsManager;
import android.appwidget.AppWidgetManager;
import android.bluetooth.BluetoothManager;
@@ -434,6 +436,15 @@ final class SystemServiceRegistry {
                return new StorageManager(ctx, ctx.mMainThread.getHandler().getLooper());
            }});

        registerService(Context.STORAGE_STATS_SERVICE, StorageStatsManager.class,
                new CachedServiceFetcher<StorageStatsManager>() {
            @Override
            public StorageStatsManager createService(ContextImpl ctx) throws ServiceNotFoundException {
                IStorageStatsManager service = IStorageStatsManager.Stub.asInterface(
                        ServiceManager.getServiceOrThrow(Context.STORAGE_STATS_SERVICE));
                return new StorageStatsManager(ctx, service);
            }});

        registerService(Context.TELEPHONY_SERVICE, TelephonyManager.class,
                new CachedServiceFetcher<TelephonyManager>() {
            @Override
Loading