Loading cmds/sm/src/com/android/commands/sm/Sm.java +8 −1 Original line number Diff line number Diff line Loading @@ -92,6 +92,8 @@ public final class Sm { runSetEmulateFbe(); } else if ("get-fbe-mode".equals(op)) { runGetFbeMode(); } else if ("fstrim".equals(op)) { runFstrim(); } else { throw new IllegalArgumentException(); } Loading Loading @@ -219,6 +221,10 @@ public final class Sm { } } public void runFstrim() throws RemoteException { mSm.fstrim(0); } private String nextArg() { if (mNextArg >= mArgs.length) { return null; Loading @@ -240,6 +246,7 @@ public final class Sm { System.err.println(" sm unmount VOLUME"); System.err.println(" sm format VOLUME"); System.err.println(" sm benchmark VOLUME"); System.err.println(" sm fstrim"); System.err.println(""); System.err.println(" sm forget [UUID|all]"); System.err.println(""); Loading core/java/android/os/storage/IStorageManager.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -288,4 +288,5 @@ interface IStorageManager { ParcelFileDescriptor mountAppFuse(in String name) = 69; void addUserKeyAuth(int userId, int serialNumber, in byte[] token, in byte[] secret) = 70; void fixateNewestUserKeyAuth(int userId) = 71; void fstrim(int flags) = 72; } core/java/android/os/storage/StorageManager.java +5 −0 Original line number Diff line number Diff line Loading @@ -134,6 +134,11 @@ public class StorageManager { /** {@hide} */ public static final int FLAG_INCLUDE_INVISIBLE = 1 << 10; /** {@hide} */ public static final int FSTRIM_FLAG_DEEP = 1 << 0; /** {@hide} */ public static final int FSTRIM_FLAG_BENCHMARK = 1 << 1; /** @hide The volume is not encrypted. */ public static final int ENCRYPTION_STATE_NONE = 1; Loading services/core/java/com/android/server/StorageManagerService.java +24 −8 Original line number Diff line number Diff line Loading @@ -644,14 +644,8 @@ class StorageManagerService extends IStorageManager.Stub Slog.e(TAG, "Unable to record last fstrim!"); } final boolean shouldBenchmark = shouldBenchmark(); try { // This method must be run on the main (handler) thread, // so it is safe to directly call into vold. mConnector.execute("fstrim", shouldBenchmark ? "dotrimbench" : "dotrim"); } catch (NativeDaemonConnectorException ndce) { Slog.e(TAG, "Failed to run fstrim!"); } final int flags = shouldBenchmark() ? StorageManager.FSTRIM_FLAG_BENCHMARK : 0; fstrim(flags); // invoke the completion callback, if any // TODO: fstrim is non-blocking, so remove this useless callback Loading Loading @@ -1956,6 +1950,28 @@ class StorageManagerService extends IStorageManager.Stub } } @Override public void fstrim(int flags) { enforcePermission(android.Manifest.permission.MOUNT_FORMAT_FILESYSTEMS); waitForReady(); String cmd; if ((flags & StorageManager.FSTRIM_FLAG_DEEP) != 0) { cmd = "dodtrim"; } else { cmd = "dotrim"; } if ((flags & StorageManager.FSTRIM_FLAG_BENCHMARK) != 0) { cmd += "bench"; } try { mConnector.execute("fstrim", cmd); } catch (NativeDaemonConnectorException e) { Slog.e(TAG, "Failed to run fstrim: " + e); } } private void remountUidExternalStorage(int uid, int mode) { waitForReady(); Loading Loading
cmds/sm/src/com/android/commands/sm/Sm.java +8 −1 Original line number Diff line number Diff line Loading @@ -92,6 +92,8 @@ public final class Sm { runSetEmulateFbe(); } else if ("get-fbe-mode".equals(op)) { runGetFbeMode(); } else if ("fstrim".equals(op)) { runFstrim(); } else { throw new IllegalArgumentException(); } Loading Loading @@ -219,6 +221,10 @@ public final class Sm { } } public void runFstrim() throws RemoteException { mSm.fstrim(0); } private String nextArg() { if (mNextArg >= mArgs.length) { return null; Loading @@ -240,6 +246,7 @@ public final class Sm { System.err.println(" sm unmount VOLUME"); System.err.println(" sm format VOLUME"); System.err.println(" sm benchmark VOLUME"); System.err.println(" sm fstrim"); System.err.println(""); System.err.println(" sm forget [UUID|all]"); System.err.println(""); Loading
core/java/android/os/storage/IStorageManager.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -288,4 +288,5 @@ interface IStorageManager { ParcelFileDescriptor mountAppFuse(in String name) = 69; void addUserKeyAuth(int userId, int serialNumber, in byte[] token, in byte[] secret) = 70; void fixateNewestUserKeyAuth(int userId) = 71; void fstrim(int flags) = 72; }
core/java/android/os/storage/StorageManager.java +5 −0 Original line number Diff line number Diff line Loading @@ -134,6 +134,11 @@ public class StorageManager { /** {@hide} */ public static final int FLAG_INCLUDE_INVISIBLE = 1 << 10; /** {@hide} */ public static final int FSTRIM_FLAG_DEEP = 1 << 0; /** {@hide} */ public static final int FSTRIM_FLAG_BENCHMARK = 1 << 1; /** @hide The volume is not encrypted. */ public static final int ENCRYPTION_STATE_NONE = 1; Loading
services/core/java/com/android/server/StorageManagerService.java +24 −8 Original line number Diff line number Diff line Loading @@ -644,14 +644,8 @@ class StorageManagerService extends IStorageManager.Stub Slog.e(TAG, "Unable to record last fstrim!"); } final boolean shouldBenchmark = shouldBenchmark(); try { // This method must be run on the main (handler) thread, // so it is safe to directly call into vold. mConnector.execute("fstrim", shouldBenchmark ? "dotrimbench" : "dotrim"); } catch (NativeDaemonConnectorException ndce) { Slog.e(TAG, "Failed to run fstrim!"); } final int flags = shouldBenchmark() ? StorageManager.FSTRIM_FLAG_BENCHMARK : 0; fstrim(flags); // invoke the completion callback, if any // TODO: fstrim is non-blocking, so remove this useless callback Loading Loading @@ -1956,6 +1950,28 @@ class StorageManagerService extends IStorageManager.Stub } } @Override public void fstrim(int flags) { enforcePermission(android.Manifest.permission.MOUNT_FORMAT_FILESYSTEMS); waitForReady(); String cmd; if ((flags & StorageManager.FSTRIM_FLAG_DEEP) != 0) { cmd = "dodtrim"; } else { cmd = "dotrim"; } if ((flags & StorageManager.FSTRIM_FLAG_BENCHMARK) != 0) { cmd += "bench"; } try { mConnector.execute("fstrim", cmd); } catch (NativeDaemonConnectorException e) { Slog.e(TAG, "Failed to run fstrim: " + e); } } private void remountUidExternalStorage(int uid, int mode) { waitForReady(); Loading