Upgrade tink to 1.7.0 in security-crypto

Changed some calls into Tink to avoid deprecation warnings.

Bug: 185219606 (and likely others)
Test: Ran the security-crypto test suite
Change-Id: I7b1dcb3bf3f5d018a93ac3b06280724559f63ded
diff --git a/security/security-crypto/build.gradle b/security/security-crypto/build.gradle
index e7ca0fc..3183bc2 100644
--- a/security/security-crypto/build.gradle
+++ b/security/security-crypto/build.gradle
@@ -25,7 +25,7 @@
 dependencies {
     api("androidx.annotation:annotation:1.1.0")
 
-    implementation("com.google.crypto.tink:tink-android:1.5.0")
+    implementation("com.google.crypto.tink:tink-android:1.7.0")
 
     implementation("androidx.annotation:annotation:1.2.0")
     implementation("androidx.collection:collection:1.1.0")
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 b51b75d..a223d30 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
@@ -26,10 +26,10 @@
 import androidx.annotation.NonNull;
 
 import com.google.crypto.tink.KeyTemplate;
+import com.google.crypto.tink.KeyTemplates;
 import com.google.crypto.tink.KeysetHandle;
 import com.google.crypto.tink.StreamingAead;
 import com.google.crypto.tink.integration.android.AndroidKeysetManager;
-import com.google.crypto.tink.streamingaead.AesGcmHkdfStreamingKeyManager;
 import com.google.crypto.tink.streamingaead.StreamingAeadConfig;
 
 import java.io.File;
@@ -92,24 +92,23 @@
      */
     public enum FileEncryptionScheme {
         /**
-         * The file content is encrypted using
-         * <a href="https://google.github.io/tink/javadoc/tink/1.4.0/com/google/crypto/tink/streamingaead/StreamingAead.html">StreamingAead</a> with AES-GCM, with the
-         * file name as associated data.
+         * The file content is encrypted using StreamingAead with AES-GCM, with the file name as
+         * associated data.
          *
          * For more information please see the Tink documentation:
          *
-         * <a href="https://google.github.io/tink/javadoc/tink/1.4.0/com/google/crypto/tink/streamingaead/AesGcmHkdfStreamingKeyManager.html">AesGcmHkdfStreamingKeyManager</a>.aes256GcmHkdf4KBTemplate()
+         * <a href="https://google.github.io/tink/javadoc/tink/1.7.0/com/google/crypto/tink/streamingaead/AesGcmHkdfStreamingKeyManager.html">AesGcmHkdfStreamingKeyManager</a>.aes256GcmHkdf4KBTemplate()
          */
-        AES256_GCM_HKDF_4KB(AesGcmHkdfStreamingKeyManager.aes256GcmHkdf4KBTemplate());
+        AES256_GCM_HKDF_4KB("AES256_GCM_HKDF_4KB");
 
-        private final KeyTemplate mStreamingAeadKeyTemplate;
+        private final String mKeyTemplateName;
 
-        FileEncryptionScheme(KeyTemplate keyTemplate) {
-            mStreamingAeadKeyTemplate = keyTemplate;
+        FileEncryptionScheme(String keyTemplateName) {
+            mKeyTemplateName = keyTemplateName;
         }
 
-        KeyTemplate getKeyTemplate() {
-            return mStreamingAeadKeyTemplate;
+        KeyTemplate getKeyTemplate() throws GeneralSecurityException {
+            return KeyTemplates.get(mKeyTemplateName);
         }
     }
 
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 ff6e681..acea0ee 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
@@ -31,10 +31,9 @@
 import com.google.crypto.tink.Aead;
 import com.google.crypto.tink.DeterministicAead;
 import com.google.crypto.tink.KeyTemplate;
+import com.google.crypto.tink.KeyTemplates;
 import com.google.crypto.tink.KeysetHandle;
 import com.google.crypto.tink.aead.AeadConfig;
-import com.google.crypto.tink.aead.AesGcmKeyManager;
-import com.google.crypto.tink.daead.AesSivKeyManager;
 import com.google.crypto.tink.daead.DeterministicAeadConfig;
 import com.google.crypto.tink.integration.android.AndroidKeysetManager;
 import com.google.crypto.tink.subtle.Base64;
@@ -176,18 +175,18 @@
          *
          * For more information please see the Tink documentation:
          *
-         * <a href="https://google.github.io/tink/javadoc/tink/1.4.0/com/google/crypto/tink/daead/AesSivKeyManager.html">AesSivKeyManager</a>.aes256SivTemplate()
+         * <a href="https://google.github.io/tink/javadoc/tink/1.7.0/com/google/crypto/tink/daead/AesSivKeyManager.html">AesSivKeyManager</a>.aes256SivTemplate()
          */
-        AES256_SIV(AesSivKeyManager.aes256SivTemplate());
+        AES256_SIV("AES256_SIV");
 
-        private final KeyTemplate mDeterministicAeadKeyTemplate;
+        private final String mDeterministicAeadKeyTemplateName;
 
-        PrefKeyEncryptionScheme(KeyTemplate keyTemplate) {
-            mDeterministicAeadKeyTemplate = keyTemplate;
+        PrefKeyEncryptionScheme(String deterministicAeadKeyTemplateName) {
+            mDeterministicAeadKeyTemplateName = deterministicAeadKeyTemplateName;
         }
 
-        KeyTemplate getKeyTemplate() {
-            return mDeterministicAeadKeyTemplate;
+        KeyTemplate getKeyTemplate() throws GeneralSecurityException {
+            return KeyTemplates.get(mDeterministicAeadKeyTemplateName);
         }
     }
 
@@ -200,18 +199,18 @@
          *
          * For more information please see the Tink documentation:
          *
-         * <a href="https://google.github.io/tink/javadoc/tink/1.4.0/com/google/crypto/tink/aead/AesGcmKeyManager.html">AesGcmKeyManager</a>.aes256GcmTemplate()
+         * <a href="https://google.github.io/tink/javadoc/tink/1.7.0/com/google/crypto/tink/aead/AesGcmKeyManager.html">AesGcmKeyManager</a>.aes256GcmTemplate()
          */
-        AES256_GCM(AesGcmKeyManager.aes256GcmTemplate());
+        AES256_GCM("AES256_GCM");
 
-        private final KeyTemplate mAeadKeyTemplate;
+        private final String mAeadKeyTemplateName;
 
-        PrefValueEncryptionScheme(KeyTemplate keyTemplates) {
-            mAeadKeyTemplate = keyTemplates;
+        PrefValueEncryptionScheme(String aeadKeyTemplateName) {
+            mAeadKeyTemplateName = aeadKeyTemplateName;
         }
 
-        KeyTemplate getKeyTemplate() {
-            return mAeadKeyTemplate;
+        KeyTemplate getKeyTemplate() throws GeneralSecurityException {
+            return KeyTemplates.get(mAeadKeyTemplateName);
         }
     }