Fix tap-to-upgrade on website releases.

Tested on Android 9.0, 7.0, and 5.1.

Fixes #7936
This commit is contained in:
Greyson Parrelli 2019-01-13 19:08:33 -08:00
parent 975d7268a1
commit 40f9b32a75
3 changed files with 7 additions and 5 deletions

View File

@ -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);

View File

@ -14,7 +14,7 @@ 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);
if (Build.VERSION.SDK_INT >= 24) return FileProvider.getUriForFile(context, AUTHORITY, file);
else return Uri.fromFile(file);
}

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION"/>
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
<application>
<receiver android:name=".service.UpdateApkRefreshListener">