From 40f9b32a75186f27cdf2d074ebd0fc477200091d Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Sun, 13 Jan 2019 19:08:33 -0800 Subject: [PATCH] Fix tap-to-upgrade on website releases. Tested on Android 9.0, 7.0, and 5.1. Fixes #7936 --- .../securesms/service/UpdateApkReadyListener.java | 7 ++++--- src/org/thoughtcrime/securesms/util/FileProviderUtil.java | 4 ++-- website/AndroidManifest.xml | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/org/thoughtcrime/securesms/service/UpdateApkReadyListener.java b/src/org/thoughtcrime/securesms/service/UpdateApkReadyListener.java index 2f1a77c7c0..50f5ded14c 100644 --- a/src/org/thoughtcrime/securesms/service/UpdateApkReadyListener.java +++ b/src/org/thoughtcrime/securesms/service/UpdateApkReadyListener.java @@ -9,6 +9,7 @@ import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.net.Uri; +import android.os.Build; import android.support.annotation.Nullable; import android.support.v4.app.NotificationCompat; import org.thoughtcrime.securesms.logging.Log; @@ -56,9 +57,9 @@ public class UpdateApkReadyListener extends BroadcastReceiver { } private void displayInstallNotification(Context context, Uri uri) { - Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_GRANT_READ_URI_PERMISSION); - intent.setDataAndType(uri, "application/vnd.android.package-archive"); + Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE); + intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + intent.setData(uri); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); diff --git a/src/org/thoughtcrime/securesms/util/FileProviderUtil.java b/src/org/thoughtcrime/securesms/util/FileProviderUtil.java index cd45228503..5cf06dad75 100644 --- a/src/org/thoughtcrime/securesms/util/FileProviderUtil.java +++ b/src/org/thoughtcrime/securesms/util/FileProviderUtil.java @@ -14,8 +14,8 @@ public class FileProviderUtil { private static final String AUTHORITY = "org.thoughtcrime.securesms.fileprovider"; public static Uri getUriFor(@NonNull Context context, @NonNull File file) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) return FileProvider.getUriForFile(context, AUTHORITY, file); - else return Uri.fromFile(file); + if (Build.VERSION.SDK_INT >= 24) return FileProvider.getUriForFile(context, AUTHORITY, file); + else return Uri.fromFile(file); } public static boolean isAuthority(@NonNull Uri uri) { diff --git a/website/AndroidManifest.xml b/website/AndroidManifest.xml index cc91be6ad9..3dbbbb1dfe 100644 --- a/website/AndroidManifest.xml +++ b/website/AndroidManifest.xml @@ -1,6 +1,7 @@ +