import { ExpoConfig } from '@expo/config-types' ; import { createAndroidManifestPlugin } from '../plugins/android-plugins' ; import { AndroidManifest , getMainApplication , StringBoolean } from './Manifest' ; export const withAllowBackup = createAndroidManifestPlugin ( setAllowBackup , 'withAllowBackup' ) ; export function getAllowBackup ( config ) { return config . android ?. allowBackup ?? true ; } export function setAllowBackup ( config , androidManifest ) { const allowBackup = getAllowBackup ( config ) ; const mainApplication = getMainApplication ( androidManifest ) ; if ( mainApplication ?. $ ) { mainApplication . $ [ 'android:allowBackup' ] = String ( allowBackup ) as StringBoolean ; } return androidManifest ; } export function getAllowBackupFromManifest ( androidManifest ) { const mainApplication = getMainApplication ( androidManifest ) ; if ( mainApplication ?. $ ) { return String ( mainApplication . $ [ 'android:allowBackup' ] ) === 'true' ; } return null ; }