From 6449273f0de3503e469e372f85097cb335bb39f4 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 4 Feb 2023 10:33:46 +0100 Subject: [PATCH] Added large heap build variant --- app/build.gradle | 33 +++++++++++++++++++- app/src/amazon/AndroidManifest.xml | 1 + app/src/fdroid/AndroidManifest.xml | 1 + app/src/github/AndroidManifest.xml | 1 + app/src/main/AndroidManifest.xml | 1 + app/src/main/java/eu/faircode/email/Log.java | 14 +++++++-- app/src/play/AndroidManifest.xml | 1 + 7 files changed, 49 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 0afab343f3..110ad27829 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -55,6 +55,9 @@ android { github { java.srcDirs = ['src/main/java', 'src/play/java', 'src/extra/java'] } + large { + java.srcDirs = ['src/main/java', 'src/play/java', 'src/extra/java'] + } fdroid { java.srcDirs = ['src/main/java', 'src/fdroid/java', 'src/extra/java'] } @@ -158,6 +161,30 @@ android { productFlavors { github { dimension "all" + manifestPlaceholders.largeHeap = false + buildConfigField "boolean", "TEST_RELEASE", "false" + buildConfigField "boolean", "BETA_RELEASE", "true" + buildConfigField "boolean", "PLAY_STORE_RELEASE", "false" + buildConfigField "boolean", "FDROID_RELEASE", "false" + buildConfigField "boolean", "AMAZON_RELEASE", "false" + buildConfigField "String", "PRO_FEATURES_URI", "\"https://email.faircode.eu/donate/\"" + buildConfigField "String", "CHANGELOG", "\"https://github.com/M66B/FairEmail/releases/\"" + buildConfigField "String", "GITHUB_LATEST_API", "\"https://api.github.com/repos/M66B/FairEmail/releases/latest\"" + buildConfigField "String", "GITHUB_LATEST_URI", "\"https://github.com/M66B/FairEmail/releases\"" + buildConfigField "String", "BITBUCKET_DOWNLOADS_API", "\"https://api.bitbucket.org/2.0/repositories/M66B/fairemail-test/downloads\"" + buildConfigField "String", "BITBUCKET_DOWNLOADS_URI", "\"https://bitbucket.org/M66B/fairemail-test/downloads/\"" + buildConfigField "String", "ANNOUNCEMENT_URI", "\"https://gist.githubusercontent.com/M66B/d544192ca56224839d6ba0f2f6314c1f/raw/\"" + buildConfigField "String", "CLOUD_URI", "\"https://api.fairemail.net/sync\"" + buildConfigField "String", "CLOUD_EMAIL", "\"cloud@in.faircode.eu\"" + buildConfigField "String", "TX_URI", localProperties.getProperty("paypal.uri", "\"\"") + buildConfigField "String", "GPA_URI", localProperties.getProperty("gpa.uri", "\"\"") + buildConfigField "String", "INFO_URI", localProperties.getProperty("info.uri", "\"\"") + buildConfigField "String", "DEV_DOMAIN", localProperties.getProperty("dev.domain", "\"\"") + buildConfigField "String", "FDROID", "\"https://f-droid.org/packages/%s/\"" + } + large { + dimension "all" + manifestPlaceholders.largeHeap = true buildConfigField "boolean", "TEST_RELEASE", "false" buildConfigField "boolean", "BETA_RELEASE", "true" buildConfigField "boolean", "PLAY_STORE_RELEASE", "false" @@ -180,6 +207,7 @@ android { } fdroid { dimension "all" + manifestPlaceholders.largeHeap = false buildConfigField "boolean", "TEST_RELEASE", "false" buildConfigField "boolean", "BETA_RELEASE", "true" buildConfigField "boolean", "PLAY_STORE_RELEASE", "false" @@ -203,6 +231,7 @@ android { play { dimension "all" //minSdkVersion 23 + manifestPlaceholders.largeHeap = false buildConfigField "boolean", "TEST_RELEASE", "false" buildConfigField "boolean", "BETA_RELEASE", "true" buildConfigField "boolean", "PLAY_STORE_RELEASE", "true" @@ -226,6 +255,7 @@ android { amazon { dimension "all" minSdkVersion 23 + manifestPlaceholders.largeHeap = false buildConfigField "boolean", "TEST_RELEASE", "false" buildConfigField "boolean", "BETA_RELEASE", "true" buildConfigField "boolean", "PLAY_STORE_RELEASE", "false" @@ -251,7 +281,7 @@ android { variantFilter { variant -> def flavors = variant.flavors*.name // Builds: release, debug - // Flavors: github, fdroid, play + // Flavors: github, large, fdroid, play if (variant.buildType.name == "debug" && (flavors.contains("fdroid") || flavors.contains("play") || flavors.contains("_amazon"))) { setIgnore(true) @@ -523,6 +553,7 @@ dependencies { // https://developer.android.com/google/play/billing/billing_library_releases_notes // https://android-developers.googleblog.com/2020/06/meet-google-play-billing-library.html githubImplementation "com.android.billingclient:billing:$billingclient_version" + largeImplementation "com.android.billingclient:billing:$billingclient_version" playImplementation "com.android.billingclient:billing:$billingclient_version" // https://developer.amazon.com/docs/in-app-purchasing/iap-get-started.html diff --git a/app/src/amazon/AndroidManifest.xml b/app/src/amazon/AndroidManifest.xml index 47a3f079af..12503a77cf 100644 --- a/app/src/amazon/AndroidManifest.xml +++ b/app/src/amazon/AndroidManifest.xml @@ -111,6 +111,7 @@ android:fullBackupContent="false" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" + android:largeHeap="${largeHeap}" android:networkSecurityConfig="@xml/network_security_config" android:requestLegacyExternalStorage="true" android:resizeableActivity="true" diff --git a/app/src/fdroid/AndroidManifest.xml b/app/src/fdroid/AndroidManifest.xml index 198850aad2..3926201adc 100644 --- a/app/src/fdroid/AndroidManifest.xml +++ b/app/src/fdroid/AndroidManifest.xml @@ -118,6 +118,7 @@ android:fullBackupContent="false" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" + android:largeHeap="${largeHeap}" android:networkSecurityConfig="@xml/network_security_config" android:requestLegacyExternalStorage="true" android:resizeableActivity="true" diff --git a/app/src/github/AndroidManifest.xml b/app/src/github/AndroidManifest.xml index 094751156a..137919d8c0 100644 --- a/app/src/github/AndroidManifest.xml +++ b/app/src/github/AndroidManifest.xml @@ -118,6 +118,7 @@ android:fullBackupContent="false" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" + android:largeHeap="${largeHeap}" android:networkSecurityConfig="@xml/network_security_config" android:requestLegacyExternalStorage="true" android:resizeableActivity="true" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b5388cb559..a0d2e4c4e2 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -111,6 +111,7 @@ android:fullBackupContent="false" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" + android:largeHeap="${largeHeap}" android:networkSecurityConfig="@xml/network_security_config" android:requestLegacyExternalStorage="true" android:resizeableActivity="true" diff --git a/app/src/main/java/eu/faircode/email/Log.java b/app/src/main/java/eu/faircode/email/Log.java index 79f89bb19f..d197f1f21c 100644 --- a/app/src/main/java/eu/faircode/email/Log.java +++ b/app/src/main/java/eu/faircode/email/Log.java @@ -2068,11 +2068,21 @@ public class Log { Helper.formatDuration(running), Helper.formatDuration(cpu), util)); } + Boolean largeHeap; + try { + ApplicationInfo info = pm.getApplicationInfo(context.getPackageName(), 0); + largeHeap = (info.flags & ApplicationInfo.FLAG_LARGE_HEAP) != 0; + } catch (Throwable ex) { + largeHeap = null; + } + ActivityManager am = Helper.getSystemService(context, ActivityManager.class); ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo(); am.getMemoryInfo(mi); - sb.append(String.format("Memory class: %d/%d MB Total: %s\r\n", - am.getMemoryClass(), am.getLargeMemoryClass(), Helper.humanReadableByteCount(mi.totalMem))); + sb.append(String.format("Memory class: %d/%d Large: %s MB Total: %s\r\n", + am.getMemoryClass(), am.getLargeMemoryClass(), + largeHeap == null ? "?" : Boolean.toString(largeHeap), + Helper.humanReadableByteCount(mi.totalMem))); long storage_available = Helper.getAvailableStorageSpace(); long storage_total = Helper.getTotalStorageSpace(); diff --git a/app/src/play/AndroidManifest.xml b/app/src/play/AndroidManifest.xml index ae9f86aa09..5093c702a8 100644 --- a/app/src/play/AndroidManifest.xml +++ b/app/src/play/AndroidManifest.xml @@ -111,6 +111,7 @@ android:fullBackupContent="false" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" + android:largeHeap="${largeHeap}" android:networkSecurityConfig="@xml/network_security_config" android:requestLegacyExternalStorage="true" android:resizeableActivity="true"