summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorZimuzo Ezeozue <zezeozue@google.com>2021-03-01 12:41:24 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2021-03-01 12:41:24 +0000
commit7df4e1c5a4c02410d9739158c47cf92a9dd4cb4d (patch)
tree33f6ee013ef6f8808f94f4dee0fc1eae93729dda /core/java
parentea1be967329819bbbf8c1d06dfc65f8c1b9bb0f9 (diff)
parentc534503ac0f431eed0acb42dc46e4650824737a7 (diff)
Merge "Add API to notify the system_server when app is blocked on I/O" into sc-dev
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/os/storage/IStorageManager.aidl4
-rw-r--r--core/java/android/os/storage/StorageManager.java74
2 files changed, 77 insertions, 1 deletions
diff --git a/core/java/android/os/storage/IStorageManager.aidl b/core/java/android/os/storage/IStorageManager.aidl
index 4669b208b163..0041699df9ef 100644
--- a/core/java/android/os/storage/IStorageManager.aidl
+++ b/core/java/android/os/storage/IStorageManager.aidl
@@ -196,4 +196,6 @@ interface IStorageManager {
void clearUserKeyAuth(int userId, int serialNumber, in byte[] token, in byte[] secret) = 88;
void fixupAppDir(in String path) = 89;
void disableAppDataIsolation(in String pkgName, int pid, int userId) = 90;
-}
+ void notifyAppIoBlocked(in String volumeUuid, int uid, int tid, int reason) = 91;
+ void notifyAppIoResumed(in String volumeUuid, int uid, int tid, int reason) = 92;
+ }
diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java
index 3a5426c60b24..7c8874cc1ea7 100644
--- a/core/java/android/os/storage/StorageManager.java
+++ b/core/java/android/os/storage/StorageManager.java
@@ -2699,6 +2699,80 @@ public class StorageManager {
}
}
+ /**
+ * Reason to provide if app IO is blocked/resumed because of transcoding
+ *
+ * @hide
+ */
+ @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
+ public static final int APP_IO_BLOCKED_REASON_TRANSCODING = 0;
+
+ /**
+ * Constants for use with
+ * {@link #notifyAppIoBlocked} and {@link notifyAppIoResumed}, to specify the reason an app's
+ * IO is blocked/resumed.
+ *
+ * @hide
+ */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = { "APP_IO_BLOCKED_REASON_" }, value = {
+ APP_IO_BLOCKED_REASON_TRANSCODING
+ })
+ public @interface AppIoBlockedReason {}
+
+ /**
+ * Notify the system that an app with {@code uid} and {@code tid} is blocked on an IO request on
+ * {@code volumeUuid} for {@code reason}.
+ *
+ * This blocked state can be used to modify the ANR behavior for the app while it's blocked.
+ * For example during transcoding.
+ *
+ * This can only be called by the {@link ExternalStorageService} holding the
+ * {@link android.Manifest.permission#WRITE_MEDIA_STORAGE} permission.
+ *
+ * @param volumeUuid the UUID of the storage volume that the app IO is blocked on
+ * @param uid the UID of the app blocked on IO
+ * @param tid the tid of the app blocked on IO
+ * @param reason the reason the app is blocked on IO
+ *
+ * @hide
+ */
+ @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
+ public void notifyAppIoBlocked(@NonNull String volumeUuid, int uid, int tid,
+ @AppIoBlockedReason int reason) {
+ try {
+ mStorageManager.notifyAppIoBlocked(volumeUuid, uid, tid, reason);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Notify the system that an app with {@code uid} and {@code tid} has resmued a previously
+ * blocked IO request on {@code volumeUuid} for {@code reason}.
+ *
+ * All app IO will be automatically marked as unblocked if {@code volumeUuid} is unmounted.
+ *
+ * This can only be called by the {@link ExternalStorageService} holding the
+ * {@link android.Manifest.permission#WRITE_MEDIA_STORAGE} permission.
+ *
+ * @param volumeUuid the UUID of the storage volume that the app IO is resumed on
+ * @param uid the UID of the app resuming IO
+ * @param tid the tid of the app resuming IO
+ * @param reason the reason the app is resuming IO
+ *
+ * @hide
+ */
+ @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
+ public void notifyAppIoResumed(@NonNull String volumeUuid, int uid, int tid,
+ @AppIoBlockedReason int reason) {
+ try {
+ mStorageManager.notifyAppIoResumed(volumeUuid, uid, tid, reason);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
private final Object mFuseAppLoopLock = new Object();
@GuardedBy("mFuseAppLoopLock")