dvAndroidSealedKeyPath function

String? dvAndroidSealedKeyPath(
  1. String? noBackupDir,
  2. String app
)

Where app's sealed key is kept, given the application's no-backup directory; null when there is none.

No-backup, because the Keystore key the blob is sealed under does not leave the device: a blob restored onto another phone can never be opened, and would only turn a clean first start into a failed read.

Implementation

String? dvAndroidSealedKeyPath(String? noBackupDir, String app) {
  if (noBackupDir == null || noBackupDir.isEmpty) return null;
  String base = noBackupDir;
  while (base.length > 1 && base.endsWith('/')) {
    base = base.substring(0, base.length - 1);
  }
  // An application name is not a path.
  final String name = app.replaceAll(RegExp(r'[^A-Za-z0-9._-]'), '_');
  return '$base/dartvel-keys/$name.sealed';
}