Deprecate all APIs in security-crypto

Bug: 301997816
Test: Check api/current.txt and ensure all classes are deprecated
Relnote: "Deprecate all the APIs in the security-crypto module"
Change-Id: I7780ede02a45e56062c59c1547d8ebe7054ed10f
diff --git a/security/security-crypto-ktx/api/current.txt b/security/security-crypto-ktx/api/current.txt
index e532c81..60a7508 100644
--- a/security/security-crypto-ktx/api/current.txt
+++ b/security/security-crypto-ktx/api/current.txt
@@ -2,15 +2,15 @@
 package androidx.security.crypto {
 
   public final class EncryptedFileKt {
-    method public static androidx.security.crypto.EncryptedFile EncryptedFile(android.content.Context context, java.io.File file, androidx.security.crypto.MasterKey masterKey, optional androidx.security.crypto.EncryptedFile.FileEncryptionScheme fileEncryptionScheme, optional String? keysetPrefName, optional String? keysetAlias);
+    method @Deprecated public static androidx.security.crypto.EncryptedFile EncryptedFile(android.content.Context context, java.io.File file, androidx.security.crypto.MasterKey masterKey, optional androidx.security.crypto.EncryptedFile.FileEncryptionScheme fileEncryptionScheme, optional String? keysetPrefName, optional String? keysetAlias);
   }
 
   public final class EncryptedSharedPreferencesKt {
-    method public static android.content.SharedPreferences EncryptedSharedPreferences(android.content.Context context, String fileName, androidx.security.crypto.MasterKey masterKey, optional androidx.security.crypto.EncryptedSharedPreferences.PrefKeyEncryptionScheme prefKeyEncryptionScheme, optional androidx.security.crypto.EncryptedSharedPreferences.PrefValueEncryptionScheme prefValueEncryptionScheme);
+    method @Deprecated public static android.content.SharedPreferences EncryptedSharedPreferences(android.content.Context context, String fileName, androidx.security.crypto.MasterKey masterKey, optional androidx.security.crypto.EncryptedSharedPreferences.PrefKeyEncryptionScheme prefKeyEncryptionScheme, optional androidx.security.crypto.EncryptedSharedPreferences.PrefValueEncryptionScheme prefValueEncryptionScheme);
   }
 
   public final class MasterKeyKt {
-    method public static androidx.security.crypto.MasterKey MasterKey(android.content.Context context, optional String keyAlias, optional androidx.security.crypto.MasterKey.KeyScheme keyScheme, optional boolean authenticationRequired, optional int userAuthenticationValidityDurationSeconds, optional boolean requestStrongBoxBacked);
+    method @Deprecated public static androidx.security.crypto.MasterKey MasterKey(android.content.Context context, optional String keyAlias, optional androidx.security.crypto.MasterKey.KeyScheme keyScheme, optional boolean authenticationRequired, optional int userAuthenticationValidityDurationSeconds, optional boolean requestStrongBoxBacked);
   }
 
 }
diff --git a/security/security-crypto-ktx/api/restricted_current.txt b/security/security-crypto-ktx/api/restricted_current.txt
index e532c81..60a7508 100644
--- a/security/security-crypto-ktx/api/restricted_current.txt
+++ b/security/security-crypto-ktx/api/restricted_current.txt
@@ -2,15 +2,15 @@
 package androidx.security.crypto {
 
   public final class EncryptedFileKt {
-    method public static androidx.security.crypto.EncryptedFile EncryptedFile(android.content.Context context, java.io.File file, androidx.security.crypto.MasterKey masterKey, optional androidx.security.crypto.EncryptedFile.FileEncryptionScheme fileEncryptionScheme, optional String? keysetPrefName, optional String? keysetAlias);
+    method @Deprecated public static androidx.security.crypto.EncryptedFile EncryptedFile(android.content.Context context, java.io.File file, androidx.security.crypto.MasterKey masterKey, optional androidx.security.crypto.EncryptedFile.FileEncryptionScheme fileEncryptionScheme, optional String? keysetPrefName, optional String? keysetAlias);
   }
 
   public final class EncryptedSharedPreferencesKt {
-    method public static android.content.SharedPreferences EncryptedSharedPreferences(android.content.Context context, String fileName, androidx.security.crypto.MasterKey masterKey, optional androidx.security.crypto.EncryptedSharedPreferences.PrefKeyEncryptionScheme prefKeyEncryptionScheme, optional androidx.security.crypto.EncryptedSharedPreferences.PrefValueEncryptionScheme prefValueEncryptionScheme);
+    method @Deprecated public static android.content.SharedPreferences EncryptedSharedPreferences(android.content.Context context, String fileName, androidx.security.crypto.MasterKey masterKey, optional androidx.security.crypto.EncryptedSharedPreferences.PrefKeyEncryptionScheme prefKeyEncryptionScheme, optional androidx.security.crypto.EncryptedSharedPreferences.PrefValueEncryptionScheme prefValueEncryptionScheme);
   }
 
   public final class MasterKeyKt {
-    method public static androidx.security.crypto.MasterKey MasterKey(android.content.Context context, optional String keyAlias, optional androidx.security.crypto.MasterKey.KeyScheme keyScheme, optional boolean authenticationRequired, optional int userAuthenticationValidityDurationSeconds, optional boolean requestStrongBoxBacked);
+    method @Deprecated public static androidx.security.crypto.MasterKey MasterKey(android.content.Context context, optional String keyAlias, optional androidx.security.crypto.MasterKey.KeyScheme keyScheme, optional boolean authenticationRequired, optional int userAuthenticationValidityDurationSeconds, optional boolean requestStrongBoxBacked);
   }
 
 }
diff --git a/security/security-crypto-ktx/src/androidTest/java/androidx/security/crypto/KtxTests.kt b/security/security-crypto-ktx/src/androidTest/java/androidx/security/crypto/KtxTests.kt
index 5e2e079..450d4ae 100644
--- a/security/security-crypto-ktx/src/androidTest/java/androidx/security/crypto/KtxTests.kt
+++ b/security/security-crypto-ktx/src/androidTest/java/androidx/security/crypto/KtxTests.kt
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+@file:Suppress("deprecation")
+
 package androidx.security.crypto
 
 import android.content.Context
diff --git a/security/security-crypto-ktx/src/main/java/androidx/security/crypto/EncryptedFile.kt b/security/security-crypto-ktx/src/main/java/androidx/security/crypto/EncryptedFile.kt
index 77767ac..6f75117 100644
--- a/security/security-crypto-ktx/src/main/java/androidx/security/crypto/EncryptedFile.kt
+++ b/security/security-crypto-ktx/src/main/java/androidx/security/crypto/EncryptedFile.kt
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+@file:Suppress("deprecation")
+
 package androidx.security.crypto
 
 import android.annotation.SuppressLint
@@ -34,6 +36,7 @@
  * [EncryptedFile].
  */
 @SuppressLint("StreamFiles")
+@Deprecated("Use java.io.File instead")
 public fun EncryptedFile(
     context: Context,
     file: File,
diff --git a/security/security-crypto-ktx/src/main/java/androidx/security/crypto/EncryptedSharedPreferences.kt b/security/security-crypto-ktx/src/main/java/androidx/security/crypto/EncryptedSharedPreferences.kt
index 7fd9bd8..7db3bd6 100644
--- a/security/security-crypto-ktx/src/main/java/androidx/security/crypto/EncryptedSharedPreferences.kt
+++ b/security/security-crypto-ktx/src/main/java/androidx/security/crypto/EncryptedSharedPreferences.kt
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+@file:Suppress("deprecation")
+
 package androidx.security.crypto
 
 import android.content.Context
@@ -30,6 +32,7 @@
  * @param prefValueEncryptionScheme The scheme to use for encrypting values.
  * @return The SharedPreferences instance that encrypts all data.
  */
+@Deprecated("Use android.content.SharedPreferences instead")
 public fun EncryptedSharedPreferences(
     context: Context,
     fileName: String,
diff --git a/security/security-crypto-ktx/src/main/java/androidx/security/crypto/MasterKey.kt b/security/security-crypto-ktx/src/main/java/androidx/security/crypto/MasterKey.kt
index 306ec76..984affc 100644
--- a/security/security-crypto-ktx/src/main/java/androidx/security/crypto/MasterKey.kt
+++ b/security/security-crypto-ktx/src/main/java/androidx/security/crypto/MasterKey.kt
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+@file:Suppress("deprecation")
+
 package androidx.security.crypto
 
 import android.content.Context
@@ -30,6 +32,7 @@
  * valid for after the user has authenticated. Must be a value > 0.
  * @param requestStrongBoxBacked `true` if the key should be stored in Strong Box, if possible.
  */
+@Deprecated("Use Android Keystore directly instead")
 public fun MasterKey(
     context: Context,
     keyAlias: String = MasterKey.DEFAULT_MASTER_KEY_ALIAS,
diff --git a/security/security-crypto/api/current.txt b/security/security-crypto/api/current.txt
index 8e8b71a..76c90c0 100644
--- a/security/security-crypto/api/current.txt
+++ b/security/security-crypto/api/current.txt
@@ -1,70 +1,70 @@
 // Signature format: 4.0
 package androidx.security.crypto {
 
-  public final class EncryptedFile {
-    method public java.io.FileInputStream openFileInput() throws java.io.FileNotFoundException, java.security.GeneralSecurityException, java.io.IOException;
-    method public java.io.FileOutputStream openFileOutput() throws java.security.GeneralSecurityException, java.io.IOException;
+  @Deprecated public final class EncryptedFile {
+    method @Deprecated public java.io.FileInputStream openFileInput() throws java.io.FileNotFoundException, java.security.GeneralSecurityException, java.io.IOException;
+    method @Deprecated public java.io.FileOutputStream openFileOutput() throws java.security.GeneralSecurityException, java.io.IOException;
   }
 
-  public static final class EncryptedFile.Builder {
-    ctor public EncryptedFile.Builder(android.content.Context, java.io.File, androidx.security.crypto.MasterKey, androidx.security.crypto.EncryptedFile.FileEncryptionScheme);
+  @Deprecated public static final class EncryptedFile.Builder {
+    ctor @Deprecated public EncryptedFile.Builder(android.content.Context, java.io.File, androidx.security.crypto.MasterKey, androidx.security.crypto.EncryptedFile.FileEncryptionScheme);
     ctor @Deprecated public EncryptedFile.Builder(java.io.File, android.content.Context, String, androidx.security.crypto.EncryptedFile.FileEncryptionScheme);
-    method public androidx.security.crypto.EncryptedFile build() throws java.security.GeneralSecurityException, java.io.IOException;
-    method public androidx.security.crypto.EncryptedFile.Builder setKeysetAlias(String);
-    method public androidx.security.crypto.EncryptedFile.Builder setKeysetPrefName(String);
+    method @Deprecated public androidx.security.crypto.EncryptedFile build() throws java.security.GeneralSecurityException, java.io.IOException;
+    method @Deprecated public androidx.security.crypto.EncryptedFile.Builder setKeysetAlias(String);
+    method @Deprecated public androidx.security.crypto.EncryptedFile.Builder setKeysetPrefName(String);
   }
 
-  public enum EncryptedFile.FileEncryptionScheme {
-    enum_constant public static final androidx.security.crypto.EncryptedFile.FileEncryptionScheme AES256_GCM_HKDF_4KB;
+  @Deprecated public enum EncryptedFile.FileEncryptionScheme {
+    enum_constant @Deprecated public static final androidx.security.crypto.EncryptedFile.FileEncryptionScheme AES256_GCM_HKDF_4KB;
   }
 
-  public final class EncryptedSharedPreferences implements android.content.SharedPreferences {
-    method public boolean contains(String?);
-    method public static android.content.SharedPreferences create(android.content.Context, String, androidx.security.crypto.MasterKey, androidx.security.crypto.EncryptedSharedPreferences.PrefKeyEncryptionScheme, androidx.security.crypto.EncryptedSharedPreferences.PrefValueEncryptionScheme) throws java.security.GeneralSecurityException, java.io.IOException;
+  @Deprecated public final class EncryptedSharedPreferences implements android.content.SharedPreferences {
+    method @Deprecated public boolean contains(String?);
+    method @Deprecated public static android.content.SharedPreferences create(android.content.Context, String, androidx.security.crypto.MasterKey, androidx.security.crypto.EncryptedSharedPreferences.PrefKeyEncryptionScheme, androidx.security.crypto.EncryptedSharedPreferences.PrefValueEncryptionScheme) throws java.security.GeneralSecurityException, java.io.IOException;
     method @Deprecated public static android.content.SharedPreferences create(String, String, android.content.Context, androidx.security.crypto.EncryptedSharedPreferences.PrefKeyEncryptionScheme, androidx.security.crypto.EncryptedSharedPreferences.PrefValueEncryptionScheme) throws java.security.GeneralSecurityException, java.io.IOException;
-    method public android.content.SharedPreferences.Editor edit();
-    method public java.util.Map<java.lang.String!,?> getAll();
-    method public boolean getBoolean(String?, boolean);
-    method public float getFloat(String?, float);
-    method public int getInt(String?, int);
-    method public long getLong(String?, long);
-    method public String? getString(String?, String?);
-    method public java.util.Set<java.lang.String!>? getStringSet(String?, java.util.Set<java.lang.String!>?);
-    method public void registerOnSharedPreferenceChangeListener(android.content.SharedPreferences.OnSharedPreferenceChangeListener);
-    method public void unregisterOnSharedPreferenceChangeListener(android.content.SharedPreferences.OnSharedPreferenceChangeListener);
+    method @Deprecated public android.content.SharedPreferences.Editor edit();
+    method @Deprecated public java.util.Map<java.lang.String!,?> getAll();
+    method @Deprecated public boolean getBoolean(String?, boolean);
+    method @Deprecated public float getFloat(String?, float);
+    method @Deprecated public int getInt(String?, int);
+    method @Deprecated public long getLong(String?, long);
+    method @Deprecated public String? getString(String?, String?);
+    method @Deprecated public java.util.Set<java.lang.String!>? getStringSet(String?, java.util.Set<java.lang.String!>?);
+    method @Deprecated public void registerOnSharedPreferenceChangeListener(android.content.SharedPreferences.OnSharedPreferenceChangeListener);
+    method @Deprecated public void unregisterOnSharedPreferenceChangeListener(android.content.SharedPreferences.OnSharedPreferenceChangeListener);
   }
 
-  public enum EncryptedSharedPreferences.PrefKeyEncryptionScheme {
-    enum_constant public static final androidx.security.crypto.EncryptedSharedPreferences.PrefKeyEncryptionScheme AES256_SIV;
+  @Deprecated public enum EncryptedSharedPreferences.PrefKeyEncryptionScheme {
+    enum_constant @Deprecated public static final androidx.security.crypto.EncryptedSharedPreferences.PrefKeyEncryptionScheme AES256_SIV;
   }
 
-  public enum EncryptedSharedPreferences.PrefValueEncryptionScheme {
-    enum_constant public static final androidx.security.crypto.EncryptedSharedPreferences.PrefValueEncryptionScheme AES256_GCM;
+  @Deprecated public enum EncryptedSharedPreferences.PrefValueEncryptionScheme {
+    enum_constant @Deprecated public static final androidx.security.crypto.EncryptedSharedPreferences.PrefValueEncryptionScheme AES256_GCM;
   }
 
-  public final class MasterKey {
-    method public static int getDefaultAuthenticationValidityDurationSeconds();
-    method public int getUserAuthenticationValidityDurationSeconds();
-    method public boolean isKeyStoreBacked();
-    method public boolean isStrongBoxBacked();
-    method public boolean isUserAuthenticationRequired();
-    field public static final int DEFAULT_AES_GCM_MASTER_KEY_SIZE = 256; // 0x100
-    field public static final String DEFAULT_MASTER_KEY_ALIAS = "_androidx_security_master_key_";
+  @Deprecated public final class MasterKey {
+    method @Deprecated public static int getDefaultAuthenticationValidityDurationSeconds();
+    method @Deprecated public int getUserAuthenticationValidityDurationSeconds();
+    method @Deprecated public boolean isKeyStoreBacked();
+    method @Deprecated public boolean isStrongBoxBacked();
+    method @Deprecated public boolean isUserAuthenticationRequired();
+    field @Deprecated public static final int DEFAULT_AES_GCM_MASTER_KEY_SIZE = 256; // 0x100
+    field @Deprecated public static final String DEFAULT_MASTER_KEY_ALIAS = "_androidx_security_master_key_";
   }
 
-  public static final class MasterKey.Builder {
-    ctor public MasterKey.Builder(android.content.Context);
-    ctor public MasterKey.Builder(android.content.Context, String);
-    method public androidx.security.crypto.MasterKey build() throws java.security.GeneralSecurityException, java.io.IOException;
-    method @RequiresApi(android.os.Build.VERSION_CODES.M) public androidx.security.crypto.MasterKey.Builder setKeyGenParameterSpec(android.security.keystore.KeyGenParameterSpec);
-    method public androidx.security.crypto.MasterKey.Builder setKeyScheme(androidx.security.crypto.MasterKey.KeyScheme);
-    method public androidx.security.crypto.MasterKey.Builder setRequestStrongBoxBacked(boolean);
-    method public androidx.security.crypto.MasterKey.Builder setUserAuthenticationRequired(boolean);
-    method public androidx.security.crypto.MasterKey.Builder setUserAuthenticationRequired(boolean, @IntRange(from=1) int);
+  @Deprecated public static final class MasterKey.Builder {
+    ctor @Deprecated public MasterKey.Builder(android.content.Context);
+    ctor @Deprecated public MasterKey.Builder(android.content.Context, String);
+    method @Deprecated public androidx.security.crypto.MasterKey build() throws java.security.GeneralSecurityException, java.io.IOException;
+    method @Deprecated @RequiresApi(android.os.Build.VERSION_CODES.M) public androidx.security.crypto.MasterKey.Builder setKeyGenParameterSpec(android.security.keystore.KeyGenParameterSpec);
+    method @Deprecated public androidx.security.crypto.MasterKey.Builder setKeyScheme(androidx.security.crypto.MasterKey.KeyScheme);
+    method @Deprecated public androidx.security.crypto.MasterKey.Builder setRequestStrongBoxBacked(boolean);
+    method @Deprecated public androidx.security.crypto.MasterKey.Builder setUserAuthenticationRequired(boolean);
+    method @Deprecated public androidx.security.crypto.MasterKey.Builder setUserAuthenticationRequired(boolean, @IntRange(from=1) int);
   }
 
-  public enum MasterKey.KeyScheme {
-    enum_constant public static final androidx.security.crypto.MasterKey.KeyScheme AES256_GCM;
+  @Deprecated public enum MasterKey.KeyScheme {
+    enum_constant @Deprecated public static final androidx.security.crypto.MasterKey.KeyScheme AES256_GCM;
   }
 
   @Deprecated @RequiresApi(android.os.Build.VERSION_CODES.M) public final class MasterKeys {
diff --git a/security/security-crypto/api/restricted_current.txt b/security/security-crypto/api/restricted_current.txt
index 8e8b71a..76c90c0 100644
--- a/security/security-crypto/api/restricted_current.txt
+++ b/security/security-crypto/api/restricted_current.txt
@@ -1,70 +1,70 @@
 // Signature format: 4.0
 package androidx.security.crypto {
 
-  public final class EncryptedFile {
-    method public java.io.FileInputStream openFileInput() throws java.io.FileNotFoundException, java.security.GeneralSecurityException, java.io.IOException;
-    method public java.io.FileOutputStream openFileOutput() throws java.security.GeneralSecurityException, java.io.IOException;
+  @Deprecated public final class EncryptedFile {
+    method @Deprecated public java.io.FileInputStream openFileInput() throws java.io.FileNotFoundException, java.security.GeneralSecurityException, java.io.IOException;
+    method @Deprecated public java.io.FileOutputStream openFileOutput() throws java.security.GeneralSecurityException, java.io.IOException;
   }
 
-  public static final class EncryptedFile.Builder {
-    ctor public EncryptedFile.Builder(android.content.Context, java.io.File, androidx.security.crypto.MasterKey, androidx.security.crypto.EncryptedFile.FileEncryptionScheme);
+  @Deprecated public static final class EncryptedFile.Builder {
+    ctor @Deprecated public EncryptedFile.Builder(android.content.Context, java.io.File, androidx.security.crypto.MasterKey, androidx.security.crypto.EncryptedFile.FileEncryptionScheme);
     ctor @Deprecated public EncryptedFile.Builder(java.io.File, android.content.Context, String, androidx.security.crypto.EncryptedFile.FileEncryptionScheme);
-    method public androidx.security.crypto.EncryptedFile build() throws java.security.GeneralSecurityException, java.io.IOException;
-    method public androidx.security.crypto.EncryptedFile.Builder setKeysetAlias(String);
-    method public androidx.security.crypto.EncryptedFile.Builder setKeysetPrefName(String);
+    method @Deprecated public androidx.security.crypto.EncryptedFile build() throws java.security.GeneralSecurityException, java.io.IOException;
+    method @Deprecated public androidx.security.crypto.EncryptedFile.Builder setKeysetAlias(String);
+    method @Deprecated public androidx.security.crypto.EncryptedFile.Builder setKeysetPrefName(String);
   }
 
-  public enum EncryptedFile.FileEncryptionScheme {
-    enum_constant public static final androidx.security.crypto.EncryptedFile.FileEncryptionScheme AES256_GCM_HKDF_4KB;
+  @Deprecated public enum EncryptedFile.FileEncryptionScheme {
+    enum_constant @Deprecated public static final androidx.security.crypto.EncryptedFile.FileEncryptionScheme AES256_GCM_HKDF_4KB;
   }
 
-  public final class EncryptedSharedPreferences implements android.content.SharedPreferences {
-    method public boolean contains(String?);
-    method public static android.content.SharedPreferences create(android.content.Context, String, androidx.security.crypto.MasterKey, androidx.security.crypto.EncryptedSharedPreferences.PrefKeyEncryptionScheme, androidx.security.crypto.EncryptedSharedPreferences.PrefValueEncryptionScheme) throws java.security.GeneralSecurityException, java.io.IOException;
+  @Deprecated public final class EncryptedSharedPreferences implements android.content.SharedPreferences {
+    method @Deprecated public boolean contains(String?);
+    method @Deprecated public static android.content.SharedPreferences create(android.content.Context, String, androidx.security.crypto.MasterKey, androidx.security.crypto.EncryptedSharedPreferences.PrefKeyEncryptionScheme, androidx.security.crypto.EncryptedSharedPreferences.PrefValueEncryptionScheme) throws java.security.GeneralSecurityException, java.io.IOException;
     method @Deprecated public static android.content.SharedPreferences create(String, String, android.content.Context, androidx.security.crypto.EncryptedSharedPreferences.PrefKeyEncryptionScheme, androidx.security.crypto.EncryptedSharedPreferences.PrefValueEncryptionScheme) throws java.security.GeneralSecurityException, java.io.IOException;
-    method public android.content.SharedPreferences.Editor edit();
-    method public java.util.Map<java.lang.String!,?> getAll();
-    method public boolean getBoolean(String?, boolean);
-    method public float getFloat(String?, float);
-    method public int getInt(String?, int);
-    method public long getLong(String?, long);
-    method public String? getString(String?, String?);
-    method public java.util.Set<java.lang.String!>? getStringSet(String?, java.util.Set<java.lang.String!>?);
-    method public void registerOnSharedPreferenceChangeListener(android.content.SharedPreferences.OnSharedPreferenceChangeListener);
-    method public void unregisterOnSharedPreferenceChangeListener(android.content.SharedPreferences.OnSharedPreferenceChangeListener);
+    method @Deprecated public android.content.SharedPreferences.Editor edit();
+    method @Deprecated public java.util.Map<java.lang.String!,?> getAll();
+    method @Deprecated public boolean getBoolean(String?, boolean);
+    method @Deprecated public float getFloat(String?, float);
+    method @Deprecated public int getInt(String?, int);
+    method @Deprecated public long getLong(String?, long);
+    method @Deprecated public String? getString(String?, String?);
+    method @Deprecated public java.util.Set<java.lang.String!>? getStringSet(String?, java.util.Set<java.lang.String!>?);
+    method @Deprecated public void registerOnSharedPreferenceChangeListener(android.content.SharedPreferences.OnSharedPreferenceChangeListener);
+    method @Deprecated public void unregisterOnSharedPreferenceChangeListener(android.content.SharedPreferences.OnSharedPreferenceChangeListener);
   }
 
-  public enum EncryptedSharedPreferences.PrefKeyEncryptionScheme {
-    enum_constant public static final androidx.security.crypto.EncryptedSharedPreferences.PrefKeyEncryptionScheme AES256_SIV;
+  @Deprecated public enum EncryptedSharedPreferences.PrefKeyEncryptionScheme {
+    enum_constant @Deprecated public static final androidx.security.crypto.EncryptedSharedPreferences.PrefKeyEncryptionScheme AES256_SIV;
   }
 
-  public enum EncryptedSharedPreferences.PrefValueEncryptionScheme {
-    enum_constant public static final androidx.security.crypto.EncryptedSharedPreferences.PrefValueEncryptionScheme AES256_GCM;
+  @Deprecated public enum EncryptedSharedPreferences.PrefValueEncryptionScheme {
+    enum_constant @Deprecated public static final androidx.security.crypto.EncryptedSharedPreferences.PrefValueEncryptionScheme AES256_GCM;
   }
 
-  public final class MasterKey {
-    method public static int getDefaultAuthenticationValidityDurationSeconds();
-    method public int getUserAuthenticationValidityDurationSeconds();
-    method public boolean isKeyStoreBacked();
-    method public boolean isStrongBoxBacked();
-    method public boolean isUserAuthenticationRequired();
-    field public static final int DEFAULT_AES_GCM_MASTER_KEY_SIZE = 256; // 0x100
-    field public static final String DEFAULT_MASTER_KEY_ALIAS = "_androidx_security_master_key_";
+  @Deprecated public final class MasterKey {
+    method @Deprecated public static int getDefaultAuthenticationValidityDurationSeconds();
+    method @Deprecated public int getUserAuthenticationValidityDurationSeconds();
+    method @Deprecated public boolean isKeyStoreBacked();
+    method @Deprecated public boolean isStrongBoxBacked();
+    method @Deprecated public boolean isUserAuthenticationRequired();
+    field @Deprecated public static final int DEFAULT_AES_GCM_MASTER_KEY_SIZE = 256; // 0x100
+    field @Deprecated public static final String DEFAULT_MASTER_KEY_ALIAS = "_androidx_security_master_key_";
   }
 
-  public static final class MasterKey.Builder {
-    ctor public MasterKey.Builder(android.content.Context);
-    ctor public MasterKey.Builder(android.content.Context, String);
-    method public androidx.security.crypto.MasterKey build() throws java.security.GeneralSecurityException, java.io.IOException;
-    method @RequiresApi(android.os.Build.VERSION_CODES.M) public androidx.security.crypto.MasterKey.Builder setKeyGenParameterSpec(android.security.keystore.KeyGenParameterSpec);
-    method public androidx.security.crypto.MasterKey.Builder setKeyScheme(androidx.security.crypto.MasterKey.KeyScheme);
-    method public androidx.security.crypto.MasterKey.Builder setRequestStrongBoxBacked(boolean);
-    method public androidx.security.crypto.MasterKey.Builder setUserAuthenticationRequired(boolean);
-    method public androidx.security.crypto.MasterKey.Builder setUserAuthenticationRequired(boolean, @IntRange(from=1) int);
+  @Deprecated public static final class MasterKey.Builder {
+    ctor @Deprecated public MasterKey.Builder(android.content.Context);
+    ctor @Deprecated public MasterKey.Builder(android.content.Context, String);
+    method @Deprecated public androidx.security.crypto.MasterKey build() throws java.security.GeneralSecurityException, java.io.IOException;
+    method @Deprecated @RequiresApi(android.os.Build.VERSION_CODES.M) public androidx.security.crypto.MasterKey.Builder setKeyGenParameterSpec(android.security.keystore.KeyGenParameterSpec);
+    method @Deprecated public androidx.security.crypto.MasterKey.Builder setKeyScheme(androidx.security.crypto.MasterKey.KeyScheme);
+    method @Deprecated public androidx.security.crypto.MasterKey.Builder setRequestStrongBoxBacked(boolean);
+    method @Deprecated public androidx.security.crypto.MasterKey.Builder setUserAuthenticationRequired(boolean);
+    method @Deprecated public androidx.security.crypto.MasterKey.Builder setUserAuthenticationRequired(boolean, @IntRange(from=1) int);
   }
 
-  public enum MasterKey.KeyScheme {
-    enum_constant public static final androidx.security.crypto.MasterKey.KeyScheme AES256_GCM;
+  @Deprecated public enum MasterKey.KeyScheme {
+    enum_constant @Deprecated public static final androidx.security.crypto.MasterKey.KeyScheme AES256_GCM;
   }
 
   @Deprecated @RequiresApi(android.os.Build.VERSION_CODES.M) public final class MasterKeys {
diff --git a/security/security-crypto/src/androidTest/java/androidx/security/crypto/EncryptedFileTest.java b/security/security-crypto/src/androidTest/java/androidx/security/crypto/EncryptedFileTest.java
index a2d3fd1..844eef4 100644
--- a/security/security-crypto/src/androidTest/java/androidx/security/crypto/EncryptedFileTest.java
+++ b/security/security-crypto/src/androidTest/java/androidx/security/crypto/EncryptedFileTest.java
@@ -16,8 +16,6 @@
 
 package androidx.security.crypto;
 
-import static androidx.security.crypto.MasterKey.KEYSTORE_PATH_URI;
-
 import static org.junit.Assert.assertTrue;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
@@ -54,6 +52,7 @@
 
 @MediumTest
 @RunWith(AndroidJUnit4.class)
+@SuppressWarnings("deprecation")
 public class EncryptedFileTest {
     private static final String KEYSET_ALIAS = "__androidx_security_crypto_encrypted_file_keyset__";
     private static final String PREFS_FILE = "__androidx_security_crypto_encrypted_file_pref__";
@@ -364,7 +363,7 @@
                 .withSharedPref(mContext,
                         KEYSET_ALIAS,
                         PREFS_FILE)
-                .withMasterKeyUri(KEYSTORE_PATH_URI + mMasterKey.getKeyAlias())
+                .withMasterKeyUri(MasterKey.KEYSTORE_PATH_URI + mMasterKey.getKeyAlias())
                 .build().getKeysetHandle();
 
         StreamingAead streamingAead = com.google.crypto.tink.streamingaead.StreamingAeadFactory
diff --git a/security/security-crypto/src/androidTest/java/androidx/security/crypto/EncryptedSharedPreferencesTest.java b/security/security-crypto/src/androidTest/java/androidx/security/crypto/EncryptedSharedPreferencesTest.java
index beaabc0..1065829 100644
--- a/security/security-crypto/src/androidTest/java/androidx/security/crypto/EncryptedSharedPreferencesTest.java
+++ b/security/security-crypto/src/androidTest/java/androidx/security/crypto/EncryptedSharedPreferencesTest.java
@@ -18,8 +18,6 @@
 
 import static android.content.Context.MODE_PRIVATE;
 
-import static androidx.security.crypto.MasterKey.KEYSTORE_PATH_URI;
-
 import static java.nio.charset.StandardCharsets.UTF_8;
 
 import android.content.Context;
@@ -53,6 +51,7 @@
 
 @MediumTest
 @RunWith(AndroidJUnit4.class)
+@SuppressWarnings("deprecation")
 public class EncryptedSharedPreferencesTest {
 
     private Context mContext;
@@ -367,7 +366,7 @@
                 .withKeyTemplate(AesSivKeyManager.aes256SivTemplate())
                 .withSharedPref(mContext,
                         "__androidx_security_crypto_encrypted_prefs_key_keyset__", tinkTestPrefs)
-                .withMasterKeyUri(KEYSTORE_PATH_URI + "_androidx_security_master_key_")
+                .withMasterKeyUri(MasterKey.KEYSTORE_PATH_URI + "_androidx_security_master_key_")
                 .build().getKeysetHandle();
 
         DeterministicAead deterministicAead =
@@ -385,7 +384,7 @@
                 .withKeyTemplate(AesGcmKeyManager.aes256GcmTemplate())
                 .withSharedPref(mContext,
                         "__androidx_security_crypto_encrypted_prefs_value_keyset__", tinkTestPrefs)
-                .withMasterKeyUri(KEYSTORE_PATH_URI + "_androidx_security_master_key_")
+                .withMasterKeyUri(MasterKey.KEYSTORE_PATH_URI + "_androidx_security_master_key_")
                 .build().getKeysetHandle();
         Aead aead = aeadKeysetHandle.getPrimitive(Aead.class);
         String encryptedValue = sharedPreferences.getString(encodedKey, null);
diff --git a/security/security-crypto/src/androidTest/java/androidx/security/crypto/MasterKeySecureTest.java b/security/security-crypto/src/androidTest/java/androidx/security/crypto/MasterKeySecureTest.java
index a624825..e29f1e6 100644
--- a/security/security-crypto/src/androidTest/java/androidx/security/crypto/MasterKeySecureTest.java
+++ b/security/security-crypto/src/androidTest/java/androidx/security/crypto/MasterKeySecureTest.java
@@ -23,7 +23,6 @@
 import android.content.SharedPreferences;
 import android.os.Build;
 
-import androidx.security.crypto.MasterKey.KeyScheme;
 import androidx.test.core.app.ApplicationProvider;
 import androidx.test.ext.junit.runners.AndroidJUnit4;
 import androidx.test.filters.MediumTest;
@@ -46,6 +45,7 @@
 @MediumTest
 @RunWith(AndroidJUnit4.class)
 @SdkSuppress(minSdkVersion = Build.VERSION_CODES.M)
+@SuppressWarnings("deprecation")
 public class MasterKeySecureTest {
     private static final String PREFS_FILE = "test_shared_prefs";
 
@@ -94,7 +94,7 @@
     public void testCreateKeyWithAuthenicationRequired() throws GeneralSecurityException,
             IOException {
         MasterKey masterKey = new MasterKey.Builder(ApplicationProvider.getApplicationContext())
-                .setKeyScheme(KeyScheme.AES256_GCM)
+                .setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
                 .setUserAuthenticationRequired(true, 10)
                 .build();
         MasterKeyTest.assertKeyExists(masterKey.getKeyAlias());
diff --git a/security/security-crypto/src/androidTest/java/androidx/security/crypto/MasterKeyTest.java b/security/security-crypto/src/androidTest/java/androidx/security/crypto/MasterKeyTest.java
index e38ca0a..773b20c 100644
--- a/security/security-crypto/src/androidTest/java/androidx/security/crypto/MasterKeyTest.java
+++ b/security/security-crypto/src/androidTest/java/androidx/security/crypto/MasterKeyTest.java
@@ -24,7 +24,6 @@
 import android.security.keystore.KeyGenParameterSpec;
 import android.security.keystore.KeyProperties;
 
-import androidx.security.crypto.MasterKey.KeyScheme;
 import androidx.test.core.app.ApplicationProvider;
 import androidx.test.ext.junit.runners.AndroidJUnit4;
 import androidx.test.filters.MediumTest;
@@ -43,6 +42,7 @@
 @MediumTest
 @SdkSuppress(minSdkVersion = Build.VERSION_CODES.M)
 @RunWith(AndroidJUnit4.class)
+@SuppressWarnings("deprecation")
 public class MasterKeyTest {
     private static final String PREFS_FILE = "test_shared_prefs";
     private static final int KEY_SIZE = 256;
@@ -153,7 +153,7 @@
     public void testCheckIfKeyIsKeyStoreBacked() throws GeneralSecurityException,
             IOException {
         MasterKey masterKey = new MasterKey.Builder(ApplicationProvider.getApplicationContext())
-                .setKeyScheme(KeyScheme.AES256_GCM)
+                .setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
                 .build();
 
         KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore");
@@ -175,7 +175,7 @@
 
         try {
             MasterKey ignored = new MasterKey.Builder(ApplicationProvider.getApplicationContext())
-                    .setKeyScheme(KeyScheme.AES256_GCM)
+                    .setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
                     .setKeyGenParameterSpec(spec)
                     .build();
             Assert.fail("Could create key with both scheme + KeyGenParameterSpec");
@@ -188,7 +188,7 @@
     public void testCheckGettersAreCallable() throws GeneralSecurityException,
             IOException {
         MasterKey masterKey = new MasterKey.Builder(ApplicationProvider.getApplicationContext())
-                .setKeyScheme(KeyScheme.AES256_GCM)
+                .setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
                 .build();
         Assert.assertFalse(masterKey.isUserAuthenticationRequired());
         Assert.assertFalse(masterKey.isStrongBoxBacked());
diff --git a/security/security-crypto/src/main/java/androidx/security/crypto/EncryptedFile.java b/security/security-crypto/src/main/java/androidx/security/crypto/EncryptedFile.java
index 251ce8a..41c8b7b 100644
--- a/security/security-crypto/src/main/java/androidx/security/crypto/EncryptedFile.java
+++ b/security/security-crypto/src/main/java/androidx/security/crypto/EncryptedFile.java
@@ -16,8 +16,6 @@
 
 package androidx.security.crypto;
 
-import static androidx.security.crypto.MasterKey.KEYSTORE_PATH_URI;
-
 import static java.nio.charset.StandardCharsets.UTF_8;
 
 import android.annotation.SuppressLint;
@@ -85,7 +83,10 @@
  *  // read the encrypted file
  *  FileInputStream encryptedInputStream = encryptedFile.openFileInput();
  * </pre>
+ * @deprecated Use {@link java.io.File} instead.
  */
+@Deprecated
+@SuppressWarnings("deprecation")
 public final class EncryptedFile {
 
     private static final String KEYSET_PREF_NAME =
@@ -111,7 +112,9 @@
 
     /**
      * The encryption scheme to encrypt files.
+     * @deprecated Use {@link java.io.File} instead.
      */
+    @Deprecated
     public enum FileEncryptionScheme {
         /**
          * The file content is encrypted using StreamingAead with AES-GCM, with the file name as
@@ -136,7 +139,9 @@
 
     /**
      * Builder class to configure EncryptedFile
+     * @deprecated Use {@link java.io.File} instead.
      */
+    @Deprecated
     public static final class Builder {
         private static final Object sLock = new Object();
 
@@ -223,7 +228,7 @@
             AndroidKeysetManager.Builder keysetManagerBuilder = new AndroidKeysetManager.Builder()
                     .withKeyTemplate(mFileEncryptionScheme.getKeyTemplate())
                     .withSharedPref(mContext, mKeysetAlias, mKeysetPrefName)
-                    .withMasterKeyUri(KEYSTORE_PATH_URI + mMasterKeyAlias);
+                    .withMasterKeyUri(MasterKey.KEYSTORE_PATH_URI + mMasterKeyAlias);
 
             // Building the keyset manager involves shared pref filesystem operations. To control
             // access to this global state in multi-threaded contexts we need to ensure mutual
diff --git a/security/security-crypto/src/main/java/androidx/security/crypto/EncryptedSharedPreferences.java b/security/security-crypto/src/main/java/androidx/security/crypto/EncryptedSharedPreferences.java
index eabaae5..b5f72f03 100644
--- a/security/security-crypto/src/main/java/androidx/security/crypto/EncryptedSharedPreferences.java
+++ b/security/security-crypto/src/main/java/androidx/security/crypto/EncryptedSharedPreferences.java
@@ -16,8 +16,6 @@
 
 package androidx.security.crypto;
 
-import static androidx.security.crypto.MasterKey.KEYSTORE_PATH_URI;
-
 import static java.nio.charset.StandardCharsets.UTF_8;
 
 import android.content.Context;
@@ -77,7 +75,10 @@
  *  // use the shared preferences and editor as you normally would
  *  SharedPreferences.Editor editor = sharedPreferences.edit();
  * </pre>
+ * @deprecated Use {@link android.content.SharedPreferences} instead.
  */
+@Deprecated
+@SuppressWarnings("deprecation")
 public final class EncryptedSharedPreferences implements SharedPreferences {
 
     private static final String KEY_KEYSET_ALIAS =
@@ -165,12 +166,12 @@
         KeysetHandle daeadKeysetHandle = new AndroidKeysetManager.Builder()
                 .withKeyTemplate(prefKeyEncryptionScheme.getKeyTemplate())
                 .withSharedPref(applicationContext, KEY_KEYSET_ALIAS, fileName)
-                .withMasterKeyUri(KEYSTORE_PATH_URI + masterKeyAlias)
+                .withMasterKeyUri(MasterKey.KEYSTORE_PATH_URI + masterKeyAlias)
                 .build().getKeysetHandle();
         KeysetHandle aeadKeysetHandle = new AndroidKeysetManager.Builder()
                 .withKeyTemplate(prefValueEncryptionScheme.getKeyTemplate())
                 .withSharedPref(applicationContext, VALUE_KEYSET_ALIAS, fileName)
-                .withMasterKeyUri(KEYSTORE_PATH_URI + masterKeyAlias)
+                .withMasterKeyUri(MasterKey.KEYSTORE_PATH_URI + masterKeyAlias)
                 .build().getKeysetHandle();
 
         DeterministicAead daead = daeadKeysetHandle.getPrimitive(DeterministicAead.class);
@@ -183,7 +184,9 @@
 
     /**
      * The encryption scheme to encrypt keys.
+     * @deprecated Use {@link android.content.SharedPreferences} instead.
      */
+    @Deprecated
     public enum PrefKeyEncryptionScheme {
         /**
          * Pref keys are encrypted deterministically with AES256-SIV-CMAC (RFC 5297).
@@ -207,7 +210,9 @@
 
     /**
      * The encryption scheme to encrypt values.
+     * @deprecated Use {@link android.content.SharedPreferences} instead.
      */
+    @Deprecated
     public enum PrefValueEncryptionScheme {
         /**
          * Pref values are encrypted with AES256-GCM. The associated data is the encrypted pref key.
diff --git a/security/security-crypto/src/main/java/androidx/security/crypto/MasterKey.java b/security/security-crypto/src/main/java/androidx/security/crypto/MasterKey.java
index b1663fb..4c1946c 100644
--- a/security/security-crypto/src/main/java/androidx/security/crypto/MasterKey.java
+++ b/security/security-crypto/src/main/java/androidx/security/crypto/MasterKey.java
@@ -44,18 +44,24 @@
  *
  * <p>On Android M (API 23) and above, this is class references a key that's stored in the
  * Android Keystore. On Android L (API 21, 22), there isn't a master key.
+ * @deprecated Use {@link javax.crypto.KeyGenerator} with AndroidKeyStore instance instead.
  */
+@Deprecated
 public final class MasterKey {
     static final String KEYSTORE_PATH_URI = "android-keystore://";
 
     /**
      * The default master key alias.
+     * @deprecated Use {@link javax.crypto.KeyGenerator} with AndroidKeyStore instance instead.
      */
+    @Deprecated
     public static final String DEFAULT_MASTER_KEY_ALIAS = "_androidx_security_master_key_";
 
     /**
      * The default and recommended size for the master key.
+     * @deprecated Use {@link javax.crypto.KeyGenerator} with AndroidKeyStore instance instead.
      */
+    @Deprecated
     public static final int DEFAULT_AES_GCM_MASTER_KEY_SIZE = 256;
 
     private static final int DEFAULT_AUTHENTICATION_VALIDITY_DURATION_SECONDS = 5 * 60;
@@ -67,7 +73,9 @@
 
     /**
      * Algorithm/Cipher choices used for the master key.
+     * @deprecated Use {@link javax.crypto.KeyGenerator} with AndroidKeyStore instance instead.
      */
+    @Deprecated
     public enum KeyScheme {
         AES256_GCM
     }
@@ -166,7 +174,9 @@
 
     /**
      * Builder for generating a {@link MasterKey}.
+     * @deprecated Use {@link javax.crypto.KeyGenerator} with AndroidKeyStore instance instead.
      */
+    @Deprecated
     public static final class Builder {
         @NonNull
         final String mKeyAlias;
diff --git a/security/security-crypto/src/main/java/androidx/security/crypto/MasterKeys.java b/security/security-crypto/src/main/java/androidx/security/crypto/MasterKeys.java
index f3ce65d..bd7edf2 100644
--- a/security/security-crypto/src/main/java/androidx/security/crypto/MasterKeys.java
+++ b/security/security-crypto/src/main/java/androidx/security/crypto/MasterKeys.java
@@ -37,7 +37,7 @@
  *
  * <p>The master keys are used to encrypt data encryption keys for encrypting files and preferences.
  *
- * @deprecated Use {@link MasterKey.Builder} to work with master keys.
+ * @deprecated Use {@link javax.crypto.KeyGenerator} with AndroidKeyStore instance instead.
  */
 @Deprecated
 @RequiresApi(Build.VERSION_CODES.M)
@@ -50,7 +50,11 @@
 
     private static final String ANDROID_KEYSTORE = "AndroidKeyStore";
 
+    /**
+     * @deprecated Use {@link android.security.keystore.KeyGenParameterSpec.Builder} instead.
+     */
     @NonNull
+    @Deprecated
     public static final KeyGenParameterSpec AES256_GCM_SPEC =
             createAES256GCMKeyGenParameterSpec(MASTER_KEY_ALIAS);
 
@@ -89,7 +93,6 @@
      * @return The key alias for the master key
      */
     @NonNull
-    @SuppressWarnings("deprecation")
     public static String getOrCreate(
             @NonNull KeyGenParameterSpec keyGenParameterSpec)
             throws GeneralSecurityException, IOException {