Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 50acdeb2 authored by Steve McKay's avatar Steve McKay Committed by android-build-merger
Browse files

Merge "Send APKs through safe install path." into nyc-dev

am: 5b6c9823

* commit '5b6c9823':
  Send APKs through safe install path.
parents efc4c3a9 5b6c9823
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -282,6 +282,24 @@ public class FilesActivity extends BaseActivity {
     * Launches an intent to view the specified document.
     */
    private void openDocument(DocumentInfo doc, Model model) {

        // Provide specialized handling of downloaded APKs This sends the APK
        // details off to get extra security information added, and finally
        // to be handled by the package manager.
        if (MimePredicate.isApkType(doc.mimeType)) {
            // First try managing the document; we expect manager to filter
            // based on authority, so we don't grant.
            final Intent manage = new Intent(DocumentsContract.ACTION_MANAGE_DOCUMENT);
            manage.setData(doc.derivedUri);

            try {
                startActivity(manage);
                return;
            } catch (ActivityNotFoundException ex) {
                // fall back to regular handling below.
            }
        }

        Intent intent = new QuickViewIntentBuilder(
                getPackageManager(), getResources(), doc, model).build();

+7 −0
Original line number Diff line number Diff line
@@ -16,12 +16,15 @@

package com.android.documentsui;

import android.annotation.Nullable;

import com.android.documentsui.model.DocumentInfo;
import com.android.internal.util.Predicate;

public class MimePredicate implements Predicate<DocumentInfo> {
    private final String[] mFilters;

    private static final String APK_TYPE = "application/vnd.android.package-archive";
    /**
     * MIME types that are visual in nature. For example, they should always be
     * shown as thumbnails in list mode.
@@ -92,4 +95,8 @@ public class MimePredicate implements Predicate<DocumentInfo> {
            return false;
        }
    }

    public static boolean isApkType(@Nullable String mimeType) {
        return APK_TYPE.equals(mimeType);
    }
}