Commit 844c795e authored by Jan Henning's avatar Jan Henning Committed by Georg Koppen
Browse files

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
parent 62ce20f7
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -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);
        if (AppConstants.Versions.preN) {
            intent.setDataAndType(Uri.fromFile(updateFile), "application/vnd.android.package-archive");
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        } 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);
    }