Loading core/api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -10689,6 +10689,7 @@ package android.net.wifi { method @NonNull public static String[] list(@NonNull String); method public static boolean put(@NonNull String, @NonNull byte[]); method public static boolean remove(@NonNull String); method @FlaggedApi("android.net.wifi.flags.wifi_keystore_remove_all_api") public static boolean removeAll(); } public final class WifiMigration { wifi/java/src/android/net/wifi/WifiKeystore.java +25 −0 Original line number Diff line number Diff line Loading @@ -15,9 +15,11 @@ */ package android.net.wifi; import android.annotation.FlaggedApi; import android.annotation.NonNull; import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.net.wifi.flags.Flags; import android.os.Binder; import android.os.Process; import android.os.ServiceSpecificException; Loading Loading @@ -169,4 +171,27 @@ public final class WifiKeystore { } return new String[0]; } /** * Remove all blobs that are stored in the database. * * @return True if the operation was successful (i.e. all blobs were removed, or the database * was already empty). False if a critical error was encountered (ex. the database file * is corrupted). * @hide */ @SystemApi @FlaggedApi(Flags.FLAG_WIFI_KEYSTORE_REMOVE_ALL_API) public static boolean removeAll() { Log.i(TAG, "Removing all blobs from the database"); final long identity = Binder.clearCallingIdentity(); try { return WifiBlobStore.getInstance().removeAll(); } catch (Exception e) { Log.e(TAG, "Failed to remove all blobs: " + e); return false; } finally { Binder.restoreCallingIdentity(identity); } } } wifi/tests/src/android/net/wifi/WifiKeystoreTest.java +13 −0 Original line number Diff line number Diff line Loading @@ -26,8 +26,10 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.validateMockitoUsage; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.when; import static org.mockito.Mockito.withSettings; Loading Loading @@ -190,4 +192,15 @@ public class WifiKeystoreTest { Arrays.sort(retrieved); assertArrayEquals(expected, retrieved); } /** * Test that removeAll only affects the WifiBlobStore database. */ @Test public void testRemoveAll() throws Exception { when(mWifiBlobStore.removeAll()).thenReturn(true); assertTrue(WifiKeystore.removeAll()); verify(mWifiBlobStore, times(1)).removeAll(); verifyNoInteractions(mLegacyKeystore); } } wifi/wifi.aconfig +8 −0 Original line number Diff line number Diff line Loading @@ -56,3 +56,11 @@ flag { purpose: PURPOSE_BUGFIX } } flag { name: "wifi_keystore_remove_all_api" is_exported: true namespace: "wifi" description: "Add an API to remove all certificates stored in WifiKeystore" bug: "365543479" } Loading
core/api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -10689,6 +10689,7 @@ package android.net.wifi { method @NonNull public static String[] list(@NonNull String); method public static boolean put(@NonNull String, @NonNull byte[]); method public static boolean remove(@NonNull String); method @FlaggedApi("android.net.wifi.flags.wifi_keystore_remove_all_api") public static boolean removeAll(); } public final class WifiMigration {
wifi/java/src/android/net/wifi/WifiKeystore.java +25 −0 Original line number Diff line number Diff line Loading @@ -15,9 +15,11 @@ */ package android.net.wifi; import android.annotation.FlaggedApi; import android.annotation.NonNull; import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.net.wifi.flags.Flags; import android.os.Binder; import android.os.Process; import android.os.ServiceSpecificException; Loading Loading @@ -169,4 +171,27 @@ public final class WifiKeystore { } return new String[0]; } /** * Remove all blobs that are stored in the database. * * @return True if the operation was successful (i.e. all blobs were removed, or the database * was already empty). False if a critical error was encountered (ex. the database file * is corrupted). * @hide */ @SystemApi @FlaggedApi(Flags.FLAG_WIFI_KEYSTORE_REMOVE_ALL_API) public static boolean removeAll() { Log.i(TAG, "Removing all blobs from the database"); final long identity = Binder.clearCallingIdentity(); try { return WifiBlobStore.getInstance().removeAll(); } catch (Exception e) { Log.e(TAG, "Failed to remove all blobs: " + e); return false; } finally { Binder.restoreCallingIdentity(identity); } } }
wifi/tests/src/android/net/wifi/WifiKeystoreTest.java +13 −0 Original line number Diff line number Diff line Loading @@ -26,8 +26,10 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.validateMockitoUsage; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.when; import static org.mockito.Mockito.withSettings; Loading Loading @@ -190,4 +192,15 @@ public class WifiKeystoreTest { Arrays.sort(retrieved); assertArrayEquals(expected, retrieved); } /** * Test that removeAll only affects the WifiBlobStore database. */ @Test public void testRemoveAll() throws Exception { when(mWifiBlobStore.removeAll()).thenReturn(true); assertTrue(WifiKeystore.removeAll()); verify(mWifiBlobStore, times(1)).removeAll(); verifyNoInteractions(mLegacyKeystore); } }
wifi/wifi.aconfig +8 −0 Original line number Diff line number Diff line Loading @@ -56,3 +56,11 @@ flag { purpose: PURPOSE_BUGFIX } } flag { name: "wifi_keystore_remove_all_api" is_exported: true namespace: "wifi" description: "Add an API to remove all certificates stored in WifiKeystore" bug: "365543479" }