Merge "Stop invoking secdiscard when deleting password data" into pi-dev
diff --git a/core/java/android/os/storage/IStorageManager.aidl b/core/java/android/os/storage/IStorageManager.aidl
index 3b53260..55a202f 100644
--- a/core/java/android/os/storage/IStorageManager.aidl
+++ b/core/java/android/os/storage/IStorageManager.aidl
@@ -185,7 +185,6 @@
long getCacheSizeBytes(String volumeUuid, int uid) = 76;
long getAllocatableBytes(String volumeUuid, int flags, String callingPackage) = 77;
void allocateBytes(String volumeUuid, long bytes, int flags, String callingPackage) = 78;
- void secdiscard(in String path) = 79;
- void runIdleMaintenance() = 80;
- void abortIdleMaintenance() = 81;
+ void runIdleMaintenance() = 79;
+ void abortIdleMaintenance() = 80;
}
diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java
index f593e80..bf20e6a 100644
--- a/core/java/android/os/storage/StorageManager.java
+++ b/core/java/android/os/storage/StorageManager.java
@@ -50,7 +50,6 @@
import android.os.ServiceManager;
import android.os.ServiceManager.ServiceNotFoundException;
import android.os.SystemProperties;
-import android.os.UserHandle;
import android.provider.Settings;
import android.system.ErrnoException;
import android.system.Os;
@@ -1323,15 +1322,6 @@
}
/** {@hide} */
- public void secdiscard(String path) {
- try {
- mStorageManager.secdiscard(path);
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
- }
-
- /** {@hide} */
public static boolean isUserKeyUnlocked(int userId) {
if (sStorageManager == null) {
sStorageManager = IStorageManager.Stub
diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java
index 7c109d5..3d7b21d 100644
--- a/services/core/java/com/android/server/StorageManagerService.java
+++ b/services/core/java/com/android/server/StorageManagerService.java
@@ -2583,17 +2583,6 @@
}
}
- @Override
- public void secdiscard(String path) {
- enforcePermission(android.Manifest.permission.STORAGE_INTERNAL);
-
- try {
- mVold.secdiscard(path);
- } catch (Exception e) {
- Slog.wtf(TAG, e);
- }
- }
-
class AppFuseMountScope extends AppFuseBridge.MountScope {
boolean opened = false;
diff --git a/services/core/java/com/android/server/locksettings/LockSettingsStorage.java b/services/core/java/com/android/server/locksettings/LockSettingsStorage.java
index f62e8a9..8b3a1a6 100644
--- a/services/core/java/com/android/server/locksettings/LockSettingsStorage.java
+++ b/services/core/java/com/android/server/locksettings/LockSettingsStorage.java
@@ -495,10 +495,11 @@
String path = getSynthenticPasswordStateFilePathForUser(userId, handle, name);
File file = new File(path);
if (file.exists()) {
- try {
- mContext.getSystemService(StorageManager.class).secdiscard(file.getAbsolutePath());
+ try (RandomAccessFile raf = new RandomAccessFile(path, "rws")) {
+ final int fileSize = (int) raf.length();
+ raf.write(new byte[fileSize]);
} catch (Exception e) {
- Slog.w(TAG, "Failed to secdiscard " + path, e);
+ Slog.w(TAG, "Failed to zeroize " + path, e);
} finally {
file.delete();
}