From 4de69dcfdd8d08a329f02221ef5b8084e4c90aeb Mon Sep 17 00:00:00 2001 From: TheScarastic Date: Tue, 3 May 2022 12:18:31 +0530 Subject: [PATCH] eDrive: Initialise folders on each new update also remove packge upgrade settings since package is persistent and can never be upgraded --- app/src/main/AndroidManifest.xml | 4 +- .../receivers/BootCompletedReceiver.java | 46 +++++++++++++++++++ .../drive/receivers/PackageEventReceiver.java | 46 ------------------- .../e/drive/services/InitializerService.java | 4 +- .../foundation/e/drive/utils/CommonUtils.java | 21 +++++++++ 5 files changed, 71 insertions(+), 50 deletions(-) create mode 100644 app/src/main/java/foundation/e/drive/receivers/BootCompletedReceiver.java delete mode 100644 app/src/main/java/foundation/e/drive/receivers/PackageEventReceiver.java diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 3426875d..dc5d04a4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -91,10 +91,10 @@ - + syncCategories = new ArrayList<>(); syncCategories.addAll(Arrays.asList(MEDIA_SYNCABLE_CATEGORIES)); diff --git a/app/src/main/java/foundation/e/drive/utils/CommonUtils.java b/app/src/main/java/foundation/e/drive/utils/CommonUtils.java index e3461d2d..34665df1 100644 --- a/app/src/main/java/foundation/e/drive/utils/CommonUtils.java +++ b/app/src/main/java/foundation/e/drive/utils/CommonUtils.java @@ -12,6 +12,7 @@ package foundation.e.drive.utils; import android.accounts.Account; import android.accounts.AccountManager; +import android.annotation.SuppressLint; import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.Service; @@ -37,6 +38,7 @@ import com.owncloud.android.lib.common.accounts.AccountUtils; import com.owncloud.android.lib.resources.files.FileUtils; import java.io.File; +import java.lang.reflect.Method; import java.text.CharacterIterator; import java.text.StringCharacterIterator; import java.util.Locale; @@ -480,4 +482,23 @@ public abstract class CommonUtils { workManager.enqueueUniquePeriodicWork(AccountUserInfoWorker.UNIQUE_WORK_NAME, ExistingPeriodicWorkPolicy.REPLACE, periodicUserInfoScanRequest); } + + /** + * Function for get build props through reflection + * + * @param prop key that you want to get value for + * @return value of the prop, returns empty if not found + */ + @SuppressLint("PrivateApi") + public static String getProp(String prop) { + String value = ""; + try { + Class c = Class.forName("android.os.SystemProperties"); + Method get = c.getMethod("get", String.class); + value = (String) get.invoke(c, prop); + } catch (Exception e) { + e.printStackTrace(); + } + return value; + } } -- GitLab