Loading core/api/system-current.txt +1 −1 Original line number Diff line number Diff line Loading @@ -10067,10 +10067,10 @@ package android.service.storage { public abstract class ExternalStorageService extends android.app.Service { ctor public ExternalStorageService(); method public void onAnrDelayStarted(@NonNull String, int, int, int); method @NonNull public final android.os.IBinder onBind(@NonNull android.content.Intent); method public abstract void onEndSession(@NonNull String) throws java.io.IOException; method public void onFreeCache(@NonNull java.util.UUID, long) throws java.io.IOException; method public long onGetAnrDelayMillis(@NonNull String, int); method public abstract void onStartSession(@NonNull String, int, @NonNull android.os.ParcelFileDescriptor, @NonNull java.io.File, @NonNull java.io.File) throws java.io.IOException; method public abstract void onVolumeStateChanged(@NonNull android.os.storage.StorageVolume) throws java.io.IOException; field public static final int FLAG_SESSION_ATTRIBUTE_INDEXABLE = 2; // 0x2 core/java/android/service/storage/ExternalStorageService.java +9 −28 Original line number Diff line number Diff line Loading @@ -102,14 +102,6 @@ public abstract class ExternalStorageService extends Service { */ public static final String EXTRA_PACKAGE_NAME = "android.service.storage.extra.package_name"; /** * {@link Bundle} key for a {@link Long} value. * * {@hide} */ public static final String EXTRA_ANR_TIMEOUT_MS = "android.service.storage.extra.anr_timeout_ms"; /** @hide */ @IntDef(flag = true, prefix = {"FLAG_SESSION_"}, value = {FLAG_SESSION_TYPE_FUSE, FLAG_SESSION_ATTRIBUTE_INDEXABLE}) Loading Loading @@ -178,12 +170,12 @@ public abstract class ExternalStorageService extends Service { } /** * Called when {@code packageName} is about to ANR * Called when {@code packageName} is about to ANR. The {@link ExternalStorageService} can * show a progress dialog for the {@code reason}. * * @return ANR dialog delay in milliseconds */ public long onGetAnrDelayMillis(@NonNull String packageName, int uid) { throw new UnsupportedOperationException("onGetAnrDelayMillis not implemented"); public void onAnrDelayStarted(@NonNull String packageName, int uid, int tid, int reason) { throw new UnsupportedOperationException("onAnrDelayStarted not implemented"); } @Override Loading Loading @@ -247,14 +239,14 @@ public abstract class ExternalStorageService extends Service { } @Override public void getAnrDelayMillis(String packageName, int uid, RemoteCallback callback) throws RemoteException { public void notifyAnrDelayStarted(String packageName, int uid, int tid, int reason, RemoteCallback callback) throws RemoteException { mHandler.post(() -> { try { long timeoutMs = onGetAnrDelayMillis(packageName, uid); sendTimeoutResult(packageName, timeoutMs, null /* throwable */, callback); onAnrDelayStarted(packageName, uid, tid, reason); sendResult(packageName, null /* throwable */, callback); } catch (Throwable t) { sendTimeoutResult(packageName, 0 /* timeoutMs */, t, callback); sendResult(packageName, t, callback); } }); } Loading @@ -267,16 +259,5 @@ public abstract class ExternalStorageService extends Service { } callback.sendResult(bundle); } private void sendTimeoutResult(String packageName, long timeoutMs, Throwable throwable, RemoteCallback callback) { Bundle bundle = new Bundle(); bundle.putString(EXTRA_PACKAGE_NAME, packageName); bundle.putLong(EXTRA_ANR_TIMEOUT_MS, timeoutMs); if (throwable != null) { bundle.putParcelable(EXTRA_ERROR, new ParcelableException(throwable)); } callback.sendResult(bundle); } } } core/java/android/service/storage/IExternalStorageService.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -32,5 +32,6 @@ oneway interface IExternalStorageService in RemoteCallback callback); void freeCache(@utf8InCpp String sessionId, in String volumeUuid, long bytes, in RemoteCallback callback); void getAnrDelayMillis(String packageName, int uid, in RemoteCallback callback); void notifyAnrDelayStarted(String packageName, int uid, int tid, int reason, in RemoteCallback callback); } No newline at end of file services/core/java/com/android/server/storage/StorageSessionController.java +8 −13 Original line number Diff line number Diff line Loading @@ -163,22 +163,17 @@ public final class StorageSessionController { * * @return ANR dialog delay in milliseconds */ public long getAnrDelayMillis(String packageName, int uid) public void notifyAnrDelayStarted(String packageName, int uid, int tid, int reason) throws ExternalStorageServiceException { final int userId = UserHandle.getUserId(uid); final StorageUserConnection connection; synchronized (mLock) { int size = mConnections.size(); for (int i = 0; i < size; i++) { int key = mConnections.keyAt(i); StorageUserConnection connection = mConnections.get(key); if (connection != null) { long delay = connection.getAnrDelayMillis(packageName, uid); if (delay > 0) { return delay; } } connection = mConnections.get(userId); } if (connection != null) { connection.notifyAnrDelayStarted(packageName, uid, tid, reason); } return 0; } /** Loading services/core/java/com/android/server/storage/StorageUserConnection.java +6 −36 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.server.storage; import static android.service.storage.ExternalStorageService.EXTRA_ANR_TIMEOUT_MS; import static android.service.storage.ExternalStorageService.EXTRA_ERROR; import static android.service.storage.ExternalStorageService.FLAG_SESSION_ATTRIBUTE_INDEXABLE; import static android.service.storage.ExternalStorageService.FLAG_SESSION_TYPE_FUSE; Loading Loading @@ -151,18 +150,14 @@ public final class StorageUserConnection { * * @return ANR dialog delay in milliseconds */ public long getAnrDelayMillis(String packageName, int uid) public void notifyAnrDelayStarted(String packageName, int uid, int tid, int reason) throws ExternalStorageServiceException { synchronized (mSessionsLock) { for (String sessionId : mSessions.keySet()) { long delay = mActiveConnection.getAnrDelayMillis(packageName, uid); if (delay > 0) { return delay; mActiveConnection.notifyAnrDelayStarted(packageName, uid, tid, reason); } } } return 0; } /** * Removes a session without ending it or waiting for exit. Loading Loading @@ -292,9 +287,6 @@ public final class StorageUserConnection { @GuardedBy("mLock") private final ArrayList<CompletableFuture<Void>> mOutstandingOps = new ArrayList<>(); @GuardedBy("mLock") private final ArrayList<CompletableFuture<Long>> mOutstandingTimeoutOps = new ArrayList<>(); @Override public void close() { ServiceConnection oldConnection = null; Loading @@ -311,9 +303,6 @@ public final class StorageUserConnection { for (CompletableFuture<Void> op : mOutstandingOps) { op.cancel(true); } for (CompletableFuture<Long> op : mOutstandingTimeoutOps) { op.cancel(true); } mOutstandingOps.clear(); } Loading @@ -336,15 +325,6 @@ public final class StorageUserConnection { DEFAULT_REMOTE_TIMEOUT_SECONDS); } private long waitForAsyncLong(AsyncStorageServiceCall asyncCall) throws Exception { CompletableFuture<Long> opFuture = new CompletableFuture<>(); RemoteCallback callback = new RemoteCallback(result -> setTimeoutResult(result, opFuture)); return waitForAsync(asyncCall, callback, opFuture, mOutstandingTimeoutOps, 1 /* timeoutSeconds */); } private <T> T waitForAsync(AsyncStorageServiceCall asyncCall, RemoteCallback callback, CompletableFuture<T> opFuture, ArrayList<CompletableFuture<T>> outstandingOps, long timeoutSeconds) throws Exception { Loading Loading @@ -419,27 +399,17 @@ public final class StorageUserConnection { } } public long getAnrDelayMillis(String packgeName, int uid) public void notifyAnrDelayStarted(String packgeName, int uid, int tid, int reason) throws ExternalStorageServiceException { try { return waitForAsyncLong((service, callback) -> service.getAnrDelayMillis(packgeName, uid, callback)); waitForAsyncVoid((service, callback) -> service.notifyAnrDelayStarted(packgeName, uid, tid, reason, callback)); } catch (Exception e) { throw new ExternalStorageServiceException("Failed to notify app not responding: " throw new ExternalStorageServiceException("Failed to notify ANR delay started: " + packgeName, e); } } private void setTimeoutResult(Bundle result, CompletableFuture<Long> future) { ParcelableException ex = result.getParcelable(EXTRA_ERROR); if (ex != null) { future.completeExceptionally(ex); } else { long timeoutMs = result.getLong(EXTRA_ANR_TIMEOUT_MS); future.complete(timeoutMs); } } private void setResult(Bundle result, CompletableFuture<Void> future) { ParcelableException ex = result.getParcelable(EXTRA_ERROR); if (ex != null) { Loading Loading
core/api/system-current.txt +1 −1 Original line number Diff line number Diff line Loading @@ -10067,10 +10067,10 @@ package android.service.storage { public abstract class ExternalStorageService extends android.app.Service { ctor public ExternalStorageService(); method public void onAnrDelayStarted(@NonNull String, int, int, int); method @NonNull public final android.os.IBinder onBind(@NonNull android.content.Intent); method public abstract void onEndSession(@NonNull String) throws java.io.IOException; method public void onFreeCache(@NonNull java.util.UUID, long) throws java.io.IOException; method public long onGetAnrDelayMillis(@NonNull String, int); method public abstract void onStartSession(@NonNull String, int, @NonNull android.os.ParcelFileDescriptor, @NonNull java.io.File, @NonNull java.io.File) throws java.io.IOException; method public abstract void onVolumeStateChanged(@NonNull android.os.storage.StorageVolume) throws java.io.IOException; field public static final int FLAG_SESSION_ATTRIBUTE_INDEXABLE = 2; // 0x2
core/java/android/service/storage/ExternalStorageService.java +9 −28 Original line number Diff line number Diff line Loading @@ -102,14 +102,6 @@ public abstract class ExternalStorageService extends Service { */ public static final String EXTRA_PACKAGE_NAME = "android.service.storage.extra.package_name"; /** * {@link Bundle} key for a {@link Long} value. * * {@hide} */ public static final String EXTRA_ANR_TIMEOUT_MS = "android.service.storage.extra.anr_timeout_ms"; /** @hide */ @IntDef(flag = true, prefix = {"FLAG_SESSION_"}, value = {FLAG_SESSION_TYPE_FUSE, FLAG_SESSION_ATTRIBUTE_INDEXABLE}) Loading Loading @@ -178,12 +170,12 @@ public abstract class ExternalStorageService extends Service { } /** * Called when {@code packageName} is about to ANR * Called when {@code packageName} is about to ANR. The {@link ExternalStorageService} can * show a progress dialog for the {@code reason}. * * @return ANR dialog delay in milliseconds */ public long onGetAnrDelayMillis(@NonNull String packageName, int uid) { throw new UnsupportedOperationException("onGetAnrDelayMillis not implemented"); public void onAnrDelayStarted(@NonNull String packageName, int uid, int tid, int reason) { throw new UnsupportedOperationException("onAnrDelayStarted not implemented"); } @Override Loading Loading @@ -247,14 +239,14 @@ public abstract class ExternalStorageService extends Service { } @Override public void getAnrDelayMillis(String packageName, int uid, RemoteCallback callback) throws RemoteException { public void notifyAnrDelayStarted(String packageName, int uid, int tid, int reason, RemoteCallback callback) throws RemoteException { mHandler.post(() -> { try { long timeoutMs = onGetAnrDelayMillis(packageName, uid); sendTimeoutResult(packageName, timeoutMs, null /* throwable */, callback); onAnrDelayStarted(packageName, uid, tid, reason); sendResult(packageName, null /* throwable */, callback); } catch (Throwable t) { sendTimeoutResult(packageName, 0 /* timeoutMs */, t, callback); sendResult(packageName, t, callback); } }); } Loading @@ -267,16 +259,5 @@ public abstract class ExternalStorageService extends Service { } callback.sendResult(bundle); } private void sendTimeoutResult(String packageName, long timeoutMs, Throwable throwable, RemoteCallback callback) { Bundle bundle = new Bundle(); bundle.putString(EXTRA_PACKAGE_NAME, packageName); bundle.putLong(EXTRA_ANR_TIMEOUT_MS, timeoutMs); if (throwable != null) { bundle.putParcelable(EXTRA_ERROR, new ParcelableException(throwable)); } callback.sendResult(bundle); } } }
core/java/android/service/storage/IExternalStorageService.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -32,5 +32,6 @@ oneway interface IExternalStorageService in RemoteCallback callback); void freeCache(@utf8InCpp String sessionId, in String volumeUuid, long bytes, in RemoteCallback callback); void getAnrDelayMillis(String packageName, int uid, in RemoteCallback callback); void notifyAnrDelayStarted(String packageName, int uid, int tid, int reason, in RemoteCallback callback); } No newline at end of file
services/core/java/com/android/server/storage/StorageSessionController.java +8 −13 Original line number Diff line number Diff line Loading @@ -163,22 +163,17 @@ public final class StorageSessionController { * * @return ANR dialog delay in milliseconds */ public long getAnrDelayMillis(String packageName, int uid) public void notifyAnrDelayStarted(String packageName, int uid, int tid, int reason) throws ExternalStorageServiceException { final int userId = UserHandle.getUserId(uid); final StorageUserConnection connection; synchronized (mLock) { int size = mConnections.size(); for (int i = 0; i < size; i++) { int key = mConnections.keyAt(i); StorageUserConnection connection = mConnections.get(key); if (connection != null) { long delay = connection.getAnrDelayMillis(packageName, uid); if (delay > 0) { return delay; } } connection = mConnections.get(userId); } if (connection != null) { connection.notifyAnrDelayStarted(packageName, uid, tid, reason); } return 0; } /** Loading
services/core/java/com/android/server/storage/StorageUserConnection.java +6 −36 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.server.storage; import static android.service.storage.ExternalStorageService.EXTRA_ANR_TIMEOUT_MS; import static android.service.storage.ExternalStorageService.EXTRA_ERROR; import static android.service.storage.ExternalStorageService.FLAG_SESSION_ATTRIBUTE_INDEXABLE; import static android.service.storage.ExternalStorageService.FLAG_SESSION_TYPE_FUSE; Loading Loading @@ -151,18 +150,14 @@ public final class StorageUserConnection { * * @return ANR dialog delay in milliseconds */ public long getAnrDelayMillis(String packageName, int uid) public void notifyAnrDelayStarted(String packageName, int uid, int tid, int reason) throws ExternalStorageServiceException { synchronized (mSessionsLock) { for (String sessionId : mSessions.keySet()) { long delay = mActiveConnection.getAnrDelayMillis(packageName, uid); if (delay > 0) { return delay; mActiveConnection.notifyAnrDelayStarted(packageName, uid, tid, reason); } } } return 0; } /** * Removes a session without ending it or waiting for exit. Loading Loading @@ -292,9 +287,6 @@ public final class StorageUserConnection { @GuardedBy("mLock") private final ArrayList<CompletableFuture<Void>> mOutstandingOps = new ArrayList<>(); @GuardedBy("mLock") private final ArrayList<CompletableFuture<Long>> mOutstandingTimeoutOps = new ArrayList<>(); @Override public void close() { ServiceConnection oldConnection = null; Loading @@ -311,9 +303,6 @@ public final class StorageUserConnection { for (CompletableFuture<Void> op : mOutstandingOps) { op.cancel(true); } for (CompletableFuture<Long> op : mOutstandingTimeoutOps) { op.cancel(true); } mOutstandingOps.clear(); } Loading @@ -336,15 +325,6 @@ public final class StorageUserConnection { DEFAULT_REMOTE_TIMEOUT_SECONDS); } private long waitForAsyncLong(AsyncStorageServiceCall asyncCall) throws Exception { CompletableFuture<Long> opFuture = new CompletableFuture<>(); RemoteCallback callback = new RemoteCallback(result -> setTimeoutResult(result, opFuture)); return waitForAsync(asyncCall, callback, opFuture, mOutstandingTimeoutOps, 1 /* timeoutSeconds */); } private <T> T waitForAsync(AsyncStorageServiceCall asyncCall, RemoteCallback callback, CompletableFuture<T> opFuture, ArrayList<CompletableFuture<T>> outstandingOps, long timeoutSeconds) throws Exception { Loading Loading @@ -419,27 +399,17 @@ public final class StorageUserConnection { } } public long getAnrDelayMillis(String packgeName, int uid) public void notifyAnrDelayStarted(String packgeName, int uid, int tid, int reason) throws ExternalStorageServiceException { try { return waitForAsyncLong((service, callback) -> service.getAnrDelayMillis(packgeName, uid, callback)); waitForAsyncVoid((service, callback) -> service.notifyAnrDelayStarted(packgeName, uid, tid, reason, callback)); } catch (Exception e) { throw new ExternalStorageServiceException("Failed to notify app not responding: " throw new ExternalStorageServiceException("Failed to notify ANR delay started: " + packgeName, e); } } private void setTimeoutResult(Bundle result, CompletableFuture<Long> future) { ParcelableException ex = result.getParcelable(EXTRA_ERROR); if (ex != null) { future.completeExceptionally(ex); } else { long timeoutMs = result.getLong(EXTRA_ANR_TIMEOUT_MS); future.complete(timeoutMs); } } private void setResult(Bundle result, CompletableFuture<Void> future) { ParcelableException ex = result.getParcelable(EXTRA_ERROR); if (ex != null) { Loading