From d913f2966242f1fd049ad0c02d66e7e9e437c7c8 Mon Sep 17 00:00:00 2001 From: PixelyIon Date: Fri, 17 Jun 2022 12:26:18 +0530 Subject: [PATCH] Only set `hasFragileUserData` for signed builds We do not want to allow saving of user data on unsigned builds as they don't have a stable signature and will not properly handle reinstallation. This can lead to a situation where the user has to resort to complex techniques to completely uninstall the package such as ADB or calling into PM directly. --- app/build.gradle | 11 +++++++++-- app/src/main/AndroidManifest.xml | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 0771db72..dc3bb86f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -16,6 +16,8 @@ idea.module { android { namespace 'emu.skyline' + var isBuildSigned = (System.getenv("CI") == "true") && (System.getenv("IS_SKYLINE_SIGNED") == "true") + compileSdkVersion 31 buildToolsVersion '33.0.0' defaultConfig { @@ -30,6 +32,11 @@ android { ndk { abiFilters "arm64-v8a" } + + if (isBuildSigned) + manifestPlaceholders = [shouldSaveUserData: "true"] + else + manifestPlaceholders = [shouldSaveUserData: "false"] } /* JVM Bytecode Options */ @@ -63,14 +70,14 @@ android { minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - signingConfig = (System.getenv("CI") == "true") && (System.getenv("IS_SKYLINE_SIGNED") == "true") ? signingConfigs.ci : signingConfigs.debug + signingConfig = isBuildSigned ? signingConfigs.ci : signingConfigs.debug } debug { debuggable true minifyEnabled false shrinkResources false - signingConfig = (System.getenv("CI") == "true") && (System.getenv("IS_SKYLINE_SIGNED") == "true") ? signingConfigs.ci : signingConfigs.debug + signingConfig = isBuildSigned ? signingConfigs.ci : signingConfigs.debug } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index cb1cbb37..abc1c103 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -16,7 +16,7 @@ android:allowBackup="true" android:extractNativeLibs="true" android:fullBackupContent="@xml/backup_descriptor" - android:hasFragileUserData="true" + android:hasFragileUserData="${shouldSaveUserData}" android:icon="@drawable/logo_skyline" android:isGame="true" android:label="@string/app_name"