diff options
-rw-r--r-- | core/java/android/os/storage/IMountService.aidl | 8 | ||||
-rw-r--r-- | services/java/com/android/server/MountService.java | 26 |
2 files changed, 33 insertions, 1 deletions
diff --git a/core/java/android/os/storage/IMountService.aidl b/core/java/android/os/storage/IMountService.aidl index 3d1ef25..816baf3 100644 --- a/core/java/android/os/storage/IMountService.aidl +++ b/core/java/android/os/storage/IMountService.aidl @@ -72,6 +72,12 @@ interface IMountService int formatVolume(String mountPoint); /** + * Returns an array of pids with open files on + * the specified path. + */ + int[] getStorageUsers(String path); + + /** * Gets the state of an volume via it's mountpoint. */ String getVolumeState(String mountPoint); @@ -94,7 +100,7 @@ interface IMountService * NOTE: Ensure all references are released prior to deleting. * Returns an int consistent with MountServiceResultCode */ - int destroySecureContainer(String id); + int destroySecureContainer(String id); /* * Mount a secure container with the specified key and owner UID. diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java index e764bbb..4e2ffa4 100644 --- a/services/java/com/android/server/MountService.java +++ b/services/java/com/android/server/MountService.java @@ -80,6 +80,7 @@ class MountService extends IMountService.Stub */ public static final int VolumeListResult = 110; public static final int AsecListResult = 111; + public static final int StorageUsersListResult = 112; /* * 200 series - Requestion action has been successfully completed. @@ -795,6 +796,31 @@ class MountService extends IMountService.Stub return doFormatVolume(path); } + public int []getStorageUsers(String path) { + validatePermission(android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS); + waitForReady(); + try { + String[] r = mConnector.doListCommand( + String.format("storage users %s", path), + VoldResponseCode.StorageUsersListResult); + // FMT: <pid> <process name> + int[] data = new int[r.length]; + for (int i = 0; i < r.length; i++) { + String []tok = r[i].split(" "); + try { + data[i] = Integer.parseInt(tok[0]); + } catch (NumberFormatException nfe) { + Log.e(TAG, String.format("Error parsing pid %s", tok[0])); + return new int[0]; + } + } + return data; + } catch (NativeDaemonConnectorException e) { + Log.e(TAG, "Failed to retrieve storage users list", e); + return new int[0]; + } + } + private void warnOnNotMounted() { if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { Log.w(TAG, "getSecureContainerList() called when storage not mounted"); |