[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-browser/tor-browser-60.4.0esr-8.5-1] Bug 1450449 - Part 4: Starting from Nougat, install updates via content:// URIs. r=jchen



commit 3b926685447ea2056e73d9b3396ea8d5cbdd349f
Author: Jan Henning <jh+bugzilla@xxxxxxxxxxxxxxx>
Date:   Sat May 12 23:34:25 2018 +0200

    Bug 1450449 - Part 4: Starting from Nougat, install updates via content:// URIs. r=jchen
    
    We download the update APK into the public downloads directory and normally the
    only relevant app consuming that URI should be the system package installer, but
    just to be safe we only switch usage from Nougat onward, too.
    
    MozReview-Commit-ID: GtoXMJ7NdJ3
    
    --HG--
    extra : rebase_source : 1e85f8352b7a59cb3cd2fd3034a0103c8705ff09
---
 .../base/java/org/mozilla/gecko/updater/UpdateService.java   | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/mobile/android/base/java/org/mozilla/gecko/updater/UpdateService.java b/mobile/android/base/java/org/mozilla/gecko/updater/UpdateService.java
index 71e1097711d9..d5093efca6d6 100644
--- a/mobile/android/base/java/org/mozilla/gecko/updater/UpdateService.java
+++ b/mobile/android/base/java/org/mozilla/gecko/updater/UpdateService.java
@@ -36,6 +36,7 @@ import android.os.Environment;
 import android.provider.Settings;
 import android.support.v4.app.NotificationManagerCompat;
 import android.support.v4.content.ContextCompat;
+import android.support.v4.content.FileProvider;
 import android.support.v4.net.ConnectivityManagerCompat;
 import android.support.v4.app.NotificationCompat;
 import android.support.v4.app.NotificationCompat.Builder;
@@ -707,8 +708,15 @@ public class UpdateService extends IntentService {
         }
 
         Intent intent = new Intent(Intent.ACTION_VIEW);
-        intent.setDataAndType(Uri.fromFile(updateFile), "application/vnd.android.package-archive");
-        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        if (AppConstants.Versions.preN) {
+            intent.setDataAndType(Uri.fromFile(updateFile), "application/vnd.android.package-archive");
+        } else {
+            Uri apkUri = FileProvider.getUriForFile(this,
+                    AppConstants.MOZ_FILE_PROVIDER_AUTHORITY, updateFile);
+            intent.setDataAndType(apkUri, "application/vnd.android.package-archive");
+            intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
+        }
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         startActivity(intent);
     }
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits