From 22ab728be0f2a070f074f9578252c3c5b97a5881 Mon Sep 17 00:00:00 2001 From: Andy Valdez Date: Thu, 18 Jan 2024 16:07:45 -0500 Subject: [PATCH 1/2] [Bug] Made updates related to targetSdk update for media. I omitted the targetSdk update in this PR simply to allow testing with the previous version to ensure everything remains the same. Additionally, I added the foreground service types related to images. --- WordPress/src/main/AndroidManifest.xml | 7 +++++-- .../wordpress/android/ui/media/MediaSettingsActivity.java | 8 +++++++- .../android/ui/mediapicker/loader/DeviceListBuilder.kt | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/WordPress/src/main/AndroidManifest.xml b/WordPress/src/main/AndroidManifest.xml index 56d049968bb8..f06af72f1ec4 100644 --- a/WordPress/src/main/AndroidManifest.xml +++ b/WordPress/src/main/AndroidManifest.xml @@ -28,6 +28,7 @@ + @@ -823,11 +824,13 @@ + android:label="Upload Service" + android:foregroundServiceType="dataSync"/> + android:exported="false" > diff --git a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaSettingsActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaSettingsActivity.java index 15672b09cd48..ba86d66631a8 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaSettingsActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaSettingsActivity.java @@ -9,6 +9,7 @@ import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; +import android.content.ContextWrapper; import android.content.Intent; import android.content.IntentFilter; import android.database.Cursor; @@ -16,6 +17,7 @@ import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Build; +import android.os.Build.VERSION_CODES; import android.os.Bundle; import android.os.Environment; import android.os.Handler; @@ -467,7 +469,11 @@ protected void onSaveInstanceState(@NonNull Bundle outState) { @SuppressLint("UnspecifiedRegisterReceiverFlag") public void onStart() { super.onStart(); - registerReceiver(mDownloadReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); + if (Build.VERSION.SDK_INT >= VERSION_CODES.UPSIDE_DOWN_CAKE) { + registerReceiver(mDownloadReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE), ContextWrapper.RECEIVER_NOT_EXPORTED); + } else { + registerReceiver(mDownloadReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); + } mDispatcher.register(this); // we only register with EventBus the first time - necessary since we don't unregister in onStop() diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mediapicker/loader/DeviceListBuilder.kt b/WordPress/src/main/java/org/wordpress/android/ui/mediapicker/loader/DeviceListBuilder.kt index c9549d250ec1..99be2e0f8dc7 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mediapicker/loader/DeviceListBuilder.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mediapicker/loader/DeviceListBuilder.kt @@ -69,7 +69,7 @@ class DeviceListBuilder( // This item sets the threshold for the visible items in all the list val lastShownTimestamp = results.fold(0L) { timestamp, (_, result) -> val nextTimestamp = result?.nextTimestamp - if (nextTimestamp != null && nextTimestamp > timestamp) { + if (result?.items?.isNotEmpty() == true && nextTimestamp != null && nextTimestamp > timestamp) { nextTimestamp } else { timestamp From eaa406c7f9bfb9448835aebcc8524c3429ed6def Mon Sep 17 00:00:00 2001 From: Andy Valdez Date: Thu, 18 Jan 2024 17:24:46 -0500 Subject: [PATCH 2/2] [Fix] Add foreground service types to all our manifest defined services --- WordPress/src/main/AndroidManifest.xml | 57 +++++++++++++++++--------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/WordPress/src/main/AndroidManifest.xml b/WordPress/src/main/AndroidManifest.xml index f06af72f1ec4..1477bacbe66f 100644 --- a/WordPress/src/main/AndroidManifest.xml +++ b/WordPress/src/main/AndroidManifest.xml @@ -836,88 +836,105 @@ + android:label="Reader Update Service" + android:foregroundServiceType="dataSync"/> + android:label="Reader Update JobService" + android:foregroundServiceType="dataSync"/> + android:label="Reader Discover Service" + android:foregroundServiceType="dataSync"/> + android:label="Reader Discover JobService" + android:foregroundServiceType="dataSync"/> + android:label="Reader Post Service" + android:foregroundServiceType="dataSync"/> + android:label="Reader Post JobService" + android:foregroundServiceType="dataSync"/> + android:label="Reader Search Service" + android:foregroundServiceType="dataSync"/> + android:label="Reader Search Job Service" + android:foregroundServiceType="dataSync"/> + android:label="Reader Comment Service" + android:foregroundServiceType="dataSync"/> + android:label="Suggestion Service" + android:foregroundServiceType="dataSync"/> + android:label="Notifications Quick Actions processing Service" + android:foregroundServiceType="dataSync"/> + android:label="Notifications Update Service" + android:foregroundServiceType="dataSync"/> + android:label="Notifications Update Job Service" + android:foregroundServiceType="dataSync"/> + android:label="Installation Referrer Service" + android:foregroundServiceType="dataSync"/> + android:label="Installation Referrer Service" + android:foregroundServiceType="dataSync"/> + android:label="Login to WPCOM Service" + android:foregroundServiceType="dataSync"/> + android:label="Site Creation Service" + android:foregroundServiceType="dataSync"/> + android:permission="android.permission.BIND_REMOTEVIEWS" + android:foregroundServiceType="dataSync"/> + android:exported="false" + android:foregroundServiceType="dataSync">